sysutils.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2004 by the Free Pascal development team.
  4. Sysutils unit for netware (libc)
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit sysutils;
  12. interface
  13. {$MODE objfpc}
  14. { force ansistrings }
  15. {$H+}
  16. uses Libc,DOS;
  17. TYPE
  18. TNetwareLibcFindData =
  19. RECORD
  20. DirP : Pdirent; { used for opendir }
  21. EntryP: Pdirent; { and readdir }
  22. Magic : longint; { to avoid abends with uninitialized TSearchRec }
  23. _mask : string; { search mask i.e. *.* }
  24. _dir : string; { directory where to search }
  25. _attr : longint; { specified attribute }
  26. fname : string; { full pathname of found file }
  27. END;
  28. {$DEFINE HAS_SLEEP}
  29. { Include platform independent interface part }
  30. {$i sysutilh.inc}
  31. { additional NetWare file flags}
  32. CONST
  33. faSHARE = M_A_SHARE shr 16; // Sharable file
  34. //faNO_SUBALLOC = $00000800; // Don't sub alloc. this file
  35. faTRANS = M_A_TRANS shr 16; // Transactional file (TTS usable)
  36. //faREADAUD = $00004000; // clib only: Read audit
  37. //faWRITAUD = $00008000; // clib only: Write audit
  38. faIMMPURG = M_A_IMMPURG shr 16; // Immediate purge
  39. faNORENAM = M_A_NORENAM shr 16; // Rename inhibit
  40. faNODELET = M_A_NODELET shr 16; // Delete inhibit
  41. faNOCOPY = M_A_NOCOPY shr 16; // Copy inhibit
  42. //faFILE_MIGRATED = $00400000; // clib only: File has been migrated
  43. //faDONT_MIGRATE = $00800000; // clib only: Don't migrate this file
  44. faIMMEDIATE_COMPRESS = M_A_IMMCOMPRESS shr 16; // Compress this file immediately
  45. faFILE_COMPRESSED = M_A_FILE_COMPRESSED shr 16; // File is compressed
  46. faDONT_COMPRESS = M_A_DONT_COMPRESS shr 16; // Don't compress this file
  47. faCANT_COMPRESS = M_A_CANT_COMPRESS shr 16; // Can't compress this file
  48. //faATTR_ARCHIVE = $40000000; // clib only: Entry has had an EA modified,
  49. // an ownerID changed, or trustee
  50. // info changed, etc.
  51. faSetNetwareAttrs = M_A_BITS_SIGNIFICANT; // if this is set, netware flags are changed also
  52. implementation
  53. uses
  54. sysconst;
  55. { Include platform independent implementation part }
  56. {$i sysutils.inc}
  57. {****************************************************************************
  58. File Functions
  59. ****************************************************************************}
  60. Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
  61. VAR NWOpenFlags : longint;
  62. BEGIN
  63. NWOpenFlags:=0;
  64. Case (Mode and 3) of
  65. 0 : NWOpenFlags:=NWOpenFlags or O_RDONLY;
  66. 1 : NWOpenFlags:=NWOpenFlags or O_WRONLY;
  67. 2 : NWOpenFlags:=NWOpenFlags or O_RDWR;
  68. end;
  69. FileOpen := Fpopen (pchar(FileName),NWOpenFlags);
  70. //!! We need to set locking based on Mode !!
  71. end;
  72. Function FileCreate (Const FileName : String) : Longint;
  73. begin
  74. FileCreate:=Fpopen(Pchar(FileName),O_RdWr or O_Creat or O_Trunc or O_Binary);
  75. if FileCreate >= 0 then
  76. FileSetAttr (Filename, 0); // dont know why but open always sets ReadOnly flag
  77. end;
  78. Function FileCreate (Const FileName : String; mode:longint) : Longint;
  79. begin
  80. FileCreate:=FileCreate (FileName);
  81. end;
  82. Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
  83. begin
  84. FileRead:=libc.fpread (Handle,@Buffer,Count);
  85. end;
  86. Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
  87. begin
  88. FileWrite:=libc.fpwrite (Handle,@Buffer,Count);
  89. end;
  90. Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
  91. begin
  92. FileSeek:=libc.fplseek (Handle,FOffset,Origin);
  93. end;
  94. Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
  95. begin
  96. FileSeek:=libc.fplseek64 (Handle,FOffset,Origin);
  97. end;
  98. Procedure FileClose (Handle : Longint);
  99. begin
  100. libc.fpclose(Handle);
  101. end;
  102. Function FileTruncate (Handle,Size: Longint) : boolean;
  103. begin
  104. FileTruncate:=(libc.fpchsize(Handle,Size) = 0);
  105. end;
  106. Function FileLock (Handle,FOffset,FLen : Longint) : Longint;
  107. begin
  108. {$warning FileLock not implemented}
  109. //FileLock := _lock (Handle,FOffset,FLen);
  110. FileLock := -1;
  111. end;
  112. Function FileLock (Handle : Longint; FOffset,FLen : Int64) : Longint;
  113. begin
  114. {$warning need to add 64bit FileLock call }
  115. //FileLock := FileLock (Handle, longint(FOffset),longint(FLen));
  116. FileLock := -1;
  117. end;
  118. Function FileUnlock (Handle,FOffset,FLen : Longint) : Longint;
  119. begin
  120. //FileUnlock := _unlock (Handle,FOffset,FLen);
  121. {$warning FileUnLock not implemented}
  122. FileUnlock := -1;
  123. end;
  124. Function FileUnlock (Handle : Longint; FOffset,FLen : Int64) : Longint;
  125. begin
  126. {$warning need to add 64bit FileUnlock call }
  127. //FileUnlock := FileUnlock (Handle, longint(FOffset),longint(FLen));
  128. FileUnlock := -1;
  129. end;
  130. Function FileAge (Const FileName : String): Longint;
  131. var Info : TStat;
  132. TM : TTM;
  133. begin
  134. If Fpstat (pchar(FileName),Info) <> 0 then
  135. exit(-1)
  136. else
  137. begin
  138. localtime_r (Info.st_mtim.tv_sec,tm);
  139. with TM do
  140. result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  141. end;
  142. end;
  143. Function FileExists (Const FileName : String) : Boolean;
  144. VAR Info : TStat;
  145. begin
  146. FileExists:=(Fpstat(pchar(filename),Info) = 0);
  147. end;
  148. Function UnixToWinAge(UnixAge : time_t): Longint;
  149. Var tm : TTm;
  150. begin
  151. libc.localtime_r (UnixAge, tm);
  152. with tm do
  153. Result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  154. end;
  155. {returns true if attributes match}
  156. function find_setfields (var f : TsearchRec; var AttrsOk : boolean) : longint;
  157. var
  158. StatBuf : TStat;
  159. fname : string;
  160. begin
  161. result := 0;
  162. with F do
  163. begin
  164. if FindData.Magic = $AD02 then
  165. begin
  166. attr := (Pdirent(FindData.EntryP)^.d_mode shr 16) and $ffff;
  167. size := Pdirent(FindData.EntryP)^.d_size;
  168. name := strpas (Pdirent(FindData.EntryP)^.d_name);
  169. fname := FindData._dir + name;
  170. if Fpstat (pchar(fname),StatBuf) = 0 then
  171. time := UnixToWinAge (StatBuf.st_mtim.tv_sec)
  172. else
  173. time := 0;
  174. AttrsOk := false;
  175. if (f.FindData._attr and faHidden) = 0 then
  176. if attr and faHidden > 0 then exit;
  177. if (f.FindData._attr and faDirectory) = 0 then
  178. if attr and faDirectory > 0 then exit;
  179. if (f.FindData._attr and faSysFile) = 0 then
  180. if attr and faSysFile > 0 then exit;
  181. AttrsOk := true;
  182. end else
  183. begin
  184. FillChar (f,sizeof(f),0);
  185. result := 18;
  186. end;
  187. end;
  188. end;
  189. function findfirst(const path : string;attr : longint; out Rslt : TsearchRec) : longint;
  190. var
  191. path0 : string;
  192. p : longint;
  193. begin
  194. IF path = '' then
  195. begin
  196. result := 18;
  197. exit;
  198. end;
  199. Rslt.FindData._attr := attr;
  200. p := length (path);
  201. while (p > 0) and (not (path[p] in ['\','/'])) do
  202. dec (p);
  203. if p > 0 then
  204. begin
  205. Rslt.FindData._mask := copy (path,p+1,255);
  206. Rslt.FindData._dir := copy (path,1,p);
  207. end else
  208. begin
  209. Rslt.FindData._mask := path;
  210. Rslt.FindData._dir := GetCurrentDir;
  211. if (Rslt.FindData._dir[length(Rslt.FindData._dir)] <> '/') and
  212. (Rslt.FindData._dir[length(Rslt.FindData._dir)] <> '\') then
  213. Rslt.FindData._dir := Rslt.FindData._dir + '/';
  214. end;
  215. if Rslt.FindData._mask = '*' then Rslt.FindData._mask := '';
  216. if Rslt.FindData._mask = '*.*' then Rslt.FindData._mask := '';
  217. //writeln (stderr,'mask: "',Rslt._mask,'" dir:"',path0,'"');
  218. Pdirent(Rslt.FindData.DirP) := opendir (pchar(Rslt.FindData._dir));
  219. if Rslt.FindData.DirP = nil then
  220. result := 18
  221. else begin
  222. Rslt.FindData.Magic := $AD02;
  223. result := findnext (Rslt);
  224. end;
  225. end;
  226. function findnext(var Rslt : TsearchRec) : longint;
  227. var attrsOk : boolean;
  228. begin
  229. if Rslt.FindData.Magic <> $AD02 then
  230. begin
  231. result := 18;
  232. exit;
  233. end;
  234. result:=0;
  235. repeat
  236. Pdirent(Rslt.FindData.EntryP) := readdir (Pdirent(Rslt.FindData.DirP));
  237. if Rslt.FindData.EntryP = nil then
  238. result := 18
  239. else
  240. result := find_setfields (Rslt,attrsOk);
  241. if (result = 0) and (attrsOk) then
  242. begin
  243. if Rslt.FindData._mask = #0 then exit;
  244. if fnmatch(@Rslt.FindData._mask[1],Pdirent(Rslt.FindData.EntryP)^.d_name,FNM_CASEFOLD) = 0 then
  245. exit;
  246. end;
  247. until result <> 0;
  248. end;
  249. Procedure FindClose(Var f: TSearchRec);
  250. begin
  251. if F.FindData.Magic <> $AD02 then exit;
  252. doserror:=0;
  253. closedir (Pdirent(f.FindData.DirP));
  254. FillChar (f,sizeof(f),0);
  255. end;
  256. Function FileGetDate (Handle : Longint) : Longint;
  257. Var Info : TStat;
  258. _PTM : PTM;
  259. begin
  260. If Fpfstat(Handle,Info) <> 0 then
  261. Result:=-1
  262. else
  263. begin
  264. _PTM := localtime (Info.st_mtim.tv_sec);
  265. IF _PTM = NIL THEN
  266. exit(-1)
  267. else
  268. with _PTM^ do
  269. Result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  270. end;
  271. end;
  272. Function FileSetDate (Handle,Age : Longint) : Longint;
  273. Begin
  274. {dont know how to do that, utime needs filename}
  275. result := -1;
  276. end;
  277. Function FileGetAttr (Const FileName : String) : Longint;
  278. Var Info : TStat;
  279. begin
  280. If Fpstat (pchar(FileName),Info) <> 0 then
  281. Result:=-1
  282. Else
  283. Result := (Info.st_mode shr 16) and $ffff;
  284. end;
  285. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  286. var
  287. StatBuf : TStat;
  288. newMode : longint;
  289. begin
  290. if Fpstat (pchar(Filename),StatBuf) = 0 then
  291. begin
  292. {what should i do here ?
  293. only support sysutils-standard attributes or also support the extensions defined
  294. only for netware libc ?
  295. For now i allow the complete attributes if the bit faSetNetwareAttrs is set. Otherwise
  296. only the standard attributes can be modified}
  297. if attr and faSetNetwareAttrs > 0 then
  298. begin
  299. newmode := ((attr shl 16) and $ffff0000) or M_A_BITS_SIGNIFICANT;
  300. end else
  301. begin
  302. attr := (attr and $2f) shl 16;
  303. newmode := StatBuf.st_mode and ($ffff0000-M_A_RDONLY-M_A_HIDDEN- M_A_SYSTEM-M_A_SUBDIR-M_A_ARCH);
  304. newmode := newmode or (attr shl 16) or M_A_BITS_SIGNIFICANT;
  305. end;
  306. if Fpchmod (pchar(Filename),newMode) < 0 then
  307. result := ___errno^ else
  308. result := 0;
  309. end else
  310. result := ___errno^;
  311. end;
  312. Function DeleteFile (Const FileName : String) : Boolean;
  313. begin
  314. Result:= (libc.UnLink (pchar(FileName)) = 0);
  315. end;
  316. Function RenameFile (Const OldName, NewName : String) : Boolean;
  317. begin
  318. RenameFile:=(libc.rename(pchar(OldName),pchar(NewName)) = 0);
  319. end;
  320. {****************************************************************************
  321. Disk Functions
  322. ****************************************************************************}
  323. {
  324. The Diskfree and Disksize functions need a file on the specified drive, since this
  325. is required for the statfs system call.
  326. These filenames are set in drivestr[0..26], and have been preset to :
  327. 0 - '.' (default drive - hence current dir is ok.)
  328. 1 - '/fd0/.' (floppy drive 1 - should be adapted to local system )
  329. 2 - '/fd1/.' (floppy drive 2 - should be adapted to local system )
  330. 3 - '/' (C: equivalent of dos is the root partition)
  331. 4..26 (can be set by you're own applications)
  332. ! Use AddDisk() to Add new drives !
  333. They both return -1 when a failure occurs.
  334. }
  335. Const
  336. FixDriveStr : array[0..3] of pchar=(
  337. '.',
  338. 'a:.',
  339. 'b:.',
  340. 'sys:/'
  341. );
  342. var
  343. Drives : byte;
  344. DriveStr : array[4..26] of pchar;
  345. Procedure AddDisk(const path:string);
  346. begin
  347. if not (DriveStr[Drives]=nil) then
  348. FreeMem(DriveStr[Drives],StrLen(DriveStr[Drives])+1);
  349. GetMem(DriveStr[Drives],length(Path)+1);
  350. StrPCopy(DriveStr[Drives],path);
  351. inc(Drives);
  352. if Drives>26 then
  353. Drives:=4;
  354. end;
  355. Function DiskFree(Drive: Byte): int64;
  356. //var fs : Tstatfs;
  357. Begin
  358. { if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and fsstat(StrPas(fixdrivestr[drive]),fs)) or
  359. ((not (drivestr[Drive]=nil)) and fsstat(StrPas(drivestr[drive]),fs)) then
  360. Diskfree:=int64(fs.bavail)*int64(fs.bsize)
  361. else
  362. Diskfree:=-1;}
  363. DiskFree := -1;
  364. ConsolePrintf ('warning: fpc sysutils.diskfree not implemented'#13#10);
  365. {$warning DiskFree not implemented (does it make sense ?) }
  366. End;
  367. Function DiskSize(Drive: Byte): int64;
  368. //var fs : statfs;
  369. Begin
  370. { if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and fsstat(StrPas(fixdrivestr[drive]),fs)) or
  371. ((not (drivestr[Drive]=nil)) and fsstat(StrPas(drivestr[drive]),fs)) then
  372. DiskSize:=int64(fs.blocks)*int64(fs.bsize)
  373. else
  374. DiskSize:=-1;}
  375. DiskSize := -1;
  376. ConsolePrintf ('warning: fpc sysutils.disksize not implemented'#13#10);
  377. {$warning DiskSize not implemented (does it make sense ?) }
  378. End;
  379. Function GetCurrentDir : String;
  380. begin
  381. GetDir (0,Result);
  382. end;
  383. Function SetCurrentDir (Const NewDir : String) : Boolean;
  384. begin
  385. Libc.FpChDir(pchar(NewDir));
  386. result := (___errno^ = 0);
  387. end;
  388. Function CreateDir (Const NewDir : String) : Boolean;
  389. begin
  390. Libc.FpMkDir(pchar(NewDir),0);
  391. result := (___errno^ = 0);
  392. end;
  393. Function RemoveDir (Const Dir : String) : Boolean;
  394. begin
  395. libc.FpRmDir(pchar(Dir));
  396. result := (___errno^ = 0);
  397. end;
  398. function DirectoryExists (const Directory: string): boolean;
  399. var Info : TStat;
  400. begin
  401. If Fpstat (pchar(Directory),Info) <> 0 then
  402. exit(false)
  403. else
  404. Exit ((Info.st_mode and M_A_SUBDIR) <> 0);
  405. end;
  406. {****************************************************************************
  407. Misc Functions
  408. ****************************************************************************}
  409. procedure Beep;
  410. begin
  411. RingBell;
  412. end;
  413. {****************************************************************************
  414. Locale Functions
  415. ****************************************************************************}
  416. Procedure GetLocalTime(var SystemTime: TSystemTime);
  417. var t : TTime;
  418. tm: Ttm;
  419. begin
  420. libc.time(t);
  421. libc.localtime_r(t,tm);
  422. with SystemTime do
  423. begin
  424. Hour := tm.tm_hour;
  425. Minute := tm.tm_min;
  426. Second := tm.tm_sec;
  427. MilliSecond := 0;
  428. Day := tm.tm_mday;
  429. Month := tm.tm_mon+1;
  430. Year := tm.tm_year+1900;
  431. end;
  432. end;
  433. Procedure InitAnsi;
  434. Var i : longint;
  435. begin
  436. { Fill table entries 0 to 127 }
  437. for i := 0 to 96 do
  438. UpperCaseTable[i] := chr(i);
  439. for i := 97 to 122 do
  440. UpperCaseTable[i] := chr(i - 32);
  441. for i := 123 to 191 do
  442. UpperCaseTable[i] := chr(i);
  443. Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  444. for i := 0 to 64 do
  445. LowerCaseTable[i] := chr(i);
  446. for i := 65 to 90 do
  447. LowerCaseTable[i] := chr(i + 32);
  448. for i := 91 to 191 do
  449. LowerCaseTable[i] := chr(i);
  450. Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  451. end;
  452. Procedure InitInternational;
  453. begin
  454. InitInternationalGeneric;
  455. InitAnsi;
  456. end;
  457. function SysErrorMessage(ErrorCode: Integer): String;
  458. begin
  459. Result:=''; // only found perror that prints the message
  460. end;
  461. {****************************************************************************
  462. OS utility functions
  463. ****************************************************************************}
  464. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  465. begin
  466. Result:=StrPas(libc.getenv(PChar(EnvVar)));
  467. end;
  468. Function GetEnvironmentVariableCount : Integer;
  469. begin
  470. Result:=FPCCountEnvVar(EnvP);
  471. end;
  472. Function GetEnvironmentString(Index : Integer) : String;
  473. begin
  474. Result:=FPCGetEnvStrFromP(Envp,Index);
  475. end;
  476. function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
  477. var
  478. params:array of AnsiString;
  479. count,i: longint;
  480. Buf : pchar;
  481. p : pchar;
  482. CLine: AnsiString;
  483. begin
  484. cLine := ComLine;
  485. buf:=pchar(CLine);
  486. count:=0;
  487. while(buf^<>#0) do
  488. begin
  489. while (buf^ in [' ',#9,#10]) do
  490. inc(buf);
  491. inc(count);
  492. while not (buf^ in [' ',#0,#9,#10]) do
  493. inc(buf);
  494. end;
  495. i := 0;
  496. setlength(params,count);
  497. buf:=pchar(CLine);
  498. while(buf^<>#0) do
  499. begin
  500. while (buf^ in [' ',#9,#10]) do
  501. inc(buf);
  502. p := buf;
  503. while not (buf^ in [' ',#0,#9,#10]) do
  504. inc(buf);
  505. if buf^ <> #0 then
  506. begin
  507. buf^ := #0;
  508. inc(buf);
  509. end;
  510. params[i]:=p;
  511. inc(i);
  512. end;
  513. result := ExecuteProcess (Path, params);
  514. end;
  515. {******************************************************************************
  516. --- Exec ---
  517. ******************************************************************************}
  518. const maxargs=256;
  519. function ExecuteProcess (const Path: AnsiString;
  520. const ComLine: array of AnsiString): integer;
  521. var c : comstr;
  522. i : integer;
  523. args : array[0..maxargs+1] of pchar;
  524. arg0 : string;
  525. numargs,wstat : integer;
  526. Wiring : TWiring;
  527. newPath : string;
  528. e : EOSError;
  529. begin
  530. if pos ('.',path) = 0 then
  531. arg0 := fexpand(path+'.nlm')
  532. else
  533. arg0 := fexpand (path);
  534. args[0] := pchar(arg0);
  535. numargs := 0;
  536. for I := 0 to High (ComLine) do
  537. if numargs < maxargs then
  538. begin
  539. inc(numargs);
  540. args[numargs] := pchar(ComLine[i]);
  541. end;
  542. args[numargs+1] := nil;
  543. Wiring.infd := StdInputHandle; //textrec(Stdin).Handle;
  544. Wiring.outfd:= textrec(stdout).Handle;
  545. Wiring.errfd:= textrec(stderr).Handle;
  546. i := procve(args[0],
  547. PROC_CURRENT_SPACE+PROC_INHERIT_CWD,
  548. envP, // const char * env[] If passed as NULL, the child process inherits the parent.s environment at the time of the call.
  549. @Wiring, // wiring_t *wiring, Pass NULL to inherit system defaults for wiring.
  550. nil, // struct fd_set *fds, Not currently implemented. Pass in NULL.
  551. nil, // void *appdata, Not currently implemented. Pass in NULL.
  552. 0, // size_t appdata_size, Not currently implemented. Pass in 0
  553. nil, // void *reserved, Reserved. Pass NULL.
  554. @args); // const char *argv[]
  555. if i <> -1 then
  556. begin
  557. Fpwaitpid(i,@wstat,0);
  558. result := wstat;
  559. end else
  560. begin
  561. e:=EOSError.CreateFmt(SExecuteProcessFailed,[arg0,___errno^]);
  562. e.ErrorCode:=___errno^;
  563. raise e;
  564. end;
  565. end;
  566. procedure Sleep(milliseconds: Cardinal);
  567. begin
  568. libc._delay (milliseconds);
  569. end;
  570. {****************************************************************************
  571. Initialization code
  572. ****************************************************************************}
  573. Initialization
  574. InitExceptions; { Initialize exceptions. OS independent }
  575. InitInternational; { Initialize internationalization settings }
  576. Finalization
  577. DoneExceptions;
  578. end.