unix.pp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  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. BSD parts (c) 2000 by Marco van de Voort
  6. members of the Free Pascal development team.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. Unit Unix;
  14. Interface
  15. Uses UnixUtil,BaseUnix;
  16. { Get Types and Constants }
  17. {$i sysconst.inc}
  18. {$i systypes.inc}
  19. {Get error numbers, some more signal definitions and other OS dependant
  20. types (that are not POSIX) }
  21. {i errno.inc}
  22. {$I signal.inc}
  23. {$i ostypes.inc}
  24. {********************
  25. File
  26. ********************}
  27. Const
  28. P_IN = 1; // pipes (?)
  29. P_OUT = 2;
  30. Const
  31. LOCK_SH = 1; // flock constants ?
  32. LOCK_EX = 2;
  33. LOCK_UN = 8;
  34. LOCK_NB = 4;
  35. Type
  36. Tpipe = array[1..2] of cint;
  37. pglob = ^tglob;
  38. tglob = record
  39. name : pchar;
  40. next : pglob;
  41. end;
  42. {******************************************************************************
  43. Procedure/Functions
  44. ******************************************************************************}
  45. {**************************
  46. Time/Date Handling
  47. ***************************}
  48. var
  49. tzdaylight : boolean;
  50. tzname : array[boolean] of pchar;
  51. { timezone support }
  52. procedure GetLocalTimezone(timer:cint;var leap_correct,leap_hit:cint);
  53. procedure GetLocalTimezone(timer:cint);
  54. procedure ReadTimezoneFile(fn:string);
  55. function GetTimezoneFile:string;
  56. Function GetEpochTime: cint;
  57. procedure GetTime (var hour,min,sec,msec,usec:word);
  58. procedure GetTime (var hour,min,sec,sec100:word);
  59. procedure GetTime (var hour,min,sec:word);
  60. Procedure GetDate (Var Year,Month,Day:Word);
  61. Procedure GetDateTime (Var Year,Month,Day,hour,minute,second:Word);
  62. function SetTime (Hour,Min,Sec:word) : Boolean;
  63. function SetDate (Year,Month,Day:Word) : Boolean;
  64. function SetDateTime (Year,Month,Day,hour,minute,second:Word) : Boolean;
  65. {**************************
  66. Process Handling
  67. ***************************}
  68. function CreateShellArgV (const prog:string):ppchar;
  69. function CreateShellArgV (const prog:Ansistring):ppchar;
  70. Function Execv (const path:pathstr;args:ppchar):cint;
  71. Function Execv (const path: AnsiString;args:ppchar):cint;
  72. Function Execvp (Path: Pathstr;Args:ppchar;Ep:ppchar):cint;
  73. Function Execvp (Path: AnsiString; Args:ppchar;Ep:ppchar):cint;
  74. Function Execl (const Todo: String):cint;
  75. Function Execl (const Todo: Ansistring):cint;
  76. Function Execle (Todo: String;Ep:ppchar):cint;
  77. Function Execle (Todo: AnsiString;Ep:ppchar):cint;
  78. Function Execlp (Todo: string;Ep:ppchar):cint;
  79. Function Execlp (Todo: Ansistring;Ep:ppchar):cint;
  80. Function Shell (const Command:String):cint;
  81. Function Shell (const Command:AnsiString):cint;
  82. Function WaitProcess (Pid:cint):cint; { like WaitPid(PID,@result,0) Handling of Signal interrupts (errno=EINTR), returning the Exitcode of Process (>=0) or -Status if terminated}
  83. Function WIFSTOPPED (Status: Integer): Boolean;
  84. Function W_EXITCODE (ReturnCode, Signal: Integer): Integer;
  85. Function W_STOPCODE (Signal: Integer): Integer;
  86. {**************************
  87. File Handling
  88. ***************************}
  89. Function fsync (fd : cint) : cint;
  90. Function Flock (fd,mode : cint) : cint ;
  91. Function Flock (var T : text;mode : cint) : cint;
  92. Function Flock (var F : File;mode : cint) : cint;
  93. Function StatFS (Path:Pathstr;Var Info:tstatfs):cint;
  94. Function fStatFS (Fd: cint;Var Info:tstatfs):cint;
  95. Function SelectText (var T:Text;TimeOut :PTimeVal):cint;
  96. Function SelectText (var T:Text;TimeOut :cint):cint;
  97. {**************************
  98. Directory Handling
  99. ***************************}
  100. procedure SeekDir(p:pdir;loc:clong);
  101. function TellDir(p:pdir):clong;
  102. {**************************
  103. Pipe/Fifo/Stream
  104. ***************************}
  105. Function AssignPipe (var pipe_in,pipe_out:cint):cint;
  106. Function AssignPipe (var pipe_in,pipe_out:text):cint;
  107. Function AssignPipe (var pipe_in,pipe_out:file):cint;
  108. Function PClose (Var F:text) : cint;
  109. Function PClose (Var F:file) : cint;
  110. Function POpen (var F:text;const Prog:String;rw:char):cint;
  111. Function POpen (var F:file;const Prog:String;rw:char):cint;
  112. function AssignStream(Var StreamIn,Streamout:text;Const Prog:String) : cint;
  113. function AssignStream(var StreamIn, StreamOut, StreamErr: Text; const prog: String): cint;
  114. {$ifndef BSD}
  115. Function GetDomainName:String;
  116. Function GetHostName:String;
  117. {$endif}
  118. {**************************
  119. Memory functions
  120. ***************************}
  121. const
  122. PROT_READ = $1; { page can be read }
  123. PROT_WRITE = $2; { page can be written }
  124. PROT_EXEC = $4; { page can be executed }
  125. PROT_NONE = $0; { page can not be accessed }
  126. MAP_SHARED = $1; { Share changes }
  127. // MAP_PRIVATE = $2; { Changes are private }
  128. MAP_TYPE = $f; { Mask for type of mapping }
  129. MAP_FIXED = $10; { Interpret addr exactly }
  130. // MAP_ANONYMOUS = $20; { don't use a file }
  131. MAP_GROWSDOWN = $100; { stack-like segment }
  132. MAP_DENYWRITE = $800; { ETXTBSY }
  133. MAP_EXECUTABLE = $1000; { mark it as an executable }
  134. MAP_LOCKED = $2000; { pages are locked }
  135. MAP_NORESERVE = $4000; { don't check for reservations }
  136. {**************************
  137. Utility functions
  138. ***************************}
  139. Function FExpand (Const Path: PathStr):PathStr;
  140. Function FSearch (const path:pathstr;dirlist:string):pathstr;
  141. Function Glob (Const path:pathstr):pglob;
  142. Procedure Globfree (var p:pglob);
  143. procedure SigRaise (sig:integer);
  144. {$i unxsysch.inc} // calls used in system and not reexported from baseunix
  145. {******************************************************************************
  146. Implementation
  147. ******************************************************************************}
  148. Implementation
  149. Uses Strings,Syscall;
  150. {$i syscallh.inc}
  151. {$i ossysch.inc}
  152. {$i unxsysc.inc}
  153. { Get the definitions of textrec and filerec }
  154. {$i textrec.inc}
  155. {$i filerec.inc}
  156. { Raw System calls are in Syscalls.inc}
  157. {$ifdef Linux} // Linux has more "oldlinux" compability.
  158. {$i sysc11.inc}
  159. {$else}
  160. {$i syscalls.inc}
  161. {$endif}
  162. {$i unixsysc.inc} {Syscalls only used in unit Unix/Linux}
  163. Function getenv(name:string):Pchar; external name 'FPC_SYSC_FPGETENV';
  164. {******************************************************************************
  165. Process related calls
  166. ******************************************************************************}
  167. { Most calls of WaitPID do not handle the result correctly, this funktion treats errors more correctly }
  168. Function WaitProcess(Pid:cint):cint; { like WaitPid(PID,@result,0) Handling of Signal interrupts (errno=EINTR), returning the Exitcode of Process (>=0) or -Status if terminated}
  169. var ret,r,s : cint;
  170. begin
  171. s:=$7F00;
  172. repeat
  173. r:=fpWaitPid(Pid,@s,0);
  174. if (r=-1) and (fpgeterrno=ESysEIntr) Then
  175. r:=0;
  176. until (r<>-1);
  177. if (r=-1) or (r=0) then // 0 is not a valid return and should never occur (it means status invalid when using WNOHANG)
  178. WaitProcess:=-1 // return -1 to indicate an error. fpwaitpid updated it.
  179. else
  180. begin
  181. {$ifndef Solaris}
  182. { at least correct for Linux and Darwin (JM) }
  183. if (s and $7F)=0 then // Only this is a valid returncode
  184. {$else}
  185. if (s and $FF)=0 then // Only this is a valid returncode
  186. {$endif}
  187. WaitProcess:=s shr 8
  188. else if (s>0) then // Until now there is not use of the highest bit , but check this for the future
  189. WaitProcess:=-s // normal case
  190. else
  191. WaitProcess:=s; // s<0 should not occur, but wie return also a negativ value
  192. end;
  193. end;
  194. function InternalCreateShellArgV(cmd:pChar; len:cint):ppchar;
  195. {
  196. Create an argv which executes a command in a shell using /bin/sh -c
  197. }
  198. const Shell = '/bin/sh'#0'-c'#0;
  199. var
  200. pp,p : ppchar;
  201. // temp : string; !! Never pass a local var back!!
  202. begin
  203. getmem(pp,4*4);
  204. p:=pp;
  205. p^:=@Shell[1];
  206. inc(p);
  207. p^:=@Shell[9];
  208. inc(p);
  209. getmem(p^,len+1);
  210. move(cmd^,p^^,len);
  211. pchar(p^)[len]:=#0;
  212. inc(p);
  213. p^:=Nil;
  214. InternalCreateShellArgV:=pp;
  215. end;
  216. function CreateShellArgV(const prog:string):ppchar;
  217. begin
  218. CreateShellArgV:=InternalCreateShellArgV(@prog[1],length(prog));
  219. end;
  220. function CreateShellArgV(const prog:Ansistring):ppchar;
  221. {
  222. Create an argv which executes a command in a shell using /bin/sh -c
  223. using a AnsiString;
  224. }
  225. begin
  226. CreateShellArgV:=InternalCreateShellArgV(@prog[1],length(prog)); // if ppc works like delphi this also work when @prog[1] is invalid (len=0)
  227. end;
  228. procedure FreeShellArgV(p:ppchar);
  229. begin
  230. if (p<>nil) then begin
  231. freemem(p[2]);
  232. freemem(p);
  233. end;
  234. end;
  235. Function Execv(const path: AnsiString;args:ppchar):cint;
  236. {
  237. Overloaded ansistring version.
  238. }
  239. begin
  240. Execv:=fpExecVe(Path,Args,envp);
  241. end;
  242. Function Execvp(Path: AnsiString; Args:ppchar;Ep:ppchar):cint;
  243. {
  244. Overloaded ansistring version
  245. }
  246. var
  247. thepath : Ansistring;
  248. begin
  249. if path[1]<>'/' then
  250. begin
  251. Thepath:=strpas(fpgetenv('PATH'));
  252. if thepath='' then
  253. thepath:='.';
  254. Path:=FSearch(path,thepath)
  255. end
  256. else
  257. Path:='';
  258. if Path='' then
  259. Begin
  260. fpsetErrno(ESysEnoEnt);
  261. Exit(-1);
  262. end
  263. else
  264. Execvp:=fpExecve(Path,args,ep);
  265. end;
  266. Function Execv(const path:pathstr;args:ppchar):cint;
  267. {
  268. Replaces the current program by the program specified in path,
  269. arguments in args are passed to Execve.
  270. the current environment is passed on.
  271. }
  272. begin
  273. Execv:=fpExecve(path,args,envp);
  274. end;
  275. Function Execvp(Path:Pathstr;Args:ppchar;Ep:ppchar):cint;
  276. {
  277. This does the same as Execve, only it searches the PATH environment
  278. for the place of the Executable, except when Path starts with a slash.
  279. if the PATH environment variable is unavailable, the path is set to '.'
  280. }
  281. var
  282. thepath : string;
  283. begin
  284. if path[1]<>'/' then
  285. begin
  286. Thepath:=strpas(fpgetenv('PATH'));
  287. if thepath='' then
  288. thepath:='.';
  289. Path:=FSearch(path,thepath)
  290. end
  291. else
  292. Path:='';
  293. if Path='' then
  294. Begin
  295. fpsetErrno(ESysEnoEnt);
  296. Exit(-1);
  297. end
  298. else
  299. execvp:=fpExecve(Path,args,ep);
  300. end;
  301. Function Execle(Todo:string;Ep:ppchar):cint;
  302. {
  303. This procedure takes the string 'Todo', parses it for command and
  304. command options, and Executes the command with the given options.
  305. The string 'Todo' shoud be of the form 'command options', options
  306. separated by commas.
  307. the PATH environment is not searched for 'command'.
  308. The specified environment(in 'ep') is passed on to command
  309. }
  310. var
  311. p : ppchar;
  312. begin
  313. p:=StringToPPChar(ToDo);
  314. if (p=nil) or (p^=nil) then
  315. Begin
  316. fpsetErrno(ESysEnoEnt);
  317. Exit(-1);
  318. end
  319. else
  320. execle:=fpExecVE(p^,p,EP);
  321. end;
  322. function Execle(Todo:AnsiString;Ep:ppchar):cint;
  323. {
  324. This procedure takes the string 'Todo', parses it for command and
  325. command options, and Executes the command with the given options.
  326. The string 'Todo' shoud be of the form 'command options', options
  327. separated by commas.
  328. the PATH environment is not searched for 'command'.
  329. The specified environment(in 'ep') is passed on to command
  330. }
  331. var
  332. p : ppchar;
  333. begin
  334. p:=StringToPPChar(ToDo);
  335. if (p=nil) or (p^=nil) then
  336. Begin
  337. fpsetErrno(ESysEnoEnt);
  338. Exit(-1);
  339. end;
  340. ExecLe:=fpExecVE(p^,p,EP);
  341. end;
  342. Function Execl(const Todo:string):cint;
  343. {
  344. This procedure takes the string 'Todo', parses it for command and
  345. command options, and Executes the command with the given options.
  346. The string 'Todo' shoud be of the form 'command options', options
  347. separated by commas.
  348. the PATH environment is not searched for 'command'.
  349. The current environment is passed on to command
  350. }
  351. begin
  352. Execl:=ExecLE(ToDo,EnvP);
  353. end;
  354. Function Execlp(Todo:string;Ep:ppchar):cint;
  355. {
  356. This procedure takes the string 'Todo', parses it for command and
  357. command options, and Executes the command with the given options.
  358. The string 'Todo' shoud be of the form 'command options', options
  359. separated by commas.
  360. the PATH environment is searched for 'command'.
  361. The specified environment (in 'ep') is passed on to command
  362. }
  363. var
  364. p : ppchar;
  365. begin
  366. p:=StringToPPchar(todo);
  367. if (p=nil) or (p^=nil) then
  368. Begin
  369. fpsetErrno(ESysEnoEnt);
  370. Exit(-1);
  371. end;
  372. Execlp:=ExecVP(StrPas(p^),p,EP);
  373. end;
  374. Function Execlp(Todo: Ansistring;Ep:ppchar):cint;
  375. {
  376. Overloaded ansistring version.
  377. }
  378. var
  379. p : ppchar;
  380. begin
  381. p:=StringToPPchar(todo);
  382. if (p=nil) or (p^=nil) then
  383. Begin
  384. fpsetErrno(ESysEnoEnt);
  385. Exit(-1);
  386. end;
  387. execlp:=ExecVP(StrPas(p^),p,EP);
  388. end;
  389. Function Shell(const Command:String):cint;
  390. {
  391. Executes the shell, and passes it the string Command. (Through /bin/sh -c)
  392. The current environment is passed to the shell.
  393. It waits for the shell to exit, and returns its exit status.
  394. If the Exec call failed exit status 127 is reported.
  395. }
  396. { Changed the structure:
  397. - the previous version returns an undefinied value if fork fails
  398. - it returns the status of Waitpid instead of the Process returnvalue (see the doc to Shell)
  399. - it uses exit(127) not ExitProc (The Result in pp386: going on Compiling in 2 processes!)
  400. - ShellArgs are now released
  401. - The Old CreateShellArg gives back pointers to a local var
  402. }
  403. var
  404. p : ppchar;
  405. pid : cint;
  406. begin
  407. p:=CreateShellArgv(command);
  408. pid:=fpfork;
  409. if pid=0 then // We are in the Child
  410. begin
  411. {This is the child.}
  412. fpExecve(p^,p,envp);
  413. fpExit(127); // was Exit(127)
  414. end
  415. else if (pid<>-1) then // Successfull started
  416. Shell:=WaitProcess(pid)
  417. else // no success
  418. Shell:=-1; // indicate an error
  419. FreeShellArgV(p);
  420. end;
  421. Function Shell(const Command:AnsiString):cint;
  422. {
  423. AnsiString version of Shell
  424. }
  425. var
  426. p : ppchar;
  427. pid : cint;
  428. begin { Changes as above }
  429. p:=CreateShellArgv(command);
  430. pid:=fpfork;
  431. if pid=0 then // We are in the Child
  432. begin
  433. fpExecve(p^,p,envp);
  434. fpExit(127); // was exit(127)!! We must exit the Process, not the function
  435. end
  436. else if (pid<>-1) then // Successfull started
  437. Shell:=WaitProcess(pid)
  438. else // no success
  439. Shell:=-1;
  440. FreeShellArgV(p);
  441. end;
  442. Function WIFSTOPPED(Status: Integer): Boolean;
  443. begin
  444. WIFSTOPPED:=((Status and $FF)=$7F);
  445. end;
  446. Function W_EXITCODE(ReturnCode, Signal: Integer): Integer;
  447. begin
  448. W_EXITCODE:=(ReturnCode shl 8) or Signal;
  449. end;
  450. Function W_STOPCODE(Signal: Integer): Integer;
  451. begin
  452. W_STOPCODE:=(Signal shl 8) or $7F;
  453. end;
  454. {******************************************************************************
  455. Date and Time related calls
  456. ******************************************************************************}
  457. Function GetEpochTime: cint;
  458. {
  459. Get the number of seconds since 00:00, January 1 1970, GMT
  460. the time NOT corrected any way
  461. }
  462. begin
  463. GetEpochTime:=fptime;
  464. end;
  465. procedure GetTime(var hour,min,sec,msec,usec:word);
  466. {
  467. Gets the current time, adjusted to local time
  468. }
  469. var
  470. year,day,month:Word;
  471. tz:timeval;
  472. begin
  473. fpgettimeofday(@tz,nil);
  474. EpochToLocal(tz.tv_sec,year,month,day,hour,min,sec);
  475. msec:=tz.tv_usec div 1000;
  476. usec:=tz.tv_usec mod 1000;
  477. end;
  478. procedure GetTime(var hour,min,sec,sec100:word);
  479. {
  480. Gets the current time, adjusted to local time
  481. }
  482. var
  483. usec : word;
  484. begin
  485. gettime(hour,min,sec,sec100,usec);
  486. sec100:=sec100 div 10;
  487. end;
  488. Procedure GetTime(Var Hour,Min,Sec:Word);
  489. {
  490. Gets the current time, adjusted to local time
  491. }
  492. var
  493. msec,usec : Word;
  494. Begin
  495. gettime(hour,min,sec,msec,usec);
  496. End;
  497. Procedure GetDate(Var Year,Month,Day:Word);
  498. {
  499. Gets the current date, adjusted to local time
  500. }
  501. var
  502. hour,minute,second : word;
  503. Begin
  504. EpochToLocal(fptime,year,month,day,hour,minute,second);
  505. End;
  506. Procedure GetDateTime(Var Year,Month,Day,hour,minute,second:Word);
  507. {
  508. Gets the current date, adjusted to local time
  509. }
  510. Begin
  511. EpochToLocal(fptime,year,month,day,hour,minute,second);
  512. End;
  513. {$ifndef BSD}
  514. {$ifdef linux}
  515. Function stime (t : cint) : Boolean;
  516. begin
  517. stime:=do_SysCall(Syscall_nr_stime,cint(@t))=0;
  518. end;
  519. {$endif}
  520. {$endif}
  521. {$ifdef BSD}
  522. Function stime (t : cint) : Boolean;
  523. begin
  524. end;
  525. {$endif}
  526. Function SetTime(Hour,Min,Sec:word) : boolean;
  527. var
  528. Year, Month, Day : Word;
  529. begin
  530. GetDate (Year, Month, Day);
  531. SetTime:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Min, Sec ) );
  532. end;
  533. Function SetDate(Year,Month,Day:Word) : boolean;
  534. var
  535. Hour, Minute, Second, Sec100 : Word;
  536. begin
  537. GetTime ( Hour, Minute, Second, Sec100 );
  538. SetDate:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Minute, Second ) );
  539. end;
  540. Function SetDateTime(Year,Month,Day,hour,minute,second:Word) : Boolean;
  541. begin
  542. SetDateTime:=stime ( LocalToEpoch ( Year, Month, Day, Hour, Minute, Second ) );
  543. end;
  544. { Include timezone handling routines which use /usr/share/timezone info }
  545. {$i timezone.inc}
  546. {******************************************************************************
  547. FileSystem calls
  548. ******************************************************************************}
  549. Function Execl(const Todo:Ansistring):cint;
  550. {
  551. Overloaded AnsiString Version of ExecL.
  552. }
  553. begin
  554. Execl:=ExecLE(ToDo,EnvP);
  555. end;
  556. Function Flock (var T : text;mode : cint) : cint;
  557. begin
  558. Flock:=Flock(TextRec(T).Handle,mode);
  559. end;
  560. Function Flock (var F : File;mode : cint) :cint;
  561. begin
  562. Flock:=Flock(FileRec(F).Handle,mode);
  563. end;
  564. Function SelectText(var T:Text;TimeOut :PTimeval):cint;
  565. Var
  566. F:TfdSet;
  567. begin
  568. if textrec(t).mode=fmclosed then
  569. begin
  570. fpseterrno(ESysEBADF);
  571. exit(-1);
  572. end;
  573. FpFD_ZERO(f);
  574. fpFD_SET(textrec(T).handle,f);
  575. if textrec(T).mode=fminput then
  576. SelectText:=fpselect(textrec(T).handle+1,@f,nil,nil,TimeOut)
  577. else
  578. SelectText:=fpselect(textrec(T).handle+1,nil,@f,nil,TimeOut);
  579. end;
  580. Function SelectText(var T:Text;TimeOut :cint):cint;
  581. var
  582. p : PTimeVal;
  583. tv : TimeVal;
  584. begin
  585. if TimeOut=-1 then
  586. p:=nil
  587. else
  588. begin
  589. tv.tv_Sec:=Timeout div 1000;
  590. tv.tv_Usec:=(Timeout mod 1000)*1000;
  591. p:=@tv;
  592. end;
  593. SelectText:=SelectText(T,p);
  594. end;
  595. {******************************************************************************
  596. Directory
  597. ******************************************************************************}
  598. procedure SeekDir(p:pdir;loc:clong);
  599. begin
  600. if p=nil then
  601. begin
  602. fpseterrno(ESysEBADF);
  603. exit;
  604. end;
  605. {$ifndef bsd}
  606. p^.dd_nextoff:=fplseek(p^.dd_fd,loc,seek_set);
  607. {$endif}
  608. p^.dd_size:=0;
  609. p^.dd_loc:=0;
  610. end;
  611. function TellDir(p:pdir):clong;
  612. begin
  613. if p=nil then
  614. begin
  615. fpseterrno(ESysEBADF);
  616. telldir:=-1;
  617. exit;
  618. end;
  619. telldir:=fplseek(p^.dd_fd,0,seek_cur)
  620. { We could try to use the nextoff field here, but on my 1.2.13
  621. kernel, this gives nothing... This may have to do with
  622. the readdir implementation of libc... I also didn't find any trace of
  623. the field in the kernel code itself, So I suspect it is an artifact of libc.
  624. Michael. }
  625. end;
  626. {******************************************************************************
  627. Pipes/Fifo
  628. ******************************************************************************}
  629. Procedure OpenPipe(var F:Text);
  630. begin
  631. case textrec(f).mode of
  632. fmoutput :
  633. if textrec(f).userdata[1]<>P_OUT then
  634. textrec(f).mode:=fmclosed;
  635. fminput :
  636. if textrec(f).userdata[1]<>P_IN then
  637. textrec(f).mode:=fmclosed;
  638. else
  639. textrec(f).mode:=fmclosed;
  640. end;
  641. end;
  642. Function IOPipe(var F:text):cint;
  643. begin
  644. IOPipe:=0;
  645. case textrec(f).mode of
  646. fmoutput :
  647. begin
  648. { first check if we need something to write, else we may
  649. get a SigPipe when Close() is called (PFV) }
  650. if textrec(f).bufpos>0 then
  651. IOPipe:=fpwrite(textrec(f).handle,pchar(textrec(f).bufptr),textrec(f).bufpos);
  652. end;
  653. fminput : Begin
  654. textrec(f).bufend:=fpread(textrec(f).handle,pchar(textrec(f).bufptr),textrec(f).bufsize);
  655. IOPipe:=textrec(f).bufend;
  656. End;
  657. end;
  658. textrec(f).bufpos:=0;
  659. end;
  660. Function FlushPipe(var F:Text):cint;
  661. begin
  662. FlushPipe:=0;
  663. if (textrec(f).mode=fmoutput) and (textrec(f).bufpos<>0) then
  664. FlushPipe:=IOPipe(f);
  665. textrec(f).bufpos:=0;
  666. end;
  667. Function ClosePipe(var F:text):cint;
  668. begin
  669. textrec(f).mode:=fmclosed;
  670. ClosePipe:=fpclose(textrec(f).handle);
  671. end;
  672. Function AssignPipe(var pipe_in,pipe_out:text):cint;
  673. {
  674. Sets up a pair of file variables, which act as a pipe. The first one can
  675. be read from, the second one can be written to.
  676. }
  677. var
  678. f_in,f_out : cint;
  679. begin
  680. if AssignPipe(f_in,f_out)=-1 then
  681. exit(-1);
  682. { Set up input }
  683. Assign(Pipe_in,'');
  684. Textrec(Pipe_in).Handle:=f_in;
  685. Textrec(Pipe_in).Mode:=fmInput;
  686. Textrec(Pipe_in).userdata[1]:=P_IN;
  687. TextRec(Pipe_in).OpenFunc:=@OpenPipe;
  688. TextRec(Pipe_in).InOutFunc:=@IOPipe;
  689. TextRec(Pipe_in).FlushFunc:=@FlushPipe;
  690. TextRec(Pipe_in).CloseFunc:=@ClosePipe;
  691. { Set up output }
  692. Assign(Pipe_out,'');
  693. Textrec(Pipe_out).Handle:=f_out;
  694. Textrec(Pipe_out).Mode:=fmOutput;
  695. Textrec(Pipe_out).userdata[1]:=P_OUT;
  696. TextRec(Pipe_out).OpenFunc:=@OpenPipe;
  697. TextRec(Pipe_out).InOutFunc:=@IOPipe;
  698. TextRec(Pipe_out).FlushFunc:=@FlushPipe;
  699. TextRec(Pipe_out).CloseFunc:=@ClosePipe;
  700. AssignPipe:=0;
  701. end;
  702. Function AssignPipe(var pipe_in,pipe_out:file):cint;
  703. {
  704. Sets up a pair of file variables, which act as a pipe. The first one can
  705. be read from, the second one can be written to.
  706. If the operation was unsuccesful,
  707. }
  708. var
  709. f_in,f_out : cint;
  710. begin
  711. if AssignPipe(f_in,f_out)=-1 then
  712. exit(-1);
  713. { Set up input }
  714. Assign(Pipe_in,'');
  715. Filerec(Pipe_in).Handle:=f_in;
  716. Filerec(Pipe_in).Mode:=fmInput;
  717. Filerec(Pipe_in).recsize:=1;
  718. Filerec(Pipe_in).userdata[1]:=P_IN;
  719. { Set up output }
  720. Assign(Pipe_out,'');
  721. Filerec(Pipe_out).Handle:=f_out;
  722. Filerec(Pipe_out).Mode:=fmoutput;
  723. Filerec(Pipe_out).recsize:=1;
  724. Filerec(Pipe_out).userdata[1]:=P_OUT;
  725. AssignPipe:=0;
  726. end;
  727. Function PCloseText(Var F:text):cint;
  728. {
  729. May not use @PClose due overloading
  730. }
  731. begin
  732. PCloseText:=PClose(f);
  733. end;
  734. function POpen(var F:text;const Prog:String;rw:char):cint;
  735. {
  736. Starts the program in 'Prog' and makes it's input or out put the
  737. other end of a pipe. If rw is 'w' or 'W', then whatever is written to
  738. F, will be read from stdin by the program in 'Prog'. The inverse is true
  739. for 'r' or 'R' : whatever the program in 'Prog' writes to stdout, can be
  740. read from 'f'.
  741. }
  742. var
  743. pipi,
  744. pipo : text;
  745. pid : pid_t;
  746. pl : ^cint;
  747. pp : ppchar;
  748. ret : cint;
  749. begin
  750. rw:=upcase(rw);
  751. if not (rw in ['R','W']) then
  752. begin
  753. FpSetErrno(ESysEnoent);
  754. exit(-1);
  755. end;
  756. if AssignPipe(pipi,pipo)=-1 Then
  757. Exit(-1);
  758. pid:=fpfork;
  759. if pid=-1 then
  760. begin
  761. close(pipi);
  762. close(pipo);
  763. exit(-1);
  764. end;
  765. if pid=0 then
  766. begin
  767. { We're in the child }
  768. if rw='W' then
  769. begin
  770. close(pipo);
  771. ret:=fpdup2(pipi,input);
  772. close(pipi);
  773. if ret=-1 then
  774. halt(127);
  775. end
  776. else
  777. begin
  778. close(pipi);
  779. ret:=fpdup2(pipo,output);
  780. close(pipo);
  781. if ret=-1 then
  782. halt(127);
  783. end;
  784. pp:=createshellargv(prog);
  785. fpExecve(pp^,pp,envp);
  786. halt(127);
  787. end
  788. else
  789. begin
  790. { We're in the parent }
  791. if rw='W' then
  792. begin
  793. close(pipi);
  794. f:=pipo;
  795. textrec(f).bufptr:=@textrec(f).buffer;
  796. end
  797. else
  798. begin
  799. close(pipo);
  800. f:=pipi;
  801. textrec(f).bufptr:=@textrec(f).buffer;
  802. end;
  803. {Save the process ID - needed when closing }
  804. pl:=@(textrec(f).userdata[2]);
  805. pl^:=pid;
  806. textrec(f).closefunc:=@PCloseText;
  807. end;
  808. ret:=0;
  809. end;
  810. Function POpen(var F:file;const Prog:String;rw:char):cint;
  811. {
  812. Starts the program in 'Prog' and makes it's input or out put the
  813. other end of a pipe. If rw is 'w' or 'W', then whatever is written to
  814. F, will be read from stdin by the program in 'Prog'. The inverse is true
  815. for 'r' or 'R' : whatever the program in 'Prog' writes to stdout, can be
  816. read from 'f'.
  817. }
  818. var
  819. pipi,
  820. pipo : file;
  821. pid : cint;
  822. pl : ^cint;
  823. p,pp : ppchar;
  824. temp : string[255];
  825. ret : cint;
  826. begin
  827. rw:=upcase(rw);
  828. if not (rw in ['R','W']) then
  829. begin
  830. FpSetErrno(ESysEnoent);
  831. exit(-1);
  832. end;
  833. ret:=AssignPipe(pipi,pipo);
  834. if ret=-1 then
  835. exit(-1);
  836. pid:=fpfork;
  837. if pid=-1 then
  838. begin
  839. close(pipi);
  840. close(pipo);
  841. exit(-1);
  842. end;
  843. if pid=0 then
  844. begin
  845. { We're in the child }
  846. if rw='W' then
  847. begin
  848. close(pipo);
  849. ret:=fpdup2(filerec(pipi).handle,stdinputhandle);
  850. close(pipi);
  851. if ret=-1 then
  852. halt(127);
  853. end
  854. else
  855. begin
  856. close(pipi);
  857. ret:=fpdup2(filerec(pipo).handle,stdoutputhandle);
  858. close(pipo);
  859. if ret=1 then
  860. halt(127);
  861. end;
  862. getmem(pp,sizeof(pchar)*4);
  863. temp:='/bin/sh'#0'-c'#0+prog+#0;
  864. p:=pp;
  865. p^:=@temp[1];
  866. inc(p);
  867. p^:=@temp[9];
  868. inc(p);
  869. p^:=@temp[12];
  870. inc(p);
  871. p^:=Nil;
  872. fpExecve(ansistring('/bin/sh'),pp,envp);
  873. halt(127);
  874. end
  875. else
  876. begin
  877. { We're in the parent }
  878. if rw='W' then
  879. begin
  880. close(pipi);
  881. f:=pipo;
  882. end
  883. else
  884. begin
  885. close(pipo);
  886. f:=pipi;
  887. end;
  888. {Save the process ID - needed when closing }
  889. pl:=@(filerec(f).userdata[2]);
  890. pl^:=pid;
  891. end;
  892. POpen:=0;
  893. end;
  894. Function AssignStream(Var StreamIn,Streamout:text;Const Prog:String) : cint;
  895. {
  896. Starts the program in 'Prog' and makes its input and output the
  897. other end of two pipes, which are the stdin and stdout of a program
  898. specified in 'Prog'.
  899. streamout can be used to write to the program, streamin can be used to read
  900. the output of the program. See the following diagram :
  901. Parent Child
  902. STreamout --> Input
  903. Streamin <-- Output
  904. Return value is the process ID of the process being spawned, or -1 in case of failure.
  905. }
  906. var
  907. pipi,
  908. pipo : text;
  909. pid : cint;
  910. pl : ^cint;
  911. begin
  912. AssignStream:=-1;
  913. if AssignPipe(streamin,pipo)=-1 Then
  914. exit(-1);
  915. if AssignPipe(pipi,streamout)=-1 Then // shouldn't this close streamin and pipo?
  916. exit(-1);
  917. pid:=fpfork;
  918. if pid=-1 then
  919. begin
  920. close(pipi);
  921. close(pipo);
  922. close (streamin);
  923. close (streamout);
  924. exit;
  925. end;
  926. if pid=0 then
  927. begin
  928. { We're in the child }
  929. { Close what we don't need }
  930. close(streamout);
  931. close(streamin);
  932. if fpdup2(pipi,input)=-1 Then
  933. halt(127);
  934. close(pipi);
  935. If fpdup2(pipo,output)=-1 Then
  936. halt (127);
  937. close(pipo);
  938. Execl(Prog);
  939. halt(127);
  940. end
  941. else
  942. begin
  943. { we're in the parent}
  944. close(pipo);
  945. close(pipi);
  946. {Save the process ID - needed when closing }
  947. pl:=@(textrec(StreamIn).userdata[2]);
  948. pl^:=pid;
  949. textrec(StreamIn).closefunc:=@PCloseText;
  950. {Save the process ID - needed when closing }
  951. pl:=@(textrec(StreamOut).userdata[2]);
  952. pl^:=pid;
  953. textrec(StreamOut).closefunc:=@PCloseText;
  954. AssignStream:=Pid;
  955. end;
  956. end;
  957. function AssignStream(var StreamIn, StreamOut, StreamErr: Text; const prog: String):cint;
  958. {
  959. Starts the program in 'prog' and makes its input, output and error output the
  960. other end of three pipes, which are the stdin, stdout and stderr of a program
  961. specified in 'prog'.
  962. StreamOut can be used to write to the program, StreamIn can be used to read
  963. the output of the program, StreamErr reads the error output of the program.
  964. See the following diagram :
  965. Parent Child
  966. StreamOut --> StdIn (input)
  967. StreamIn <-- StdOut (output)
  968. StreamErr <-- StdErr (error output)
  969. }
  970. var
  971. PipeIn, PipeOut, PipeErr: text;
  972. pid: cint;
  973. pl: ^cint;
  974. begin
  975. AssignStream := -1;
  976. // Assign pipes
  977. if AssignPipe(StreamIn, PipeOut)=-1 Then
  978. Exit(-1);
  979. If AssignPipe(StreamErr, PipeErr)=-1 Then
  980. begin
  981. Close(StreamIn);
  982. Close(PipeOut);
  983. exit(-1);
  984. end;
  985. if AssignPipe(PipeIn, StreamOut)=-1 Then
  986. begin
  987. Close(StreamIn);
  988. Close(PipeOut);
  989. Close(StreamErr);
  990. Close(PipeErr);
  991. exit(-1);
  992. end;
  993. // Fork
  994. pid := fpFork;
  995. if pid=-1 then begin
  996. Close(StreamIn);
  997. Close(PipeOut);
  998. Close(StreamErr);
  999. Close(PipeErr);
  1000. Close(PipeIn);
  1001. Close(StreamOut);
  1002. exit(-1);
  1003. end;
  1004. if pid = 0 then begin
  1005. // *** We are in the child ***
  1006. // Close what we don not need
  1007. Close(StreamOut);
  1008. Close(StreamIn);
  1009. Close(StreamErr);
  1010. // Connect pipes
  1011. if fpdup2(PipeIn, Input)=-1 Then
  1012. Halt(127);
  1013. Close(PipeIn);
  1014. if fpdup2(PipeOut, Output)=-1 Then
  1015. Halt(127);
  1016. Close(PipeOut);
  1017. if fpdup2(PipeErr, StdErr)=-1 Then
  1018. Halt(127);
  1019. Close(PipeErr);
  1020. // Execute program
  1021. Execl(Prog);
  1022. Halt(127);
  1023. end else begin
  1024. // *** We are in the parent ***
  1025. Close(PipeErr);
  1026. Close(PipeOut);
  1027. Close(PipeIn);
  1028. // Save the process ID - needed when closing
  1029. pl := @(TextRec(StreamIn).userdata[2]);
  1030. pl^ := pid;
  1031. TextRec(StreamIn).closefunc := @PCloseText;
  1032. // Save the process ID - needed when closing
  1033. pl := @(TextRec(StreamOut).userdata[2]);
  1034. pl^ := pid;
  1035. TextRec(StreamOut).closefunc := @PCloseText;
  1036. // Save the process ID - needed when closing
  1037. pl := @(TextRec(StreamErr).userdata[2]);
  1038. pl^ := pid;
  1039. TextRec(StreamErr).closefunc := @PCloseText;
  1040. AssignStream := pid;
  1041. end;
  1042. end;
  1043. {******************************************************************************
  1044. General information calls
  1045. ******************************************************************************}
  1046. {$ifndef BSD}
  1047. Function GetDomainName:String; { linux only!}
  1048. // domainname is a glibc extension.
  1049. {
  1050. Get machines domain name. Returns empty string if not set.
  1051. }
  1052. Var
  1053. Sysn : utsname;
  1054. begin
  1055. If fpUname(sysn)<>0 then
  1056. getdomainname:=''
  1057. else
  1058. getdomainname:=strpas(@Sysn.domain[0]);
  1059. end;
  1060. {$endif}
  1061. Function GetHostName:String;
  1062. {
  1063. Get machines name. Returns empty string if not set.
  1064. }
  1065. Var
  1066. Sysn : utsname;
  1067. begin
  1068. If fpuname(sysn)=-1 then
  1069. gethostname:=''
  1070. else
  1071. gethostname:=strpas(@Sysn.nodename[0]);
  1072. end;
  1073. {******************************************************************************
  1074. Signal handling calls
  1075. ******************************************************************************}
  1076. procedure SigRaise(sig:integer);
  1077. begin
  1078. fpKill(fpGetPid,Sig);
  1079. end;
  1080. {******************************************************************************
  1081. Utility calls
  1082. ******************************************************************************}
  1083. {
  1084. Function Octal(l:cint):cint;
  1085. {
  1086. Convert an octal specified number to decimal;
  1087. }
  1088. var
  1089. octnr,
  1090. oct : cint;
  1091. begin
  1092. octnr:=0;
  1093. oct:=0;
  1094. while (l>0) do
  1095. begin
  1096. oct:=oct or ((l mod 10) shl octnr);
  1097. l:=l div 10;
  1098. inc(octnr,3);
  1099. end;
  1100. Octal:=oct;
  1101. end;
  1102. }
  1103. {$DEFINE FPC_FEXPAND_TILDE} { Tilde is expanded to home }
  1104. {$DEFINE FPC_FEXPAND_GETENVPCHAR} { GetEnv result is a PChar }
  1105. {$I fexpand.inc}
  1106. {$UNDEF FPC_FEXPAND_GETENVPCHAR}
  1107. {$UNDEF FPC_FEXPAND_TILDE}
  1108. Function FSearch(const path:pathstr;dirlist:string):pathstr;
  1109. {
  1110. Searches for a file 'path' in the list of direcories in 'dirlist'.
  1111. returns an empty string if not found. Wildcards are NOT allowed.
  1112. If dirlist is empty, it is set to '.'
  1113. }
  1114. Var
  1115. NewDir : PathStr;
  1116. p1 : cint;
  1117. Info : Stat;
  1118. Begin
  1119. {Replace ':' with ';'}
  1120. for p1:=1to length(dirlist) do
  1121. if dirlist[p1]=':' then
  1122. dirlist[p1]:=';';
  1123. {Check for WildCards}
  1124. If (Pos('?',Path) <> 0) or (Pos('*',Path) <> 0) Then
  1125. FSearch:='' {No wildcards allowed in these things.}
  1126. Else
  1127. Begin
  1128. Dirlist:='.;'+dirlist;{Make sure current dir is first to be searched.}
  1129. Repeat
  1130. p1:=Pos(';',DirList);
  1131. If p1=0 Then
  1132. p1:=255;
  1133. NewDir:=Copy(DirList,1,P1 - 1);
  1134. if NewDir[Length(NewDir)]<>'/' then
  1135. NewDir:=NewDir+'/';
  1136. NewDir:=NewDir+Path;
  1137. Delete(DirList,1,p1);
  1138. if (FpStat(NewDir,Info)>=0) and
  1139. (not fpS_ISDIR(Info.st_Mode)) then
  1140. Begin
  1141. If Pos('./',NewDir)=1 Then
  1142. Delete(NewDir,1,2);
  1143. {DOS strips off an initial .\}
  1144. End
  1145. Else
  1146. NewDir:='';
  1147. Until (DirList='') or (Length(NewDir) > 0);
  1148. FSearch:=NewDir;
  1149. End;
  1150. End;
  1151. Procedure Globfree(var p : pglob);
  1152. {
  1153. Release memory occupied by pglob structure, and names in it.
  1154. sets p to nil.
  1155. }
  1156. var
  1157. temp : pglob;
  1158. begin
  1159. while assigned(p) do
  1160. begin
  1161. temp:=p^.next;
  1162. if assigned(p^.name) then
  1163. freemem(p^.name);
  1164. dispose(p);
  1165. p:=temp;
  1166. end;
  1167. end;
  1168. Function Glob(Const path:pathstr):pglob;
  1169. {
  1170. Fills a tglob structure with entries matching path,
  1171. and returns a pointer to it. Returns nil on error,
  1172. linuxerror is set accordingly.
  1173. }
  1174. var
  1175. temp,
  1176. temp2 : string[255];
  1177. thedir : pdir;
  1178. buffer : pdirent;
  1179. root,
  1180. current : pglob;
  1181. begin
  1182. { Get directory }
  1183. temp:=dirname(path);
  1184. if temp='' then
  1185. temp:='.';
  1186. temp:=temp+#0;
  1187. thedir:=fpopendir(@temp[1]);
  1188. if thedir=nil then
  1189. exit(nil);
  1190. temp:=basename(path,''); { get the pattern }
  1191. if thedir^.dd_fd<0 then
  1192. exit(nil);
  1193. {get the entries}
  1194. root:=nil;
  1195. current:=nil;
  1196. repeat
  1197. buffer:=fpreaddir(thedir^);
  1198. if buffer=nil then
  1199. break;
  1200. temp2:=strpas(@(buffer^.d_name[0]));
  1201. if fnmatch(temp,temp2) then
  1202. begin
  1203. if root=nil then
  1204. begin
  1205. new(root);
  1206. current:=root;
  1207. end
  1208. else
  1209. begin
  1210. new(current^.next);
  1211. current:=current^.next;
  1212. end;
  1213. if current=nil then
  1214. begin
  1215. fpseterrno(ESysENOMEM);
  1216. globfree(root);
  1217. break;
  1218. end;
  1219. current^.next:=nil;
  1220. getmem(current^.name,length(temp2)+1);
  1221. if current^.name=nil then
  1222. begin
  1223. fpseterrno(ESysENOMEM);
  1224. globfree(root);
  1225. break;
  1226. end;
  1227. move(buffer^.d_name[0],current^.name^,length(temp2)+1);
  1228. end;
  1229. until false;
  1230. fpclosedir(thedir^);
  1231. glob:=root;
  1232. end;
  1233. {--------------------------------
  1234. Stat.Mode Macro's
  1235. --------------------------------}
  1236. Initialization
  1237. InitLocalTime;
  1238. finalization
  1239. DoneLocalTime;
  1240. End.
  1241. {
  1242. $Log$
  1243. Revision 1.52 2003-12-08 17:16:30 peter
  1244. * fsearch should only find files
  1245. Revision 1.51 2003/11/19 17:11:40 marco
  1246. * termio unit
  1247. Revision 1.50 2003/11/19 10:54:32 marco
  1248. * some simple restructures
  1249. Revision 1.49 2003/11/17 11:28:08 marco
  1250. * Clone moved to linux, + few small unit unix changes
  1251. Revision 1.48 2003/11/17 10:05:51 marco
  1252. * threads for FreeBSD. Not working tho
  1253. Revision 1.47 2003/11/14 17:30:14 marco
  1254. * weeehoo linuxerror is no more :-)
  1255. Revision 1.46 2003/11/14 16:44:48 marco
  1256. * stream functions converted to work without linuxerror
  1257. Revision 1.45 2003/11/13 18:44:06 marco
  1258. * small fi
  1259. Revision 1.44 2003/11/12 22:19:45 marco
  1260. * more linuxeror fixes
  1261. Revision 1.43 2003/11/03 09:42:28 marco
  1262. * Peter's Cardinal<->Longint fixes patch
  1263. Revision 1.42 2003/10/30 16:42:58 marco
  1264. * fixes for old syscall() convention removing
  1265. Revision 1.41 2003/10/12 19:40:43 marco
  1266. * ioctl fixes. IDE now starts, but
  1267. Revision 1.40 2003/09/29 14:36:06 peter
  1268. * fixed for stricter compiler
  1269. Revision 1.39 2003/09/27 12:51:33 peter
  1270. * fpISxxx macros renamed to C compliant fpS_ISxxx
  1271. Revision 1.38 2003/09/20 12:38:29 marco
  1272. * FCL now compiles for FreeBSD with new 1.1. Now Linux.
  1273. Revision 1.37 2003/09/17 19:07:44 marco
  1274. * more fixes for Unix<->unixutil
  1275. Revision 1.36 2003/09/17 17:30:46 marco
  1276. * Introduction of unixutil
  1277. Revision 1.35 2003/09/16 21:46:27 marco
  1278. * small fixes, checking things on linux
  1279. Revision 1.34 2003/09/16 20:52:24 marco
  1280. * small cleanups. Mostly killing of already commented code in unix etc
  1281. Revision 1.33 2003/09/16 16:13:56 marco
  1282. * fdset functions renamed to fp<posix name>
  1283. Revision 1.32 2003/09/15 20:08:49 marco
  1284. * small fixes. FreeBSD now cycles
  1285. Revision 1.31 2003/09/14 20:15:01 marco
  1286. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  1287. Revision 1.30 2003/07/08 21:23:24 peter
  1288. * sparc fixes
  1289. Revision 1.29 2003/05/30 19:58:40 marco
  1290. * Getting NetBSD/i386 to compile.
  1291. Revision 1.28 2003/05/29 19:16:16 marco
  1292. * fixed a small *BSD gotcha
  1293. Revision 1.27 2003/05/24 20:39:54 jonas
  1294. * fixed ExitCode translation in WaitProcess for Linux and Darwin (and
  1295. probably other BSD's as well)
  1296. Revision 1.26 2003/03/11 08:27:59 michael
  1297. * stringtoppchar should use tabs instead of backspace as delimiter
  1298. Revision 1.25 2002/12/18 16:50:39 marco
  1299. * Unix RTL generic parts. Linux working, *BSD will follow shortly
  1300. Revision 1.24 2002/09/07 16:01:28 peter
  1301. * old logs removed and tabs fixed
  1302. Revision 1.23 2002/08/06 13:30:46 sg
  1303. * replaced some Longints with Cardinals, to mach the C headers
  1304. * updated the termios record
  1305. Revision 1.22 2002/03/05 20:04:25 michael
  1306. + Patch from Sebastian for FCNTL call
  1307. Revision 1.21 2002/01/02 12:22:54 marco
  1308. * Removed ifdef arround getepoch.
  1309. }