system.pp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2002 by Olle Raab
  5. FreePascal system unit for MacOS.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit System;
  13. interface
  14. {If MAC_SYS_RUNABLE is defined, this file can be included in a
  15. runnable program, but it then lacks lot of features. If not defined
  16. it tries to be faithful to a real system.pp, but it may not be
  17. able to assemble and link. The switch is only temporary, and only for
  18. use when system.pp is developed.}
  19. {$Y-}
  20. {$ifdef MAC_SYS_RUNABLE}
  21. type
  22. integer = -32768 .. 32767;
  23. byte =0..255;
  24. shortint=-128..127;
  25. word=0..65535;
  26. longint=+(-$7FFFFFFF-1)..$7FFFFFFF;
  27. pchar=^char;
  28. {$else}
  29. {$I systemh.inc}
  30. {$I heaph.inc}
  31. {Platform specific information}
  32. const
  33. LineEnding = #13;
  34. LFNSupport = true;
  35. DirectorySeparator = ':';
  36. DriveSeparator = ':';
  37. PathSeparator = ';';
  38. FileNameCaseSensitive = false;
  39. const
  40. UnusedHandle = -1;
  41. StdInputHandle = 0;
  42. StdOutputHandle = 0;
  43. StdErrorHandle = 0;
  44. sLineBreak : string[1] = LineEnding;
  45. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCR;
  46. var
  47. argc : longint;
  48. argv : ppchar;
  49. envp : ppchar;
  50. {$endif}
  51. implementation
  52. {$ifdef MAC_SYS_RUNABLE}
  53. procedure do_exit;[public,alias:'FPC_DO_EXIT'];
  54. begin
  55. end;
  56. procedure fpc_initializeunits;[public,alias:'FPC_INITIALIZEUNITS'];
  57. begin
  58. end;
  59. {$else}
  60. {$I system.inc}
  61. {*********************** ??????? *************}
  62. procedure SysInitStdIO;
  63. begin
  64. end;
  65. {*****************************************************************************}
  66. procedure setup_arguments;
  67. begin
  68. end;
  69. procedure setup_environment;
  70. begin
  71. end;
  72. {*****************************************************************************
  73. System Dependent Exit code
  74. *****************************************************************************}
  75. Procedure system_exit;
  76. begin
  77. end;
  78. {*****************************************************************************
  79. ParamStr/Randomize
  80. *****************************************************************************}
  81. { number of args }
  82. function paramcount : longint;
  83. begin
  84. {paramcount := argc - 1;}
  85. paramcount:=0;
  86. end;
  87. { argument number l }
  88. function paramstr(l : longint) : string;
  89. begin
  90. {if (l>=0) and (l+1<=argc) then
  91. paramstr:=strpas(argv[l])
  92. else}
  93. paramstr:='';
  94. end;
  95. { set randseed to a new pseudo random value }
  96. procedure randomize;
  97. begin
  98. {regs.realeax:=$2c00;
  99. sysrealintr($21,regs);
  100. hl:=regs.realedx and $ffff;
  101. randseed:=hl*$10000+ (regs.realecx and $ffff);}
  102. randseed:=0;
  103. end;
  104. {*****************************************************************************
  105. Heap Management
  106. *****************************************************************************}
  107. { first address of heap }
  108. function getheapstart:pointer;
  109. begin
  110. getheapstart:=0;
  111. end;
  112. { current length of heap }
  113. function getheapsize:longint;
  114. begin
  115. getheapsize:=0;
  116. end;
  117. { function to allocate size bytes more for the program }
  118. { must return the first address of new data space or -1 if fail }
  119. function Sbrk(size : longint):longint;
  120. begin
  121. Sbrk:=-1;
  122. end;
  123. {$I heap.inc}
  124. {****************************************************************************
  125. Low level File Routines
  126. All these functions can set InOutRes on errors
  127. ****************************************************************************}
  128. { close a file from the handle value }
  129. procedure do_close(handle : longint);
  130. begin
  131. InOutRes:=1;
  132. end;
  133. procedure do_erase(p : pchar);
  134. begin
  135. InOutRes:=1;
  136. end;
  137. procedure do_rename(p1,p2 : pchar);
  138. begin
  139. InOutRes:=1;
  140. end;
  141. function do_write(h,addr,len : longint) : longint;
  142. begin
  143. InOutRes:=1;
  144. end;
  145. function do_read(h,addr,len : longint) : longint;
  146. begin
  147. InOutRes:=1;
  148. end;
  149. function do_filepos(handle : longint) : longint;
  150. begin
  151. InOutRes:=1;
  152. end;
  153. procedure do_seek(handle,pos : longint);
  154. begin
  155. InOutRes:=1;
  156. end;
  157. function do_seekend(handle:longint):longint;
  158. begin
  159. InOutRes:=1;
  160. end;
  161. function do_filesize(handle : longint) : longint;
  162. begin
  163. InOutRes:=1;
  164. end;
  165. { truncate at a given position }
  166. procedure do_truncate (handle,pos:longint);
  167. begin
  168. InOutRes:=1;
  169. end;
  170. procedure do_open(var f;p:pchar;flags:longint);
  171. {
  172. filerec and textrec have both handle and mode as the first items so
  173. they could use the same routine for opening/creating.
  174. when (flags and $10) the file will be append
  175. when (flags and $100) the file will be truncate/rewritten
  176. when (flags and $1000) there is no check for close (needed for textfiles)
  177. }
  178. begin
  179. InOutRes:=1;
  180. end;
  181. function do_isdevice(handle:longint):boolean;
  182. begin
  183. do_isdevice:=false;
  184. end;
  185. {*****************************************************************************
  186. UnTyped File Handling
  187. *****************************************************************************}
  188. {$i file.inc}
  189. {*****************************************************************************
  190. Typed File Handling
  191. *****************************************************************************}
  192. {$i typefile.inc}
  193. {*****************************************************************************
  194. Text File Handling
  195. *****************************************************************************}
  196. { should we consider #26 as the end of a file ? }
  197. {?? $DEFINE EOF_CTRLZ}
  198. {$i text.inc}
  199. {*****************************************************************************
  200. Directory Handling
  201. *****************************************************************************}
  202. procedure mkdir(const s : string);[IOCheck];
  203. begin
  204. InOutRes:=1;
  205. end;
  206. procedure rmdir(const s : string);[IOCheck];
  207. begin
  208. InOutRes:=1;
  209. end;
  210. procedure chdir(const s : string);[IOCheck];
  211. begin
  212. InOutRes:=1;
  213. end;
  214. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  215. begin
  216. InOutRes := 1;
  217. end;
  218. {*****************************************************************************
  219. SystemUnit Initialization
  220. *****************************************************************************}
  221. Begin
  222. { To be set if this is a GUI or console application }
  223. IsConsole := TRUE;
  224. { To be set if this is a library and not a program }
  225. IsLibrary := FALSE;
  226. StackBottom := SPtr - StackLength;
  227. ExitCode := 0;
  228. { Setup heap }
  229. InitHeap;
  230. { Setup stdin, stdout and stderr }
  231. OpenStdIO(Input,fmInput,StdInputHandle);
  232. OpenStdIO(Output,fmOutput,StdOutputHandle);
  233. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  234. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  235. { Setup environment and arguments }
  236. Setup_Environment;
  237. Setup_Arguments;
  238. { Reset IO Error }
  239. InOutRes:=0;
  240. {$endif}
  241. End.
  242. {
  243. $Log$
  244. Revision 1.3 2002-10-23 15:29:09 olle
  245. + added switch MAC_SYS_RUNABLE
  246. + added include of system.h etc
  247. + added standard globals
  248. + added dummy hook procedures
  249. Revision 1.2 2002/10/10 19:44:05 florian
  250. * changes from Olle to compile/link a simple program
  251. Revision 1.1 2002/10/02 21:34:31 florian
  252. * first dummy implementation
  253. }