sysutils.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2004 by the Free Pascal development team.
  5. Sysutils unit for netware (libc)
  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. unit sysutils;
  13. interface
  14. {$MODE objfpc}
  15. { force ansistrings }
  16. {$H+}
  17. uses Libc,DOS;
  18. TYPE
  19. TNetwareLibcFindData =
  20. RECORD
  21. DirP : Pdirent; { used for opendir }
  22. EntryP: Pdirent; { and readdir }
  23. Magic : longint; { to avoid abends with uninitialized TSearchRec }
  24. _mask : string; { search mask i.e. *.* }
  25. _dir : string; { directory where to search }
  26. _attr : longint; { specified attribute }
  27. fname : string; { full pathname of found file }
  28. END;
  29. {$DEFINE HAS_SLEEP}
  30. { Include platform independent interface part }
  31. {$i sysutilh.inc}
  32. { additional NetWare file flags}
  33. CONST
  34. faSHARE = M_A_SHARE shr 16; // Sharable file
  35. //faNO_SUBALLOC = $00000800; // Don't sub alloc. this file
  36. faTRANS = M_A_TRANS shr 16; // Transactional file (TTS usable)
  37. //faREADAUD = $00004000; // clib only: Read audit
  38. //faWRITAUD = $00008000; // clib only: Write audit
  39. faIMMPURG = M_A_IMMPURG shr 16; // Immediate purge
  40. faNORENAM = M_A_NORENAM shr 16; // Rename inhibit
  41. faNODELET = M_A_NODELET shr 16; // Delete inhibit
  42. faNOCOPY = M_A_NOCOPY shr 16; // Copy inhibit
  43. //faFILE_MIGRATED = $00400000; // clib only: File has been migrated
  44. //faDONT_MIGRATE = $00800000; // clib only: Don't migrate this file
  45. faIMMEDIATE_COMPRESS = M_A_IMMCOMPRESS shr 16; // Compress this file immediately
  46. faFILE_COMPRESSED = M_A_FILE_COMPRESSED shr 16; // File is compressed
  47. faDONT_COMPRESS = M_A_DONT_COMPRESS shr 16; // Don't compress this file
  48. faCANT_COMPRESS = M_A_CANT_COMPRESS shr 16; // Can't compress this file
  49. //faATTR_ARCHIVE = $40000000; // clib only: Entry has had an EA modified,
  50. // an ownerID changed, or trustee
  51. // info changed, etc.
  52. faSetNetwareAttrs = M_A_BITS_SIGNIFICANT; // if this is set, netware flags are changed also
  53. implementation
  54. uses
  55. sysconst;
  56. { Include platform independent implementation part }
  57. {$i sysutils.inc}
  58. {****************************************************************************
  59. File Functions
  60. ****************************************************************************}
  61. Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
  62. VAR NWOpenFlags : longint;
  63. BEGIN
  64. NWOpenFlags:=0;
  65. Case (Mode and 3) of
  66. 0 : NWOpenFlags:=NWOpenFlags or O_RDONLY;
  67. 1 : NWOpenFlags:=NWOpenFlags or O_WRONLY;
  68. 2 : NWOpenFlags:=NWOpenFlags or O_RDWR;
  69. end;
  70. FileOpen := Fpopen (pchar(FileName),NWOpenFlags);
  71. //!! We need to set locking based on Mode !!
  72. end;
  73. Function FileCreate (Const FileName : String) : Longint;
  74. begin
  75. FileCreate:=Fpopen(Pchar(FileName),O_RdWr or O_Creat or O_Trunc or O_Binary);
  76. if FileCreate >= 0 then
  77. FileSetAttr (Filename, 0); // dont know why but open always sets ReadOnly flag
  78. end;
  79. Function FileCreate (Const FileName : String; mode:longint) : Longint;
  80. begin
  81. FileCreate:=FileCreate (FileName);
  82. end;
  83. Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
  84. begin
  85. FileRead:=libc.fpread (Handle,@Buffer,Count);
  86. end;
  87. Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
  88. begin
  89. FileWrite:=libc.fpwrite (Handle,@Buffer,Count);
  90. end;
  91. Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
  92. begin
  93. FileSeek:=libc.fplseek (Handle,FOffset,Origin);
  94. end;
  95. Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
  96. begin
  97. FileSeek:=libc.fplseek64 (Handle,FOffset,Origin);
  98. end;
  99. Procedure FileClose (Handle : Longint);
  100. begin
  101. libc.fpclose(Handle);
  102. end;
  103. Function FileTruncate (Handle,Size: Longint) : boolean;
  104. begin
  105. FileTruncate:=(libc.fpchsize(Handle,Size) = 0);
  106. end;
  107. Function FileLock (Handle,FOffset,FLen : Longint) : Longint;
  108. begin
  109. {$warning FileLock not implemented}
  110. //FileLock := _lock (Handle,FOffset,FLen);
  111. FileLock := -1;
  112. end;
  113. Function FileLock (Handle : Longint; FOffset,FLen : Int64) : Longint;
  114. begin
  115. {$warning need to add 64bit FileLock call }
  116. //FileLock := FileLock (Handle, longint(FOffset),longint(FLen));
  117. FileLock := -1;
  118. end;
  119. Function FileUnlock (Handle,FOffset,FLen : Longint) : Longint;
  120. begin
  121. //FileUnlock := _unlock (Handle,FOffset,FLen);
  122. {$warning FileUnLock not implemented}
  123. FileUnlock := -1;
  124. end;
  125. Function FileUnlock (Handle : Longint; FOffset,FLen : Int64) : Longint;
  126. begin
  127. {$warning need to add 64bit FileUnlock call }
  128. //FileUnlock := FileUnlock (Handle, longint(FOffset),longint(FLen));
  129. FileUnlock := -1;
  130. end;
  131. Function FileAge (Const FileName : String): Longint;
  132. var Info : TStat;
  133. TM : TTM;
  134. begin
  135. If Fpstat (pchar(FileName),Info) <> 0 then
  136. exit(-1)
  137. else
  138. begin
  139. localtime_r (Info.st_mtim.tv_sec,tm);
  140. with TM do
  141. result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  142. end;
  143. end;
  144. Function FileExists (Const FileName : String) : Boolean;
  145. VAR Info : TStat;
  146. begin
  147. FileExists:=(Fpstat(pchar(filename),Info) = 0);
  148. end;
  149. Function UnixToWinAge(UnixAge : time_t): Longint;
  150. Var tm : TTm;
  151. begin
  152. libc.localtime_r (UnixAge, tm);
  153. with tm do
  154. Result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  155. end;
  156. {returns true if attributes match}
  157. function find_setfields (var f : TsearchRec; var AttrsOk : boolean) : longint;
  158. var
  159. StatBuf : TStat;
  160. fname : string;
  161. begin
  162. result := 0;
  163. with F do
  164. begin
  165. if FindData.Magic = $AD02 then
  166. begin
  167. attr := (Pdirent(FindData.EntryP)^.d_mode shr 16) and $ffff;
  168. size := Pdirent(FindData.EntryP)^.d_size;
  169. name := strpas (Pdirent(FindData.EntryP)^.d_name);
  170. fname := FindData._dir + name;
  171. if Fpstat (pchar(fname),StatBuf) = 0 then
  172. time := UnixToWinAge (StatBuf.st_mtim.tv_sec)
  173. else
  174. time := 0;
  175. AttrsOk := false;
  176. if (f.FindData._attr and faHidden) = 0 then
  177. if attr and faHidden > 0 then exit;
  178. if (f.FindData._attr and faDirectory) = 0 then
  179. if attr and faDirectory > 0 then exit;
  180. if (f.FindData._attr and faSysFile) = 0 then
  181. if attr and faSysFile > 0 then exit;
  182. AttrsOk := true;
  183. end else
  184. begin
  185. FillChar (f,sizeof(f),0);
  186. result := 18;
  187. end;
  188. end;
  189. end;
  190. function findfirst(const path : string;attr : longint;var Rslt : TsearchRec) : longint;
  191. var
  192. path0 : string;
  193. p : longint;
  194. begin
  195. IF path = '' then
  196. begin
  197. result := 18;
  198. exit;
  199. end;
  200. Rslt.FindData._attr := attr;
  201. p := length (path);
  202. while (p > 0) and (not (path[p] in ['\','/'])) do
  203. dec (p);
  204. if p > 0 then
  205. begin
  206. Rslt.FindData._mask := copy (path,p+1,255);
  207. Rslt.FindData._dir := copy (path,1,p);
  208. end else
  209. begin
  210. Rslt.FindData._mask := path;
  211. Rslt.FindData._dir := GetCurrentDir;
  212. if (Rslt.FindData._dir[length(Rslt.FindData._dir)] <> '/') and
  213. (Rslt.FindData._dir[length(Rslt.FindData._dir)] <> '\') then
  214. Rslt.FindData._dir := Rslt.FindData._dir + '/';
  215. end;
  216. if Rslt.FindData._mask = '*' then Rslt.FindData._mask := '';
  217. if Rslt.FindData._mask = '*.*' then Rslt.FindData._mask := '';
  218. //writeln (stderr,'mask: "',Rslt._mask,'" dir:"',path0,'"');
  219. Pdirent(Rslt.FindData.DirP) := opendir (pchar(Rslt.FindData._dir));
  220. if Rslt.FindData.DirP = nil then
  221. result := 18
  222. else begin
  223. Rslt.FindData.Magic := $AD02;
  224. result := findnext (Rslt);
  225. end;
  226. end;
  227. function findnext(var Rslt : TsearchRec) : longint;
  228. var attrsOk : boolean;
  229. begin
  230. if Rslt.FindData.Magic <> $AD02 then
  231. begin
  232. result := 18;
  233. exit;
  234. end;
  235. result:=0;
  236. repeat
  237. Pdirent(Rslt.FindData.EntryP) := readdir (Pdirent(Rslt.FindData.DirP));
  238. if Rslt.FindData.EntryP = nil then
  239. result := 18
  240. else
  241. result := find_setfields (Rslt,attrsOk);
  242. if (result = 0) and (attrsOk) then
  243. begin
  244. if Rslt.FindData._mask = #0 then exit;
  245. if fnmatch(@Rslt.FindData._mask[1],Pdirent(Rslt.FindData.EntryP)^.d_name,FNM_CASEFOLD) = 0 then
  246. exit;
  247. end;
  248. until result <> 0;
  249. end;
  250. Procedure FindClose(Var f: TSearchRec);
  251. begin
  252. if F.FindData.Magic <> $AD02 then exit;
  253. doserror:=0;
  254. closedir (Pdirent(f.FindData.DirP));
  255. FillChar (f,sizeof(f),0);
  256. end;
  257. Function FileGetDate (Handle : Longint) : Longint;
  258. Var Info : TStat;
  259. _PTM : PTM;
  260. begin
  261. If Fpfstat(Handle,Info) <> 0 then
  262. Result:=-1
  263. else
  264. begin
  265. _PTM := localtime (Info.st_mtim.tv_sec);
  266. IF _PTM = NIL THEN
  267. exit(-1)
  268. else
  269. with _PTM^ do
  270. Result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  271. end;
  272. end;
  273. Function FileSetDate (Handle,Age : Longint) : Longint;
  274. Begin
  275. {dont know how to do that, utime needs filename}
  276. result := -1;
  277. end;
  278. Function FileGetAttr (Const FileName : String) : Longint;
  279. Var Info : TStat;
  280. begin
  281. If Fpstat (pchar(FileName),Info) <> 0 then
  282. Result:=-1
  283. Else
  284. Result := (Info.st_mode shr 16) and $ffff;
  285. end;
  286. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  287. var
  288. StatBuf : TStat;
  289. newMode : longint;
  290. begin
  291. if Fpstat (pchar(Filename),StatBuf) = 0 then
  292. begin
  293. {what should i do here ?
  294. only support sysutils-standard attributes or also support the extensions defined
  295. only for netware libc ?
  296. For now i allow the complete attributes if the bit faSetNetwareAttrs is set. Otherwise
  297. only the standard attributes can be modified}
  298. if attr and faSetNetwareAttrs > 0 then
  299. begin
  300. newmode := ((attr shl 16) and $ffff0000) or M_A_BITS_SIGNIFICANT;
  301. end else
  302. begin
  303. attr := (attr and $2f) shl 16;
  304. newmode := StatBuf.st_mode and ($ffff0000-M_A_RDONLY-M_A_HIDDEN- M_A_SYSTEM-M_A_SUBDIR-M_A_ARCH);
  305. newmode := newmode or (attr shl 16) or M_A_BITS_SIGNIFICANT;
  306. end;
  307. if Fpchmod (pchar(Filename),newMode) < 0 then
  308. result := ___errno^ else
  309. result := 0;
  310. end else
  311. result := ___errno^;
  312. end;
  313. Function DeleteFile (Const FileName : String) : Boolean;
  314. begin
  315. Result:= (libc.UnLink (pchar(FileName)) = 0);
  316. end;
  317. Function RenameFile (Const OldName, NewName : String) : Boolean;
  318. begin
  319. RenameFile:=(libc.rename(pchar(OldName),pchar(NewName)) = 0);
  320. end;
  321. {****************************************************************************
  322. Disk Functions
  323. ****************************************************************************}
  324. {
  325. The Diskfree and Disksize functions need a file on the specified drive, since this
  326. is required for the statfs system call.
  327. These filenames are set in drivestr[0..26], and have been preset to :
  328. 0 - '.' (default drive - hence current dir is ok.)
  329. 1 - '/fd0/.' (floppy drive 1 - should be adapted to local system )
  330. 2 - '/fd1/.' (floppy drive 2 - should be adapted to local system )
  331. 3 - '/' (C: equivalent of dos is the root partition)
  332. 4..26 (can be set by you're own applications)
  333. ! Use AddDisk() to Add new drives !
  334. They both return -1 when a failure occurs.
  335. }
  336. Const
  337. FixDriveStr : array[0..3] of pchar=(
  338. '.',
  339. 'a:.',
  340. 'b:.',
  341. 'sys:/'
  342. );
  343. var
  344. Drives : byte;
  345. DriveStr : array[4..26] of pchar;
  346. Procedure AddDisk(const path:string);
  347. begin
  348. if not (DriveStr[Drives]=nil) then
  349. FreeMem(DriveStr[Drives],StrLen(DriveStr[Drives])+1);
  350. GetMem(DriveStr[Drives],length(Path)+1);
  351. StrPCopy(DriveStr[Drives],path);
  352. inc(Drives);
  353. if Drives>26 then
  354. Drives:=4;
  355. end;
  356. Function DiskFree(Drive: Byte): int64;
  357. //var fs : Tstatfs;
  358. Begin
  359. { if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and fsstat(StrPas(fixdrivestr[drive]),fs)) or
  360. ((not (drivestr[Drive]=nil)) and fsstat(StrPas(drivestr[drive]),fs)) then
  361. Diskfree:=int64(fs.bavail)*int64(fs.bsize)
  362. else
  363. Diskfree:=-1;}
  364. DiskFree := -1;
  365. ConsolePrintf ('warning: fpc sysutils.diskfree not implemented'#13#10);
  366. {$warning DiskFree not implemented (does it make sense ?) }
  367. End;
  368. Function DiskSize(Drive: Byte): int64;
  369. //var fs : statfs;
  370. Begin
  371. { if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and fsstat(StrPas(fixdrivestr[drive]),fs)) or
  372. ((not (drivestr[Drive]=nil)) and fsstat(StrPas(drivestr[drive]),fs)) then
  373. DiskSize:=int64(fs.blocks)*int64(fs.bsize)
  374. else
  375. DiskSize:=-1;}
  376. DiskSize := -1;
  377. ConsolePrintf ('warning: fpc sysutils.disksize not implemented'#13#10);
  378. {$warning DiskSize not implemented (does it make sense ?) }
  379. End;
  380. Function GetCurrentDir : String;
  381. begin
  382. GetDir (0,Result);
  383. end;
  384. Function SetCurrentDir (Const NewDir : String) : Boolean;
  385. begin
  386. Libc.FpChDir(pchar(NewDir));
  387. result := (___errno^ = 0);
  388. end;
  389. Function CreateDir (Const NewDir : String) : Boolean;
  390. begin
  391. Libc.FpMkDir(pchar(NewDir),0);
  392. result := (___errno^ = 0);
  393. end;
  394. Function RemoveDir (Const Dir : String) : Boolean;
  395. begin
  396. libc.FpRmDir(pchar(Dir));
  397. result := (___errno^ = 0);
  398. end;
  399. function DirectoryExists (const Directory: string): boolean;
  400. var Info : TStat;
  401. begin
  402. If Fpstat (pchar(Directory),Info) <> 0 then
  403. exit(false)
  404. else
  405. Exit ((Info.st_mode and M_A_SUBDIR) <> 0);
  406. end;
  407. {****************************************************************************
  408. Misc Functions
  409. ****************************************************************************}
  410. procedure Beep;
  411. begin
  412. RingBell;
  413. end;
  414. {****************************************************************************
  415. Locale Functions
  416. ****************************************************************************}
  417. Procedure GetLocalTime(var SystemTime: TSystemTime);
  418. var t : TTime;
  419. tm: Ttm;
  420. begin
  421. libc.time(t);
  422. libc.localtime_r(t,tm);
  423. with SystemTime do
  424. begin
  425. Hour := tm.tm_hour;
  426. Minute := tm.tm_min;
  427. Second := tm.tm_sec;
  428. MilliSecond := 0;
  429. Day := tm.tm_mday;
  430. Month := tm.tm_mon+1;
  431. Year := tm.tm_year+1900;
  432. end;
  433. end;
  434. Procedure InitAnsi;
  435. Var i : longint;
  436. begin
  437. { Fill table entries 0 to 127 }
  438. for i := 0 to 96 do
  439. UpperCaseTable[i] := chr(i);
  440. for i := 97 to 122 do
  441. UpperCaseTable[i] := chr(i - 32);
  442. for i := 123 to 191 do
  443. UpperCaseTable[i] := chr(i);
  444. Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  445. for i := 0 to 64 do
  446. LowerCaseTable[i] := chr(i);
  447. for i := 65 to 90 do
  448. LowerCaseTable[i] := chr(i + 32);
  449. for i := 91 to 191 do
  450. LowerCaseTable[i] := chr(i);
  451. Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  452. end;
  453. Procedure InitInternational;
  454. begin
  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.
  579. {
  580. $Log$
  581. Revision 1.8 2005-01-04 11:25:34 armin
  582. * rtl code cleanup, compat fixes between clib and libc
  583. Revision 1.7 2004/12/16 12:42:55 armin
  584. * added NetWare Alert
  585. * added sysutils.sleep
  586. Revision 1.6 2004/12/14 19:23:22 armin
  587. * dont copy imp files with a rule because this always builds system.pp
  588. * implemented GetEnvironmentVariableCount and GetEnvironmentString
  589. * removed dependency from dos unit
  590. Revision 1.5 2004/12/11 11:32:44 michael
  591. + Added GetEnvironmentVariableCount and GetEnvironmentString calls
  592. Revision 1.4 2004/09/26 19:23:34 armin
  593. * exiting threads at nlm unload
  594. * renamed some libc functions
  595. Revision 1.3 2004/09/19 20:06:37 armin
  596. * removed get/free video buf from video.pp
  597. * implemented sockets
  598. * basic library support
  599. * threadvar memory leak removed
  600. * fixes (ide now starts and editor is usable)
  601. * support for lineinfo
  602. Revision 1.2 2004/09/12 20:51:22 armin
  603. * added keyboard and video
  604. * a lot of fixes
  605. Revision 1.1 2004/09/05 20:58:47 armin
  606. * first rtl version for netwlibc
  607. }