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. {.$DEFINE WINHEAP} { Use windows heap manager, if not set use FPC heap }
  17. interface
  18. { include system-independent routine headers }
  19. {$I systemh.inc}
  20. {$ifndef WinHeap}
  21. { include heap support headers }
  22. {$I heaph.inc}
  23. {$endif}
  24. const
  25. { Default filehandles }
  26. UnusedHandle : longint = -1;
  27. StdInputHandle : longint = 0;
  28. StdOutputHandle : longint = 0;
  29. StdErrorHandle : longint = 0;
  30. type
  31. TStartupInfo=packed record
  32. cb : longint;
  33. lpReserved : Pointer;
  34. lpDesktop : Pointer;
  35. lpTitle : Pointer;
  36. dwX : longint;
  37. dwY : longint;
  38. dwXSize : longint;
  39. dwYSize : longint;
  40. dwXCountChars : longint;
  41. dwYCountChars : longint;
  42. dwFillAttribute : longint;
  43. dwFlags : longint;
  44. wShowWindow : Word;
  45. cbReserved2 : Word;
  46. lpReserved2 : Pointer;
  47. hStdInput : longint;
  48. hStdOutput : longint;
  49. hStdError : longint;
  50. end;
  51. var
  52. { C compatible arguments }
  53. argc : longint;
  54. argv : ppchar;
  55. { Win32 Info }
  56. startupinfo : tstartupinfo;
  57. hprevinst,
  58. hinstance,
  59. cmdshow : longint;
  60. {$ifdef WinHeap}
  61. var
  62. heaperror : pointer;
  63. function HeapSize:longint;
  64. {$endif}
  65. implementation
  66. { include system independent routines }
  67. {$I system.inc}
  68. { some declarations for Win32 API calls }
  69. {$I win32.inc}
  70. CONST
  71. { These constants are used for conversion of error codes }
  72. { from win32 i/o errors to tp i/o errors }
  73. { errors 1 to 18 are the same as in Turbo Pascal }
  74. { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING! }
  75. { The media is write protected. }
  76. ERROR_WRITE_PROTECT = 19;
  77. { The system cannot find the device specified. }
  78. ERROR_BAD_UNIT = 20;
  79. { The device is not ready. }
  80. ERROR_NOT_READY = 21;
  81. { The device does not recognize the command. }
  82. ERROR_BAD_COMMAND = 22;
  83. { Data error (cyclic redundancy check) }
  84. ERROR_CRC = 23;
  85. { The program issued a command but the }
  86. { command length is incorrect. }
  87. ERROR_BAD_LENGTH = 24;
  88. { The drive cannot locate a specific }
  89. { area or track on the disk. }
  90. ERROR_SEEK = 25;
  91. { The specified disk or diskette cannot be accessed. }
  92. ERROR_NOT_DOS_DISK = 26;
  93. { The drive cannot find the sector requested. }
  94. ERROR_SECTOR_NOT_FOUND = 27;
  95. { The printer is out of paper. }
  96. ERROR_OUT_OF_PAPER = 28;
  97. { The system cannot write to the specified device. }
  98. ERROR_WRITE_FAULT = 29;
  99. { The system cannot read from the specified device. }
  100. ERROR_READ_FAULT = 30;
  101. { A device attached to the system is not functioning.}
  102. ERROR_GEN_FAILURE = 31;
  103. { The process cannot access the file because }
  104. { it is being used by another process. }
  105. ERROR_SHARING_VIOLATION = 32;
  106. var
  107. errno : longint;
  108. { misc. functions }
  109. function GetLastError : DWORD;
  110. external 'kernel32' name 'GetLastError';
  111. function MessageBox(w1:longint;l1,l2:pointer;w2:longint):longint;
  112. external 'user32' name 'MessageBoxA';
  113. { time and date functions }
  114. function GetTickCount : longint;
  115. external 'kernel32' name 'GetTickCount';
  116. { process functions }
  117. procedure ExitProcess(uExitCode : UINT);
  118. external 'kernel32' name 'ExitProcess';
  119. Procedure Errno2InOutRes;
  120. Begin
  121. { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING }
  122. if (errno >= ERROR_WRITE_PROTECT) and (errno <= ERROR_GEN_FAILURE) THEN
  123. BEGIN
  124. { This is the offset to the Win32 to add to directly map }
  125. { to the DOS/TP compatible error codes when in this range }
  126. InOutRes := word(errno)+131;
  127. END
  128. else
  129. { This case is special }
  130. if errno=ERROR_SHARING_VIOLATION THEN
  131. BEGIN
  132. InOutRes :=5;
  133. END
  134. else
  135. { other error codes can directly be mapped }
  136. InOutRes := Word(errno);
  137. errno:=0;
  138. end;
  139. {$ifdef dummy}
  140. procedure int_stackcheck(stack_size:longint);[public,alias: 'STACKCHECK'];
  141. {
  142. called when trying to get local stack if the compiler directive $S
  143. is set this function must preserve esi !!!! because esi is set by
  144. the calling proc for methods it must preserve all registers !!
  145. With a 2048 byte safe area used to write to StdIo without crossing
  146. the stack boundary
  147. }
  148. begin
  149. asm
  150. pushl %eax
  151. pushl %ebx
  152. movl stack_size,%ebx
  153. addl $2048,%ebx
  154. movl %esp,%eax
  155. subl %ebx,%eax
  156. movl stacklimit,%ebx
  157. cmpl %eax,%ebx
  158. jae __short_on_stack
  159. popl %ebx
  160. popl %eax
  161. leave
  162. ret $4
  163. __short_on_stack:
  164. { can be usefull for error recovery !! }
  165. popl %ebx
  166. popl %eax
  167. end['EAX','EBX'];
  168. HandleError(202);
  169. end;
  170. {$endif dummy}
  171. procedure halt(errnum : byte);
  172. begin
  173. do_exit;
  174. ExitProcess(errnum);
  175. end;
  176. function paramcount : longint;
  177. begin
  178. paramcount := argc - 1;
  179. end;
  180. function paramstr(l : longint) : string;
  181. begin
  182. if (l>=0) and (l+1<=argc) then
  183. paramstr:=strpas(argv[l])
  184. else
  185. paramstr:='';
  186. end;
  187. procedure randomize;
  188. begin
  189. randseed:=GetTickCount;
  190. end;
  191. {*****************************************************************************
  192. Heap Management
  193. *****************************************************************************}
  194. {$ifdef WinHeap}
  195. {$i winheap.inc}
  196. {$else}
  197. { memory functions }
  198. function GlobalAlloc(mode,size:longint):longint;
  199. external 'kernel32' name 'GlobalAlloc';
  200. function GlobalLock(handle:longint):pointer;
  201. external 'kernel32' name 'GlobalLock';
  202. function GlobalSize(h:longint):longint;
  203. external 'kernel32' name 'GlobalSize';
  204. function Sbrk(size : longint):longint;
  205. var
  206. h,l : longint;
  207. begin
  208. h:=GlobalAlloc(258,size);
  209. l:=longint(GlobalLock(h));
  210. {$ifdef SYSTEMDEBUG}
  211. Writeln('new heap part at $',hexstr(l,8), ' size = ',GlobalSize(h));
  212. {$endif SYSTEMDEBUG}
  213. if l=0 then
  214. sbrk:=-1
  215. else
  216. sbrk:=l;
  217. end;
  218. { include standard heap management }
  219. {$I heap.inc}
  220. {$endif WinHeap}
  221. {*****************************************************************************
  222. Low Level File Routines
  223. *****************************************************************************}
  224. function WriteFile(fh:longint;buf:pointer;len:longint;var loaded:longint;
  225. overlap:pointer):longint;
  226. external 'kernel32' name 'WriteFile';
  227. function ReadFile(fh:longint;buf:pointer;len:longint;var loaded:longint;
  228. overlap:pointer):longint;
  229. external 'kernel32' name 'ReadFile';
  230. function CloseHandle(h : longint) : longint;
  231. external 'kernel32' name 'CloseHandle';
  232. function DeleteFile(p : pchar) : longint;
  233. external 'kernel32' name 'DeleteFileA';
  234. function MoveFile(old,_new : pchar) : longint;
  235. external 'kernel32' name 'MoveFileA';
  236. function SetFilePointer(l1,l2 : longint;l3 : pointer;l4 : longint) : longint;
  237. external 'kernel32' name 'SetFilePointer';
  238. function GetFileSize(h:longint;p:pointer) : longint;
  239. external 'kernel32' name 'GetFileSize';
  240. function CreateFile(name : pointer;access,sharing : longint;
  241. security : pointer;how,attr,template : longint) : longint;
  242. external 'kernel32' name 'CreateFileA';
  243. function SetEndOfFile(h : longint) : boolean;
  244. external 'kernel32' name 'SetEndOfFile';
  245. function GetFileType(Handle:DWORD):DWord;
  246. external 'kernel32' name 'GetFileType';
  247. procedure AllowSlash(p:pchar);
  248. var
  249. i : longint;
  250. begin
  251. { allow slash as backslash }
  252. for i:=0 to strlen(p) do
  253. if p[i]='/' then p[i]:='\';
  254. end;
  255. procedure do_close(h : longint);
  256. begin
  257. closehandle(h);
  258. end;
  259. procedure do_erase(p : pchar);
  260. begin
  261. AllowSlash(p);
  262. if DeleteFile(p)=0 then
  263. Begin
  264. errno:=GetLastError;
  265. Errno2InoutRes;
  266. end;
  267. end;
  268. procedure do_rename(p1,p2 : pchar);
  269. begin
  270. AllowSlash(p1);
  271. AllowSlash(p2);
  272. if MoveFile(p1,p2)=0 then
  273. Begin
  274. errno:=GetLastError;
  275. Errno2InoutRes;
  276. end;
  277. end;
  278. function do_write(h,addr,len : longint) : longint;
  279. var
  280. size:longint;
  281. begin
  282. if writefile(h,pointer(addr),len,size,nil)=0 then
  283. Begin
  284. errno:=GetLastError;
  285. Errno2InoutRes;
  286. end;
  287. do_write:=size;
  288. end;
  289. function do_read(h,addr,len : longint) : longint;
  290. var
  291. result:longint;
  292. begin
  293. if readfile(h,pointer(addr),len,result,nil)=0 then
  294. Begin
  295. errno:=GetLastError;
  296. Errno2InoutRes;
  297. end;
  298. do_read:=result;
  299. end;
  300. function do_filepos(handle : longint) : longint;
  301. var
  302. l:longint;
  303. begin
  304. l:=SetFilePointer(handle,0,nil,FILE_CURRENT);
  305. if l=-1 then
  306. begin
  307. l:=0;
  308. errno:=GetLastError;
  309. Errno2InoutRes;
  310. end;
  311. do_filepos:=l;
  312. end;
  313. procedure do_seek(handle,pos : longint);
  314. begin
  315. if SetFilePointer(handle,pos,nil,FILE_BEGIN)=-1 then
  316. Begin
  317. errno:=GetLastError;
  318. Errno2InoutRes;
  319. end;
  320. end;
  321. function do_seekend(handle:longint):longint;
  322. begin
  323. do_seekend:=SetFilePointer(handle,0,nil,FILE_END);
  324. if do_seekend=-1 then
  325. begin
  326. errno:=GetLastError;
  327. Errno2InoutRes;
  328. end;
  329. end;
  330. function do_filesize(handle : longint) : longint;
  331. var
  332. aktfilepos : longint;
  333. begin
  334. aktfilepos:=do_filepos(handle);
  335. do_filesize:=do_seekend(handle);
  336. do_seek(handle,aktfilepos);
  337. end;
  338. procedure do_truncate (handle,pos:longint);
  339. begin
  340. do_seek(handle,pos);
  341. if not(SetEndOfFile(handle)) then
  342. begin
  343. errno:=GetLastError;
  344. Errno2InoutRes;
  345. end;
  346. end;
  347. procedure do_open(var f;p : pchar;flags:longint);
  348. {
  349. filerec and textrec have both handle and mode as the first items so
  350. they could use the same routine for opening/creating.
  351. when (flags and $10) the file will be append
  352. when (flags and $100) the file will be truncate/rewritten
  353. when (flags and $1000) there is no check for close (needed for textfiles)
  354. }
  355. var
  356. oflags,cd : longint;
  357. begin
  358. AllowSlash(p);
  359. { close first if opened }
  360. if ((flags and $1000)=0) then
  361. begin
  362. case filerec(f).mode of
  363. fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
  364. fmclosed : ;
  365. else
  366. begin
  367. {not assigned}
  368. inoutres:=102;
  369. exit;
  370. end;
  371. end;
  372. end;
  373. { reset file handle }
  374. filerec(f).handle:=UnusedHandle;
  375. { convert filemode to filerec modes }
  376. case (flags and 3) of
  377. 0 : begin
  378. filerec(f).mode:=fminput;
  379. oflags:=GENERIC_READ;
  380. end;
  381. 1 : begin
  382. filerec(f).mode:=fmoutput;
  383. oflags:=GENERIC_WRITE;
  384. end;
  385. 2 : begin
  386. filerec(f).mode:=fminout;
  387. oflags:=GENERIC_WRITE or GENERIC_READ;
  388. end;
  389. end;
  390. { standard is opening and existing file }
  391. cd:=OPEN_EXISTING;
  392. { create it ? }
  393. if (flags and $100)<>0 then
  394. cd:=CREATE_ALWAYS
  395. { or append ? }
  396. else
  397. if (flags and $10)<>0 then
  398. cd:=OPEN_ALWAYS;
  399. { empty name is special }
  400. if p[0]=#0 then
  401. begin
  402. case filerec(f).mode of
  403. fminput : filerec(f).handle:=StdInputHandle;
  404. fmappend,
  405. fmoutput : begin
  406. filerec(f).handle:=StdOutputHandle;
  407. filerec(f).mode:=fmoutput; {fool fmappend}
  408. end;
  409. end;
  410. exit;
  411. end;
  412. filerec(f).handle:=CreateFile(p,oflags,0,nil,cd,FILE_ATTRIBUTE_NORMAL,0);
  413. { append mode }
  414. if (flags and $10)<>0 then
  415. begin
  416. do_seekend(filerec(f).handle);
  417. filerec(f).mode:=fmoutput; {fool fmappend}
  418. end;
  419. { get errors }
  420. if filerec(f).handle=0 then
  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. {$ifndef WinHeap}
  623. InitHeap;
  624. {$endif WinHeap}
  625. { Setup stdin, stdout and stderr }
  626. StdInputHandle:=longint(GetStdHandle(STD_INPUT_HANDLE));
  627. StdOutputHandle:=longint(GetStdHandle(STD_OUTPUT_HANDLE));
  628. StdErrorHandle:=longint(GetStdHandle(STD_ERROR_HANDLE));
  629. OpenStdIO(Input,fmInput,StdInputHandle);
  630. OpenStdIO(Output,fmOutput,StdOutputHandle);
  631. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  632. { Arguments }
  633. setup_arguments;
  634. { Reset IO Error }
  635. InOutRes:=0;
  636. { Reset internal error variable }
  637. errno := 0;
  638. end.
  639. {
  640. $Log$
  641. Revision 1.17 1998-08-26 10:05:08 peter
  642. * sbrk returns -1 on error
  643. Revision 1.16 1998/08/24 14:45:22 pierre
  644. * sbrk was wrong
  645. heap growing now works for win32
  646. Revision 1.15 1998/08/21 10:10:16 peter
  647. * winheap turned off by default
  648. Revision 1.14 1998/07/30 13:27:19 michael
  649. + Added support for errorproc. Changed runerror to HandleError
  650. Revision 1.13 1998/07/13 21:19:15 florian
  651. * some problems with ansi string support fixed
  652. Revision 1.12 1998/07/07 12:37:28 carl
  653. * correct mapping of error codes for TP compatibility
  654. + implemented stack checking in ifdef dummy
  655. Revision 1.11 1998/07/02 12:33:18 carl
  656. * IOCheck/InOutRes check for mkdir,rmdir and chdir like in TP
  657. Revision 1.10 1998/07/01 15:30:02 peter
  658. * better readln/writeln
  659. Revision 1.9 1998/06/10 10:39:17 peter
  660. * working w32 rtl
  661. Revision 1.8 1998/06/08 23:07:47 peter
  662. * dos interface is now 100% compatible
  663. * fixed call PASCALMAIN which must be direct asm
  664. Revision 1.7 1998/05/06 12:36:51 michael
  665. + Removed log from before restored version.
  666. Revision 1.6 1998/04/27 18:29:09 florian
  667. + do_open implemented, the file-I/O should be now complete
  668. Revision 1.5 1998/04/27 13:58:21 florian
  669. + paramstr/paramcount implemented
  670. Revision 1.4 1998/04/26 22:37:22 florian
  671. * some small extensions
  672. Revision 1.3 1998/04/26 21:49:57 florian
  673. + more stuff added (??dir procedures etc.)
  674. }