system.pp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2002-2004 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. { include system-independent routine headers }
  15. {$I systemh.inc}
  16. {Platform specific information}
  17. type
  18. {$ifdef CPU64}
  19. THandle = Int64;
  20. {$else CPU64}
  21. THandle = Longint;
  22. {$endif CPU64}
  23. const
  24. LineEnding = #13;
  25. LFNSupport = true;
  26. DirectorySeparator = ':';
  27. DriveSeparator = ':';
  28. PathSeparator = ','; {Is used in MPW and OzTeX}
  29. FileNameCaseSensitive = false;
  30. maxExitCode = 65535;
  31. { include heap support headers }
  32. {$I heaph.inc}
  33. const
  34. { Default filehandles }
  35. UnusedHandle : Longint = -1;
  36. StdInputHandle : Longint = 0;
  37. StdOutputHandle : Longint = 1;
  38. StdErrorHandle : Longint = 2;
  39. sLineBreak = LineEnding;
  40. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCR;
  41. var
  42. argc : longint;
  43. argv : ppchar;
  44. envp : ppchar;
  45. {*********************************}
  46. {** MacOS specific functions **}
  47. {*********************************}
  48. {To be called at regular intervals, for lenghty tasks.
  49. Yield might give time for other tasks to run under the cooperative
  50. multitasked macos. For an MPW Tool, it also spinns the cursor.}
  51. procedure Yield;
  52. {*********************************}
  53. {** Available features on macos **}
  54. {*********************************}
  55. var
  56. macosHasGestalt: Boolean;
  57. macosHasWaitNextEvent: Boolean;
  58. macosHasColorQD: Boolean;
  59. macosHasFPU: Boolean;
  60. macosSystemVersion: Integer;
  61. macosHasSysDebugger: Boolean = false;
  62. macosHasCFM: Boolean;
  63. macosHasAppleEvents: Boolean;
  64. macosHasAliasMgr: Boolean;
  65. macosHasFSSpec: Boolean;
  66. macosHasFindFolder: Boolean;
  67. macosHasScriptMgr: Boolean;
  68. macosNrOfScriptsInstalled: Integer;
  69. macosHasAppearance: Boolean;
  70. macosHasAppearance101: Boolean;
  71. macosHasAppearance11: Boolean;
  72. macosBootVolumeVRefNum: Integer;
  73. macosBootVolumeName: String[31];
  74. {
  75. MacOS paths
  76. ===========
  77. MacOS directory separator is a colon ":" which is the only character not
  78. allowed in filenames.
  79. A path containing no colon or which begins with a colon is a partial path.
  80. E g ":kalle:petter" ":kalle" "kalle"
  81. All other paths are full (absolute) paths. E g "HD:kalle:" "HD:"
  82. When generating paths, one is safe is one ensures that all partial paths
  83. begins with a colon, and all full paths ends with a colon.
  84. In full paths the first name (e g HD above) is the name of a mounted volume.
  85. These names are not unique, because, for instance, two diskettes with the
  86. same names could be inserted. This means that paths on MacOS is not
  87. waterproof. In case of equal names the first volume found will do.
  88. Two colons "::" are the relative path to the parent. Three is to the
  89. grandparent etc.
  90. }
  91. implementation
  92. {
  93. About the implementation
  94. ========================
  95. A MacOS application is assembled and linked by MPW (Macintosh
  96. Programmers Workshop), which nowadays is free to use. For info
  97. and download of MPW and MacOS api, see www.apple.com
  98. It can be linked to either a graphical user interface application,
  99. a standalone text only application (using SIOW) or
  100. to an MPW tool, this is entirely controlled by the linking step.
  101. It requires system 7 and CFM, which is always the case for PowerPC.
  102. If a m68k version would be implemented, it would save a lot
  103. of efforts if it also uses CFM. This System.pp should, with
  104. minor modifications, probably work with m68k.
  105. Initial working directory is the directory of the application,
  106. or for an MPWTool, the working directory as set by the
  107. Directory command in MPW.
  108. Note about working directory. There is a facility in MacOS which
  109. manages a working directory for an application, initially set to
  110. the applications directory, or for an MPWTool, the tool's directory.
  111. However, this requires the application to have a unique application
  112. signature (creator code), to distinguish its working directory
  113. from working directories of other applications. Due to the fact
  114. that casual applications are anonymous in this sense (without an
  115. application signature), this facility will not work. Also, this
  116. working directory facility is not present in Carbon. Hence we
  117. will manage a working directory by our self.
  118. Deviations
  119. ==========
  120. In current implementation, working directory is stored as
  121. directory id. This means there is a possibility the user moves the
  122. working directory or a parent to it, while the application uses it.
  123. Then the path to the wd suddenly changes. This is AFAIK not in
  124. accordance with other OS's. Although this is a minor caveat,
  125. it is mentioned here. To overcome this the wd could be stored
  126. as a path instead, but this imposes translations from fullpath
  127. to directory ID each time the filesystem is accessed.
  128. The initial working directory for an MPWTool, as considered by
  129. FPC, is different from the MacOS working directory facility,
  130. see above.
  131. Possible improvements:
  132. =====================
  133. Perhaps handle readonly filesystems, as in sysunix.inc
  134. }
  135. {This implementation uses StdCLib, which is included in the MPW.}
  136. {$define MACOS_USE_STDCLIB}
  137. {******** include system independent routines **********}
  138. {$I system.inc}
  139. {*********************** MacOS API *********************}
  140. {Below is some MacOS API routines included for internal use.
  141. Note, because the System unit is the most low level, it should not
  142. depend on any other units, and thus the macos api must be accessed
  143. as an include file and not a unit.}
  144. {$I macostp.inc}
  145. {If the Apples Universal Interfaces are used, the qd variable is required
  146. to be allocated somewhere, so we do it here for the convenience to the user.}
  147. var
  148. qd: QDGlobals; cvar;
  149. {$ifdef MACOS_USE_STDCLIB}
  150. {************** API to StdCLib in MacOS ***************}
  151. {The reason StdCLib is used is that it can easily be connected
  152. to either SIOW or, in case of MPWTOOL, to MPW }
  153. {The prefix C_ or c_ is used where names conflicts with pascal
  154. keywords and names. Suffix Ptr is added for pointer to a type.}
  155. type
  156. size_t = Longint;
  157. off_t = Longint;
  158. C_int = Longint;
  159. C_short = Integer;
  160. C_long = Longint;
  161. C_unsigned_int = Cardinal;
  162. var
  163. errno: C_int; external name 'errno';
  164. MacOSErr: C_short; external name 'MacOSErr';
  165. const
  166. _IOFBF = $00;
  167. _IOLBF = $40;
  168. _IONBF = $04;
  169. O_RDONLY = $00; // Open for reading only.
  170. O_WRONLY = $01; // Open for writing only.
  171. O_RDWR = $02; // Open for reading & writing.
  172. O_APPEND = $08; // Write to the end of the file.
  173. O_RSRC = $10; // Open the resource fork.
  174. O_ALIAS = $20; // Open alias file.
  175. O_CREAT = $100; // Open or create a file.
  176. O_TRUNC = $200; // Open and truncate to zero length.
  177. O_EXCL = $400; // Create file only; fail if exists.
  178. O_BINARY = $800; // Open as a binary stream.
  179. O_NRESOLVE = $4000; // Don't resolve any aliases.
  180. SEEK_SET = 0;
  181. SEEK_CUR = 1;
  182. SEEK_END = 2;
  183. FIOINTERACTIVE = $00006602; // If device is interactive
  184. FIOBUFSIZE = $00006603; // Return optimal buffer size
  185. FIOFNAME = $00006604; // Return filename
  186. FIOREFNUM = $00006605; // Return fs refnum
  187. FIOSETEOF = $00006606; // Set file length
  188. TIOFLUSH = $00007408; // discard unread input. arg is ignored
  189. function c_open(path: PChar; oflag: C_int): C_int; cdecl;
  190. external 'StdCLib' name 'open';
  191. function c_close(filedes: C_int): C_int; cdecl;
  192. external 'StdCLib' name 'close';
  193. function c_write(filedes: C_int; buf: pointer; nbyte: size_t): size_t; cdecl;
  194. external 'StdCLib' name 'write';
  195. function c_read(filedes: C_int; buf: pointer; nbyte: size_t): size_t; cdecl;
  196. external 'StdCLib' name 'read';
  197. function lseek(filedes: C_int; offset: off_t; whence: C_int): off_t; cdecl;
  198. external 'StdCLib' name 'lseek';
  199. function ioctl(filedes: C_int; cmd: C_unsigned_int; arg: pointer): C_int; cdecl;
  200. external 'StdCLib' name 'ioctl';
  201. function remove(filename: PChar): C_int; cdecl;
  202. external 'StdCLib';
  203. function c_rename(old, c_new: PChar): C_int; cdecl;
  204. external 'StdCLib' name 'rename';
  205. procedure c_exit(status: C_int); cdecl;
  206. external 'StdCLib' name 'exit';
  207. {cdecl is actually only needed for m68k}
  208. var
  209. {Is set to nonzero for MPWTool, zero otherwise.}
  210. StandAlone: C_int; external name 'StandAlone';
  211. CONST
  212. Sys_EPERM = 1; { No permission match }
  213. Sys_ENOENT = 2; { No such file or directory }
  214. Sys_ENORSRC = 3; { Resource not found *}
  215. Sys_EINTR = 4; { System service interrupted *}
  216. Sys_EIO = 5; { I/O error }
  217. Sys_ENXIO = 6; { No such device or address }
  218. Sys_E2BIG = 7; { Insufficient space for return argument * }
  219. Sys_ENOEXEC = 8; { File not executable * }
  220. Sys_EBADF = 9; { Bad file number }
  221. Sys_ECHILD = 10; { No child processes }
  222. Sys_EAGAIN = 11; { Resource temporarily unavailable * }
  223. Sys_ENOMEM = 12; { Not enough space * }
  224. Sys_EACCES = 13; { Permission denied }
  225. Sys_EFAULT = 14; { Illegal filename * }
  226. Sys_ENOTBLK = 15; { Block device required }
  227. Sys_EBUSY = 16; { Device or resource busy }
  228. Sys_EEXIST = 17; { File exists }
  229. Sys_EXDEV = 18; { Cross-device link }
  230. Sys_ENODEV = 19; { No such device }
  231. Sys_ENOTDIR = 20; { Not a directory }
  232. Sys_EISDIR = 21; { Is a directory }
  233. Sys_EINVAL = 22; { Invalid parameter * }
  234. Sys_ENFILE = 23; { File table overflow }
  235. Sys_EMFILE = 24; { Too many open files }
  236. Sys_ENOTTY = 25; { Not a typewriter }
  237. Sys_ETXTBSY = 26; { Text file busy. The new process was
  238. a pure procedure (shared text) file which was
  239. open for writing by another process, or file
  240. which was open for writing by another process,
  241. or while the pure procedure file was being
  242. executed an open(2) call requested write access
  243. requested write access.
  244. (Probably not applicable on macos)}
  245. Sys_EFBIG = 27; { File too large }
  246. Sys_ENOSPC = 28; { No space left on device }
  247. Sys_ESPIPE = 29; { Illegal seek }
  248. Sys_EROFS = 30; { Read-only file system }
  249. Sys_EMLINK = 31; { Too many links }
  250. Sys_EPIPE = 32; { Broken pipe }
  251. Sys_EDOM = 33; { Math argument out of domain of func }
  252. Sys_ERANGE = 34; { Math result not representable }
  253. { Note * is slightly different, compared to rtl/sunos/errno.inc}
  254. {$endif}
  255. {*********************** Macutils *********************}
  256. {And also include the same utilities as in the macutils.pp unit.}
  257. var
  258. {emulated working directory}
  259. workingDirectorySpec: FSSpec; cvar;
  260. {Also declared in macutils.pp as external. Declared here to be available
  261. to macutils.inc and below in this file.}
  262. {$I macutils.inc}
  263. {******************************************************}
  264. function GetAppFileLocation (var spec: FSSpec): Boolean;
  265. {Requires >= System 7}
  266. var
  267. PSN: ProcessSerialNumber;
  268. info: ProcessInfoRec;
  269. appFileRefNum: Integer;
  270. appName: Str255;
  271. dummy: Mac_Handle;
  272. begin
  273. begin
  274. PSN.highLongOfPSN := 0;
  275. PSN.lowLongOfPSN := kCurrentProcess;
  276. info.processInfoLength := SizeOf(info);
  277. info.processName := nil;
  278. info.processAppSpec := @spec;
  279. if GetProcessInformation(PSN, info) = noErr then
  280. begin
  281. spec.name := '';
  282. GetAppFileLocation := true;
  283. end
  284. else
  285. GetAppFileLocation := false;
  286. end
  287. end;
  288. Procedure Errno2InOutRes;
  289. {
  290. Convert ErrNo error to the correct InOutRes value.
  291. It seems that some of the errno is, in macos,
  292. used for other purposes than its original definition.
  293. }
  294. begin
  295. if errno = 0 then { Else it will go through all the cases }
  296. exit;
  297. case Errno of
  298. Sys_ENFILE,
  299. Sys_EMFILE : Inoutres:=4;
  300. Sys_ENOENT : Inoutres:=2;
  301. Sys_EBADF : Inoutres:=6;
  302. Sys_ENOMEM,
  303. Sys_EFAULT : Inoutres:=217; //TODO Exchange to something better
  304. Sys_EINVAL : Inoutres:=218; //TODO RTE 218 doesn't exist
  305. Sys_EAGAIN,
  306. Sys_ENOSPC : Inoutres:=101;
  307. Sys_ENOTDIR : Inoutres:=3;
  308. Sys_EPERM,
  309. Sys_EROFS,
  310. Sys_EEXIST,
  311. Sys_EISDIR,
  312. Sys_EINTR, //Happens when attempt to rename a file fails
  313. Sys_EBUSY, //Happens when attempt to remove a locked file
  314. Sys_EACCES,
  315. Sys_EMLINK : Inoutres:=5; //Happens when attempt to remove open file
  316. Sys_ENXIO : InOutRes:=152;
  317. Sys_ESPIPE : InOutRes:=156; //Illegal seek
  318. else
  319. InOutRes := Integer(errno);//TODO Exchange to something better
  320. end;
  321. errno:=0;
  322. end;
  323. Procedure OSErr2InOutRes(err: OSErr);
  324. begin
  325. InOutRes:= MacOSErr2RTEerr(err);
  326. end;
  327. function FSpLocationFromFullPath(fullPathLength: Integer;
  328. fullPath: Mac_Ptr; var spec: FSSpec ):OSErr;
  329. var
  330. alias: AliasHandle;
  331. res: OSErr;
  332. wasChanged: Boolean;
  333. nullString: Str32;
  334. begin
  335. nullString:= '';
  336. res:= NewAliasMinimalFromFullPath(fullPathLength,
  337. fullPath, nullString, nullString, alias);
  338. if res = noErr then
  339. begin
  340. res:= ResolveAlias(nil, alias, spec, wasChanged);
  341. DisposeHandle(Mac_Handle(alias));
  342. end;
  343. FSpLocationFromFullPath:= res;
  344. end;
  345. {*****************************************************************************
  346. MacOS specific functions
  347. *****************************************************************************}
  348. procedure Yield;
  349. begin
  350. if StandAlone = 0 then
  351. SpinCursor(1);
  352. end;
  353. {*****************************************************************************
  354. ParamStr/Randomize
  355. *****************************************************************************}
  356. { number of args }
  357. function paramcount : longint;
  358. begin
  359. paramcount := argc - 1;
  360. //paramcount:=0;
  361. end;
  362. { argument number l }
  363. function paramstr(l : longint) : string;
  364. begin
  365. if (l>=0) and (l+1<=argc) then
  366. paramstr:=strpas(argv[l])
  367. else
  368. paramstr:='';
  369. end;
  370. { set randseed to a new pseudo random value }
  371. procedure randomize;
  372. begin
  373. randseed:= Cardinal(TickCount);
  374. end;
  375. {*****************************************************************************
  376. Heap Management
  377. *****************************************************************************}
  378. var
  379. { Pointer to a block allocated with the MacOS Memory Manager, which
  380. is used as the initial FPC heap. }
  381. theHeap: Mac_Ptr;
  382. intern_heapsize : longint;external name 'HEAPSIZE';
  383. { first address of heap }
  384. function getheapstart:pointer;
  385. begin
  386. getheapstart:= theHeap;
  387. end;
  388. { current length of heap }
  389. function getheapsize:longint;
  390. begin
  391. getheapsize:= intern_heapsize ;
  392. end;
  393. {*****************************************************************************
  394. OS Memory allocation / deallocation
  395. ****************************************************************************}
  396. { function to allocate size bytes more for the program }
  397. { must return the first address of new data space or nil if failed }
  398. function SysOSAlloc(size: ptrint): pointer;
  399. begin
  400. result := NewPtr(size);
  401. end;
  402. {$define HAS_SYSOSFREE}
  403. procedure SysOSFree(p: pointer; size: ptrint);
  404. begin
  405. DisposePtr(p);
  406. end;
  407. { include standard heap management }
  408. {$I heap.inc}
  409. {*****************************************************************************
  410. Low Level File Routines
  411. ****************************************************************************}
  412. function do_isdevice(handle:longint):boolean;
  413. begin
  414. do_isdevice:=false;
  415. end;
  416. { close a file from the handle value }
  417. procedure do_close(h : longint);
  418. var
  419. err: OSErr;
  420. {No error handling, according to the other targets, which seems reasonable,
  421. because close might be used to clean up after an error.}
  422. begin
  423. {$ifdef MACOS_USE_STDCLIB}
  424. c_close(h);
  425. // Errno2InOutRes;
  426. {$else}
  427. err:= FSClose(h);
  428. // OSErr2InOutRes(err);
  429. {$endif}
  430. end;
  431. procedure do_erase(p : pchar);
  432. var
  433. spec: FSSpec;
  434. err: OSErr;
  435. res: Integer;
  436. begin
  437. res:= PathArgToFSSpec(p, spec);
  438. if (res = 0) then
  439. begin
  440. if not IsDirectory(spec) then
  441. begin
  442. err:= FSpDelete(spec);
  443. OSErr2InOutRes(err);
  444. end
  445. else
  446. InOutRes:= 2;
  447. end
  448. else
  449. InOutRes:=res;
  450. end;
  451. procedure do_rename(p1,p2 : pchar);
  452. var
  453. s1,s2: AnsiString;
  454. begin
  455. {$ifdef MACOS_USE_STDCLIB}
  456. InOutRes:= PathArgToFullPath(p1, s1);
  457. if InOutRes <> 0 then
  458. exit;
  459. InOutRes:= PathArgToFullPath(p2, s2);
  460. if InOutRes <> 0 then
  461. exit;
  462. c_rename(PChar(s1),PChar(s2));
  463. Errno2InoutRes;
  464. {$else}
  465. InOutRes:=1;
  466. {$endif}
  467. end;
  468. function do_write(h:longint;addr:pointer;len : longint) : longint;
  469. begin
  470. {$ifdef MACOS_USE_STDCLIB}
  471. do_write:= c_write(h, addr, len);
  472. Errno2InoutRes;
  473. {$else}
  474. InOutRes:=1;
  475. if FSWrite(h, len, Mac_Ptr(addr)) = noErr then
  476. InOutRes:=0;
  477. do_write:= len;
  478. {$endif}
  479. end;
  480. function do_read(h:longint;addr:pointer;len : longint) : longint;
  481. var
  482. i: Longint;
  483. begin
  484. {$ifdef MACOS_USE_STDCLIB}
  485. len:= c_read(h, addr, len);
  486. Errno2InoutRes;
  487. do_read:= len;
  488. {$else}
  489. InOutRes:=1;
  490. if FSread(h, len, Mac_Ptr(addr)) = noErr then
  491. InOutRes:=0;
  492. do_read:= len;
  493. {$endif}
  494. end;
  495. function do_filepos(handle : longint) : longint;
  496. var
  497. pos: Longint;
  498. begin
  499. {$ifdef MACOS_USE_STDCLIB}
  500. {This returns the filepos without moving it.}
  501. do_filepos := lseek(handle, 0, SEEK_CUR);
  502. Errno2InoutRes;
  503. {$else}
  504. InOutRes:=1;
  505. if GetFPos(handle, pos) = noErr then
  506. InOutRes:=0;
  507. do_filepos:= pos;
  508. {$endif}
  509. end;
  510. procedure do_seek(handle,pos : longint);
  511. begin
  512. {$ifdef MACOS_USE_STDCLIB}
  513. lseek(handle, pos, SEEK_SET);
  514. Errno2InoutRes;
  515. {$else}
  516. InOutRes:=1;
  517. if SetFPos(handle, fsFromStart, pos) = noErr then
  518. InOutRes:=0;
  519. {$endif}
  520. end;
  521. function do_seekend(handle:longint):longint;
  522. begin
  523. {$ifdef MACOS_USE_STDCLIB}
  524. do_seekend:= lseek(handle, 0, SEEK_END);
  525. Errno2InoutRes;
  526. {$else}
  527. InOutRes:=1;
  528. if SetFPos(handle, fsFromLEOF, 0) = noErr then
  529. InOutRes:=0;
  530. {TODO Resulting file position is to be returned.}
  531. {$endif}
  532. end;
  533. function do_filesize(handle : longint) : longint;
  534. var
  535. aktfilepos: Longint;
  536. begin
  537. {$ifdef MACOS_USE_STDCLIB}
  538. aktfilepos:= lseek(handle, 0, SEEK_CUR);
  539. if errno = 0 then
  540. begin
  541. do_filesize := lseek(handle, 0, SEEK_END);
  542. Errno2InOutRes; {Report the error from this operation.}
  543. lseek(handle, aktfilepos, SEEK_SET); {Always try to move back,
  544. even in presence of error.}
  545. end
  546. else
  547. Errno2InOutRes;
  548. {$else}
  549. InOutRes:=1;
  550. if GetEOF(handle, pos) = noErr then
  551. InOutRes:=0;
  552. do_filesize:= pos;
  553. {$endif}
  554. end;
  555. { truncate at a given position }
  556. procedure do_truncate (handle,pos:longint);
  557. begin
  558. {$ifdef MACOS_USE_STDCLIB}
  559. ioctl(handle, FIOSETEOF, pointer(pos));
  560. Errno2InoutRes;
  561. {$else}
  562. InOutRes:=1;
  563. do_seek(handle,pos); //TODO: Is this needed (Does the user anticipate the filemarker is at the end?)
  564. if SetEOF(handle, pos) = noErr then
  565. InOutRes:=0;
  566. {$endif}
  567. end;
  568. procedure do_open(var f;p:pchar;flags:longint);
  569. {
  570. filerec and textrec have both handle and mode as the first items so
  571. they could use the same routine for opening/creating.
  572. when (flags and $100) the file will be append
  573. when (flags and $1000) the file will be truncate/rewritten
  574. when (flags and $10000) there is no check for close (needed for textfiles)
  575. }
  576. var
  577. creator, fileType: OSType;
  578. scriptTag: ScriptCode;
  579. refNum: Integer;
  580. res: OSErr;
  581. fh: Longint;
  582. oflags : longint;
  583. s: AnsiString;
  584. begin
  585. // AllowSlash(p);
  586. { close first if opened }
  587. if ((flags and $10000)=0) then
  588. begin
  589. case filerec(f).mode of
  590. fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
  591. fmclosed : ;
  592. else
  593. begin
  594. {not assigned}
  595. inoutres:=102;
  596. exit;
  597. end;
  598. end;
  599. end;
  600. { reset file handle }
  601. filerec(f).handle:=UnusedHandle;
  602. {$ifdef MACOS_USE_STDCLIB}
  603. { We do the conversion of filemodes here, concentrated on 1 place }
  604. case (flags and 3) of
  605. 0 : begin
  606. oflags :=O_RDONLY;
  607. filerec(f).mode:=fminput;
  608. end;
  609. 1 : begin
  610. oflags :=O_WRONLY;
  611. filerec(f).mode:=fmoutput;
  612. end;
  613. 2 : begin
  614. oflags :=O_RDWR;
  615. filerec(f).mode:=fminout;
  616. end;
  617. end;
  618. if (flags and $1000)=$1000 then
  619. oflags:=oflags or (O_CREAT or O_TRUNC)
  620. else if (flags and $100)=$100 then
  621. oflags:=oflags or (O_APPEND);
  622. { empty name is special }
  623. if p[0]=#0 then
  624. begin
  625. case FileRec(f).mode of
  626. fminput :
  627. FileRec(f).Handle:=StdInputHandle;
  628. fminout, { this is set by rewrite }
  629. fmoutput :
  630. FileRec(f).Handle:=StdOutputHandle;
  631. fmappend :
  632. begin
  633. FileRec(f).Handle:=StdOutputHandle;
  634. FileRec(f).mode:=fmoutput; {fool fmappend}
  635. end;
  636. end;
  637. exit;
  638. end
  639. else
  640. begin
  641. InOutRes:= PathArgToFullPath(p, s);
  642. if InOutRes <> 0 then
  643. exit;
  644. p:= PChar(s);
  645. end;
  646. fh:= c_open(p, oflags);
  647. if (fh = -1) and (errno = Sys_EROFS) and ((oflags and O_RDWR)<>0) then
  648. begin
  649. oflags:=oflags and not(O_RDWR);
  650. fh:= c_open(p, oflags);
  651. end;
  652. Errno2InOutRes;
  653. if fh <> -1 then
  654. filerec(f).handle:= fh
  655. else
  656. filerec(f).handle:= UnusedHandle;
  657. {$else}
  658. InOutRes:=1;
  659. //creator:= $522A6368; {'MPS ' -- MPW}
  660. //creator:= $74747874; {'ttxt'}
  661. creator:= $522A6368; {'R*ch' -- BBEdit}
  662. fileType:= $54455854; {'TEXT'}
  663. { reset file handle }
  664. filerec(f).handle:=UnusedHandle;
  665. res:= FSpLocationFromFullPath(StrLen(p), p, spec);
  666. if (res = noErr) or (res = fnfErr) then
  667. begin
  668. if FSpCreate(spec, creator, fileType, smSystemScript) = noErr then
  669. ;
  670. if FSpOpenDF(spec, fsCurPerm, refNum) = noErr then
  671. begin
  672. filerec(f).handle:= refNum;
  673. InOutRes:=0;
  674. end;
  675. end;
  676. if (filerec(f).handle=UnusedHandle) then
  677. begin
  678. //errno:=GetLastError;
  679. //Errno2InoutRes;
  680. end;
  681. {$endif}
  682. end;
  683. {*****************************************************************************
  684. UnTyped File Handling
  685. *****************************************************************************}
  686. {$i file.inc}
  687. {*****************************************************************************
  688. Typed File Handling
  689. *****************************************************************************}
  690. {$i typefile.inc}
  691. {*****************************************************************************
  692. Text File Handling
  693. *****************************************************************************}
  694. { #26 is not end of a file in MacOS ! }
  695. {$i text.inc}
  696. {*****************************************************************************
  697. Directory Handling
  698. *****************************************************************************}
  699. procedure mkdir(const s:string);[IOCheck];
  700. var
  701. spec: FSSpec;
  702. createdDirID: Longint;
  703. err: OSErr;
  704. res: Integer;
  705. begin
  706. If (s='') or (InOutRes <> 0) then
  707. exit;
  708. res:= PathArgToFSSpec(s, spec);
  709. if (res = 0) or (res = 2) then
  710. begin
  711. err:= FSpDirCreate(spec, smSystemScript, createdDirID);
  712. OSErr2InOutRes(err);
  713. end
  714. else
  715. InOutRes:=res;
  716. end;
  717. procedure rmdir(const s:string);[IOCheck];
  718. var
  719. spec: FSSpec;
  720. err: OSErr;
  721. res: Integer;
  722. begin
  723. If (s='') or (InOutRes <> 0) then
  724. exit;
  725. res:= PathArgToFSSpec(s, spec);
  726. if (res = 0) then
  727. begin
  728. if IsDirectory(spec) then
  729. begin
  730. err:= FSpDelete(spec);
  731. OSErr2InOutRes(err);
  732. end
  733. else
  734. InOutRes:= 20;
  735. end
  736. else
  737. InOutRes:=res;
  738. end;
  739. procedure chdir(const s:string);[IOCheck];
  740. var
  741. spec, newDirSpec: FSSpec;
  742. err: OSErr;
  743. res: Integer;
  744. begin
  745. if (s='') or (InOutRes <> 0) then
  746. exit;
  747. res:= PathArgToFSSpec(s, spec);
  748. if (res = 0) or (res = 2) then
  749. begin
  750. { The fictive file x is appended to the directory name to make
  751. FSMakeFSSpec return a FSSpec to a file in the directory.
  752. Then by clearing the name, the FSSpec then
  753. points to the directory. It doesn't matter whether x exists or not.}
  754. err:= FSMakeFSSpec (spec.vRefNum, spec.parID, ':'+spec.name+':x', newDirSpec);
  755. if (err = noErr) or (err = fnfErr) then
  756. begin
  757. workingDirectorySpec:= newDirSpec;
  758. workingDirectorySpec.name:='';
  759. InOutRes:= 0;
  760. end
  761. else
  762. begin
  763. {E g if the directory doesn't exist.}
  764. OSErr2InOutRes(err);
  765. end;
  766. end
  767. else
  768. InOutRes:=res;
  769. end;
  770. procedure getDir (DriveNr: byte; var Dir: ShortString);
  771. var
  772. pathHandle: Mac_Handle;
  773. pathHandleSize: Longint;
  774. begin
  775. if FSpGetFullPath(workingDirectorySpec, pathHandle, false) <> noErr then
  776. Halt(3); {exit code 3 according to MPW}
  777. pathHandleSize:= GetHandleSize(pathHandle);
  778. SetString(dir, pathHandle^, pathHandleSize);
  779. DisposeHandle(pathHandle);
  780. if pathHandleSize <= 255 then {because dir is ShortString}
  781. InOutRes := 0
  782. else
  783. InOutRes := 1; //TODO Exchange to something better
  784. end;
  785. {*****************************************************************************
  786. SystemUnit Initialization
  787. *****************************************************************************}
  788. procedure pascalmain; external name 'PASCALMAIN';
  789. {Main entry point in C style, needed to capture program parameters.
  790. For this to work, the system unit must be before the main program
  791. in the linking order.}
  792. procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
  793. begin
  794. argc:= argcparam;
  795. argv:= argvparam;
  796. envp:= envpparam;
  797. pascalmain; {run the pascal main program}
  798. end;
  799. procedure setup_arguments;
  800. begin
  801. {Nothing needs to be done here.}
  802. end;
  803. procedure setup_environment;
  804. begin
  805. end;
  806. { FindSysFolder returns the (real) vRefNum, and the DirID of the current
  807. system folder. It uses the Folder Manager if present, otherwise it falls
  808. back to SysEnvirons. It returns zero on success, otherwise a standard
  809. system error. }
  810. function FindSysFolder(var foundVRefNum: Integer; var foundDirID: Longint): OSErr;
  811. var
  812. gesResponse: Longint;
  813. envRec: SysEnvRec;
  814. myWDPB: WDPBRec;
  815. volName: String[34];
  816. err: OSErr;
  817. begin
  818. foundVRefNum := 0;
  819. foundDirID := 0;
  820. if macosHasGestalt
  821. and (Gestalt (FourCharCodeToLongword(gestaltFindFolderAttr), gesResponse) = noErr)
  822. and BitIsSet (gesResponse, gestaltFindFolderPresent) then
  823. begin { Does Folder Manager exist? }
  824. err := FindFolder (kOnSystemDisk, FourCharCodeToLongword(kSystemFolderType),
  825. kDontCreateFolder, foundVRefNum, foundDirID);
  826. end
  827. else
  828. begin
  829. { Gestalt can't give us the answer, so we resort to SysEnvirons }
  830. err := SysEnvirons (curSysEnvVers, envRec);
  831. if (err = noErr) then
  832. begin
  833. myWDPB.ioVRefNum := envRec.sysVRefNum;
  834. volName := '';
  835. myWDPB.ioNamePtr := @volName;
  836. myWDPB.ioWDIndex := 0;
  837. myWDPB.ioWDProcID := 0;
  838. err := PBGetWDInfoSync (@myWDPB);
  839. if (err = noErr) then
  840. begin
  841. foundVRefNum := myWDPB.ioWDVRefNum;
  842. foundDirID := myWDPB.ioWDDirID;
  843. end;
  844. end;
  845. end;
  846. FindSysFolder:= err;
  847. end;
  848. procedure InvestigateSystem;
  849. {$IFDEF CPUM68K}
  850. const
  851. _GestaltDispatch = $A0AD;
  852. _WaitNextEvent = $A860;
  853. _ScriptUtil = $A8B5;
  854. qdOffscreenTrap = $AB1D;
  855. {$ENDIF}
  856. var
  857. err: Integer;
  858. response: Longint;
  859. {$IFDEF CPUM68K}
  860. environs: SysEnvRec;
  861. {$ENDIF}
  862. {Vi rŠknar med att man kšr pŒ minst system 6.0.5. DŒ finns bŒde Gestalt och GDevice med.}
  863. {Enligt Change Histrory Šr MacOS 6.0.5 mera konsistent mellan maskinmodellerna Šn fšregŒende system}
  864. begin
  865. {$IFDEF CPUM68K}
  866. macosHasGestalt := TrapAvailable(_GestaltDispatch);
  867. {$ELSE}
  868. macosHasGestalt := true; {There is always Gestalt on PowerPC}
  869. {$ENDIF}
  870. if not macosHasGestalt then (* If we don't have Gestalt, then we can't have any System 7 features *)
  871. begin
  872. {$IFDEF CPUM68K}
  873. { Detta kan endast gŠlla pŒ en 68K maskin.}
  874. macosHasScriptMgr := TrapAvailable(_ScriptUtil);
  875. macosNrOfScriptsInstalled := 1; (* assume only Roman script, to start with *)
  876. err := SysEnvirons(1, environs);
  877. if err = noErr then
  878. begin
  879. if environs.machineType < 0 then { gammalt ROM}
  880. macosHasWaitNextEvent := FALSE
  881. else
  882. macosHasWaitNextEvent := TrapAvailable(_WaitNextEvent);
  883. macosHasColorQD := environs.hasColorQD;
  884. macosHasFPU := environs.hasFPU;
  885. macosSystemVersion := environs.systemVersion;
  886. end
  887. else
  888. begin
  889. macosHasWaitNextEvent := FALSE;
  890. macosHasColorQD := FALSE;
  891. macosHasFPU := FALSE;
  892. macosSystemVersion := 0;
  893. end;
  894. macosHasSysDebugger := (LongintPtr(MacJmp)^ <> 0);
  895. macosHasCFM := false;
  896. macosHasAppleEvents := false;
  897. macosHasAliasMgr := false;
  898. macosHasFSSpec := false;
  899. macosHasFindFolder := false;
  900. macosHasAppearance := false;
  901. macosHasAppearance101 := false;
  902. macosHasAppearance11 := false;
  903. {$IFDEF THINK_PASCAL}
  904. if (macosHasScriptMgr) then
  905. macosNrOfScriptsInstalled := GetEnvirons(smEnabled);
  906. {$ELSE}
  907. if (macosHasScriptMgr) then
  908. macosNrOfScriptsInstalled := GetScriptManagerVariable(smEnabled); {Gamla rutinnamnet var GetEnvirons.}
  909. {$ENDIF}
  910. {$ENDIF}
  911. end
  912. else
  913. begin
  914. macosHasScriptMgr := Gestalt(FourCharCodeToLongword(gestaltScriptMgrVersion), response) = noErr; {Fšr att ta reda pŒ om script mgr finns.}
  915. macosNrOfScriptsInstalled := 1; (* assume only Roman script, to start with *)
  916. macosHasWaitNextEvent := true;
  917. if Gestalt(FourCharCodeToLongword(gestaltSystemVersion), response) = noErr then
  918. macosSystemVersion := response
  919. else
  920. macosSystemVersion := 0; {Borde inte kunna hŠnda.}
  921. if Gestalt(FourCharCodeToLongword(gestaltOSAttr), response) = noErr then
  922. macosHasSysDebugger := BitIsSet(response, gestaltSysDebuggerSupport)
  923. else
  924. macosHasSysDebugger := false;
  925. if Gestalt(FourCharCodeToLongword(gestaltQuickdrawVersion), response) = noErr then
  926. macosHasColorQD := (response >= $0100)
  927. else
  928. macosHasColorQD := false;
  929. if Gestalt(FourCharCodeToLongword(gestaltFPUType), response) = noErr then
  930. macosHasFPU := (response <> gestaltNoFPU)
  931. else
  932. macosHasFPU := false;
  933. if Gestalt(FourCharCodeToLongword(gestaltCFMAttr), response) = noErr then
  934. macosHasCFM := BitIsSet(response, gestaltCFMPresent)
  935. else
  936. macosHasCFM := false;
  937. macosHasAppleEvents := Gestalt(FourCharCodeToLongword(gestaltAppleEventsAttr), response) = noErr;
  938. macosHasAliasMgr := Gestalt(FourCharCodeToLongword(gestaltAliasMgrAttr), response) = noErr;
  939. if Gestalt(FourCharCodeToLongword(gestaltFSAttr), response) = noErr then
  940. macosHasFSSpec := BitIsSet(response, gestaltHasFSSpecCalls)
  941. else
  942. macosHasFSSpec := false;
  943. macosHasFindFolder := Gestalt(FourCharCodeToLongword(gestaltFindFolderAttr), response) = noErr;
  944. if macosHasScriptMgr then
  945. begin
  946. err := Gestalt(FourCharCodeToLongword(gestaltScriptCount), response);
  947. if (err = noErr) then
  948. macosNrOfScriptsInstalled := Integer(response);
  949. end;
  950. if (Gestalt(FourCharCodeToLongword(gestaltAppearanceAttr), response) = noErr) then
  951. begin
  952. macosHasAppearance := BitIsSet(response, gestaltAppearanceExists);
  953. if Gestalt(FourCharCodeToLongword(gestaltAppearanceVersion), response) = noErr then
  954. begin
  955. macosHasAppearance101 := (response >= $101);
  956. macosHasAppearance11 := (response >= $110);
  957. end
  958. end
  959. else
  960. begin
  961. macosHasAppearance := false;
  962. macosHasAppearance101 := false;
  963. macosHasAppearance11 := false;
  964. end;
  965. end;
  966. end;
  967. {*****************************************************************************
  968. System Dependent Exit code
  969. *****************************************************************************}
  970. Procedure system_exit;
  971. var
  972. s: ShortString;
  973. begin
  974. if StandAlone <> 0 then
  975. if exitcode <> 0 then
  976. begin
  977. Str(exitcode,s);
  978. if IsConsole then
  979. Writeln( '### Program exited with exit code ' + s)
  980. else if macosHasSysDebugger then
  981. DebugStr('A possible error occured, exit code: ' + s + '. Type "g" and return to continue.')
  982. else
  983. {Be quiet}
  984. end;
  985. {$ifndef MACOS_USE_STDCLIB}
  986. if StandAlone <> 0 then
  987. ExitToShell;
  988. {$else}
  989. c_exit(exitcode); {exitcode is only utilized by an MPW tool}
  990. {$endif}
  991. end;
  992. procedure SysInitStdIO;
  993. begin
  994. { Setup stdin, stdout and stderr }
  995. {$ifdef MACOS_USE_STDCLIB}
  996. OpenStdIO(Input,fmInput,StdInputHandle);
  997. OpenStdIO(Output,fmOutput,StdOutputHandle);
  998. OpenStdIO(StdOut,fmOutput,StdOutputHandle);
  999. OpenStdIO(StdErr,fmOutput,StdErrorHandle);
  1000. {$endif }
  1001. end;
  1002. var
  1003. resHdl: Mac_Handle;
  1004. isFolder, hadAlias, leafIsAlias: Boolean;
  1005. dirStr: string[2];
  1006. err: OSErr;
  1007. dummySysFolderDirID: Longint;
  1008. begin
  1009. InvestigateSystem; {Must be first}
  1010. {Check requred features for system.pp to work.}
  1011. if not macosHasFSSpec then
  1012. Halt(3); //exit code 3 according to MPW
  1013. if FindSysFolder(macosBootVolumeVRefNum, dummySysFolderDirID) <> noErr then
  1014. Halt(3); //exit code 3 according to MPW
  1015. if GetVolumeName(macosBootVolumeVRefNum, macosBootVolumeName) <> noErr then
  1016. Halt(3); //exit code 3 according to MPW
  1017. { To be set if this is a GUI or console application }
  1018. if StandAlone = 0 then
  1019. IsConsole := true {Its an MPW tool}
  1020. else
  1021. begin
  1022. resHdl:= Get1Resource(FourCharCodeToLongword('siow'),0);
  1023. IsConsole := (resHdl <> nil); {A SIOW app is also a console}
  1024. ReleaseResource(resHdl);
  1025. end;
  1026. { To be set if this is a library and not a program }
  1027. IsLibrary := FALSE;
  1028. StackLength := InitialStkLen;
  1029. StackBottom := SPtr - StackLength;
  1030. { Setup working directory }
  1031. if StandAlone <> 0 then
  1032. begin
  1033. if not GetAppFileLocation(workingDirectorySpec) then
  1034. Halt(3); //exit code 3 according to MPW
  1035. end
  1036. else
  1037. begin
  1038. { The fictive file x is used to make
  1039. FSMakeFSSpec return a FSSpec to a file in the directory.
  1040. Then by clearing the name, the FSSpec then
  1041. points to the directory. It doesn't matter whether x exists or not.}
  1042. dirStr:= ':x';
  1043. err:= ResolveFolderAliases(0, 0, @dirStr, true,
  1044. workingDirectorySpec, isFolder, hadAlias, leafIsAlias);
  1045. if (err <> noErr) and (err <> fnfErr) then
  1046. Halt(3); //exit code 3 according to MPW
  1047. end;
  1048. { Setup heap }
  1049. if StandAlone <> 0 then
  1050. MaxApplZone;
  1051. if Mac_FreeMem - intern_heapsize < 30000 then
  1052. Halt(3); //exit code 3 according to MPW
  1053. theHeap:= SysOSAlloc(intern_heapsize);
  1054. if theHeap = nil then
  1055. Halt(3); //exit code 3 according to MPW
  1056. InitHeap;
  1057. SysInitStdIO;
  1058. { Setup environment and arguments }
  1059. Setup_Environment;
  1060. setup_arguments;
  1061. { Reset IO Error }
  1062. InOutRes:=0;
  1063. errno:=0;
  1064. (* This should be changed to a real value during *)
  1065. (* thread driver initialization if appropriate. *)
  1066. ThreadID := 1;
  1067. {$ifdef HASVARIANT}
  1068. initvariantmanager;
  1069. {$endif HASVARIANT}
  1070. if StandAlone = 0 then
  1071. InitCursorCtl(nil);
  1072. end.
  1073. {
  1074. $Log$
  1075. Revision 1.20 2004-09-03 19:26:08 olle
  1076. + added maxExitCode to all System.pp
  1077. * constrained error code to be below maxExitCode in RunError et. al.
  1078. Revision 1.19 2004/08/20 10:18:15 olle
  1079. + added Yield routine
  1080. Revision 1.18 2004/07/14 23:34:07 olle
  1081. + added qd, the "QuickDraw globals"
  1082. Revision 1.17 2004/06/21 19:23:34 olle
  1083. + Variables describing misc OS features added
  1084. + Detection of GUI app
  1085. * Working directory for APPTYPE TOOL correct now
  1086. + Exit code <> 0 written to, console for console apps, to system debugger (if installed) for GUI apps.
  1087. * Misc fixes
  1088. Revision 1.16 2004/06/17 16:16:13 peter
  1089. * New heapmanager that releases memory back to the OS, donated
  1090. by Micha Nelissen
  1091. Revision 1.15 2004/05/11 18:05:41 olle
  1092. + added call to MaxApplZone to have the whole MacOS heap available
  1093. Revision 1.14 2004/04/29 11:27:36 olle
  1094. * do_read/do_write addr arg changed to pointer
  1095. * misc internal changes
  1096. Revision 1.13 2004/02/04 15:17:16 olle
  1097. * internal changes
  1098. Revision 1.12 2004/01/20 23:11:20 hajny
  1099. * ExecuteProcess fixes, ProcessID and ThreadID added
  1100. Revision 1.11 2004/01/04 21:06:43 jonas
  1101. * make the C-main public
  1102. Revision 1.10 2003/10/29 22:34:52 olle
  1103. + handles program parameters for MPW
  1104. + program start stub
  1105. * improved working directory handling
  1106. * minor changes
  1107. + some documentation
  1108. Revision 1.9 2003/10/17 23:44:30 olle
  1109. + working direcory emulated
  1110. + implemented directory handling procs
  1111. + all proc which take a path param, now resolve it relative wd
  1112. Revision 1.8 2003/10/16 15:43:13 peter
  1113. * THandle is platform dependent
  1114. Revision 1.7 2003/09/27 11:52:35 peter
  1115. * sbrk returns pointer
  1116. Revision 1.6 2003/09/12 12:45:15 olle
  1117. + filehandling complete
  1118. + heaphandling complete
  1119. + support for random
  1120. * filehandling now uses filedecriptors in StdCLib
  1121. * other minor changes
  1122. - removed DEFINE MAC_SYS_RUNNABLE
  1123. Revision 1.5 2003/01/13 17:18:55 olle
  1124. + added support for rudimentary file handling
  1125. Revision 1.4 2002/11/28 10:58:02 olle
  1126. + added support for rudimentary heap
  1127. Revision 1.3 2002/10/23 15:29:09 olle
  1128. + added switch MAC_SYS_RUNABLE
  1129. + added include of system.h etc
  1130. + added standard globals
  1131. + added dummy hook procedures
  1132. Revision 1.2 2002/10/10 19:44:05 florian
  1133. * changes from Olle to compile/link a simple program
  1134. Revision 1.1 2002/10/02 21:34:31 florian
  1135. * first dummy implementation
  1136. }