syswin32.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993-98 by Florian Klaempfl and Pavel Ozerski
  5. member of the Free Pascal development team.
  6. FPC Pascal system unit for the Win32 API.
  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. {$S-}
  14. unit syswin32;
  15. {$I os.inc}
  16. interface
  17. { include system-independent routine headers }
  18. {$I systemh.inc}
  19. { include heap support headers }
  20. {$I heaph.inc}
  21. const
  22. { Default filehandles }
  23. UnusedHandle : longint = -1;
  24. StdInputHandle : longint = 0;
  25. StdOutputHandle : longint = 0;
  26. StdErrorHandle : longint = 0;
  27. type
  28. TStartupInfo=packed record
  29. cb : longint;
  30. lpReserved : Pointer;
  31. lpDesktop : Pointer;
  32. lpTitle : Pointer;
  33. dwX : longint;
  34. dwY : longint;
  35. dwXSize : longint;
  36. dwYSize : longint;
  37. dwXCountChars : longint;
  38. dwYCountChars : longint;
  39. dwFillAttribute : longint;
  40. dwFlags : longint;
  41. wShowWindow : Word;
  42. cbReserved2 : Word;
  43. lpReserved2 : Pointer;
  44. hStdInput : longint;
  45. hStdOutput : longint;
  46. hStdError : longint;
  47. end;
  48. var
  49. { C compatible arguments }
  50. argc : longint;
  51. argv : ppchar;
  52. { Win32 Info }
  53. startupinfo : tstartupinfo;
  54. hprevinst,
  55. hinstance,
  56. cmdshow : longint;
  57. implementation
  58. { include system independent routines }
  59. {$I system.inc}
  60. { some declarations for Win32 API calls }
  61. {$I win32.inc}
  62. CONST
  63. { These constants are used for conversion of error codes }
  64. { from win32 i/o errors to tp i/o errors }
  65. { errors 1 to 18 are the same as in Turbo Pascal }
  66. { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING! }
  67. { The media is write protected. }
  68. ERROR_WRITE_PROTECT = 19;
  69. { The system cannot find the device specified. }
  70. ERROR_BAD_UNIT = 20;
  71. { The device is not ready. }
  72. ERROR_NOT_READY = 21;
  73. { The device does not recognize the command. }
  74. ERROR_BAD_COMMAND = 22;
  75. { Data error (cyclic redundancy check) }
  76. ERROR_CRC = 23;
  77. { The program issued a command but the }
  78. { command length is incorrect. }
  79. ERROR_BAD_LENGTH = 24;
  80. { The drive cannot locate a specific }
  81. { area or track on the disk. }
  82. ERROR_SEEK = 25;
  83. { The specified disk or diskette cannot be accessed. }
  84. ERROR_NOT_DOS_DISK = 26;
  85. { The drive cannot find the sector requested. }
  86. ERROR_SECTOR_NOT_FOUND = 27;
  87. { The printer is out of paper. }
  88. ERROR_OUT_OF_PAPER = 28;
  89. { The system cannot write to the specified device. }
  90. ERROR_WRITE_FAULT = 29;
  91. { The system cannot read from the specified device. }
  92. ERROR_READ_FAULT = 30;
  93. { A device attached to the system is not functioning.}
  94. ERROR_GEN_FAILURE = 31;
  95. { The process cannot access the file because }
  96. { it is being used by another process. }
  97. ERROR_SHARING_VIOLATION = 32;
  98. var
  99. errno : longint;
  100. { misc. functions }
  101. function GetLastError : DWORD;
  102. external 'kernel32' name 'GetLastError';
  103. function MessageBox(w1:longint;l1,l2:pointer;w2:longint):longint;
  104. external 'user32' name 'MessageBoxA';
  105. { time and date functions }
  106. function GetTickCount : longint;
  107. external 'kernel32' name 'GetTickCount';
  108. { process functions }
  109. procedure ExitProcess(uExitCode : UINT);
  110. external 'kernel32' name 'ExitProcess';
  111. Procedure Errno2InOutRes;
  112. Begin
  113. { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING }
  114. if (errno >= ERROR_WRITE_PROTECT) and (errno <= ERROR_GEN_FAILURE) THEN
  115. BEGIN
  116. { This is the offset to the Win32 to add to directly map }
  117. { to the DOS/TP compatible error codes when in this range }
  118. InOutRes := word(errno)+131;
  119. END
  120. else
  121. { This case is special }
  122. if errno=ERROR_SHARING_VIOLATION THEN
  123. BEGIN
  124. InOutRes :=5;
  125. END
  126. else
  127. { other error codes can directly be mapped }
  128. InOutRes := Word(errno);
  129. errno:=0;
  130. end;
  131. {$ifdef dummy}
  132. procedure int_stackcheck(stack_size:longint);[public,alias: 'STACKCHECK'];
  133. {
  134. called when trying to get local stack if the compiler directive $S
  135. is set this function must preserve esi !!!! because esi is set by
  136. the calling proc for methods it must preserve all registers !!
  137. With a 2048 byte safe area used to write to StdIo without crossing
  138. the stack boundary
  139. }
  140. begin
  141. asm
  142. pushl %eax
  143. pushl %ebx
  144. movl stack_size,%ebx
  145. addl $2048,%ebx
  146. movl %esp,%eax
  147. subl %ebx,%eax
  148. movl stacklimit,%ebx
  149. cmpl %eax,%ebx
  150. jae __short_on_stack
  151. popl %ebx
  152. popl %eax
  153. leave
  154. ret $4
  155. __short_on_stack:
  156. { can be usefull for error recovery !! }
  157. popl %ebx
  158. popl %eax
  159. end['EAX','EBX'];
  160. HandleError(202);
  161. end;
  162. {$endif dummy}
  163. procedure halt(errnum : byte);
  164. begin
  165. do_exit;
  166. ExitProcess(errnum);
  167. end;
  168. function paramcount : longint;
  169. begin
  170. paramcount := argc - 1;
  171. end;
  172. function paramstr(l : longint) : string;
  173. begin
  174. if (l>=0) and (l+1<=argc) then
  175. paramstr:=strpas(argv[l])
  176. else
  177. paramstr:='';
  178. end;
  179. procedure randomize;
  180. begin
  181. randseed:=GetTickCount;
  182. end;
  183. {*****************************************************************************
  184. Heap Management
  185. *****************************************************************************}
  186. { memory functions }
  187. function GlobalAlloc(mode,size:longint):longint;
  188. external 'kernel32' name 'GlobalAlloc';
  189. function GlobalLock(handle:longint):pointer;
  190. external 'kernel32' name 'GlobalLock';
  191. {$ifdef SYSTEMDEBUG}
  192. function GlobalSize(h:longint):longint;
  193. external 'kernel32' name 'GlobalSize';
  194. {$endif}
  195. {$ASMMODE DIRECT}
  196. function getheapstart:pointer;assembler;
  197. asm
  198. leal HEAP,%eax
  199. end ['EAX'];
  200. function getheapsize:longint;assembler;
  201. asm
  202. movl HEAPSIZE,%eax
  203. end ['EAX'];
  204. {$ASMMODE ATT}
  205. function Sbrk(size : longint):longint;
  206. var
  207. h,l : longint;
  208. begin
  209. h:=GlobalAlloc(258,size);
  210. l:=longint(GlobalLock(h));
  211. if l=0 then
  212. l:=-1;
  213. {$ifdef SYSTEMDEBUG}
  214. Writeln('new heap part at $',hexstr(l,8), ' size = ',GlobalSize(h));
  215. {$endif}
  216. sbrk:=l;
  217. end;
  218. { include standard heap management }
  219. {$I heap.inc}
  220. {*****************************************************************************
  221. Low Level File Routines
  222. *****************************************************************************}
  223. function WriteFile(fh:longint;buf:pointer;len:longint;var loaded:longint;
  224. overlap:pointer):longint;
  225. external 'kernel32' name 'WriteFile';
  226. function ReadFile(fh:longint;buf:pointer;len:longint;var loaded:longint;
  227. overlap:pointer):longint;
  228. external 'kernel32' name 'ReadFile';
  229. function CloseHandle(h : longint) : longint;
  230. external 'kernel32' name 'CloseHandle';
  231. function DeleteFile(p : pchar) : longint;
  232. external 'kernel32' name 'DeleteFileA';
  233. function MoveFile(old,_new : pchar) : longint;
  234. external 'kernel32' name 'MoveFileA';
  235. function SetFilePointer(l1,l2 : longint;l3 : pointer;l4 : longint) : longint;
  236. external 'kernel32' name 'SetFilePointer';
  237. function GetFileSize(h:longint;p:pointer) : longint;
  238. external 'kernel32' name 'GetFileSize';
  239. function CreateFile(name : pointer;access,sharing : longint;
  240. security : pointer;how,attr,template : longint) : longint;
  241. external 'kernel32' name 'CreateFileA';
  242. function SetEndOfFile(h : longint) : boolean;
  243. external 'kernel32' name 'SetEndOfFile';
  244. function GetFileType(Handle:DWORD):DWord;
  245. external 'kernel32' name 'GetFileType';
  246. procedure AllowSlash(p:pchar);
  247. var
  248. i : longint;
  249. begin
  250. { allow slash as backslash }
  251. for i:=0 to strlen(p) do
  252. if p[i]='/' then p[i]:='\';
  253. end;
  254. procedure do_close(h : longint);
  255. begin
  256. closehandle(h);
  257. end;
  258. procedure do_erase(p : pchar);
  259. begin
  260. AllowSlash(p);
  261. if DeleteFile(p)=0 then
  262. Begin
  263. errno:=GetLastError;
  264. Errno2InoutRes;
  265. end;
  266. end;
  267. procedure do_rename(p1,p2 : pchar);
  268. begin
  269. AllowSlash(p1);
  270. AllowSlash(p2);
  271. if MoveFile(p1,p2)=0 then
  272. Begin
  273. errno:=GetLastError;
  274. Errno2InoutRes;
  275. end;
  276. end;
  277. function do_write(h,addr,len : longint) : longint;
  278. var
  279. size:longint;
  280. begin
  281. if writefile(h,pointer(addr),len,size,nil)=0 then
  282. Begin
  283. errno:=GetLastError;
  284. Errno2InoutRes;
  285. end;
  286. do_write:=size;
  287. end;
  288. function do_read(h,addr,len : longint) : longint;
  289. var
  290. result:longint;
  291. begin
  292. if readfile(h,pointer(addr),len,result,nil)=0 then
  293. Begin
  294. errno:=GetLastError;
  295. Errno2InoutRes;
  296. end;
  297. do_read:=result;
  298. end;
  299. function do_filepos(handle : longint) : longint;
  300. var
  301. l:longint;
  302. begin
  303. l:=SetFilePointer(handle,0,nil,FILE_CURRENT);
  304. if l=-1 then
  305. begin
  306. l:=0;
  307. errno:=GetLastError;
  308. Errno2InoutRes;
  309. end;
  310. do_filepos:=l;
  311. end;
  312. procedure do_seek(handle,pos : longint);
  313. begin
  314. if SetFilePointer(handle,pos,nil,FILE_BEGIN)=-1 then
  315. Begin
  316. errno:=GetLastError;
  317. Errno2InoutRes;
  318. end;
  319. end;
  320. function do_seekend(handle:longint):longint;
  321. begin
  322. do_seekend:=SetFilePointer(handle,0,nil,FILE_END);
  323. if do_seekend=-1 then
  324. begin
  325. errno:=GetLastError;
  326. Errno2InoutRes;
  327. end;
  328. end;
  329. function do_filesize(handle : longint) : longint;
  330. var
  331. aktfilepos : longint;
  332. begin
  333. aktfilepos:=do_filepos(handle);
  334. do_filesize:=do_seekend(handle);
  335. do_seek(handle,aktfilepos);
  336. end;
  337. procedure do_truncate (handle,pos:longint);
  338. begin
  339. do_seek(handle,pos);
  340. if not(SetEndOfFile(handle)) then
  341. begin
  342. errno:=GetLastError;
  343. Errno2InoutRes;
  344. end;
  345. end;
  346. procedure do_open(var f;p : pchar;flags:longint);
  347. {
  348. filerec and textrec have both handle and mode as the first items so
  349. they could use the same routine for opening/creating.
  350. when (flags and $10) the file will be append
  351. when (flags and $100) the file will be truncate/rewritten
  352. when (flags and $1000) there is no check for close (needed for textfiles)
  353. }
  354. var
  355. oflags,cd : longint;
  356. begin
  357. AllowSlash(p);
  358. { close first if opened }
  359. if ((flags and $1000)=0) then
  360. begin
  361. case filerec(f).mode of
  362. fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
  363. fmclosed : ;
  364. else
  365. begin
  366. {not assigned}
  367. inoutres:=102;
  368. exit;
  369. end;
  370. end;
  371. end;
  372. { reset file handle }
  373. filerec(f).handle:=UnusedHandle;
  374. { convert filemode to filerec modes }
  375. case (flags and 3) of
  376. 0 : begin
  377. filerec(f).mode:=fminput;
  378. oflags:=GENERIC_READ;
  379. end;
  380. 1 : begin
  381. filerec(f).mode:=fmoutput;
  382. oflags:=GENERIC_WRITE;
  383. end;
  384. 2 : begin
  385. filerec(f).mode:=fminout;
  386. oflags:=GENERIC_WRITE or GENERIC_READ;
  387. end;
  388. end;
  389. { standard is opening and existing file }
  390. cd:=OPEN_EXISTING;
  391. { create it ? }
  392. if (flags and $100)<>0 then
  393. cd:=CREATE_ALWAYS
  394. { or append ? }
  395. else
  396. if (flags and $10)<>0 then
  397. cd:=OPEN_ALWAYS;
  398. { empty name is special }
  399. if p[0]=#0 then
  400. begin
  401. case filerec(f).mode of
  402. fminput : filerec(f).handle:=StdInputHandle;
  403. fmappend,
  404. fmoutput : begin
  405. filerec(f).handle:=StdOutputHandle;
  406. filerec(f).mode:=fmoutput; {fool fmappend}
  407. end;
  408. end;
  409. exit;
  410. end;
  411. filerec(f).handle:=CreateFile(p,oflags,0,nil,cd,FILE_ATTRIBUTE_NORMAL,0);
  412. { append mode }
  413. if (flags and $10)<>0 then
  414. begin
  415. do_seekend(filerec(f).handle);
  416. filerec(f).mode:=fmoutput; {fool fmappend}
  417. end;
  418. { get errors }
  419. if (filerec(f).handle=0) or (filerec(f).handle=-1) then
  420. { handle -1 is returned sometimes !! (PM) }
  421. begin
  422. errno:=GetLastError;
  423. Errno2InoutRes;
  424. end;
  425. end;
  426. function do_isdevice(handle:longint):boolean;
  427. begin
  428. do_isdevice:=(getfiletype(handle)=2);
  429. end;
  430. {*****************************************************************************
  431. UnTyped File Handling
  432. *****************************************************************************}
  433. {$i file.inc}
  434. {*****************************************************************************
  435. Typed File Handling
  436. *****************************************************************************}
  437. {$i typefile.inc}
  438. {*****************************************************************************
  439. Text File Handling
  440. *****************************************************************************}
  441. {$DEFINE EOF_CTRLZ}
  442. {$i text.inc}
  443. {*****************************************************************************
  444. Directory Handling
  445. *****************************************************************************}
  446. function CreateDirectory(name : pointer;sec : pointer) : longint;
  447. external 'kernel32' name 'CreateDirectoryA';
  448. function RemoveDirectory(name:pointer):longint;
  449. external 'kernel32' name 'RemoveDirectoryA';
  450. function SetCurrentDirectory(name : pointer) : longint;
  451. external 'kernel32' name 'SetCurrentDirectoryA';
  452. function GetCurrentDirectory(bufsize : longint;name : pchar) : longint;
  453. external 'kernel32' name 'GetCurrentDirectoryA';
  454. type
  455. TDirFnType=function(name:pointer):word;
  456. procedure dirfn(afunc : TDirFnType;const s:string);
  457. var
  458. buffer : array[0..255] of char;
  459. begin
  460. move(s[1],buffer,length(s));
  461. buffer[length(s)]:=#0;
  462. AllowSlash(pchar(@buffer));
  463. if aFunc(@buffer)=0 then
  464. begin
  465. errno:=GetLastError;
  466. Errno2InoutRes;
  467. end;
  468. end;
  469. function CreateDirectoryTrunc(name:pointer):word;
  470. begin
  471. CreateDirectoryTrunc:=CreateDirectory(name,nil);
  472. end;
  473. procedure mkdir(const s:string);[IOCHECK];
  474. begin
  475. If InOutRes <> 0 then exit;
  476. dirfn(TDirFnType(@CreateDirectoryTrunc),s);
  477. end;
  478. procedure rmdir(const s:string);[IOCHECK];
  479. begin
  480. If InOutRes <> 0 then exit;
  481. dirfn(TDirFnType(@RemoveDirectory),s);
  482. end;
  483. procedure chdir(const s:string);[IOCHECK];
  484. begin
  485. If InOutRes <> 0 then exit;
  486. dirfn(TDirFnType(@SetCurrentDirectory),s);
  487. end;
  488. procedure getdir(drivenr:byte;var dir:string);
  489. const
  490. Drive:array[0..3]of char=(#0,':',#0,#0);
  491. var
  492. defaultdrive:boolean;
  493. DirBuf,SaveBuf:array[0..259] of Char;
  494. begin
  495. defaultdrive:=drivenr=0;
  496. if not defaultdrive then
  497. begin
  498. byte(Drive[0]):=Drivenr+64;
  499. GetCurrentDirectory(SizeOf(SaveBuf),SaveBuf);
  500. SetCurrentDirectory(@Drive);
  501. end;
  502. GetCurrentDirectory(SizeOf(DirBuf),DirBuf);
  503. if not defaultdrive then
  504. SetCurrentDirectory(@SaveBuf);
  505. dir:=strpas(DirBuf);
  506. end;
  507. {*****************************************************************************
  508. SystemUnit Initialization
  509. *****************************************************************************}
  510. { Startup }
  511. procedure GetStartupInfo(p : pointer);
  512. external 'kernel32' name 'GetStartupInfoA';
  513. function GetStdHandle(nStdHandle:DWORD):THANDLE;
  514. external 'kernel32' name 'GetStdHandle';
  515. { command line/enviroment functions }
  516. function GetCommandLine : pchar;
  517. external 'kernel32' name 'GetCommandLineA';
  518. { module functions }
  519. function GetModuleFileName(l1:longint;p:pointer;l2:longint):longint;
  520. external 'kernel32' name 'GetModuleFileNameA';
  521. function GetModuleHandle(p : pointer) : longint;
  522. external 'kernel32' name 'GetModuleHandleA';
  523. var
  524. ModuleName : array[0..255] of char;
  525. function GetCommandFile:pchar;
  526. begin
  527. GetModuleFileName(0,@ModuleName,255);
  528. GetCommandFile:=@ModuleName;
  529. end;
  530. procedure setup_arguments;
  531. var
  532. arglen,
  533. count : longint;
  534. argstart,
  535. cmdline : pchar;
  536. quote : set of char;
  537. argsbuf : array[0..127] of pchar;
  538. begin
  539. { create commandline, it starts with the executed filename which is argv[0] }
  540. cmdline:=GetCommandLine;
  541. count:=0;
  542. repeat
  543. { skip leading spaces }
  544. while cmdline^ in [' ',#9,#13] do
  545. inc(longint(cmdline));
  546. case cmdline^ of
  547. #0 : break;
  548. '"' : begin
  549. quote:=['"'];
  550. inc(longint(cmdline));
  551. end;
  552. '''' : begin
  553. quote:=[''''];
  554. inc(longint(cmdline));
  555. end;
  556. else
  557. quote:=[' ',#9,#13];
  558. end;
  559. { scan until the end of the argument }
  560. argstart:=cmdline;
  561. while (cmdline^<>#0) and not(cmdline^ in quote) do
  562. inc(longint(cmdline));
  563. { reserve some memory }
  564. arglen:=cmdline-argstart;
  565. getmem(argsbuf[count],arglen+1);
  566. move(argstart^,argsbuf[count]^,arglen);
  567. argsbuf[count][arglen]:=#0;
  568. { skip quote }
  569. if cmdline^ in quote then
  570. inc(longint(cmdline));
  571. inc(count);
  572. until false;
  573. { create argc }
  574. argc:=count;
  575. { create an nil entry }
  576. argsbuf[count]:=nil;
  577. inc(count);
  578. { create the argv }
  579. getmem(argv,count shl 2);
  580. move(argsbuf,argv^,count shl 2);
  581. end;
  582. {$ASMMODE DIRECT}
  583. procedure Entry;[public,alias: '_mainCRTStartup'];
  584. begin
  585. { call to the pascal main }
  586. asm
  587. call PASCALMAIN
  588. end;
  589. { that's all folks }
  590. ExitProcess(0);
  591. end;
  592. {$ifdef dummy}
  593. Function SetUpStack : longint;
  594. { This routine does the following : }
  595. { returns the value of the initial SP - __stklen }
  596. begin
  597. asm
  598. pushl %ebx
  599. pushl %eax
  600. movl __stklen,%ebx
  601. movl %esp,%eax
  602. subl %ebx,%eax
  603. movl %eax,__RESULT
  604. popl %eax
  605. popl %ebx
  606. end;
  607. end;
  608. {$endif}
  609. {$ASMMODE ATT}
  610. begin
  611. { get some helpful informations }
  612. GetStartupInfo(@startupinfo);
  613. { some misc Win32 stuff }
  614. hprevinst:=0;
  615. hinstance:=getmodulehandle(GetCommandFile);
  616. cmdshow:=startupinfo.wshowwindow;
  617. { to test stack depth }
  618. loweststack:=maxlongint;
  619. { real test stack depth }
  620. { stacklimit := setupstack; }
  621. { Setup heap }
  622. InitHeap;
  623. { Setup stdin, stdout and stderr }
  624. StdInputHandle:=longint(GetStdHandle(STD_INPUT_HANDLE));
  625. StdOutputHandle:=longint(GetStdHandle(STD_OUTPUT_HANDLE));
  626. StdErrorHandle:=longint(GetStdHandle(STD_ERROR_HANDLE));
  627. OpenStdIO(Input,fmInput,StdInputHandle);
  628. OpenStdIO(Output,fmOutput,StdOutputHandle);
  629. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  630. { Arguments }
  631. setup_arguments;
  632. { Reset IO Error }
  633. InOutRes:=0;
  634. { Reset internal error variable }
  635. errno := 0;
  636. end.
  637. {
  638. $Log$
  639. Revision 1.20 1998-09-14 10:48:33 peter
  640. * FPC_ names
  641. * Heap manager is now system independent
  642. Revision 1.19 1998/09/02 09:03:46 pierre
  643. * do_open sometimes returns -1 as handle on fail
  644. was not checked correctly
  645. Revision 1.16 1998/08/24 14:45:22 pierre
  646. * sbrk was wrong
  647. heap growing now works for win32
  648. Revision 1.15 1998/08/21 10:10:16 peter
  649. * winheap turned off by default
  650. Revision 1.14 1998/07/30 13:27:19 michael
  651. + Added support for errorproc. Changed runerror to HandleError
  652. Revision 1.13 1998/07/13 21:19:15 florian
  653. * some problems with ansi string support fixed
  654. Revision 1.12 1998/07/07 12:37:28 carl
  655. * correct mapping of error codes for TP compatibility
  656. + implemented stack checking in ifdef dummy
  657. Revision 1.11 1998/07/02 12:33:18 carl
  658. * IOCheck/InOutRes check for mkdir,rmdir and chdir like in TP
  659. Revision 1.10 1998/07/01 15:30:02 peter
  660. * better readln/writeln
  661. Revision 1.9 1998/06/10 10:39:17 peter
  662. * working w32 rtl
  663. Revision 1.8 1998/06/08 23:07:47 peter
  664. * dos interface is now 100% compatible
  665. * fixed call PASCALMAIN which must be direct asm
  666. Revision 1.7 1998/05/06 12:36:51 michael
  667. + Removed log from before restored version.
  668. Revision 1.6 1998/04/27 18:29:09 florian
  669. + do_open implemented, the file-I/O should be now complete
  670. Revision 1.5 1998/04/27 13:58:21 florian
  671. + paramstr/paramcount implemented
  672. Revision 1.4 1998/04/26 22:37:22 florian
  673. * some small extensions
  674. Revision 1.3 1998/04/26 21:49:57 florian
  675. + more stuff added (??dir procedures etc.)
  676. }