syswin32.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  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. MainInstance,
  56. cmdshow : longint;
  57. IsLibrary,IsMultiThreaded,IsConsole : boolean;
  58. implementation
  59. { include system independent routines }
  60. {$I system.inc}
  61. { some declarations for Win32 API calls }
  62. {$I win32.inc}
  63. CONST
  64. { These constants are used for conversion of error codes }
  65. { from win32 i/o errors to tp i/o errors }
  66. { errors 1 to 18 are the same as in Turbo Pascal }
  67. { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING! }
  68. { The media is write protected. }
  69. ERROR_WRITE_PROTECT = 19;
  70. { The system cannot find the device specified. }
  71. ERROR_BAD_UNIT = 20;
  72. { The device is not ready. }
  73. ERROR_NOT_READY = 21;
  74. { The device does not recognize the command. }
  75. ERROR_BAD_COMMAND = 22;
  76. { Data error (cyclic redundancy check) }
  77. ERROR_CRC = 23;
  78. { The program issued a command but the }
  79. { command length is incorrect. }
  80. ERROR_BAD_LENGTH = 24;
  81. { The drive cannot locate a specific }
  82. { area or track on the disk. }
  83. ERROR_SEEK = 25;
  84. { The specified disk or diskette cannot be accessed. }
  85. ERROR_NOT_DOS_DISK = 26;
  86. { The drive cannot find the sector requested. }
  87. ERROR_SECTOR_NOT_FOUND = 27;
  88. { The printer is out of paper. }
  89. ERROR_OUT_OF_PAPER = 28;
  90. { The system cannot write to the specified device. }
  91. ERROR_WRITE_FAULT = 29;
  92. { The system cannot read from the specified device. }
  93. ERROR_READ_FAULT = 30;
  94. { A device attached to the system is not functioning.}
  95. ERROR_GEN_FAILURE = 31;
  96. { The process cannot access the file because }
  97. { it is being used by another process. }
  98. ERROR_SHARING_VIOLATION = 32;
  99. var
  100. errno : longint;
  101. { misc. functions }
  102. function GetLastError : DWORD;
  103. external 'kernel32' name 'GetLastError';
  104. function MessageBox(w1:longint;l1,l2:pointer;w2:longint):longint;
  105. external 'user32' name 'MessageBoxA';
  106. { time and date functions }
  107. function GetTickCount : longint;
  108. external 'kernel32' name 'GetTickCount';
  109. { process functions }
  110. procedure ExitProcess(uExitCode : UINT);
  111. external 'kernel32' name 'ExitProcess';
  112. Procedure Errno2InOutRes;
  113. Begin
  114. { DO NOT MODIFY UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING }
  115. if (errno >= ERROR_WRITE_PROTECT) and (errno <= ERROR_GEN_FAILURE) THEN
  116. BEGIN
  117. { This is the offset to the Win32 to add to directly map }
  118. { to the DOS/TP compatible error codes when in this range }
  119. InOutRes := word(errno)+131;
  120. END
  121. else
  122. { This case is special }
  123. if errno=ERROR_SHARING_VIOLATION THEN
  124. BEGIN
  125. InOutRes :=5;
  126. END
  127. else
  128. { other error codes can directly be mapped }
  129. InOutRes := Word(errno);
  130. errno:=0;
  131. end;
  132. {$ifdef dummy}
  133. procedure int_stackcheck(stack_size:longint);[public,alias: 'STACKCHECK'];
  134. {
  135. called when trying to get local stack if the compiler directive $S
  136. is set this function must preserve esi !!!! because esi is set by
  137. the calling proc for methods it must preserve all registers !!
  138. With a 2048 byte safe area used to write to StdIo without crossing
  139. the stack boundary
  140. }
  141. begin
  142. asm
  143. pushl %eax
  144. pushl %ebx
  145. movl stack_size,%ebx
  146. addl $2048,%ebx
  147. movl %esp,%eax
  148. subl %ebx,%eax
  149. movl stacklimit,%ebx
  150. cmpl %eax,%ebx
  151. jae __short_on_stack
  152. popl %ebx
  153. popl %eax
  154. leave
  155. ret $4
  156. __short_on_stack:
  157. { can be usefull for error recovery !! }
  158. popl %ebx
  159. popl %eax
  160. end['EAX','EBX'];
  161. HandleError(202);
  162. end;
  163. {$endif dummy}
  164. procedure halt(errnum : byte);
  165. begin
  166. do_exit;
  167. ExitProcess(errnum);
  168. end;
  169. function paramcount : longint;
  170. begin
  171. paramcount := argc - 1;
  172. end;
  173. function paramstr(l : longint) : string;
  174. begin
  175. if (l>=0) and (l+1<=argc) then
  176. paramstr:=strpas(argv[l])
  177. else
  178. paramstr:='';
  179. end;
  180. procedure randomize;
  181. begin
  182. randseed:=GetTickCount;
  183. end;
  184. {*****************************************************************************
  185. Heap Management
  186. *****************************************************************************}
  187. { memory functions }
  188. function GlobalAlloc(mode,size:longint):longint;
  189. external 'kernel32' name 'GlobalAlloc';
  190. function GlobalLock(handle:longint):pointer;
  191. external 'kernel32' name 'GlobalLock';
  192. {$ifdef SYSTEMDEBUG}
  193. function GlobalSize(h:longint):longint;
  194. external 'kernel32' name 'GlobalSize';
  195. {$endif}
  196. {$ASMMODE DIRECT}
  197. function getheapstart:pointer;assembler;
  198. asm
  199. leal HEAP,%eax
  200. end ['EAX'];
  201. function getheapsize:longint;assembler;
  202. asm
  203. movl HEAPSIZE,%eax
  204. end ['EAX'];
  205. {$ASMMODE ATT}
  206. function Sbrk(size : longint):longint;
  207. var
  208. h,l : longint;
  209. begin
  210. h:=GlobalAlloc(258,size);
  211. l:=longint(GlobalLock(h));
  212. if l=0 then
  213. l:=-1;
  214. {$ifdef SYSTEMDEBUG}
  215. Writeln('new heap part at $',hexstr(l,8), ' size = ',GlobalSize(h));
  216. {$endif}
  217. sbrk:=l;
  218. end;
  219. { include standard heap management }
  220. {$I heap.inc}
  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) or (filerec(f).handle=-1) then
  421. { handle -1 is returned sometimes !! (PM) }
  422. begin
  423. errno:=GetLastError;
  424. Errno2InoutRes;
  425. end;
  426. end;
  427. function do_isdevice(handle:longint):boolean;
  428. begin
  429. do_isdevice:=(getfiletype(handle)=2);
  430. end;
  431. {*****************************************************************************
  432. UnTyped File Handling
  433. *****************************************************************************}
  434. {$i file.inc}
  435. {*****************************************************************************
  436. Typed File Handling
  437. *****************************************************************************}
  438. {$i typefile.inc}
  439. {*****************************************************************************
  440. Text File Handling
  441. *****************************************************************************}
  442. {$DEFINE EOF_CTRLZ}
  443. {$i text.inc}
  444. {*****************************************************************************
  445. Directory Handling
  446. *****************************************************************************}
  447. function CreateDirectory(name : pointer;sec : pointer) : longint;
  448. external 'kernel32' name 'CreateDirectoryA';
  449. function RemoveDirectory(name:pointer):longint;
  450. external 'kernel32' name 'RemoveDirectoryA';
  451. function SetCurrentDirectory(name : pointer) : longint;
  452. external 'kernel32' name 'SetCurrentDirectoryA';
  453. function GetCurrentDirectory(bufsize : longint;name : pchar) : longint;
  454. external 'kernel32' name 'GetCurrentDirectoryA';
  455. type
  456. TDirFnType=function(name:pointer):word;
  457. procedure dirfn(afunc : TDirFnType;const s:string);
  458. var
  459. buffer : array[0..255] of char;
  460. begin
  461. move(s[1],buffer,length(s));
  462. buffer[length(s)]:=#0;
  463. AllowSlash(pchar(@buffer));
  464. if aFunc(@buffer)=0 then
  465. begin
  466. errno:=GetLastError;
  467. Errno2InoutRes;
  468. end;
  469. end;
  470. function CreateDirectoryTrunc(name:pointer):word;
  471. begin
  472. CreateDirectoryTrunc:=CreateDirectory(name,nil);
  473. end;
  474. procedure mkdir(const s:string);[IOCHECK];
  475. begin
  476. If InOutRes <> 0 then exit;
  477. dirfn(TDirFnType(@CreateDirectoryTrunc),s);
  478. end;
  479. procedure rmdir(const s:string);[IOCHECK];
  480. begin
  481. If InOutRes <> 0 then exit;
  482. dirfn(TDirFnType(@RemoveDirectory),s);
  483. end;
  484. procedure chdir(const s:string);[IOCHECK];
  485. begin
  486. If InOutRes <> 0 then exit;
  487. dirfn(TDirFnType(@SetCurrentDirectory),s);
  488. end;
  489. procedure getdir(drivenr:byte;var dir:string);
  490. const
  491. Drive:array[0..3]of char=(#0,':',#0,#0);
  492. var
  493. defaultdrive:boolean;
  494. DirBuf,SaveBuf:array[0..259] of Char;
  495. begin
  496. defaultdrive:=drivenr=0;
  497. if not defaultdrive then
  498. begin
  499. byte(Drive[0]):=Drivenr+64;
  500. GetCurrentDirectory(SizeOf(SaveBuf),SaveBuf);
  501. SetCurrentDirectory(@Drive);
  502. end;
  503. GetCurrentDirectory(SizeOf(DirBuf),DirBuf);
  504. if not defaultdrive then
  505. SetCurrentDirectory(@SaveBuf);
  506. dir:=strpas(DirBuf);
  507. end;
  508. {*****************************************************************************
  509. SystemUnit Initialization
  510. *****************************************************************************}
  511. { Startup }
  512. procedure GetStartupInfo(p : pointer);
  513. external 'kernel32' name 'GetStartupInfoA';
  514. function GetStdHandle(nStdHandle:DWORD):THANDLE;
  515. external 'kernel32' name 'GetStdHandle';
  516. { command line/enviroment functions }
  517. function GetCommandLine : pchar;
  518. external 'kernel32' name 'GetCommandLineA';
  519. { module functions }
  520. function GetModuleFileName(l1:longint;p:pointer;l2:longint):longint;
  521. external 'kernel32' name 'GetModuleFileNameA';
  522. function GetModuleHandle(p : pointer) : longint;
  523. external 'kernel32' name 'GetModuleHandleA';
  524. var
  525. ModuleName : array[0..255] of char;
  526. function GetCommandFile:pchar;
  527. begin
  528. GetModuleFileName(0,@ModuleName,255);
  529. GetCommandFile:=@ModuleName;
  530. end;
  531. procedure setup_arguments;
  532. var
  533. arglen,
  534. count : longint;
  535. argstart,
  536. cmdline : pchar;
  537. quote : set of char;
  538. argsbuf : array[0..127] of pchar;
  539. begin
  540. { create commandline, it starts with the executed filename which is argv[0] }
  541. cmdline:=GetCommandLine;
  542. count:=0;
  543. repeat
  544. { skip leading spaces }
  545. while cmdline^ in [' ',#9,#13] do
  546. inc(longint(cmdline));
  547. case cmdline^ of
  548. #0 : break;
  549. '"' : begin
  550. quote:=['"'];
  551. inc(longint(cmdline));
  552. end;
  553. '''' : begin
  554. quote:=[''''];
  555. inc(longint(cmdline));
  556. end;
  557. else
  558. quote:=[' ',#9,#13];
  559. end;
  560. { scan until the end of the argument }
  561. argstart:=cmdline;
  562. while (cmdline^<>#0) and not(cmdline^ in quote) do
  563. inc(longint(cmdline));
  564. { reserve some memory }
  565. arglen:=cmdline-argstart;
  566. getmem(argsbuf[count],arglen+1);
  567. move(argstart^,argsbuf[count]^,arglen);
  568. argsbuf[count][arglen]:=#0;
  569. { skip quote }
  570. if cmdline^ in quote then
  571. inc(longint(cmdline));
  572. inc(count);
  573. until false;
  574. { create argc }
  575. argc:=count;
  576. { create an nil entry }
  577. argsbuf[count]:=nil;
  578. inc(count);
  579. { create the argv }
  580. getmem(argv,count shl 2);
  581. move(argsbuf,argv^,count shl 2);
  582. end;
  583. {$ASMMODE DIRECT}
  584. var
  585. fpucw : word;
  586. procedure Entry;[public,alias: '_mainCRTStartup'];
  587. { Can't use here any locals, because ebp is set to zero to indicate end of
  588. backtrace (PFV) }
  589. begin
  590. { init fpu and call to the pascal main }
  591. fpucw:=$1332;
  592. asm
  593. finit
  594. fwait
  595. fldcw _FPUCW
  596. xorl %ebp,%ebp
  597. call PASCALMAIN
  598. end;
  599. { that's all folks }
  600. ExitProcess(0);
  601. end;
  602. {$ifdef dummy}
  603. Function SetUpStack : longint;
  604. { This routine does the following : }
  605. { returns the value of the initial SP - __stklen }
  606. begin
  607. asm
  608. pushl %ebx
  609. pushl %eax
  610. movl __stklen,%ebx
  611. movl %esp,%eax
  612. subl %ebx,%eax
  613. movl %eax,__RESULT
  614. popl %eax
  615. popl %ebx
  616. end;
  617. end;
  618. {$endif}
  619. {$ASMMODE ATT}
  620. begin
  621. { get some helpful informations }
  622. GetStartupInfo(@startupinfo);
  623. { some misc Win32 stuff }
  624. hprevinst:=0;
  625. MainInstance:=getmodulehandle(GetCommandFile);
  626. IsLibrary:=MainInstance=0;
  627. IsConsole:=true;
  628. IsMultithreaded:=false;
  629. cmdshow:=startupinfo.wshowwindow;
  630. { to test stack depth }
  631. loweststack:=maxlongint;
  632. { real test stack depth }
  633. { stacklimit := setupstack; }
  634. { Setup heap }
  635. InitHeap;
  636. { Setup stdin, stdout and stderr }
  637. StdInputHandle:=longint(GetStdHandle(STD_INPUT_HANDLE));
  638. StdOutputHandle:=longint(GetStdHandle(STD_OUTPUT_HANDLE));
  639. StdErrorHandle:=longint(GetStdHandle(STD_ERROR_HANDLE));
  640. OpenStdIO(Input,fmInput,StdInputHandle);
  641. OpenStdIO(Output,fmOutput,StdOutputHandle);
  642. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  643. { Arguments }
  644. setup_arguments;
  645. { Reset IO Error }
  646. InOutRes:=0;
  647. { Reset internal error variable }
  648. errno := 0;
  649. end.
  650. {
  651. $Log$
  652. Revision 1.22 1998-10-27 15:07:16 florian
  653. + Is* flags added
  654. + IsLibrary works also
  655. Revision 1.21 1998/10/15 16:26:19 peter
  656. + fpuinit
  657. + end of backtrace indicator
  658. Revision 1.20 1998/09/14 10:48:33 peter
  659. * FPC_ names
  660. * Heap manager is now system independent
  661. Revision 1.19 1998/09/02 09:03:46 pierre
  662. * do_open sometimes returns -1 as handle on fail
  663. was not checked correctly
  664. Revision 1.16 1998/08/24 14:45:22 pierre
  665. * sbrk was wrong
  666. heap growing now works for win32
  667. Revision 1.15 1998/08/21 10:10:16 peter
  668. * winheap turned off by default
  669. Revision 1.14 1998/07/30 13:27:19 michael
  670. + Added support for errorproc. Changed runerror to HandleError
  671. Revision 1.13 1998/07/13 21:19:15 florian
  672. * some problems with ansi string support fixed
  673. Revision 1.12 1998/07/07 12:37:28 carl
  674. * correct mapping of error codes for TP compatibility
  675. + implemented stack checking in ifdef dummy
  676. Revision 1.11 1998/07/02 12:33:18 carl
  677. * IOCheck/InOutRes check for mkdir,rmdir and chdir like in TP
  678. Revision 1.10 1998/07/01 15:30:02 peter
  679. * better readln/writeln
  680. Revision 1.9 1998/06/10 10:39:17 peter
  681. * working w32 rtl
  682. Revision 1.8 1998/06/08 23:07:47 peter
  683. * dos interface is now 100% compatible
  684. * fixed call PASCALMAIN which must be direct asm
  685. Revision 1.7 1998/05/06 12:36:51 michael
  686. + Removed log from before restored version.
  687. Revision 1.6 1998/04/27 18:29:09 florian
  688. + do_open implemented, the file-I/O should be now complete
  689. Revision 1.5 1998/04/27 13:58:21 florian
  690. + paramstr/paramcount implemented
  691. Revision 1.4 1998/04/26 22:37:22 florian
  692. * some small extensions
  693. Revision 1.3 1998/04/26 21:49:57 florian
  694. + more stuff added (??dir procedures etc.)
  695. }