syslinux.pp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { These things are set in the makefile, }
  13. { But you can override them here.}
  14. { If you use an aout system, set the conditional AOUT}
  15. { $Define AOUT}
  16. Unit SysLinux;
  17. Interface
  18. {$ifdef m68k}
  19. { used for single computations }
  20. const
  21. BIAS4 = $7f-1;
  22. {$endif}
  23. {$define newsignal}
  24. {$I systemh.inc}
  25. {$I heaph.inc}
  26. const
  27. UnusedHandle = -1;
  28. StdInputHandle = 0;
  29. StdOutputHandle = 1;
  30. StdErrorHandle = 2;
  31. var
  32. argc : longint;
  33. argv : ppchar;
  34. envp : ppchar;
  35. Implementation
  36. {$I system.inc}
  37. { used in syscall to report errors.}
  38. var
  39. Errno : longint;
  40. { Include constant and type definitions }
  41. {$i errno.inc } { Error numbers }
  42. {$i sysnr.inc } { System call numbers }
  43. {$i sysconst.inc } { Miscellaneous constants }
  44. {$i systypes.inc } { Types needed for system calls }
  45. { Read actual system call definitions. }
  46. {$i syscalls.inc }
  47. {*****************************************************************************
  48. Misc. System Dependent Functions
  49. *****************************************************************************}
  50. procedure prthaltproc;external name '_haltproc';
  51. procedure System_exit;
  52. begin
  53. {$ifdef i386}
  54. asm
  55. jmp prthaltproc
  56. end;
  57. {$else}
  58. asm
  59. jmp prthaltproc
  60. end;
  61. {$endif}
  62. End;
  63. Function ParamCount: Longint;
  64. Begin
  65. Paramcount:=argc-1
  66. End;
  67. Function ParamStr(l: Longint): String;
  68. var
  69. link,
  70. hs : string;
  71. i : longint;
  72. begin
  73. if l=0 then
  74. begin
  75. str(sys_getpid,hs);
  76. hs:='/proc/'+hs+'/exe'#0;
  77. i:=Sys_readlink(@hs[1],@link[1],high(link));
  78. { it must also be an absolute filename, linux 2.0 points to a memory
  79. location so this will skip that }
  80. if (i>0) and (link[1]='/') then
  81. begin
  82. link[0]:=chr(i);
  83. paramstr:=link;
  84. end
  85. else
  86. paramstr:=strpas(argv[0]);
  87. end
  88. else
  89. if (l>0) and (l<argc) then
  90. paramstr:=strpas(argv[l])
  91. else
  92. paramstr:='';
  93. end;
  94. Procedure Randomize;
  95. Begin
  96. randseed:=sys_time;
  97. End;
  98. {*****************************************************************************
  99. Heap Management
  100. *****************************************************************************}
  101. var
  102. _HEAP : longint;external name 'HEAP';
  103. _HEAPSIZE : longint;external name 'HEAPSIZE';
  104. function getheapstart:pointer;assembler;
  105. {$ifdef i386}
  106. asm
  107. leal _HEAP,%eax
  108. end ['EAX'];
  109. {$else}
  110. asm
  111. lea.l _HEAP,a0
  112. move.l a0,d0
  113. end;
  114. {$endif}
  115. function getheapsize:longint;assembler;
  116. {$ifdef i386}
  117. asm
  118. movl _HEAPSIZE,%eax
  119. end ['EAX'];
  120. {$else}
  121. asm
  122. move.l _HEAPSIZE,d0
  123. end ['D0'];
  124. {$endif}
  125. {$ifdef bsd}
  126. Function sbrk(size : longint) : Longint;
  127. CONST MAP_PRIVATE =2;
  128. MAP_ANONYMOUS =$1000; {$20 under linux}
  129. begin
  130. Sbrk:=do_syscall(syscall_nr_mmap,0,size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0,0);
  131. if ErrNo<>0 then
  132. Sbrk:=0;
  133. end;
  134. {$else}
  135. Function sbrk(size : longint) : Longint;
  136. type
  137. tmmapargs=packed record
  138. address : longint;
  139. size : longint;
  140. prot : longint;
  141. flags : longint;
  142. fd : longint;
  143. offset : longint;
  144. end;
  145. var
  146. t : syscallregs;
  147. mmapargs : tmmapargs;
  148. begin
  149. mmapargs.address:=0;
  150. mmapargs.size:=Size;
  151. mmapargs.prot:=3;
  152. mmapargs.flags:=$22;
  153. mmapargs.fd:=-1;
  154. mmapargs.offset:=0;
  155. t.reg2:=longint(@mmapargs);
  156. Sbrk:=syscall(syscall_nr_mmap,t);
  157. if ErrNo<>0 then
  158. Sbrk:=0;
  159. end;
  160. {$endif}
  161. { include standard heap management }
  162. {$I heap.inc}
  163. {*****************************************************************************
  164. Low Level File Routines
  165. *****************************************************************************}
  166. {
  167. The lowlevel file functions should take care of setting the InOutRes to the
  168. correct value if an error has occured, else leave it untouched
  169. }
  170. Procedure Errno2Inoutres;
  171. {
  172. Convert ErrNo error to the correct Inoutres value
  173. }
  174. begin
  175. if ErrNo=0 then { Else it will go through all the cases }
  176. exit;
  177. case ErrNo of
  178. Sys_ENFILE,
  179. Sys_EMFILE : Inoutres:=4;
  180. Sys_ENOENT : Inoutres:=2;
  181. Sys_EBADF : Inoutres:=6;
  182. Sys_ENOMEM,
  183. Sys_EFAULT : Inoutres:=217;
  184. Sys_EINVAL : Inoutres:=218;
  185. Sys_EPIPE,
  186. Sys_EINTR,
  187. Sys_EIO,
  188. Sys_EAGAIN,
  189. Sys_ENOSPC : Inoutres:=101;
  190. Sys_ENAMETOOLONG,
  191. Sys_ELOOP,
  192. Sys_ENOTDIR : Inoutres:=3;
  193. Sys_EROFS,
  194. Sys_EEXIST,
  195. Sys_EACCES : Inoutres:=5;
  196. Sys_ETXTBSY : Inoutres:=162;
  197. end;
  198. end;
  199. Procedure Do_Close(Handle:Longint);
  200. Begin
  201. sys_close(Handle);
  202. End;
  203. Procedure Do_Erase(p:pchar);
  204. Begin
  205. sys_unlink(p);
  206. Errno2Inoutres;
  207. End;
  208. Procedure Do_Rename(p1,p2:pchar);
  209. Begin
  210. sys_rename(p1,p2);
  211. Errno2Inoutres;
  212. End;
  213. Function Do_Write(Handle,Addr,Len:Longint):longint;
  214. Begin
  215. repeat
  216. Do_Write:=sys_write(Handle,pchar(addr),len);
  217. until ErrNo<>Sys_EINTR;
  218. Errno2Inoutres;
  219. if Do_Write<0 then
  220. Do_Write:=0;
  221. End;
  222. Function Do_Read(Handle,Addr,Len:Longint):Longint;
  223. Begin
  224. repeat
  225. Do_Read:=sys_read(Handle,pchar(addr),len);
  226. until ErrNo<>Sys_EINTR;
  227. Errno2Inoutres;
  228. if Do_Read<0 then
  229. Do_Read:=0;
  230. End;
  231. Function Do_FilePos(Handle: Longint): Longint;
  232. Begin
  233. Do_FilePos:=sys_lseek(Handle, 0, Seek_Cur);
  234. Errno2Inoutres;
  235. End;
  236. Procedure Do_Seek(Handle,Pos:Longint);
  237. Begin
  238. sys_lseek(Handle, pos, Seek_set);
  239. End;
  240. Function Do_SeekEnd(Handle:Longint): Longint;
  241. begin
  242. Do_SeekEnd:=sys_lseek(Handle,0,Seek_End);
  243. end;
  244. {$ifdef BSD}
  245. Function Do_FileSize(Handle:Longint): Longint;
  246. var
  247. Info : Stat;
  248. Begin
  249. if do_SysCall(syscall_nr_fstat,handle,longint(@info))=0 then
  250. Do_FileSize:=Info.Size
  251. else
  252. Do_FileSize:=0;
  253. Errno2Inoutres;
  254. End;
  255. {$ELSE}
  256. Function Do_FileSize(Handle:Longint): Longint;
  257. var
  258. regs : Syscallregs;
  259. Info : Stat;
  260. Begin
  261. regs.reg2:=Handle;
  262. regs.reg3:=longint(@Info);
  263. if SysCall(SysCall_nr_fstat,regs)=0 then
  264. Do_FileSize:=Info.Size
  265. else
  266. Do_FileSize:=0;
  267. Errno2Inoutres;
  268. End;
  269. {$endif}
  270. Procedure Do_Truncate(Handle,Pos:longint);
  271. {$ifndef bsd}
  272. var
  273. sr : syscallregs;
  274. {$endif}
  275. begin
  276. {$ifdef bsd}
  277. do_syscall(syscall_nr_ftruncate,handle,pos,0);
  278. {$else}
  279. sr.reg2:=Handle;
  280. sr.reg3:=Pos;
  281. syscall(syscall_nr_ftruncate,sr);
  282. {$endif}
  283. Errno2Inoutres;
  284. end;
  285. Procedure Do_Open(var f;p:pchar;flags:longint);
  286. {
  287. FileRec and textrec have both Handle and mode as the first items so
  288. they could use the same routine for opening/creating.
  289. when (flags and $100) the file will be append
  290. when (flags and $1000) the file will be truncate/rewritten
  291. when (flags and $10000) there is no check for close (needed for textfiles)
  292. }
  293. var
  294. oflags : longint;
  295. dirtest : stat;
  296. Begin
  297. { close first if opened }
  298. if ((flags and $10000)=0) then
  299. begin
  300. case FileRec(f).mode of
  301. fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
  302. fmclosed : ;
  303. else
  304. begin
  305. inoutres:=102; {not assigned}
  306. exit;
  307. end;
  308. end;
  309. end;
  310. { reset file Handle }
  311. FileRec(f).Handle:=UnusedHandle;
  312. { We do the conversion of filemodes here, concentrated on 1 place }
  313. case (flags and 3) of
  314. 0 : begin
  315. oflags :=Open_RDONLY;
  316. FileRec(f).mode:=fminput;
  317. end;
  318. 1 : begin
  319. oflags :=Open_WRONLY;
  320. FileRec(f).mode:=fmoutput;
  321. end;
  322. 2 : begin
  323. oflags :=Open_RDWR;
  324. FileRec(f).mode:=fminout;
  325. end;
  326. end;
  327. if (flags and $1000)=$1000 then
  328. oflags:=oflags or (Open_CREAT or Open_TRUNC)
  329. else
  330. if (flags and $100)=$100 then
  331. oflags:=oflags or (Open_APPEND);
  332. { empty name is special }
  333. if p[0]=#0 then
  334. begin
  335. case FileRec(f).mode of
  336. fminput :
  337. FileRec(f).Handle:=StdInputHandle;
  338. fminout, { this is set by rewrite }
  339. fmoutput :
  340. FileRec(f).Handle:=StdOutputHandle;
  341. fmappend :
  342. begin
  343. FileRec(f).Handle:=StdOutputHandle;
  344. FileRec(f).mode:=fmoutput; {fool fmappend}
  345. end;
  346. end;
  347. exit;
  348. end;
  349. { real open call }
  350. FileRec(f).Handle:=sys_open(p,oflags,438);
  351. if (ErrNo=Sys_EROFS) and ((OFlags and Open_RDWR)<>0) then
  352. begin
  353. Oflags:=Oflags and not(Open_RDWR);
  354. FileRec(f).Handle:=sys_open(p,oflags,438);
  355. end;
  356. Errno2Inoutres;
  357. End;
  358. Function Do_IsDevice(Handle:Longint):boolean;
  359. {
  360. Interface to Unix ioctl call.
  361. Performs various operations on the filedescriptor Handle.
  362. Ndx describes the operation to perform.
  363. Data points to data needed for the Ndx function. The structure of this
  364. data is function-dependent.
  365. }
  366. var
  367. {$ifndef BSD}
  368. sr: SysCallRegs;
  369. {$endif}
  370. Data : array[0..255] of byte; {Large enough for termios info}
  371. begin
  372. {$ifdef BSD}
  373. Do_IsDevice:=(do_SysCall(syscall_nr_ioctl,handle,$5401,longint(@data))=0);
  374. {$else}
  375. sr.reg2:=Handle;
  376. sr.reg3:=$5401; {=TCGETS}
  377. sr.reg4:=Longint(@Data);
  378. Do_IsDevice:=(SysCall(Syscall_nr_ioctl,sr)=0);
  379. {$endif}
  380. end;
  381. {*****************************************************************************
  382. UnTyped File Handling
  383. *****************************************************************************}
  384. {$i file.inc}
  385. {*****************************************************************************
  386. Typed File Handling
  387. *****************************************************************************}
  388. {$i typefile.inc}
  389. {*****************************************************************************
  390. Text File Handling
  391. *****************************************************************************}
  392. {$DEFINE SHORT_LINEBREAK}
  393. {$DEFINE EXTENDED_EOF}
  394. {$i text.inc}
  395. {*****************************************************************************
  396. Directory Handling
  397. *****************************************************************************}
  398. Procedure MkDir(Const s: String);[IOCheck];
  399. Var
  400. Buffer: Array[0..255] of Char;
  401. Begin
  402. If InOutRes <> 0 then exit;
  403. Move(s[1], Buffer, Length(s));
  404. Buffer[Length(s)] := #0;
  405. sys_mkdir(@buffer, 511);
  406. Errno2Inoutres;
  407. End;
  408. Procedure RmDir(Const s: String);[IOCheck];
  409. Var
  410. Buffer: Array[0..255] of Char;
  411. Begin
  412. If InOutRes <> 0 then exit;
  413. Move(s[1], Buffer, Length(s));
  414. Buffer[Length(s)] := #0;
  415. sys_rmdir(@buffer);
  416. Errno2Inoutres;
  417. End;
  418. Procedure ChDir(Const s: String);[IOCheck];
  419. Var
  420. Buffer: Array[0..255] of Char;
  421. Begin
  422. If InOutRes <> 0 then exit;
  423. Move(s[1], Buffer, Length(s));
  424. Buffer[Length(s)] := #0;
  425. sys_chdir(@buffer);
  426. Errno2Inoutres;
  427. End;
  428. procedure getdir(drivenr : byte;var dir : shortstring);
  429. var
  430. thisdir : stat;
  431. rootino,
  432. thisino,
  433. dotdotino : longint;
  434. rootdev,
  435. thisdev,
  436. dotdotdev : {$ifdef bsd}longint{$else}word{$endif};
  437. thedir,dummy : string[255];
  438. dirstream : pdir;
  439. d : pdirent;
  440. mountpoint,validdir : boolean;
  441. predot : string[255];
  442. begin
  443. drivenr:=0;
  444. dir:='';
  445. thedir:='/'#0;
  446. if sys_stat(@thedir[1],thisdir)<0 then
  447. exit;
  448. rootino:=thisdir.ino;
  449. rootdev:=thisdir.dev;
  450. thedir:='.'#0;
  451. if sys_stat(@thedir[1],thisdir)<0 then
  452. exit;
  453. thisino:=thisdir.ino;
  454. thisdev:=thisdir.dev;
  455. { Now we can uniquely identify the current and root dir }
  456. thedir:='';
  457. predot:='';
  458. while not ((thisino=rootino) and (thisdev=rootdev)) do
  459. begin
  460. { Are we on a mount point ? }
  461. dummy:=predot+'..'#0;
  462. if sys_stat(@dummy[1],thisdir)<0 then
  463. exit;
  464. dotdotino:=thisdir.ino;
  465. dotdotdev:=thisdir.dev;
  466. mountpoint:=(thisdev<>dotdotdev);
  467. { Now, Try to find the name of this dir in the previous one }
  468. dirstream:=opendir (@dummy[1]);
  469. if dirstream=nil then
  470. exit;
  471. repeat
  472. d:=sys_readdir (dirstream);
  473. validdir:=false;
  474. if (d<>nil) and
  475. (not ((d^.name[0]='.') and ((d^.name[1]=#0) or ((d^.name[1]='.')
  476. and (d^.name[2]=#0))))) and
  477. (mountpoint or (d^.ino=thisino)) then
  478. begin
  479. dummy:=predot+'../'+strpas(@(d^.name[0]))+#0;
  480. validdir:=not (sys_stat (@(dummy[1]),thisdir)<0);
  481. end
  482. else
  483. validdir:=false;
  484. until (d=nil) or
  485. ((validdir) and (thisdir.dev=thisdev) and (thisdir.ino=thisino) );
  486. if (closedir(dirstream)<0) or (d=nil) then
  487. exit;
  488. { At this point, d.name contains the name of the current dir}
  489. thedir:='/'+strpas(@(d^.name[0]))+thedir;
  490. thisdev:=dotdotdev;
  491. thisino:=dotdotino;
  492. predot:=predot+'../';
  493. end;
  494. { Now rootino=thisino and rootdev=thisdev so we've reached / }
  495. dir:=thedir
  496. end;
  497. {*****************************************************************************
  498. SystemUnit Initialization
  499. *****************************************************************************}
  500. {$ifdef I386}
  501. { this should be defined in i386 directory !! PM }
  502. const
  503. fpucw : word = $1332;
  504. FPU_Invalid = 1;
  505. FPU_Denormal = 2;
  506. FPU_DivisionByZero = 4;
  507. FPU_Overflow = 8;
  508. FPU_Underflow = $10;
  509. FPU_StackUnderflow = $20;
  510. FPU_StackOverflow = $40;
  511. {$endif I386}
  512. Procedure ResetFPU;
  513. begin
  514. {$ifdef I386}
  515. asm
  516. fninit
  517. fldcw fpucw
  518. end;
  519. {$endif I386}
  520. end;
  521. {$ifndef BSD}
  522. {$ifndef newSignal}
  523. Procedure SignalToRunError(Sig:longint);
  524. begin
  525. case sig of
  526. 8 : begin
  527. { this is not allways necessary but I don't know yet
  528. how to tell if it is or not PM }
  529. ResetFPU;
  530. HandleError(200);
  531. end;
  532. 11 : HandleError(216);
  533. end;
  534. end;
  535. Procedure InstallSignals;
  536. var
  537. sr : syscallregs;
  538. begin
  539. sr.reg3:=longint(@SignalToRunError);
  540. { sigsegv }
  541. sr.reg2:=11;
  542. syscall(syscall_nr_signal,sr);
  543. { sigfpe }
  544. sr.reg2:=8;
  545. syscall(syscall_nr_signal,sr);
  546. end;
  547. {$else newSignal}
  548. {$i i386/signal.inc}
  549. procedure SignalToRunerror(Sig: longint; SigContext: SigContextRec); cdecl;
  550. var
  551. res,fpustate : word;
  552. begin
  553. res:=0;
  554. case sig of
  555. 8 : begin
  556. { this is not allways necessary but I don't know yet
  557. how to tell if it is or not PM }
  558. {$ifdef I386}
  559. fpustate:=0;
  560. res:=200;
  561. if assigned(SigContext.fpstate) then
  562. fpuState:=SigContext.fpstate^.sw;
  563. {$ifdef SYSTEMDEBUG}
  564. Writeln(stderr,'FpuState = ',Hexstr(FpuState,4));
  565. {$endif SYSTEMDEBUG}
  566. if (FpuState and $7f) <> 0 then
  567. begin
  568. { first check te more precise options }
  569. if (FpuState and FPU_DivisionByZero)<>0 then
  570. res:=200
  571. else if (FpuState and FPU_Overflow)<>0 then
  572. res:=205
  573. else if (FpuState and FPU_Underflow)<>0 then
  574. res:=206
  575. else if (FpuState and FPU_Denormal)<>0 then
  576. res:=216
  577. else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow))<>0 then
  578. res:=207
  579. else if (FpuState and FPU_Invalid)<>0 then
  580. res:=216
  581. else
  582. res:=207; {'Coprocessor Error'}
  583. end;
  584. {$endif I386}
  585. ResetFPU;
  586. end;
  587. 11 : res:=216;
  588. end;
  589. { give runtime error at the position where the signal was raised }
  590. if res<>0 then
  591. begin
  592. {$ifdef I386}
  593. HandleErrorAddrFrame(res,SigContext.eip,SigContext.ebp);
  594. {$else}
  595. HandleError(res);
  596. {$endif}
  597. end;
  598. end;
  599. Procedure InstallSignals;
  600. const
  601. act: SigActionRec = (handler:(Sa:@SignalToRunError);sa_mask:0;sa_flags:0;
  602. Sa_restorer: NIL);
  603. oldact: PSigActionRec = Nil;
  604. begin
  605. ResetFPU;
  606. SigAction(8,@act,oldact);
  607. SigAction(11,@act,oldact);
  608. end;
  609. {$endif newSignal}
  610. {$endif bsd}
  611. procedure SetupCmdLine;
  612. var
  613. bufsize,
  614. len,j,
  615. size,i : longint;
  616. found : boolean;
  617. buf : array[0..1026] of char;
  618. procedure AddBuf;
  619. begin
  620. reallocmem(cmdline,size+bufsize);
  621. move(buf,cmdline[size],bufsize);
  622. inc(size,bufsize);
  623. bufsize:=0;
  624. end;
  625. begin
  626. size:=0;
  627. bufsize:=0;
  628. i:=0;
  629. while (i<argc) do
  630. begin
  631. len:=strlen(argv[i]);
  632. if len>sizeof(buf)-2 then
  633. len:=sizeof(buf)-2;
  634. found:=false;
  635. for j:=1 to len do
  636. if argv[i][j]=' ' then
  637. begin
  638. found:=true;
  639. break;
  640. end;
  641. if bufsize+len>=sizeof(buf)-2 then
  642. AddBuf;
  643. if found then
  644. begin
  645. buf[bufsize]:='"';
  646. inc(bufsize);
  647. end;
  648. move(argv[i]^,buf[bufsize],len);
  649. inc(bufsize,len);
  650. if found then
  651. begin
  652. buf[bufsize]:='"';
  653. inc(bufsize);
  654. end;
  655. if i<argc then
  656. buf[bufsize]:=' '
  657. else
  658. buf[bufsize]:=#0;
  659. inc(bufsize);
  660. inc(i);
  661. end;
  662. AddBuf;
  663. end;
  664. Begin
  665. { Set up signals handlers }
  666. {$ifndef bsd}
  667. InstallSignals;
  668. {$endif}
  669. { Setup heap }
  670. InitHeap;
  671. InitExceptions;
  672. { Arguments }
  673. SetupCmdLine;
  674. { Setup stdin, stdout and stderr }
  675. OpenStdIO(Input,fmInput,StdInputHandle);
  676. OpenStdIO(Output,fmOutput,StdOutputHandle);
  677. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  678. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  679. { Reset IO Error }
  680. InOutRes:=0;
  681. End.
  682. {
  683. $Log$
  684. Revision 1.5 2000-08-13 08:43:45 peter
  685. * don't check for directory in do_open (merged)
  686. Revision 1.4 2000/08/05 18:33:51 peter
  687. * paramstr(0) fix for linux 2.0 kernels (merged)
  688. Revision 1.3 2000/07/14 10:33:10 michael
  689. + Conditionals fixed
  690. Revision 1.2 2000/07/13 11:33:49 michael
  691. + removed logs
  692. }