amigados.pas 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2014 by Free Pascal development team
  4. dos.library functions
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {
  12. BSTR Funktions
  13. defines:
  14. AROS_FAST_BPTR: BPTR is a pointer or a 2 shifted Pointer
  15. -> atm its standard ABIv0, for v1 needs a ifdef
  16. }
  17. {$define AROS_FAST_BPTR}
  18. unit amigados;
  19. interface
  20. uses
  21. exec, utility, timer;
  22. {$PACKRECORDS C}
  23. const
  24. { Predefined Amiga DOS global constants }
  25. DOSTRUE = -1;
  26. DOSFALSE = 0;
  27. TICKS_PER_SECOND = 50; { Number of ticks in one second }
  28. // Still to TEST
  29. BITSPERBYTE = 8;
  30. BYTESPERLONG = 4;
  31. BITSPERLONG = 32;
  32. type
  33. FileHandle = BPTR;
  34. FileLock = BPTR;
  35. {* All BCPL data must be long Integer aligned. BCPL pointers are the long Integer
  36. * address (i.e byte address divided by 4 (>>2)) *}
  37. {* BCPL strings have a length in the first byte and then the characters.
  38. * For example: s[0]=3 s[1]=S s[2]=Y s[3]=S *}
  39. const
  40. // DOS functions will return this when they reach EOF. */
  41. ENDSTREAMCH = -1;
  42. // Buffering types for SetVBuf().
  43. BUF_LINE = 0; // Flush at the end of lines '\n'.
  44. BUF_FULL = 1; // Flush only when buffer is full.
  45. BUF_NONE = 2; // Do not buffer, read and write immediatly.
  46. type
  47. PDateStamp = ^TDateStamp;
  48. TDateStamp = record
  49. ds_Days: Longint; { Number of days since Jan. 1, 1978 }
  50. ds_Minute: Longint; { Number of minutes past midnight }
  51. ds_Tick: Longint; { Number of ticks past minute }
  52. end;
  53. const
  54. { The maximum length of filenames in AmigaOS. You should not depend on
  55. this value, as it may change in future versions.}
  56. MAXFILENAMELENGTH = 108;
  57. { The maximum length of comments in AmigaOS. You should not depend on
  58. this value, as it may change in future versions.}
  59. MAXCOMMENTLENGTH = 80;
  60. type
  61. { Returned by Examine() and ExInfo(), must be on a 4 byte boundary
  62. Structure used to describe a directory entry. Note that not all fields
  63. are supported by all filesystems. This structure should be allocated
  64. with AllocDosObject(). }
  65. PFileInfoBlock = ^TFileInfoBlock;
  66. TFileInfoBlock = record
  67. fib_DiskKey: IPTR;
  68. fib_DirEntryType: LongInt; // type of Directory. If < 0, then a plain file. If > 0 a directory
  69. fib_FileName: array [0..MAXFILENAMELENGTH - 1] of Char; // Null terminated. Max 30 chars used for now
  70. fib_Protection: LongInt; // bit mask of protection, rwxd are 3-0.
  71. fib_EntryType: LongInt;
  72. fib_Size: LongInt; // Number of bytes in file
  73. fib_NumBlocks: LongInt; // Number of blocks in file
  74. fib_Date: TDateStamp; // Date file last changed
  75. fib_Comment: array [0..MAXCOMMENTLENGTH - 1] of Char; // Null terminated comment associated with file
  76. fib_OwnerUID: Word; // UserID of fileowner.
  77. fib_OwnerGID: Word; // GroupID of fileowner.
  78. fib_Reserved: array [0..31] of Char; // PRIVATE
  79. end;
  80. const
  81. { FIB stands for TFileInfoBlock (fib_Protection)}
  82. { FIBB are bit definitions, FIBF are field definitions
  83. Regular RWED bits are 0 == allowed.
  84. NOTE: GRP and OTR RWED permissions are 0 == not allowed!
  85. Group and Other permissions are not directly handled by the filesystem}
  86. FIBB_DELETE = 0; // prevent file from being deleted }
  87. FIBB_EXECUTE = 1; // ignored by system, used by Shell }
  88. FIBB_WRITE = 2; // ignored by old filesystem }
  89. FIBB_READ = 3; // ignored by old filesystem }
  90. FIBB_ARCHIVE = 4; // cleared whenever file is changed }
  91. FIBB_PURE = 5; // program is reentrant and rexecutable}
  92. FIBB_SCRIPT = 6; // program is a script (execute) file }
  93. // group flags
  94. FIBB_GRP_DELETE = 8; // Group: prevent file from being deleted *}
  95. FIBB_GRP_EXECUTE = 9; // Group: file is executable *}
  96. FIBB_GRP_WRITE = 10; // Group: file is writable *}
  97. FIBB_GRP_READ = 11; // Group: file is readable *}
  98. // other
  99. FIBB_OTR_DELETE = 12; // Other: prevent file from being deleted *}
  100. FIBB_OTR_EXECUTE = 13; // Other: file is executable *}
  101. FIBB_OTR_WRITE = 14; // Other: file is writable *}
  102. FIBB_OTR_READ = 15; // Other: file is readable *}
  103. // Values
  104. FIBF_DELETE = (1 shl FIBB_DELETE);
  105. FIBF_EXECUTE = (1 shl FIBB_EXECUTE);
  106. FIBF_WRITE = (1 shl FIBB_WRITE);
  107. FIBF_READ = (1 shl FIBB_READ);
  108. FIBF_ARCHIVE = (1 shl FIBB_ARCHIVE);
  109. FIBF_PURE = (1 shl FIBB_PURE);
  110. FIBF_SCRIPT = (1 shl FIBB_SCRIPT);
  111. // Group Values
  112. FIBF_GRP_DELETE = (1 shl FIBB_GRP_DELETE);
  113. FIBF_GRP_EXECUTE = (1 shl FIBB_GRP_EXECUTE);
  114. FIBF_GRP_WRITE = (1 shl FIBB_GRP_WRITE);
  115. FIBF_GRP_READ = (1 shl FIBB_GRP_READ);
  116. // Other Values
  117. FIBF_OTR_DELETE = (1 shl FIBB_OTR_DELETE);
  118. FIBF_OTR_EXECUTE = (1 shl FIBB_OTR_EXECUTE);
  119. FIBF_OTR_WRITE = (1 shl FIBB_OTR_WRITE);
  120. FIBF_OTR_READ = (1 shl FIBB_OTR_READ);
  121. // Devices
  122. type
  123. { returned by Info(), must be on a 4 byte boundary }
  124. PInfoData = ^TInfoData;
  125. TInfoData = record
  126. id_NumSoftErrors: LongInt; // Number of soft errors on disk
  127. id_UnitNumber: LongInt; // Which unit disk is (was) mounted on
  128. id_DiskState: LongInt; // Dtate of Volume See defines below
  129. id_NumBlocks: LongInt; // Number of blocks on device
  130. id_NumBlocksUsed: LongInt; // Number of block in use
  131. id_BytesPerBlock: LongInt; // Bytes per Block
  132. id_DiskType: LongInt; // Type of Disk
  133. id_VolumeNode: BPTR; // BCPL pointer to volume node
  134. id_InUse: IPTR; // Flag, zero if not in use
  135. end;
  136. {$PACKRECORDS NORMAL}
  137. const
  138. { ID stands for InfoData }
  139. { Disk states }
  140. ID_WRITE_PROTECTED = 80; // Disk is write protected
  141. ID_VALIDATING = 81; // Disk is currently being validated
  142. ID_VALIDATED = 82; // Disk is consistent and writeable
  143. { Filesystem types as used for id_DiskType. These are multi-character
  144. constants of identifier strings. They are self-descriptive.}
  145. ID_NO_DISK_PRESENT = -1;
  146. ID_UNREADABLE_DISK = $42414400; // 'BAD#0'
  147. ID_DOS_DISK = $444F5300; // 'DOS#0'
  148. ID_FFS_DISK = $444F5301; // 'DOS#1'
  149. ID_INTER_DOS_DISK = $444F5302; // 'DOS#2'
  150. ID_INTER_FFS_DISK = $444F5303; // 'DOS#3'
  151. ID_FASTDIR_DOS_DISK = $444F5304; // 'DOS#4'
  152. ID_FASTDIR_FFS_DISK = $444F5305; // 'DOS#5'
  153. ID_NOT_REALLY_DOS = $4E444F53; // 'NDOS'
  154. ID_KICKSTART_DISK = $4B49434B; // 'KICK'
  155. ID_MSDOS_DISK = $4d534400; // 'MSD#0'
  156. ID_SFS_BE_DISK = $53465300; // 'SFS#0'
  157. ID_SFS_LE_DISK = $73667300; // 'sfs#0'
  158. { These are the return codes used by convention by AmigaDOS commands
  159. See FAILAT and IF for relvance to EXECUTE files}
  160. // No Problem, success
  161. RETURN_OK = 0;
  162. { Program succeeded, but there was something not quite right.
  163. This value may also be used to express a boolean state
  164. (RETURN_WARN meaning TRUE, RETURN_OK meaning FALSE).}
  165. RETURN_WARN = 5;
  166. { Program succeeded partly. This may be returned, if the user aborts a
  167. program or some external data were wrong.}
  168. RETURN_ERROR = 10; // Something wrong
  169. { Program execution failed. Normally used, if some system resources could
  170. not be allocated.}
  171. RETURN_FAIL = 20; // Complete or severe failure
  172. { Secondary errors codes as used for IoErr(), SetIoErr() and in
  173. Process^.pr_Result2. The term 'object' refers to files of all kinds
  174. (ie plain files, directories, links, etc).}
  175. {This is used, if something went wrong, but it is unknown what exactly
  176. went wrong. This is especially useful for emulation devices, when the
  177. underlying system returned an error that the emulation side does not
  178. know.}
  179. ERROR_UNKNOWN = 100;
  180. //General system errors
  181. ERROR_NO_FREE_STORE = 103; // Out of memory.
  182. ERROR_TASK_TABLE_FULL = 105; // Too many tasks are already running.
  183. //Errors concerning ReadArgs().
  184. ERROR_BAD_TEMPLATE = 114; // Supplied template is broken
  185. ERROR_BAD_NUMBER = 115; { A supplied argument that was expected to be numeric, was not numeric.
  186. This is also returned by some functions to expresss that a supplied
  187. number is out of range (ie to express application internal errors).}
  188. ERROR_REQUIRED_ARG_MISSING = 116; // An argument that has to be supplied (ie signed with the '/A' flag) was not supplied.
  189. ERROR_KEY_NEEDS_ARG = 117; // Keyword was specified, but not its contents.
  190. ERROR_TOO_MANY_ARGS = 118; // There were more arguments than the template needs.
  191. ERROR_UNMATCHED_QUOTES = 119; // An odd number of quotation marks was supplied.
  192. ERROR_LINE_TOO_LONG = 120; { Either the command-line was longer than hardcoded line length limit or the
  193. maximum number of multiple arguments (flag '/M') was exceeded. This can
  194. also indicate that some argument is too long or a supplied buffer is too small.}
  195. // Errors in files.
  196. ERROR_FILE_NOT_OBJECT = 121; // You tried to execute a file that is not an executable.
  197. ERROR_INVALID_RESIDENT_LIBRARY = 122; // A library or device could not be opened or that library or device is broken.
  198. ERROR_NO_DEFAULT_DIR = 201;
  199. ERROR_OBJECT_IN_USE = 202; // The accessed object is already in use (eg locked) by another task.
  200. ERROR_OBJECT_EXISTS = 203; // You tried to overwrite an object.
  201. ERROR_DIR_NOT_FOUND = 204; // The given directory or the path of a given object does not exist.
  202. ERROR_OBJECT_NOT_FOUND = 205; // The given object does not exist.
  203. // Miscellaneous errors.
  204. ERROR_BAD_STREAM_NAME = 206;
  205. ERROR_OBJECT_TOO_LARGE = 207; { The given object is too large for the operation to be made. Object is
  206. this context are for example components of path-names.}
  207. ERROR_ACTION_NOT_KNOWN = 209; { This is usually used to indicate that a filesystem does not support a
  208. certain action, but may generally also be used by functions.}
  209. ERROR_INVALID_COMPONENT_NAME = 210; // A path component was invalid (eg there were multiple colons in a path name
  210. ERROR_INVALID_LOCK = 211;
  211. ERROR_OBJECT_WRONG_TYPE = 212; { You tried to perform an action on an object, which this kind of object
  212. does not support (eg makedir on a file).}
  213. ERROR_DISK_NOT_VALIDATED = 213; // Writing failed, because the volume is not validated.
  214. ERROR_DISK_WRITE_PROTECTED = 214; // Writing failed, because the volume is write-protected.
  215. ERROR_RENAME_ACROSS_DEVICES = 215; { You tried to move/rename a file across different devices. Rename does only
  216. work on the same device, as only the inode-data has to be changed to
  217. perform that action.}
  218. ERROR_DIRECTORY_NOT_EMPTY = 216; // You tried to delete a directory that still contains some files. Delete these files first.
  219. ERROR_TOO_MANY_LEVELS = 217; // A recursive directory search could not be performed, because the stack was too small.
  220. ERROR_DEVICE_NOT_MOUNTED = 218; // You tried to access a device that is currently not mounted.
  221. ERROR_SEEK_ERROR = 219; // An error occurred, while executing DosSeek().
  222. ERROR_COMMENT_TOO_BIG = 220; // The supplied file comment was longer than the hardcoded length limit for file comments.
  223. ERROR_DISK_FULL = 221; // A write-operation could not be performed, because the volume has no space left.
  224. ERROR_DELETE_PROTECTED = 222; // You tried to delete a delete-protected object.
  225. ERROR_WRITE_PROTECTED = 223; { You tried to write to a write-protected object. This does not mean that
  226. the volume, you wanted to write to, is write-protected!}
  227. ERROR_READ_PROTECTED = 224; // You tried to read a read-protected object.
  228. ERROR_NOT_A_DOS_DISK = 225; // Accessed disk is unreadable.
  229. ERROR_NO_DISK = 226; // You tried to perform an action on a device that has no volume mounted (eg. an empty disk drive).
  230. ERROR_NO_MORE_ENTRIES = 232; { This does not indicate an error, but is returned by several functions to
  231. indicate that the last entry of a list was reached.}
  232. ERROR_IS_SOFT_LINK = 233; { Given action can not be performed on a given object, because it is a
  233. soft-link. This is usually only used by filesystem handlers and is catched
  234. by dos. Applications should not see this.}
  235. ERROR_OBJECT_LINKED = 234; // Given action can not be performed on a given object, because it is a link.
  236. ERROR_BAD_HUNK = 235; // There was a bad hunk in a file that was to load.
  237. ERROR_NOT_IMPLEMENTED = 236; { Indicates that a function does not implement a certain functionality.
  238. There are more special error conditions (ERROR_BAD_NUMBER and
  239. ERROR_ACTION_NOT_KNOWN), which should be preferred, if applicable.}
  240. ERROR_RECORD_NOT_LOCKED = 240; // You tried to access a record that was not locked.
  241. ERROR_LOCK_COLLISION = 241; // Somebody already locked a part of the record, you wanted to lock.
  242. ERROR_LOCK_TIMEOUT = 242; // LockRecord() timed out.
  243. ERROR_UNLOCK_ERROR = 243; // An error occurred, while unlocking a record.
  244. { more error codes are defined in dosasl.h and filesystem.h }
  245. { Maximum length of strings got from Fault(). Note that they should be
  246. shorter than 60 characters. }
  247. FAULT_MAX = 82;
  248. { Signals that are set, if the user presses the corresponding keys on
  249. the controlling terminal. They may also be sent by using Signal().
  250. For more information see <exec/tasks.h>. }
  251. SIGBREAKB_CTRL_C = 12; // CTRL-c, usually meaning program abortion.
  252. SIGBREAKB_CTRL_D = 13; // CTRL-d
  253. SIGBREAKB_CTRL_E = 14; // CTRL-e, usually meaning that the application should iconify itself.
  254. SIGBREAKB_CTRL_F = 15; // CTRL-f, usually meaning that the application should uniconify itself.
  255. { Bit fields that signal you that a user has issued a break
  256. for example: if (SetSignal(0,0) and SIGBREAKF_CTRL_C) then cleanup_and_exit();}
  257. SIGBREAKF_CTRL_C = 1 shl SIGBREAKB_CTRL_C;
  258. SIGBREAKF_CTRL_D = 1 shl SIGBREAKB_CTRL_D;
  259. SIGBREAKF_CTRL_E = 1 shl SIGBREAKB_CTRL_E;
  260. SIGBREAKF_CTRL_F = 1 shl SIGBREAKB_CTRL_F;
  261. { Mode parameter to Open() }
  262. MODE_OLDFILE = 1005; // Open existing file read/write positioned at beginning of file.
  263. MODE_NEWFILE = 1006; // Open freshly created file (delete old file) read/write
  264. MODE_READWRITE = 1004; // An old file is opened. If it does not exist, a new one is created.
  265. { Passed as type to Lock() }
  266. SHARED_LOCK = -2; // Non-exclusive lock, other tasks may lock this file as well.
  267. ACCESS_READ = SHARED_LOCK; // This is used for read-only operations.
  268. EXCLUSIVE_LOCK = -1; // Exclusive lock, other tasks may not lock this file.
  269. ACCESS_WRITE = EXCLUSIVE_LOCK; // This is used for write operations.
  270. { Values returned by SameLock() }
  271. LOCK_SAME = 0;
  272. LOCK_SAME_HANDLER = 1; // actually same volume
  273. LOCK_DIFFERENT = -1;
  274. { Values for MakeLink() }
  275. LINK_HARD = 0;
  276. LINK_SOFT = 1;
  277. { Relative position to Seek() }
  278. OFFSET_BEGINNING = -1; // relative to Begining Of File
  279. OFFSET_CURRENT = 0; // relative to Current file position
  280. OFFSET_END = 1; // relative to End Of File
  281. { Limits of the "Integer" type already defined in FPC... but ok}
  282. MAXINT = $7FFFFFFF;
  283. MININT = $80000000;
  284. { types for ChangeMode() }
  285. CHANGE_LOCK = 0;
  286. CHANGE_FH = 1;
  287. { values returned by ReadItem() }
  288. ITEM_EQUAL = -2; // '=' Symbol
  289. ITEM_ERROR = -1; // error
  290. ITEM_NOTHING = 0; // *N, ;, endstreamch
  291. ITEM_UNQUOTED = 1; // unquoted item
  292. ITEM_QUOTED = 2; // quoted item
  293. { types for AllocDosObject/FreeDosObject }
  294. DOS_FILEHANDLE = 0; // PFileHandle
  295. DOS_EXALLCONTROL = 1; // PExAllControl
  296. DOS_FIB = 2; // PFileInfoBlock
  297. DOS_STDPKT = 3; // PDosPacket
  298. DOS_CLI = 4; // PCommandLineInterface
  299. DOS_RDARGS = 5; // PRDArgs
  300. { Data structures and equates used by the V1.4 DOS functions StrtoDate() and DatetoStr() }
  301. {--------- String/Date structures etc }
  302. type
  303. _PDateTime = ^_TDateTime;
  304. _TDateTime = record
  305. dat_Stamp: TDateStamp; // DOS DateStamp
  306. dat_Format, // controls appearance of dat_StrDate
  307. dat_Flags: Byte; // see BITDEF's below
  308. dat_StrDay, // day of the week string
  309. dat_StrDate, // date string
  310. dat_StrTime: STRPTR; // time string
  311. end;
  312. { You need this much room for each of the DateTime strings: }
  313. const
  314. LEN_DATSTRING = 16;
  315. { date format values }
  316. FORMAT_DOS = 0; // DOS internal format, dd-mmm-yy
  317. FORMAT_INT = 1; // International format, yy-mm-dd
  318. FORMAT_USA = 2; // US-American format, mm-dd-yy }
  319. FORMAT_CDN = 3; // Canadian format, dd-mm-yy }
  320. FORMAT_MAX = FORMAT_CDN;
  321. FORMAT_DEF = 4; { use default format, as defined by locale; if locale not
  322. available, use FORMAT_DOS instead }
  323. { flags for dat_Flags }
  324. DTB_SUBST = 0; // Substitute Today, Tomorrow, etc. if possible.
  325. DTF_SUBST = 1 shl DTB_SUBST;
  326. DTB_FUTURE = 1; // Day of the week is in future.
  327. DTF_FUTURE = 1 shl DTB_FUTURE;
  328. {**********************************************************************
  329. ************************ PATTERN MATCHING ******************************
  330. ************************************************************************
  331. * structure expected by MatchFirst, MatchNext.
  332. * Allocate this structure and initialize it as follows:
  333. *
  334. * Set ap_BreakBits to the signal bits (CDEF) that you want to take a
  335. * break on, or NULL, if you don't want to convenience the user.
  336. *
  337. * If you want to have the FULL PATH NAME of the files you found,
  338. * allocate a buffer at the END of this structure, and put the size of
  339. * it into ap_Strlen. If you don't want the full path name, make sure
  340. * you set ap_Strlen to zero. In this case, the name of the file, and stats
  341. * are available in the ap_Info, as per usual.
  342. *
  343. * Then call MatchFirst() and then afterwards, MatchNext() with this structure.
  344. * You should check the return value each time (see below) and take the
  345. * appropriate action, ultimately calling MatchEnd() when there are
  346. * no more files and you are done. You can tell when you are done by
  347. * checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.
  348. *
  349. }
  350. type
  351. // PRIVATE structure, which describes an anchor for matching functions.
  352. PAChain = ^TAChain;
  353. TAChain = record
  354. an_Child, // The next anchor
  355. an_Parent: PAChain; // The last anchor
  356. an_Lock: BPTR; // Lock of this anchor
  357. an_Info: TFileInfoBlock; // fib Discribing this anchor
  358. an_Flags: ShortInt; // se below
  359. an_String: array[0..0] of Char;
  360. end;
  361. const
  362. // an_Flags
  363. DDB_PatternBit = 0;
  364. DDB_ExaminedBit = 1;
  365. DDB_Completed = 2;
  366. DDB_AllBit = 3;
  367. DDB_Single = 4;
  368. DDF_PatternBit = 1 shl DDB_PatternBit;
  369. DDF_ExaminedBit = 1 shl DDB_ExaminedBit;
  370. DDF_Completed = 1 shl DDB_Completed;
  371. DDF_AllBit = 1 shl DDB_AllBit;
  372. DDF_Single = 1 shl DDB_Single;
  373. type
  374. PAnchorPath = ^TAnchorPath;
  375. TAnchorPath = record
  376. case SmallInt of
  377. 0 :(
  378. ap_First : PAChain;
  379. ap_Last : PAChain;
  380. );
  381. 1 :(
  382. ap_Base, // pointer to first anchor
  383. ap_Current : PAChain; // pointer to last anchor
  384. ap_BreakBits, // Signal bits that caused the function to break.
  385. ap_FoundBreak : LongInt; // Bits we broke on. Also returns ERROR_BREAK
  386. ap_Flags : Shortint; // see below
  387. ap_Reserved : Shortint; // Private
  388. ap_Strlen : SmallInt; // Size of ap_Buf (see below). This may be zero.
  389. ap_Info : TFileInfoBlock; // describes any files found by matching-functions.
  390. ap_Buf : Array[0..0] of Char; // Buffer for path name, allocated by user!!
  391. );
  392. end;
  393. const
  394. APB_DOWILD = 0; // Please check for wildcards in supplied string.
  395. APB_ITSWILD = 1; // There is actually a wildcard in the supplied string. READ-ONLY
  396. APB_DODIR = 2; { Set, if a directory is to be entered.
  397. Applications may clear this bit to prohibit the
  398. matching-functions from entering a directory. }
  399. APB_DIDDIR = 3; // Set, if directory was already searched. READ-ONLY
  400. APB_NOMEMERR = 4; // Set, if function was out of memory. READ-ONLY
  401. APB_DODOT = 5; // '.' may refer to the current directory (unix-style).
  402. APB_DirChanged = 6; // Directory changed since last call.
  403. APB_FollowHLinks = 7; // Follow hardlinks, too.
  404. APF_DOWILD = 1 shl APB_DOWILD;
  405. APF_ITSWILD = 1 shl APB_ITSWILD;
  406. APF_DODIR = 1 shl APB_DODIR;
  407. APF_DIDDIR = 1 shl APB_DIDDIR;
  408. APF_NOMEMERR = 1 shl APB_NOMEMERR;
  409. APF_DODOT = 1 shl APB_DODOT;
  410. APF_DirChanged = 1 shl APB_DirChanged;
  411. APF_FollowHLinks = 1 shl APB_FollowHLinks;
  412. { Predefined tokens for wildcards. The characters are replaced by these
  413. tokens in the tokenized string returned by the ParsePattern() function
  414. family.}
  415. P_ANY = $80; // Matches everything '#?' and '*'
  416. P_SINGLE = $81; // Any character '?'
  417. P_ORSTART = $82; // Opening parenthesis for OR'ing '('
  418. P_ORNEXT = $83; // Field delimiter for OR'ing '|'
  419. P_OREND = $84; // Closing parenthesis for OR'ing ')'
  420. P_NOT = $85; // Inversion '~'
  421. P_NOTEND = $86; // Inversion end
  422. P_NOTCLASS = $87; // Inversion class '^'
  423. P_CLASS = $88; // Class '[]'
  424. P_REPBEG = $89; // Beginning of repetition '['
  425. P_REPEND = $8A; // End of repetition ']'
  426. P_STOP = $8B; // token to force end of evaluation
  427. { Values for an_Status, NOTE: These are the actual bit numbers }
  428. COMPLEX_BIT = 1; // Parsing complex pattern
  429. EXAMINE_BIT = 2; // Searching directory
  430. { Returns from MatchFirst(), MatchNext() more see before}
  431. ERROR_BUFFER_OVERFLOW = 303; // User OR internal buffer overflow
  432. ERROR_BREAK = 304; // A break character was received
  433. ERROR_NOT_EXECUTABLE = 305; // A file has E bit cleared
  434. { hunk types }
  435. HUNK_UNIT = 999 ;
  436. HUNK_NAME = 1000;
  437. HUNK_CODE = 1001;
  438. HUNK_DATA = 1002;
  439. HUNK_BSS = 1003;
  440. HUNK_RELOC32 = 1004;
  441. HUNK_RELOC16 = 1005;
  442. HUNK_RELOC8 = 1006;
  443. HUNK_EXT = 1007;
  444. HUNK_SYMBOL = 1008;
  445. HUNK_DEBUG = 1009;
  446. HUNK_END = 1010;
  447. HUNK_HEADER = 1011;
  448. HUNK_OVERLAY = 1013;
  449. HUNK_BREAK = 1014;
  450. HUNK_DREL32 = 1015;
  451. HUNK_DREL16 = 1016;
  452. HUNK_DREL8 = 1017;
  453. HUNK_LIB = 1018;
  454. HUNK_INDEX = 1019;
  455. HUNK_RELOC32SHORT = 1020;
  456. HUNK_RELRELOC32 = 1021;
  457. HUNK_ABSRELOC16 = 1022;
  458. { hunk_ext sub-types }
  459. EXT_SYMB = 0; // symbol table
  460. EXT_DEF = 1; // relocatable definition
  461. EXT_ABS = 2; // Absolute hunks
  462. EXT_REF32 = 129; // 32bit absolute reference to symbol
  463. EXT_ABSREF32 = 129;
  464. EXT_COMMON = 130; // 32bit absolute reference to common block
  465. EXT_ABSCOMMON = 130;
  466. EXT_REF16 = 131; // 16bit relative reference to symbol
  467. EXT_RELREF16 = 131;
  468. EXT_REF8 = 132; // 8bit relative reference to symbol
  469. EXT_RELREF8 = 132;
  470. EXT_DEXT32 = 133; // 32 bit data releative reference
  471. EXT_DEXT16 = 134; // 16 bit data releative reference
  472. EXT_DEXT8 = 135; // 8 bit data releative reference
  473. EXT_RELREF32 = 136; // 32bit relative reference to symbol
  474. EXT_RELCOMMON = 137; // 32bit relative reference to common block
  475. EXT_ABSREF16 = 138;
  476. EXT_ABSREF8 = 139;
  477. { Hunk flags }
  478. HUNKB_ADVISORY = 29; // Hunk is ignored, if unknown to loader.
  479. HUNKB_CHIP = 30;
  480. HUNKB_FAST = 31;
  481. HUNKF_ADVISORY = 1 shl HUNKB_ADVISORY;
  482. HUNKF_CHIP = 1 shl HUNKB_CHIP;
  483. HUNKF_FAST = 1 shl HUNKB_FAST;
  484. type
  485. PDosInfo = ^TDosInfo;
  486. TDosInfo = record
  487. di_McName: BPTR; // Network name of this machine; currently nil
  488. di_DevInfo: BPTR; // Device List
  489. di_Devices: BPTR; // Reserved
  490. di_Handlers: BPTR; // Reserved
  491. di_NetHand: BPTR; // Reserved (actually resident segment list)
  492. di_DevLock, // do NOT access directly!
  493. di_EntryLock, // do NOT access directly!
  494. di_DeleteLock: TSignalSemaphore; // do NOT access directly!
  495. end;
  496. { All DOS processes have this structure }
  497. { Create and Device Proc returns pointer to the MsgPort in this structure }
  498. { dev_proc = Address(SmallInt(DeviceProc()) - SizeOf(Task)) }
  499. TExitProcedure = procedure(Arg: IPTR); cdecl;
  500. PProcess = ^TProcess;
  501. TProcess = record
  502. pr_Task: TTask;
  503. pr_MsgPort: TMsgPort; // This is BPTR address from DOS functions
  504. pr_Pad: SmallInt; // Remaining variables on 4 byte boundaries
  505. pr_SegList: BPTR; // Array of seg lists used by this process
  506. pr_StackSize: LongInt; // Size of process stack in bytes
  507. pr_GlobVec: APTR; // Global vector for this process (BCPL)
  508. pr_TaskNum: LongInt; // CLI task number of zero if not a CLI
  509. pr_StackBase: BPTR; // Ptr to high memory end of process stack
  510. pr_Result2: STRPTR; // Value of secondary result from last call
  511. pr_CurrentDir: BPTR; // Lock associated with current directory
  512. pr_CIS: BPTR; // Current CLI Input Stream
  513. pr_COS: BPTR; // Current CLI Output Stream
  514. pr_ConsoleTask: APTR; // Console handler process for current window
  515. pr_FileSystemTask: APTR; // File handler process for current drive
  516. pr_CLI: BPTR; // pointer to ConsoleLineInterpreter
  517. pr_ReturnAddr: APTR; // pointer to previous stack frame
  518. pr_PktWait: APTR; // Function to be called when awaiting msg
  519. pr_WindowPtr: APTR; // Window for error printing
  520. pr_HomeDir: BPTR; // Home directory of executing program
  521. pr_Flags: LongInt; // flags telling dos about process
  522. pr_ExitCode: TExitProcedure; // code to call on exit of program OR nil
  523. pr_ExitData: IPTR; // Passed as an argument to pr_ExitCode.
  524. pr_Arguments: STRPTR; // Arguments passed to the process at start
  525. pr_LocalVars: TMinList; // Local environment variables
  526. pr_ShellPrivate: ULONG; // for the use of the current shell
  527. pr_CES: BPTR; // Error stream - IF NULL, use pr_COS
  528. end;
  529. { Flags for pr_Flags. (all PRIVATE) They mainly descibe what happens if the process
  530. exits, i.e. which resources the process should clean itself. The flags
  531. are self-explaining.}
  532. const
  533. PRB_FREESEGLIST = 0;
  534. PRB_FREECURRDIR = 1;
  535. PRB_FREECLI = 2;
  536. PRB_CLOSEINPUT = 3;
  537. PRB_CLOSEOUTPUT = 4;
  538. PRB_FREEARGS = 5;
  539. PRB_CLOSEERROR = 6;
  540. PRB_SYNCHRONOUS = 7;
  541. PRB_WAITINGFORCHILD = 8; // This one is subject to change!
  542. PRB_NOTIFYONDEATH = 9;
  543. PRF_FREESEGLIST = 1 shl PRB_FREESEGLIST;
  544. PRF_FREECURRDIR = 1 shl PRB_FREECURRDIR;
  545. PRF_FREECLI = 1 shl PRB_FREECLI;
  546. PRF_CLOSEINPUT = 1 shl PRB_CLOSEINPUT;
  547. PRF_CLOSEOUTPUT = 1 shl PRB_CLOSEOUTPUT;
  548. PRF_FREEARGS = 1 shl PRB_FREEARGS;
  549. PRF_CLOSEERROR = 1 shl PRB_CLOSEERROR;
  550. PRF_SYNCHRONOUS = 1 shl PRB_SYNCHRONOUS;
  551. PRF_WAITINGFORCHILD = 1 shl PRB_WAITINGFORCHILD; // This one is subject to change!
  552. PRF_NOTIFYONDEATH = 1 shl PRB_NOTIFYONDEATH;
  553. { The long SmallInt address (BPTR) of this structure is returned by
  554. Open() and other routines that return a file. You need only worry
  555. about this struct to do async io's via PutMsg() instead of
  556. standard file system calls }
  557. type
  558. PFileHandle = ^TFileHandle;
  559. TFileHandle = record
  560. fh_Flags: ULONG; { EXEC message }
  561. fh_Port: PMsgPort; { Reply port for the packet }
  562. fh_Type: PMsgPort; { Port to do PutMsg() to Address is negative if a plain file }
  563. fh_Buf: BPTR;
  564. fh_Pos: LongInt;
  565. fh_End: LongInt;
  566. fh_Func1: LongInt;
  567. fh_Func2: LongInt;
  568. fh_Func3: LongInt;
  569. fh_Arg1: LongInt;
  570. fh_Arg2: APTR;
  571. fh_Size: ULONG; // Size of buffered io buffer
  572. fh_Buf2: BPTR; // Always the same as fh_Buf
  573. end;
  574. { This is the extension to EXEC Messages used by DOS }
  575. PDosPacket = ^TDosPacket;
  576. TDosPacket = record
  577. dp_Link : PMessage; // Pointer to a standard exec message.
  578. dp_Port : PMsgPort; // Reply-Port of that packet. Must be filled in each send.
  579. case SmallInt of
  580. 0 : (
  581. dp_Action : LongInt;
  582. dp_Status : LongInt;
  583. dp_Status2 : LongInt;
  584. dp_BufAddr : LongInt;
  585. );
  586. 1 : (
  587. dp_Type : LongInt; { See ACTION_... below and
  588. * 'R' means Read, 'W' means Write to the
  589. * file system }
  590. dp_Res1 : LongInt; { For file system calls this is the result
  591. * that would have been returned by the
  592. * function, e.g. Write ('W') returns actual
  593. * length written }
  594. dp_Res2 : LongInt; { For file system calls this is what would
  595. * have been returned by IoErr() }
  596. dp_Arg1 : LongInt;
  597. dp_Arg2 : LongInt;
  598. dp_Arg3 : LongInt;
  599. dp_Arg4 : LongInt;
  600. dp_Arg5 : LongInt;
  601. dp_Arg6 : LongInt;
  602. dp_Arg7 : LongInt;
  603. );
  604. end;
  605. const
  606. { Packet types dp_Type }
  607. ACTION_NIL = 0;
  608. ACTION_STARTUP = 0;
  609. ACTION_GET_BLOCK = 2; // OBSOLETE
  610. ACTION_SET_MAP = 4;
  611. ACTION_DIE = 5;
  612. ACTION_EVENT = 6;
  613. ACTION_CURRENT_VOLUME = 7;
  614. ACTION_LOCATE_OBJECT = 8;
  615. ACTION_RENAME_DISK = 9;
  616. ACTION_FREE_LOCK = 15;
  617. ACTION_DELETE_OBJECT = 16;
  618. ACTION_RENAME_OBJECT = 17;
  619. ACTION_MORE_CACHE = 18;
  620. ACTION_COPY_DIR = 19;
  621. ACTION_WAIT_CHAR = 20;
  622. ACTION_SET_PROTECT = 21;
  623. ACTION_CREATE_DIR = 22;
  624. ACTION_EXAMINE_OBJECT = 23;
  625. ACTION_EXAMINE_NEXT = 24;
  626. ACTION_DISK_INFO = 25;
  627. ACTION_INFO = 26;
  628. ACTION_FLUSH = 27;
  629. ACTION_SET_COMMENT = 28;
  630. ACTION_PARENT = 29;
  631. ACTION_TIMER = 30;
  632. ACTION_INHIBIT = 31;
  633. ACTION_DISK_TYPE = 32;
  634. ACTION_DISK_CHANGE = 33;
  635. ACTION_SET_DATE = 34;
  636. ACTION_SAME_LOCK = 40;
  637. ACTION_WRITE = $57; // 'W'
  638. ACTION_READ = $52; // 'R'
  639. ACTION_SCREEN_MODE = 994;
  640. ACTION_CHANGE_SIGNAL = 995;
  641. ACTION_READ_RETURN = 1001;
  642. ACTION_WRITE_RETURN = 1002;
  643. ACTION_FINDUPDATE = 1004;
  644. ACTION_FINDINPUT = 1005;
  645. ACTION_FINDOUTPUT = 1006;
  646. ACTION_END = 1007;
  647. ACTION_SEEK = 1008;
  648. ACTION_FORMAT = 1020;
  649. ACTION_MAKE_LINK = 1021;
  650. ACTION_SET_FILE_SIZE = 1022;
  651. ACTION_WRITE_PROTECT = 1023;
  652. ACTION_READ_LINK = 1024;
  653. ACTION_FH_FROM_LOCK = 1026;
  654. ACTION_IS_FILESYSTEM = 1027;
  655. ACTION_CHANGE_MODE = 1028;
  656. {}
  657. ACTION_COPY_DIR_FH = 1030;
  658. ACTION_PARENT_FH = 1031;
  659. ACTION_EXAMINE_ALL = 1033;
  660. ACTION_EXAMINE_FH = 1034;
  661. ACTION_EXAMINE_ALL_END = 1035;
  662. ACTION_SET_OWNER = 1036;
  663. ACTION_LOCK_RECORD = 2008;
  664. ACTION_FREE_RECORD = 2009;
  665. ACTION_ADD_NOTIFY = 4097;
  666. ACTION_REMOVE_NOTIFY = 4098;
  667. { Tell a file system to serialize the current volume. This is typically
  668. done by changing the creation date of the disk. This packet does not take
  669. any arguments.}
  670. ACTION_SERIALIZE_DISK = 4200;
  671. type
  672. { A Packet does not require the Message to be before it in memory, but
  673. for convenience it is useful to associate the two.
  674. Also see the function init_std_pkt for initializing this structure }
  675. PStandardPacket = ^TStandardPacket;
  676. TStandardPacket = record
  677. sp_Msg: TMessage;
  678. sp_Pkt: TDosPacket;
  679. end;
  680. const
  681. { types for initial packets to shells from run/newcli/execute/system.
  682. NOTE: AROS doesn't use startup packets. This will ONLY make a difference
  683. for shell writers...}
  684. RUN_EXECUTE = -1;
  685. RUN_SYSTEM = -2;
  686. RUN_SYSTEM_ASYNCH = -3;
  687. type
  688. { ONLY to be allocated by DOS! }
  689. PCliProcList = ^TCliProcList;
  690. TCliProcList = record
  691. cpl_Node: TMinNode;
  692. cpl_First: LongInt; { number of first entry in array }
  693. cpl_Array: array[0..0] of PMsgPort;
  694. { [0] is max number of CLI's in this entry (n)
  695. [1] is CPTR to process id of CLI cpl_First
  696. [n] is CPTR to process id of CLI cpl_First+n-1}
  697. end;
  698. { structure for the Dos resident list. Do NOT allocate these, use }
  699. { AddSegment(), and heed the warnings in the autodocs! }
  700. type
  701. PSegment = ^TSegment;
  702. TSegment = record
  703. seg_Next: BPTR; // Pointer to next segment.
  704. seg_UC: LongInt; // Usage count/type
  705. seg_Seg: BPTR; // Actual Segment
  706. seg_Name: array[0..3] of Char; // actually the first 4 chars of BSTR name }
  707. end;
  708. const
  709. CMD_SYSTEM = -1;
  710. CMD_INTERNAL = -2;
  711. CMD_DISABLED = -999;
  712. { DOS Processes started from the CLI via RUN or NEWCLI have this additional
  713. * set to data associated with them }
  714. type
  715. PCommandLineInterface = ^TCommandLineInterface;
  716. TCommandLineInterface = record
  717. cli_Result2: LongInt; // Value of IoErr from last command
  718. cli_SetName: BSTR; // Name of current directory
  719. cli_CommandDir: BPTR; // Lock associated with command directory
  720. cli_ReturnCode: LongInt; // Return code from last command
  721. cli_CommandName: BSTR; // Name of current command
  722. cli_FailLevel: LongInt; // Fail level (set by FAILAT)
  723. cli_Prompt: BSTR; // Current prompt (set by PROMPT)
  724. cli_StandardInput: BPTR; // Default (terminal) CLI input
  725. cli_CurrentInput: BPTR; // Current CLI input
  726. cli_CommandFile: BSTR; // Name of EXECUTE command file
  727. cli_Interactive: LongInt; // Boolean; True if prompts required
  728. cli_Background: LongInt; // Boolean; True if CLI created by RUN
  729. cli_CurrentOutput: BPTR; // Current CLI output
  730. cli_DefaultStack: LongInt; // Stack size to be obtained in long words
  731. cli_StandardOutput: BPTR; // Default (terminal) CLI output
  732. cli_Module: BPTR; // SegList of currently loaded command
  733. {$ifdef aros}
  734. cli_StandardError: BPTR; // Standard/Default Error file. PFileLock
  735. {$endif}
  736. end;
  737. const
  738. // CLI_DEFAULTSTACK_UNIT * cli_DefaultStack = stack in bytes
  739. CLI_DEFAULTSTACK_UNIT = SizeOf(IPTR);
  740. type
  741. {$ifdef aros}
  742. PDosListAROSExt = ^TDosListAROSExt;
  743. TDosListAROSExt = record
  744. dol_DevName: STRPTR;
  745. dol_Device: PDevice;
  746. dol_Unit: PUnit;
  747. end;
  748. {$endif}
  749. { This structure can take on different values depending on whether it is
  750. * a device, an assigned directory, or a volume. Below is the structure
  751. * reflecting volumes only. Following that is the structure representing
  752. * only devices.
  753. }
  754. { structure representing a volume }
  755. PDeviceList = ^TDeviceList;
  756. TDeviceList = record
  757. dl_Next: BPTR; // bptr to next device list
  758. dl_Type: LongInt; // see DLT below
  759. dl_Task: PMsgPort; // ptr to handler task
  760. dl_Lock: BPTR; // not for volumes
  761. dl_VolumeDate: TDateStamp; // creation date
  762. dl_LockList: BPTR; // outstanding locks
  763. dl_DiskType: LongInt; // 'DOS', etc
  764. dl_unused: BPTR;
  765. dl_Name: BSTR; // bptr to bcpl name
  766. end;
  767. { device structure (same as the DeviceNode structure in filehandler.h) }
  768. PDevInfo = ^TDevInfo;
  769. TDevInfo = record
  770. dvi_Next: BPTR;
  771. dvi_Type: LongInt;
  772. dvi_Task: PMsgPort;
  773. dvi_Lock: BPTR;
  774. dvi_Handler: BSTR;
  775. dvi_StackSize: LongInt;
  776. dvi_Priority: LongInt;
  777. dvi_Startup: BPTR;
  778. {$ifdef aros}
  779. dvi_NoAROS4: array[0..1] of BPTR;
  780. {$else}
  781. dvi_SegList: BPTR;
  782. dvi_GlobVec: BSTR;
  783. {$endif}
  784. dvi_Name: BSTR;
  785. end;
  786. const
  787. { Dos list scanning and locking modes as used in LockDosList()
  788. Specify either LDF_READ, if you want a non-exclusive lock, or LDF_WRITE,
  789. if you want an exclusive lock (i.e. if you want to modify the list).}
  790. LDB_READ = 0;
  791. LDB_WRITE = 1;
  792. // Specify which list(s) to lock.
  793. LDB_DEVICES = 2;
  794. LDB_VOLUMES = 3;
  795. LDB_ASSIGNS = 4;
  796. LDB_ENTRY = 5;
  797. LDB_DELETE = 6;
  798. LDF_READ = 1 shl LDB_READ;
  799. LDF_WRITE = 1 shl LDB_WRITE;
  800. LDF_DEVICES = 1 shl LDB_DEVICES;
  801. LDF_VOLUMES = 1 shl LDB_VOLUMES;
  802. LDF_ASSIGNS = 1 shl LDB_ASSIGNS;
  803. LDF_ENTRY = 1 shl LDB_ENTRY;
  804. LDF_DELETE = 1 shl LDB_DELETE;
  805. { actually all but LDF_ENTRY (which is used for internal locking) }
  806. LDF_ALL = (LDF_DEVICES or LDF_VOLUMES or LDF_ASSIGNS);
  807. type
  808. { Used for assigns that point to multiple directories. }
  809. PAssignList = ^TAssignList;
  810. TAssignList = record
  811. al_Next: PAssignList; // Pointer to next assign node.
  812. al_Lock: BPTR; // (struct FileLock *) Lock of on of the directories.
  813. end;
  814. { combined structure for devices, assigned directories, volumes }
  815. PDosList = ^TDosList;
  816. TDosList = record
  817. dol_Next: BPTR; { bptr to next device on list }
  818. dol_Type: LongInt; { see DLT below }
  819. dol_Task: PMsgPort; { ptr to handler task }
  820. dol_Lock: BPTR;
  821. case SmallInt of
  822. 0 :(
  823. dol_Handler : record
  824. dol_Handler: BSTR; { file name to load IF seglist is null }
  825. dol_StackSize, { stacksize to use when starting process }
  826. dol_Priority: LongInt; { task priority when starting process }
  827. dol_Startup: BPTR; { startup msg: FileSysStartupMsg for disks }
  828. dol_SegList, { already loaded code for new task }
  829. dol_GlobVec: BPTR; { BCPL global vector to use when starting }
  830. end;
  831. );
  832. 1 :(
  833. dol_Volume: record
  834. dol_VolumeDate: TDateStamp; { creation date }
  835. dol_LockList: BPTR; { outstanding locks }
  836. dol_DiskType: LongInt; { 'DOS', etc }
  837. dol_Unused: BPTR
  838. end;
  839. );
  840. 2 :(
  841. dol_assign: record
  842. dol_AssignName: STRPTR; { name for non-OR-late-binding assign }
  843. dol_List: PAssignList; { for multi-directory assigns (regular) }
  844. end;
  845. );
  846. 3 :(
  847. {$ifdef CPU64}
  848. dol_Misc: array[0..39] of Byte;
  849. {$else}
  850. dol_Misc: array[0..23] of Byte;
  851. {$endif}
  852. dol_Name: BSTR; { bptr to bcpl name }
  853. );
  854. end;
  855. const
  856. { definitions for dl_Type }
  857. DLT_DEVICE = 0;
  858. DLT_DIRECTORY = 1;
  859. DLT_VOLUME = 2;
  860. DLT_LATE = 3; // late-binding assign
  861. DLT_NONBINDING = 4; // non-binding assign
  862. DLT_PRIVATE = -1; // for internal use only
  863. { structure return by GetDeviceProc() }
  864. type
  865. PDevProc = ^TDevProc;
  866. TDevProc = record
  867. dvp_Port: PMsgPort;
  868. dvp_Lock: BPTR; // PFileLock
  869. dvp_Flags: LongInt; // see below (DVPF_*)
  870. dvp_DevNode: PDosList; // Private
  871. end;
  872. const
  873. { definitions for dvp_Flags }
  874. DVPB_UNLOCK = 0;
  875. DVPB_ASSIGN = 1;
  876. DVPF_UNLOCK = 1 shl DVPB_UNLOCK;
  877. DVPF_ASSIGN = 1 shl DVPB_ASSIGN;
  878. { Types for fib_DirEntryType. NOTE that both USERDIR and ROOT are
  879. directories, and that directory/file checks should use <0 and >=0.
  880. This is not necessarily exhaustive! Some handlers may use other
  881. values as needed, though <0 and >=0 should remain as supported as
  882. possible.}
  883. ST_ROOT = 1 ; // Root directory of filesystem
  884. ST_USERDIR = 2 ; // Normal directory
  885. ST_SOFTLINK = 3 ; // Soft link (may be a file or directory)
  886. ST_LINKDIR = 4 ; // Hard link to a directory
  887. ST_FILE = -3; // Plain file
  888. ST_LINKFILE = -4; // Hard link to a file
  889. ST_PIPEFILE = -5; // File is a pipe
  890. type
  891. { a lock structure, as returned by Lock() or DupLock() }
  892. PFileLock = ^TFileLock;
  893. TFileLock = record
  894. fl_Link: BPTR; // bcpl pointer to next lock
  895. fl_Key: IPTR; // disk block number
  896. fl_Access: LongInt; // exclusive or shared
  897. fl_Task: PMsgPort; // handler task's port
  898. fl_Volume: BPTR; // bptr to a DeviceList
  899. end;
  900. { Structure (as used in ExAll()), containing information about a file. This
  901. structure is only as long as it need to be. If is for example ED_SIZE was
  902. specified, when calling ExAll(), this structure only consists of the fields
  903. ed_Name through ed_Size. Therefore you can use the ED_ definitions below
  904. as longword offsets into this structure.}
  905. type
  906. PExAllData = ^TExAllData;
  907. TExAllData = record
  908. ed_Next: PExAllData;
  909. ed_Name: PChar; // Name of the file
  910. ed_Type: LongInt; // Type of File
  911. ed_Size, // Size of File
  912. ed_Prot, // Protection Bits
  913. { The following three fields are de facto an embedded datestamp
  914. structure (see <dos/dos.h>), which describes the last modification date.}
  915. ed_Days,
  916. ed_Mins,
  917. ed_Ticks : ULONG;
  918. ed_Comment: PChar; // The file comment
  919. ed_OwnerUID, // The owner ID
  920. ed_OwnerGID : Word; // the group-owner ID
  921. end;
  922. { Type argument for ExAll(). Each number includes the information of all
  923. lower numbers, too. If you specify for example ED_SIZE, you will get
  924. information about name, type and the size of a file. Note that all
  925. filehandlers must handle all types up to ED_OWNER. If they do not support
  926. a type, they must return ERROR_WRONG_NUMBER. Currently
  927. that means, if a value higher than ED_OWNER is specified, filehandlers
  928. must fail with this error.}
  929. const
  930. ED_NAME = 1; // Filename.
  931. ED_TYPE = 2; // Type of file.
  932. ED_SIZE = 3; // Size of file.
  933. ED_PROTECTION = 4; // Protection bits.
  934. ED_DATE = 5; // Last modification date.
  935. ED_COMMENT = 6; // Addtional file comment.
  936. ED_OWNER = 7; // Owner information.
  937. { Structure as used for controlling ExAll(). Allocate this structure by using
  938. AllocDosObject(DOS_EXALLCONTROL,...) only. All fields must be initialized
  939. to 0, before using this structure. (AllocDosObject() does that for you.)
  940. After calling ExAll() the first time, this structure is READ-ONLY. }
  941. type
  942. PExAllControl = ^TExAllControl;
  943. TExAllControl = record
  944. eac_Entries: ULONG; // number of entries returned in buffer
  945. eac_LastKey: IPTR; // Don't touch inbetween linked ExAll calls!
  946. eac_MatchString: PChar; // wildcard string for pattern match OR nil
  947. eac_MatchFunc: PHook; // optional private wildcard FUNCTION
  948. end;
  949. { The disk "environment" is a longword array that describes the
  950. * disk geometry. It is variable sized, with the length at the beginning.
  951. * Here are the constants for a standard geometry.}
  952. type
  953. PDosEnvec = ^TDosEnvec;
  954. TDosEnvec = record
  955. de_TableSize: IPTR; // Size of this structure. Must be at least 11 (DE_NUMBUFFERS).
  956. de_SizeBlock: IPTR; // Size in longwords of a block on the disk.
  957. de_SecOrg: IPTR; // Unused. Must be 0 for now.
  958. de_Surfaces: IPTR; // Number of heads/surfaces in drive.
  959. de_SectorPerBlock: IPTR; // Unused. Must be 1 for now.
  960. de_BlocksPerTrack: IPTR; // blocks per track. drive specific
  961. de_Reserved: IPTR; // DOS reserved blocks at start of partition.
  962. de_PreAlloc: IPTR; // DOS reserved blocks at end of partition
  963. de_Interleave: IPTR; // usually 0
  964. de_LowCyl: IPTR; // starting cylinder. typically 0
  965. de_HighCyl: IPTR; // max cylinder. drive specific
  966. de_NumBuffers: IPTR; // Initial # DOS of buffers.
  967. de_BufMemType: IPTR; // type of mem to allocate for buffers
  968. de_MaxTransfer: IPTR; // Max number of bytes to transfer at a time
  969. de_Mask: IPTR; // Address Mask to block out certain memory
  970. de_BootPri: LongInt; // Boot priority for autoboot
  971. de_DosType: IPTR; // ASCII (HEX) string showing filesystem type
  972. de_Baud: IPTR; // Baud rate for serial handler
  973. de_Control: IPTR; // Control SmallInt for handler/filesystem
  974. de_BootBlocks: IPTR; // Number of blocks containing boot code
  975. end;
  976. const
  977. { The following constants are longword offsets, which point into a filehandler
  978. structure (like the one above). For more information about the meaning
  979. of these constants see the structure above. }
  980. DE_TABLESIZE = 0; // standard value is 11 }
  981. DE_SIZEBLOCK = 1; // in longwords: standard value is 128 }
  982. DE_SECORG = 2; // not used; must be 0 }
  983. DE_NUMHEADS = 3; // # of heads (surfaces). drive specific }
  984. DE_SECSPERBLK = 4; // not used; must be 1 }
  985. DE_BLKSPERTRACK = 5; // blocks per track. drive specific }
  986. DE_RESERVEDBLKS = 6; // unavailable blocks at start. usually 2 }
  987. DE_PREFAC = 7; // not used; must be 0 }
  988. DE_INTERLEAVE = 8; // usually 0 }
  989. DE_LOWCYL = 9; // starting cylinder. typically 0 }
  990. DE_UPPERCYL = 10; // max cylinder. drive specific }
  991. DE_NUMBUFFERS = 11; // starting # of buffers. typically 5 }
  992. DE_MEMBUFTYPE = 12; // type of mem to allocate for buffers. }
  993. DE_BUFMEMTYPE = 12; // same as above, 1 is public, 3 is chip, 5 is fast }
  994. DE_MAXTRANSFER = 13; // Max number bytes to transfer at a time }
  995. DE_MASK = 14; // Address Mask to block out certain memory }
  996. DE_BOOTPRI = 15; // Boot priority for autoboot }
  997. DE_DOSTYPE = 16; // ASCII (HEX) string showing filesystem type;
  998. DE_BAUD = 17; // Baud rate for serial handler }
  999. DE_CONTROL = 18; // Control SmallInt for handler/filesystem }
  1000. DE_BOOTBLOCKS = 19; // Number of blocks containing boot code }
  1001. { This is the message that is passed to a file handler during startup
  1002. in the DeviceNode->dn_Startup field. It is not used in AROS DOS handlers
  1003. as they are now Device based, and the information is passed in during
  1004. OpenDevice(), however this needs to be stored for late opening
  1005. handlers.}
  1006. type
  1007. PFileSysStartupMsg = ^TFileSysStartupMsg;
  1008. TFileSysStartupMsg = record
  1009. fssm_Unit: IPTR; // exec unit number for this device
  1010. fssm_Device: BSTR; // null terminated bstring to the device name
  1011. fssm_Environ: BPTR; // ptr to environment table (see above)
  1012. fssm_Flags: ULONG; // flags for OpenDevice()
  1013. end;
  1014. { This is an unwound version of the DosList structure.
  1015. This is the version for a DOS "device" DLT_DEVICE.
  1016. It is essentially the same structure as DevInfo.
  1017. For AROS this is notably different, as filehandlers are no longer
  1018. DOS tasks (ie Processes), some of the fields here have no purpose
  1019. and are ignored. The only fields retained are the dn_Next, dn_Type,
  1020. dn_Startup and dn_Handler fields.}
  1021. PDeviceNode = ^TDeviceNode;
  1022. TDeviceNode = record
  1023. dn_Next: BPTR; { singly linked list }
  1024. dn_Type: ULONG; { always 0 for dos "devices" }
  1025. dn_Task: PMsgPort; { standard dos "task" field. If this is
  1026. * null when the node is accesses, a task
  1027. * will be started up }
  1028. dn_Lock: BPTR; { not used for devices -- leave null }
  1029. dn_Handler: BSTR; { filename to loadseg (if seglist is null) }
  1030. dn_StackSize: ULONG; { stacksize to use when starting task }
  1031. dn_Priority: LongInt; { task priority when starting task }
  1032. dn_Startup: BPTR; { startup msg: FileSysStartupMsg for disks }
  1033. dn_SegList: BPTR; { code to run to start new task (if necessary).
  1034. * if null then dn_Handler will be loaded. }
  1035. dn_GlobalVec: BPTR; { BCPL global vector to use when starting
  1036. * a task. -1 means that dn_SegList is not
  1037. * for a bcpl program, so the dos won't
  1038. * try and construct one. 0 tell the
  1039. * dos that you obey BCPL linkage rules,
  1040. * and that it should construct a global
  1041. * vector for you.
  1042. }
  1043. dn_Name: BSTR; { the node name, e.g. '\3','D','F','3' }
  1044. end;
  1045. type
  1046. { General notification structure as passed to StartNotify() and EndNotify().
  1047. After passing it to StartNotify() the first time, this structure becomes
  1048. READ-ONLY! }
  1049. PNotifyRequest = ^TNotifyRequest;
  1050. TNotifyRequest = record
  1051. nr_Name: STRPTR; // Name of the watched file.
  1052. nr_FullName: STRPTR; // Fully qualified name of the watched file. This is READ-ONLY!
  1053. nr_UserData: IPTR; // Fill in with your own data.
  1054. nr_Flags: LongWord; // Flags: (NRB_*)
  1055. // The following case specified the way to notify the application, if
  1056. nr_stuff: record // the watched file changes. IF NRF_SEND_MESSAGE is set, nr_Msg is used,
  1057. case SmallInt of // when NRF_SEND_SIGNAL is set, nr_Signal is used.
  1058. 0: ( nr_Msg: record
  1059. nr_Port: PMsgPort; // Port to send message to.
  1060. end );
  1061. 1 : ( nr_Signal: record
  1062. nr_Task: pTask; // Task to notify.
  1063. nr_SignalNum: Byte; // Signal number to set.
  1064. nr_pad: array[0..2] of Byte; // PRIVATE
  1065. end );
  1066. end;
  1067. nr_Reserved: array[0..3] of LongWord; // PRIVATE! Set to 0 for now.
  1068. nr_MsgCount: LongWord; // Number of unreplied messages.
  1069. nr_Handler: PMsgPort; // Filesystem task/device. Used by EndNotify()
  1070. end;
  1071. PNotifyMessage = ^TNotifyMessage;
  1072. TNotifyMessage = record
  1073. nm_ExecMessage: TMessage;
  1074. nm_Class: LongWord; // Class: NOTIFY_CLASS
  1075. nm_Code: Word; // Code: NOTIFY_CODE
  1076. nm_NReq: PNotifyRequest; // The notify structure that was passed to StartNotify(). Read-Only
  1077. nm_DoNotTouch, // like it says! For use by handlers
  1078. nm_DoNotTouch2 : LongWord; // dito
  1079. end;
  1080. const
  1081. // The two following flags specify by which means the watching task is to be notified.
  1082. NRB_SEND_MESSAGE = 0; // Send a message to the specified message port.
  1083. NRB_SEND_SIGNAL = 1; // Set a signal of the specified task.
  1084. NRB_WAIT_REPLY = 3; // Wait for a reply by the application before going on with watching?
  1085. NRB_NOTIFY_INITIAL = 4; // Notify if the file/directory exists when the notification request is posted
  1086. // Flag Values for TNotifyRequest.nr_Flags
  1087. NRF_SEND_MESSAGE = 1 shl NRB_SEND_MESSAGE;
  1088. NRF_SEND_SIGNAL = 1 shl NRB_SEND_SIGNAL;
  1089. NRF_WAIT_REPLY = 1 shl NRB_WAIT_REPLY;
  1090. NRF_NOTIFY_INITIAL = 1 shl NRB_NOTIFY_INITIAL;
  1091. // The following flags are for use by handlers only!
  1092. NR_HANDLER_FLAGS = $ffff0000;
  1093. NRB_MAGIC = 31;
  1094. NRF_MAGIC = 1 shl NRB_MAGIC;
  1095. // nm_Class. Do not use, yet.
  1096. NOTIFY_CLASS = $40000000;
  1097. //nm_Code. Do not use, yet.
  1098. NOTIFY_CODE = $1234;
  1099. { *********************************************************************
  1100. *
  1101. * The CSource data structure defines the input source for "ReadItem()"
  1102. * as well as the ReadArgs call. It is a publicly defined structure
  1103. * which may be used by applications which use code that follows the
  1104. * conventions defined for access.
  1105. *
  1106. * When passed to the dos.library functions, the value passed as
  1107. * struct *CSource is defined as follows:
  1108. * if ( CSource == 0) Use buffered IO "ReadChar()" as data source
  1109. * else Use CSource for input character stream
  1110. *
  1111. * The following two pseudo-code routines define how the CSource structure
  1112. * is used:
  1113. *
  1114. * long CS_ReadChar( struct CSource *CSource )
  1115. *
  1116. * if ( CSource == 0 ) return ReadChar();
  1117. * if ( CSource->CurChr >= CSource->Length ) return ENDSTREAMCHAR;
  1118. * return CSource->Buffer[ CSource->CurChr++ ];
  1119. *
  1120. *
  1121. * BOOL CS_UnReadChar( struct CSource *CSource )
  1122. *
  1123. * if ( CSource == 0 ) return UnReadChar();
  1124. * if ( CSource->CurChr <= 0 ) return FALSE;
  1125. * CSource->CurChr--;
  1126. * return TRUE;
  1127. *
  1128. *
  1129. * To initialize a struct CSource, you set CSource->CS_Buffer to
  1130. * a string which is used as the data source, and set CS_Length to
  1131. * the number of characters in the string. Normally CS_CurChr should
  1132. * be initialized to ZERO, or left as it was from prior use as
  1133. * a CSource.
  1134. *
  1135. *********************************************************************}
  1136. type
  1137. // This structure emulates an input stream by using a buffer.
  1138. PCSource = ^TCSource;
  1139. TCSource = record
  1140. CS_Buffer: PChar; // The buffer, which contains the stream. In most cases this may be nil,
  1141. // in which case the current input stream is used.
  1142. CS_Length,
  1143. CS_CurChr: LongInt;
  1144. end;
  1145. { *********************************************************************
  1146. *
  1147. * The RDArgs data structure is the input parameter passed to the DOS
  1148. * ReadArgs() function call.
  1149. *
  1150. * The RDA_Source structure is a CSource as defined above;
  1151. * if RDA_Source.CS_Buffer is non-null, RDA_Source is used as the input
  1152. * character stream to parse, else the input comes from the buffered STDIN
  1153. * calls ReadChar/UnReadChar.
  1154. *
  1155. * RDA_DAList is a private address which is used internally to track
  1156. * allocations which are freed by FreeArgs(). This MUST be initialized
  1157. * to NULL prior to the first call to ReadArgs().
  1158. *
  1159. * The RDA_Buffer and RDA_BufSiz fields allow the application to supply
  1160. * a fixed-size buffer in which to store the parsed data. This allows
  1161. * the application to pre-allocate a buffer rather than requiring buffer
  1162. * space to be allocated. If either RDA_Buffer or RDA_BufSiz is NULL,
  1163. * the application has not supplied a buffer.
  1164. *
  1165. * RDA_ExtHelp is a text string which will be displayed instead of the
  1166. * template string, if the user is prompted for input.
  1167. *
  1168. * RDA_Flags bits control how ReadArgs() works. The flag bits are
  1169. * defined below. Defaults are initialized to ZERO.
  1170. *
  1171. *********************************************************************}
  1172. { The main structure used for ReadArgs(). It contains everything needed for
  1173. ReadArgs() handling. Allocate this structure with AllocDosObject().}
  1174. PRDArgs = ^TRDArgs;
  1175. TRDArgs = record
  1176. RDA_Source: TCSource; // Select input source use this structure as source
  1177. // for parsing, otherwise use DosInput() as source.
  1178. RDA_DAList: IPTR; // PRIVATE. Must be initialized to 0
  1179. {The next two fields allow an application to supply a buffer to be parsed
  1180. to ReadArgs(). If either of these fields is 0, ReadArgs() allocates this
  1181. buffer itself.}
  1182. RDA_Buffer: PChar; // Pointer to buffer. May be nil.
  1183. RDA_BufSiz: LongInt; // Size of the supplied RDA_Buffer. May be 0.
  1184. RDA_ExtHelp: PChar; // Additional help, if user requests it, by supplying '?' as argument.
  1185. RDA_Flags: LongInt; // Flags for any required control (RDAF_?)
  1186. end;
  1187. const
  1188. RDAB_STDIN = 0; // Use Input() instead of the supplied command line.
  1189. RDAB_NOALLOC = 1; // If set, do not allocate extra string space.
  1190. RDAB_NOPROMPT = 2; // Do not prompt for input.
  1191. RDAF_STDIN = 1 shl RDAB_STDIN;
  1192. RDAF_NOALLOC = 1 shl RDAB_NOALLOC;
  1193. RDAF_NOPROMPT = 1 shl RDAB_NOPROMPT;
  1194. { Maximum number of template keywords which can be in a template passed
  1195. to ReadArgs(). IMPLEMENTOR NOTE - must be a multiple of 4.}
  1196. MAX_TEMPLATE_ITEMS = 100;
  1197. { Maximum number of MULTIARG items (/M) returned by ReadArgs(), before
  1198. an ERROR_LINE_TOO_LONG. These two limitations are due to stack
  1199. usage. Applications should allow "a lot" of stack to use ReadArgs().
  1200. This may change in the future}
  1201. MAX_MULTIARGS = 128;
  1202. const
  1203. { LockRecord() and LockRecords() locking modes. EXCLUSIVE modes mean that
  1204. nobody else is allowed to lock a specific record, which is allowed, when
  1205. locking with SHARED mode. When using IMMED modes, the timeout is ignored. }
  1206. REC_EXCLUSIVE = 0;
  1207. REC_EXCLUSIVE_IMMED = 1;
  1208. REC_SHARED = 2;
  1209. REC_SHARED_IMMED = 3;
  1210. // Structure as passed to LockRecords() and UnLockRecords().
  1211. type
  1212. PRecordLock = ^TRecordLock;
  1213. TRecordLock = record
  1214. rec_FH : BPTR; // PFileHandle The file to get the current record from.
  1215. rec_Offset, // The offset, the current record should start.
  1216. rec_Length, // The length of the current record.
  1217. rec_Mode : LongWord; // The mode od locking (REC_*).
  1218. end;
  1219. { This structure describes a local variable. The list is normally held in
  1220. Process^.pr_LocalVars. Note that this structure is READ-ONLY!
  1221. Allocate it with SetVar(). }
  1222. type
  1223. PLocalVar = ^TLocalVar;
  1224. TLocalVar = record
  1225. lv_Node: TNode; // Standard node structure as defined in Exec
  1226. lv_Flags: Word;
  1227. lv_Value: STRPTR; // The contents of the variable.
  1228. lv_Len: LongWord; // The length of the contents.
  1229. end;
  1230. { The lv_Flags bits are available to the application. The unused
  1231. lv_Node.ln_Pri bits are reserved for system use.}
  1232. const
  1233. // bit definitions for lv_Node.ln_Type:
  1234. LV_VAR = 0; // This is a variable.
  1235. LV_ALIAS = 1; // This is an alias.
  1236. { This flag may be or'ed into lv_Node.ln_Type. It means that dos.library
  1237. should ignore this entry.}
  1238. LVB_IGNORE = 7; // ignore this entry on GetVar, etc
  1239. LVF_IGNORE = 1 shl LVB_IGNORE;
  1240. { definitions of flags passed to GetVar()/SetVar()/DeleteVar()
  1241. bit defs to be OR'ed with the type:
  1242. item will be treated as a single line of text unless BINARY_VAR is used }
  1243. GVB_GLOBAL_ONLY = 8; //The variable is not to be used locally.
  1244. GVB_LOCAL_ONLY = 9; // The variable is not to be used globally.
  1245. GVB_BINARY_VAR = 10; // The variable is a binary variable. lv_Value points to binary data.
  1246. GVB_DONT_NULL_TERM = 11; // lv_Value is not null-terminated. This is only allowed, if GVB_BINARY_VAR is also set.
  1247. GVB_SAVE_VAR = 12; // This flag tells dos to save the variable to ENVARC: too.
  1248. GVF_GLOBAL_ONLY = 1 shl GVB_GLOBAL_ONLY;
  1249. GVF_LOCAL_ONLY = 1 shl GVB_LOCAL_ONLY;
  1250. GVF_BINARY_VAR = 1 shl GVB_BINARY_VAR;
  1251. GVF_DONT_NULL_TERM = 1 shl GVB_DONT_NULL_TERM;
  1252. GVF_SAVE_VAR = 1 shl GVB_SAVE_VAR;
  1253. const
  1254. { ***************************************************************************}
  1255. { definitions for the System() call }
  1256. SYS_Dummy = (TAG_USER + 32);
  1257. SYS_Input = (SYS_Dummy + 1); // specifies the input filehandle
  1258. SYS_Output = (SYS_Dummy + 2); // specifies the output filehandle
  1259. SYS_Asynch = (SYS_Dummy + 3); // run asynch, close input/output on exit(!)
  1260. SYS_UserShell = (SYS_Dummy + 4); // send to user shell instead of boot shell
  1261. SYS_CustomShell = (SYS_Dummy + 5); // send to a specific shell (data is name)
  1262. {$ifdef aros}
  1263. SYS_Error = (SYS_Dummy + 10); // (BPTR/struct FileHandle *) Output filehandle.
  1264. SYS_ScriptInput = (SYS_Dummy + 11); // Filehandle to script to execute
  1265. SYS_Background = (SYS_Dummy + 12); // (BOOL) The shell is run as a "background shell
  1266. SYS_CliNumPtr = (SYS_Dummy + 13); // (LONG *) ti_Data to store the cli number
  1267. { This is not a Tag its a TAG Item Use this together with SYS_Input, SYS_Output and
  1268. SYS_Error, to tell SystemTagList to *duplicate* the respective caller's streams.}
  1269. SYS_DupStream = 1;
  1270. {$endif}
  1271. { Tags for CreateNewProc(). All tags, where no default is stated, the default
  1272. is inherited from the parent process. Additionally you may use tags for
  1273. AllocDosObject(DOS_CLI, ...).}
  1274. NP_Dummy = (TAG_USER + 1000);
  1275. NP_Seglist = (NP_Dummy + 1); // seglist of code to run for the process
  1276. NP_FreeSeglist = (NP_Dummy + 2); // free seglist on exit - only valid for for NP_Seglist. Default is True.
  1277. NP_Entry = (NP_Dummy + 3); // entry point to run, mutually exclusive with NP_Seglist!
  1278. NP_Input = (NP_Dummy + 4); // filehandle - default is Open("NIL:"...)
  1279. NP_Output = (NP_Dummy + 5); // filehandle - default is Open("NIL:"...)
  1280. NP_CloseInput = (NP_Dummy + 6); // close input filehandle on exit default True
  1281. NP_CloseOutput = (NP_Dummy + 7); // close output filehandle on exit default True
  1282. NP_Error = (NP_Dummy + 8); // filehandle - default is Open("NIL:"...)
  1283. NP_CloseError = (NP_Dummy + 9); // close error filehandle on exit default True
  1284. NP_CurrentDir = (NP_Dummy + 10);// lock - default is parent's current dir
  1285. NP_StackSize = (NP_Dummy + 11);// stacksize for process - default 4000
  1286. NP_Name = (NP_Dummy + 12);// name for process - default "New Process"
  1287. NP_Priority = (NP_Dummy + 13);// priority - default same as parent
  1288. NP_ConsoleTask = (NP_Dummy + 14);// consoletask - default same as parent
  1289. NP_WindowPtr = (NP_Dummy + 15);// window ptr - default is same as parent
  1290. NP_HomeDir = (NP_Dummy + 16);// home directory - default curr home dir
  1291. NP_CopyVars = (NP_Dummy + 17);// boolean to copy local vars-default True
  1292. NP_Cli = (NP_Dummy + 18);// create cli structure - default FALSE
  1293. NP_Path = (NP_Dummy + 19);// path - default is copy of parents path only valid if a cli process!
  1294. NP_CommandName = (NP_Dummy + 20);// commandname - valid only for CLI
  1295. NP_Arguments = (NP_Dummy + 21);// If this tag is used, NP_Input must not be NULL.
  1296. //The following two tags do not work, yet.
  1297. NP_NotifyOnDeath = (NP_Dummy + 22); // (BOOL) Notify parent, when process exits? (Default: FALSE)
  1298. NP_Synchronous = (NP_Dummy + 23); // (BOOL) Wait until called process returns. (Default: FALSE)
  1299. NP_ExitCode = (NP_Dummy + 24);// (APTR) Code that is to be called, when process exits. (Default: NULL)
  1300. NP_ExitData = (NP_Dummy + 25);// (APTR) Optional data for NP_ExitCode. (Default: NULL)
  1301. {$ifdef aros}
  1302. NP_UserData = (NP_Dummy + 26); //(IPTR) User dependant data. Do with it, what you want to. (Default: NULL)
  1303. {$endif}
  1304. { Tags for AllocDosObject }
  1305. ADO_Dummy = (TAG_USER + 2000);
  1306. ADO_FH_Mode = (ADO_Dummy + 1); // Sets up FH to the specified mode.
  1307. ADO_DirLen = (ADO_Dummy + 2); // size in bytes for current dir buffer
  1308. ADO_CommNameLen = (ADO_Dummy + 3); // size in bytes for command name buffer
  1309. ADO_CommFileLen = (ADO_Dummy + 4); // size in bytes for command file buffer
  1310. ADO_PromptLen = (ADO_Dummy + 5); // size in bytes for the prompt buffer
  1311. type
  1312. PRootNode = ^TRootNode;
  1313. TRootNode = record
  1314. rn_TaskArray: BPTR; // Pointer to the SegList for CLIs.
  1315. rn_ConsoleSegment: BPTR; // SegList for the CLI
  1316. rn_Time: TDateStamp; // Current time
  1317. rn_RestartSeg: APTR; // SegList for the disk validator process
  1318. rn_Info: BPTR; // Pointer ot the Info structure
  1319. rn_FileHandlerSegment: BPTR; // segment for a file handler
  1320. rn_CliList: TMinList; // List of all CLI processe (CliProcList)
  1321. rn_BootProc: PMsgPort; // private ptr to msgport of boot fs
  1322. rn_ShellSegment: BPTR; // seglist for Shell (for NewShell)
  1323. rn_Flags: LongInt; // dos flags
  1324. rn_RootLock: TSignalSemaphore; // RootNode arbitrator
  1325. end;
  1326. { Structure that is linked into the rootnode's rn_CliList. Completely
  1327. private, of course! ... and it's not compatible to AmigaOS.}
  1328. PCLIInfo = ^TCLIInfo;
  1329. TCLIInfo = record
  1330. ci_Node: TNode;
  1331. ci_Process: PProcess;
  1332. end;
  1333. { A structure for holding error messages - stored as array with error == 0
  1334. for the last entry.}
  1335. PErrorString = ^TErrorString;
  1336. TErrorString = record
  1337. estr_Nums: PLongInt;
  1338. estr_Strings: STRPTR;
  1339. end;
  1340. const
  1341. { error report types for ErrorReport() }
  1342. REPORT_STREAM = 0; // a stream
  1343. REPORT_TASK = 1; // a process - unused
  1344. REPORT_LOCK = 2; // a lock
  1345. REPORT_VOLUME = 3; // a volume node
  1346. REPORT_INSERT = 4; // please insert volume
  1347. { Special error codes for ErrorReport() }
  1348. ABORT_DISK_ERROR = 296; // Read/write error
  1349. ABORT_BUSY = 288; // You MUST replace...
  1350. type
  1351. // This is how the base of dos.library looks like.
  1352. PDosLibrary = ^TDosLibrary;
  1353. TDosLibrary = record
  1354. dl_lib: TLibrary;
  1355. dl_Root: PRootNode; // Pointer to RootNode, described below }
  1356. dl_GV: APTR; // Pointer to BCPL global vector }
  1357. dl_A2: LongInt; // Private register dump of DOS }
  1358. dl_A5: LongInt;
  1359. dl_A6: LongInt;
  1360. dl_Errors: PErrorString; // pointer to array of error msgs
  1361. dl_TimeReq: PTimeRequest; // private pointer to timer request
  1362. dl_UtilityBase : PLibrary; // private ptr to utility library
  1363. dl_IntuitionBase : PLibrary;
  1364. end;
  1365. const
  1366. RNB_WILDSTAR = 24;
  1367. RNF_WILDSTAR = 1 shl RNB_WILDSTAR;
  1368. RNB_PRIVATE1 = 1; // private for dos
  1369. RNF_PRIVATE1 = 1 shl RNB_PRIVATE1;
  1370. { ***************************************************************************}
  1371. { tags for NewLoadSeg }
  1372. { no tags are defined yet for NewLoadSeg }
  1373. {$ifdef aros}
  1374. type
  1375. // FSA_Open, Returns a new filehandle. The file may be newly created (depending on io_FileMode)
  1376. PIFS_OPEN = ^TIFS_OPEN;
  1377. TIFS_OPEN = record
  1378. io_FileName: STRPTR; // File to open.
  1379. io_FileMode: LongWord; // Filemode (FMF_*)
  1380. end;
  1381. // Reads from a filehandle into a buffer.
  1382. PIFS_READ_WRITE = ^TIFS_READ_WRITE;
  1383. TIFS_READ_WRITE = record
  1384. io_Buffer: PChar; // The buffer for the data to read/write.
  1385. io_Length: LongInt; // The length of the buffer. This is filled by the filesystem handler
  1386. end; // with the number of bytes actually read/written.
  1387. // This action does exactly the same as the function Seek().
  1388. PIFS_SEEK = ^TIFS_SEEK;
  1389. TIFS_SEEK = record
  1390. io_Offset: QWord; // Offset from position, specified as mode. This is filled by the
  1391. // filehandler with the old position in the file.
  1392. io_SeekMode: LongInt; // Seek mode (OFFSET_*)
  1393. end;
  1394. { Waits for a character to arrive at the filehandle. This is not used for
  1395. plain files, but for queues only. Optionally a maximum time to wait may be
  1396. specified.}
  1397. PIFS_WAIT_CHAR = ^TIFS_WAIT_CHAR;
  1398. TIFS_WAIT_CHAR = record
  1399. io_Timeout: LongInt; // Maximum time (in microseconds) to wait for a character.
  1400. io_Success: LongBool; // This is set to False by the filehandler if no character arrived in
  1401. end; // time. Otherwise it is set to True.
  1402. { Applies a new mode to a file. If you supply io_Mask with a value of 0,
  1403. no changes are made and you can just read the resulting io_FileMode.}
  1404. PIFS_FILE_MODE = ^TIFS_FILE_MODE;
  1405. TIFS_FILE_MODE = record
  1406. io_FileMode: LongWord; // The new mode to apply to the filehandle. See below for definitions.
  1407. // The filehandler fills this with the old mode bits.
  1408. io_Mask: LongWord; // This mask defines which flags are to be changed.
  1409. end;
  1410. { This action can be used to query if a filehandle is interactive, i.e. if it
  1411. is a terminal or not.}
  1412. PIFS_IS_INTERACTIVE = ^TIFS_IS_INTERACTIVE;
  1413. TIFS_IS_INTERACTIVE = record
  1414. io_IsInteractive: LongBool; // This boolean is filled by the filehandler. It is set to TRUE if the
  1415. // filehandle is interactive, otherwise it is set to FALSE.
  1416. end;
  1417. // Compares two locks for equality.
  1418. PIFS_SAME_LOCK = ^TIFS_SAME_LOCK;
  1419. TIFS_SAME_LOCK = record
  1420. io_Lock: array[0..1] of APTR; // The two locks to compare.
  1421. io_Same: LongInt; // This is set to one of LOCK_DIFFERENT or LOCK_SAME
  1422. end;
  1423. // Examines a filehandle, giving various information about it.
  1424. PIFS_EXAMINE = ^TIFS_EXAMINE;
  1425. TIFS_EXAMINE = record
  1426. io_ead: PExAllData; // ExAllData structure buffer to be filled by the filehandler.
  1427. io_Size: LongInt; // Size of the buffer.
  1428. io_Mode: LongInt; // With which kind of information shall the buffer be filled with?
  1429. end; // see ED_* definitions for more information.
  1430. PIFS_EXAMINE_NEXT = ^TIFS_EXAMINE_NEXT;
  1431. TIFS_EXAMINE_NEXT = record
  1432. io_fib: PFileInfoBlock; // FileInfoBlock structure buffer to be used and filled by the filehandler.
  1433. end;
  1434. { Works exactly like FSA_EXAMINE with the exeption that multiple files may be
  1435. examined, i.e. the filehandle must be a directory.}
  1436. PIFS_EXAMINE_ALL = ^TIFS_EXAMINE_ALL;
  1437. TIFS_EXAMINE_ALL = record
  1438. io_ead: PExAllData;
  1439. io_eac: PExallControl;
  1440. io_Size: LongInt;
  1441. io_Mode: LongInt;
  1442. end;
  1443. { Works exactly like FSA_OPEN, but you can additionally specify protection
  1444. bits to be applied to new files.}
  1445. PIFS_OPEN_FILE = ^TIFS_OPEN_FILE;
  1446. TIFS_OPEN_FILE = record
  1447. io_Filename: STRPTR; // File to open.
  1448. io_FileMode: LongWord; // see below.
  1449. io_Protection: LongWord; // The protection bits
  1450. end;
  1451. // Creates a new directory. The filehandle of that new directory is returned.
  1452. PIFS_CREATE_DIR = ^TIFS_CREATE_DIR;
  1453. TIFS_CREATE_DIR = record
  1454. io_FileName: STRPTR; // Name of directory to create.
  1455. io_Protection: LongWord; // The protection bits.
  1456. end;
  1457. // Creates a hard link (i.e. gives one file/directory a second name).
  1458. PIFS_CREATE_HARDLINK = ^TIFS_CREATE_HARDLINK;
  1459. TIFS_CREATE_HARDLINK = record
  1460. io_Filename: STRPTR; // The filename of the link to create.
  1461. io_OldFile: APTR; // Filehandle of the file to link to.
  1462. end;
  1463. // Creates a soft link (i.e. a file is created that references another by its name).
  1464. PIFS_CREATE_SOFTLINK = ^TIFS_CREATE_SOFTLINK;
  1465. TIFS_CREATE_SOFTLINK = record
  1466. io_Filename: STRPTR; // The filename of the link to create.
  1467. io_Reference: STRPTR; // The name of the file to link to.
  1468. end;
  1469. // Renames a file. To the old and the new name, the current directory is applied to.
  1470. PIFS_RENAME = ^TIFS_RENAME;
  1471. TIFS_RENAME = record
  1472. io_Filename: STRPTR; // The old filename.
  1473. io_NewName: STRPTR; // The new filename.
  1474. end;
  1475. // Resolves the full path name of the file a softlink filehandle points to.
  1476. PIFS_READ_SOFTLINK = ^TIFS_READ_SOFTLINK;
  1477. TIFS_READ_SOFTLINK = record
  1478. io_Filename: STRPTR; // file name which returned ERROR_IS_SOFT_LINK
  1479. io_Buffer: STRPTR; { The buffer to fill with the pathname. If this buffer is too small, the
  1480. filesystem handler is supposed to return ERROR_LINE_TOO_LONG.}
  1481. io_Size: LongWord; // The size of the buffer pointed to by io_Buffer.
  1482. end;
  1483. // Deletes an object on the volume.
  1484. PIFS_DELETE_OBJECT = ^TIFS_DELETE_OBJECT;
  1485. TIFS_DELETE_OBJECT = record
  1486. io_Filename: STRPTR; // The name of the file to delete.
  1487. end;
  1488. // Sets a filecomment for a file.
  1489. PIFS_SET_COMMENT = ^TIFS_SET_COMMENT;
  1490. TIFS_SET_COMMENT = record
  1491. io_Filename: STRPTR; // The name of the file to be commented.
  1492. io_Comment: STRPTR; // The new filecomment. May be nil, in which case the current filecomment is deleted.
  1493. end;
  1494. // Sets the protection bits of a file.
  1495. PIFS_SET_PROTECT = ^TIFS_SET_PROTECT;
  1496. TIFS_SET_PROTECT = record
  1497. io_Filename: STRPTR; // The file to change.
  1498. io_Protection: LongWord; // The new protection bits.
  1499. end;
  1500. // Sets the ownership of a file.
  1501. PIFS_SET_OWNER = ^TIFS_SET_OWNER;
  1502. TIFS_SET_OWNER = record
  1503. io_Filename: STRPTR; // The file to change.
  1504. io_UID: Word; // The new owner.
  1505. io_GID: Word; // The new group owner.
  1506. end;
  1507. { Sets the last modification date/time of the filename given as first
  1508. argument. The date/time is given as standard DateStamp structure}
  1509. PIFS_SET_DATE = ^TIFS_SET_DATE;
  1510. TIFS_SET_DATE = record
  1511. io_Filename: STRPTR; // The file to change
  1512. io_Date: TDateStamp; // The new date
  1513. end;
  1514. // Check if a filesystem is in fact a FILEsystem, i.e. can contain different files.
  1515. PIFS_IS_FILESYSTEM = ^TIFS_IS_FILESYSTEM;
  1516. TIFS_IS_FILESYSTEM = record
  1517. io_IsFilesystem: LongBool; // This is set to True by the filesystem handler if it is a filesystem
  1518. end; // and set to False if it is not.
  1519. { Changes the number of buffers for the filesystem. The current number of
  1520. buffers is returned. The size of the buffers is filesystem-dependent.}
  1521. PIFS_MORE_CACHE = ^TIFS_MORE_CACHE;
  1522. TIFS_MORE_CACHE = record
  1523. io_NumBuffers: LongInt; // Number of buffers to add. May be negative to reduce number of buffers.
  1524. end; // This is to be set to the current number of buffers on success.
  1525. // Formats a volume, i.e. erases all data on it.
  1526. PIFS_FORMAT = ^TIFS_FORMAT;
  1527. TIFS_FORMAT = record
  1528. io_VolumeName: STRPTR; // New name for the volume.
  1529. io_DosType: LongWord; // New type for the volume. Filesystem specific.
  1530. end;
  1531. { Resets/reads the mount-mode of the volume passed in as io_Unit. The first
  1532. and second arguments work exactly like FSA_FILE_MODE, but the third
  1533. argument can contain a password, if MMF_LOCKED is set.}
  1534. PIFS_MOUNT_MODE = ^TIFS_MOUNT_MODE;
  1535. TIFS_MOUNT_MODE = record
  1536. io_MountMode: LongWord; // The new mode to apply to the volume. See below for definitions.
  1537. // The filehandler fills this with the old mode bits.
  1538. io_Mask: LongWord; // This mask defines which flags are to be changed.
  1539. io_Password: STRPTR; // A password, which is needed if MMF_LOCKED is set.
  1540. end;
  1541. PIFS_INHIBIT = ^TIFS_INHIBIT;
  1542. TIFS_INHIBIT = record
  1543. io_Inhibit: LongBool;
  1544. end;
  1545. PIFS_NOTIFY = ^TIFS_NOTIFY;
  1546. TIFS_NOTIFY = record
  1547. io_FileName: STRPTR; // Needed for synchronous operation
  1548. io_NotificationRequest: PNotifyRequest;
  1549. end;
  1550. PIFS_INFO = ^TIFS_INFO;
  1551. TIFS_INFO = record
  1552. io_Info: PInfoData;
  1553. end;
  1554. PIFS_CHANGE_SIGNAL = ^TIFS_CHANGE_SIGNAL;
  1555. TIFS_CHANGE_SIGNAL = record
  1556. io_Task: PTask;
  1557. end;
  1558. PIFS_RECORD = ^TIFS_RECORD;
  1559. TIFS_RECORD = record
  1560. io_Offset: QWord;
  1561. io_Size: LongInt;
  1562. io_RecordMode: LongWord;
  1563. io_Timeout: LongWord;
  1564. end;
  1565. PIFS_PARENT_DIR = ^TIFS_PARENT_DIR;
  1566. TIFS_PARENT_DIR = record
  1567. io_DirName: PChar; // This will contain the return value of the parent directory, or
  1568. end; // nil if we are at the root directory already
  1569. // Allows us to change a console between raw and cooked mode.
  1570. PIFS_CONSOLE_MODE = ^TIFS_CONSOLE_MODE;
  1571. TIFS_CONSOLE_MODE = record
  1572. io_ConsoleMode: LongInt; // (FCM_*)
  1573. end;
  1574. PIFS_RELABEL = ^TIFS_RELABEL;
  1575. TIFS_RELABEL = record
  1576. io_NewName: STRPTR;
  1577. io_Result: LongBool;
  1578. end;
  1579. { FSA_PIPE: create a pair of handles connected to each other
  1580. This opens a "file" (which will usually be a pipe device) and returns two
  1581. handles such that writing data to the writer will result in that data
  1582. appearing on the reader. Both handles must be closed for the underlying
  1583. file to be closed. If a NULL/empty path is supplied, an unnamed pipe will
  1584. be created, which will be destroyed once both handles are closed.
  1585. The read handle is returned in io_Unit.}
  1586. PIFS_PIPE = ^TIFS_PIPE;
  1587. TIFS_PIPE = record
  1588. io_FileName: STRPTR;
  1589. io_Writer: PUnit;
  1590. end;
  1591. const
  1592. FSA_OPEN = 1; // Returns a new filehandle. The file may be newly created (depending on io_FileMode) TIFS_OPEN
  1593. FAS_CLOSE = 2; // Closes an opened filehandle. Takes no extra arguments.
  1594. FSA_READ = 3; // Reads from a filehandle into a buffer. TIFS_READ_WRITE
  1595. FSA_WRITE = 4; // Writes the contents of a buffer into a filehandle. Uses TIFS_READ_WRITE.
  1596. FSA_SEEK = 5; // This action does exactly the same as the function Seek(). TIFS_SEEK
  1597. FSA_SET_FILE_SIZE = 6; // Sets the size of filehandle. Uses TIFS_SEEK (see above) as argument array.
  1598. FSA_WAIT_CHAR = 7; // Waits for a character to arrive at the filehandle. (TIFS_WAIT_CHAR)
  1599. FSA_FILE_MODE = 8; // Applies a new mode to a file.
  1600. FSA_IS_INTERACTIVE = 9; // Query if a filehandle is interactive
  1601. FSA_SAME_LOCK = 10; // Compares two locks for equality.
  1602. FSA_EXAMINE = 11; // Examines a filehandle, giving various information about it.
  1603. FSA_EXAMINE_NEXT = 12; // Examine next file
  1604. FSA_EXAMINE_ALL = 13; // Works exactly like FSA_EXAMINE on directories
  1605. FSA_EXAMINE_ALL_END = 14; { This has to be called if FSA_EXAMINE_ALL is stopped before all examined
  1606. files were returned. It takes no arguments except the filehandle in io_Unit.}
  1607. FSA_OPEN_FILE = 15; // Works exactly like FSA_OPEN but with special protection bits
  1608. FSA_CREATE_DIR = 16; // Creates a new directory. The filehandle of that new directory is returned.
  1609. FSA_CREATE_HARDLINK = 17; // Creates a hard link (i.e. gives one file/directory a second name).
  1610. FSA_CREATE_SOFTLINK = 18; // Creates a soft link (i.e. a file is created that references another by its name).
  1611. FSA_RENAME = 19; // Renames a file. To the old and the new name, the current directory is applied to.
  1612. FSA_READ_SOFTLINK = 20; // Resolves the full path name of the file a softlink filehandle points to.
  1613. FSA_DELETE_OBJECT = 21; // Deletes an object on the volume.
  1614. FSA_SET_COMMENT = 22; // Sets a filecomment for a file.
  1615. FSA_SET_PROTECT = 23; // Sets the ownership of a file.
  1616. FSA_SET_OWNER = 24; // Sets the last modification date/time
  1617. FSA_SET_DATE = 25; // Set file date
  1618. FSA_IS_FILESYSTEM = 26; // Check if a filesystem is in fact a FILEsystem, i.e. can contain different files.
  1619. FSA_MORE_CACHE = 27; // Changes the number of buffers for the filesystem.
  1620. FSA_FORMAT = 28; // Formats a volume, i.e. erases all data on it.
  1621. FSA_MOUNT_MODE = 29; // Resets/reads the mount-mode
  1622. //FSA_SERIALIZE_DISK = 30; // currently not supported
  1623. // FSA_FLUSH = 31; // currently not supported
  1624. FSA_INHIBIT = 32;
  1625. //FSA_WRITE_PROTECT = 33; // currently not supported
  1626. //FSA_DISK_CHANGE = 34; // currently not supported
  1627. FSA_ADD_NOTIFY = 35;
  1628. FSA_REMOVE_NOTIFY = 36;
  1629. FSA_DISK_INFO = 37;
  1630. FSA_CHANGE_SIGNAL = 38;
  1631. FSA_LOCK_RECORD = 39;
  1632. FSA_UNLOCK_RECORD = 40;
  1633. FSA_PARENT_DIR = 41;
  1634. FSA_PARENT_DIR_POST = 42;
  1635. FSA_CONSOLE_MODE = 43; // Allows us to change a console between raw and cooked mode.
  1636. FSA_RELABEL = 44;
  1637. FSA_PIPE = 45; // create a pair of handles connected to each other
  1638. // io_ConsoleMode
  1639. FCM_COOKED = 0;
  1640. FCM_RAW = 1 shl 0;
  1641. FCM_NOECHO = 1 shl 1;
  1642. { io_FileMode for FSA_OPEN, FSA_OPEN_FILE and FSA_FILE_MODE. These are flags
  1643. and may be OR'ed. Note that not all filesystems support all flags.}
  1644. FMF_LOCK = 1 shl 0; // Lock exclusively.
  1645. FMF_EXECUTE = 1 shl 1; // Open for executing.
  1646. // At least one of the following two flags must be specified. Otherwise expect strange things to happen.
  1647. FMF_WRITE = 1 shl 2; // Open for writing.
  1648. FMF_READ = 1 shl 3; // Open for reading.
  1649. FMF_CREATE = 1 shl 4; // Create file if it doesn't exist.
  1650. FMF_CLEAR = 1 shl 5; // Truncate file on open.
  1651. FMF_RAW = 1 shl 6; // Switch cooked to raw and vice versa.
  1652. FMF_NONBLOCK = 1 shl 7; // Don't block Open() in case it would and return an error in case Write()/Read() would block
  1653. FMF_APPEND = 1 shl 8; // Every write will happen always at the end of the file
  1654. FMF_AMIGADOS = (1 shl 9) or (1 shl 31); // Identifies the old AmigaDOS modes:
  1655. // - bit 9 is the first bit set in the MODE_#? modes
  1656. // - bit 31 is the first bit set in ACCESS_#? modes
  1657. FMF_MODE_OLDFILE = FMF_AMIGADOS or FMF_WRITE or FMF_READ;
  1658. FMF_MODE_READWRITE = FMF_MODE_OLDFILE or FMF_CREATE;
  1659. FMF_MODE_NEWFILE = FMF_MODE_READWRITE or FMF_LOCK or FMF_CLEAR;
  1660. // io_MountMode for FSA_MOUNT_MODE. These are flags and may be OR'ed.
  1661. MMF_READ = 1 shl 0; // Mounted for reading.
  1662. MMF_WRITE = 1 shl 1; // Mounted for writing.
  1663. MMF_READ_CACHE = 1 shl 2; // Read cache enabled.
  1664. MMF_WRITE_CACHE = 1 shl 3; // Write cache enabled.
  1665. MMF_OFFLINE = 1 shl 4; // Filesystem currently does not use the device.
  1666. MMF_LOCKED = 1 shl 5; // Mount mode is password protected.
  1667. { This structure is an extended TIORequest. It is used for
  1668. requesting actions from AROS filesystem handlers.
  1669. Note that this structure may grow in the future. Do not depend on its size!
  1670. You may use sizeof(TIOFileSys) nevertheless if you are reserving
  1671. memory for a TIOFileSys as the size of it will never shrink.}
  1672. type
  1673. PIOFileSys = ^TIOFileSys;
  1674. TIOFileSys = record
  1675. IOFS: TIORequest; // Standard I/O request.
  1676. io_DosError: LongInt; // Dos error code.
  1677. io_PacketEmulation: PDosPacket; // Private
  1678. io_DirPos: IPTR; // Handler-private key to current directory position
  1679. //* This union contains all the data needed for the various actions. */
  1680. io_Union: record
  1681. case Smallint of
  1682. 0: (io_OpenDevice : record
  1683. io_DeviceName: STRPTR; // Name of the device to open. */
  1684. io_Unit: IPTR; // Number of unit to open. */
  1685. io_Environ: ^IPTR; // Pointer to environment array.
  1686. io_DosName: STRPTR; // The name with which the
  1687. // filesystem is being mounted
  1688. // (the mount point, one might
  1689. // say)
  1690. io_DeviceNode: PDeviceNode; // The DOS entry for this
  1691. // filesystem. Packet-based
  1692. // filesystems expect to receive
  1693. // this along with the
  1694. // startup message
  1695. end;
  1696. );
  1697. 1: (io_NamedFile: record
  1698. io_Filename: STRPTR;
  1699. end;
  1700. );
  1701. 2: (
  1702. io_OPEN: TIFS_OPEN; // FSA_OPEN
  1703. io_READ_WRITE: TIFS_READ_WRITE; // FSA_READ, FSA_WRITE
  1704. io_SEEK: TIFS_SEEK; // FSA_SEEK
  1705. io_WAIT_CHAR: TIFS_WAIT_CHAR; // FSA_WAIT_CHAR
  1706. io_FILE_MODE: TIFS_FILE_MODE; // FSA_FILE_MODE */
  1707. io_IS_INTERACTIVE: TIFS_IS_INTERACTIVE; // FSA_IS_INTERACTIVE */
  1708. io_SAME_LOCK: TIFS_SAME_LOCK; // FSA_SAME_LOCK */
  1709. io_EXAMINE: TIFS_EXAMINE; // FSA_EXAMINE */
  1710. io_EXAMINE_ALL: TIFS_EXAMINE_ALL; // FSA_EXAMINE_ALL */
  1711. io_EXAMINE_NEXT: TIFS_EXAMINE_NEXT; // FSA_EXAMINE_NEXT */
  1712. io_OPEN_FILE: TIFS_OPEN_FILE; // FSA_OPEN_FILE */
  1713. io_CREATE_DIR: TIFS_CREATE_DIR; // FSA_CREATE_DIR */
  1714. io_CREATE_HARDLINK: TIFS_CREATE_HARDLINK; // FSA_CREATE_HARDLINK */
  1715. io_CREATE_SOFTLINK: TIFS_CREATE_SOFTLINK; // FSA_CREATE_SOFTLINK */
  1716. io_RENAME: TIFS_RENAME; // FSA_RENAME */
  1717. io_READ_SOFTLINK: TIFS_READ_SOFTLINK; // FSA_READ_SOFTLINK */
  1718. io_DELETE_OBJECT: TIFS_DELETE_OBJECT; // FSA_DELETE_OBJECT */
  1719. io_SET_COMMENT: TIFS_SET_COMMENT; // FSA_SET_COMMENT */
  1720. io_SET_PROTECT: TIFS_SET_PROTECT; // FSA_SET_PROTECT */
  1721. io_SET_OWNER: TIFS_SET_OWNER; // FSA_SET_OWNER */
  1722. io_SET_DATE: TIFS_SET_DATE; // FSA_SET_DATE */
  1723. io_IS_FILESYSTEM: TIFS_IS_FILESYSTEM; // FSA_IS_FILESYSTEM */
  1724. io_MORE_CACHE: TIFS_MORE_CACHE; // FSA_MORE_CACHE */
  1725. io_FORMAT: TIFS_FORMAT; // FSA_FORMAT */
  1726. io_MOUNT_MODE: TIFS_MOUNT_MODE; // FSA_MOUNT_MODE */
  1727. io_INHIBIT: TIFS_INHIBIT; // FSA_INHIBIT */
  1728. io_PARENT_DIR: TIFS_PARENT_DIR; // FSA_PARENT_DIR */
  1729. io_CONSOLE_MODE: TIFS_CONSOLE_MODE; // FSA_CONSOLE_MODE */
  1730. io_RELABEL: TIFS_RELABEL; // FSA_RELABEL */
  1731. io_NOTIFY: TIFS_NOTIFY; // FSA_ADD_NOTIFY
  1732. io_INFO: TIFS_INFO; // FSA_INFO
  1733. io_RECORD: TIFS_RECORD; // FSA_LOCK_RECORD
  1734. io_CHANGE_SIGNAL: TIFS_CHANGE_SIGNAL; // FSA_CHANGE_SIGNAL
  1735. io_PIPE: TIFS_PIPE; // FSA_PIPE
  1736. );
  1737. end;
  1738. end;
  1739. const
  1740. ERROR_BROKEN_PIPE = 400; // An attempt to write on a pipe without any reader has been made
  1741. ERROR_WOULD_BLOCK = 401; // A Read() or a Write() on a file opened with the FMF_NONBLOCK flag would block
  1742. ERROR_INTERRUPTED = 402; // The I/O file operation has been interrupted for some reason
  1743. // elf.h
  1744. type
  1745. //*
  1746. //* Define one of ELF_64BIT or ELF_32BIT in your code if you want to enforce specific
  1747. //* version of ELF structures. Otherwize it fails back to your native machine's size.
  1748. //*
  1749. {$IFDEF ELF_64BIT}
  1750. {$define elf_ptr_t}
  1751. elf_ptr_t = UQUAD;
  1752. elf_uintptr_t = UQUAD;
  1753. elf_intptr_t = QUAD;
  1754. {$ENDIF}
  1755. {$IFDEF ELF_32BIT}
  1756. {$define elf_ptr_t}
  1757. elf_ptr_t = ULONG;
  1758. elf_uintptr_t = ULONG;
  1759. elf_intptr_t = LONG;
  1760. {$ENDIF}
  1761. {$IFNDEF elf_ptr_t}
  1762. elf_ptr_t = APTR;
  1763. elf_uintptr_t = IPTR;
  1764. elf_intptr_t = SIPTR;
  1765. {$ENDIF}
  1766. Const
  1767. SHT_PROGBITS = 1;
  1768. SHT_SYMTAB = 2;
  1769. SHT_STRTAB = 3;
  1770. SHT_RELA = 4;
  1771. SHT_NOBITS = 8;
  1772. SHT_REL = 9;
  1773. SHT_SYMTAB_SHNDX = 18;
  1774. SHT_ARM_ATTRIBUTES = $70000003;
  1775. ET_REL = 1;
  1776. ET_EXEC = 2;
  1777. EM_386 = 3;
  1778. EM_68K = 4;
  1779. EM_PPC = 20;
  1780. EM_ARM = 40;
  1781. EM_X86_64 = 62; //* AMD x86-64 */
  1782. R_386_NONE = 0;
  1783. R_386_32 = 1;
  1784. R_386_PC32 = 2;
  1785. //* AMD x86-64 relocations. */
  1786. R_X86_64_NONE = 0; //* No reloc */
  1787. R_X86_64_64 = 1; //* Direct 64 bit */
  1788. R_X86_64_PC32 = 2; //* PC relative 32 bit signed */
  1789. R_X86_64_32 = 10;
  1790. R_X86_64_32S = 11;
  1791. R_68K_NONE = 0;
  1792. R_68K_32 = 1;
  1793. R_68K_16 = 2;
  1794. R_68K_8 = 3;
  1795. R_68K_PC32 = 4;
  1796. R_68K_PC16 = 5;
  1797. R_68K_PC8 = 6;
  1798. R_PPC_NONE = 0;
  1799. R_PPC_ADDR32 = 1;
  1800. R_PPC_ADDR16_LO = 4;
  1801. R_PPC_ADDR16_HA = 6;
  1802. R_PPC_REL24 = 10;
  1803. R_PPC_REL32 = 26;
  1804. R_PPC_REL16_LO = 250;
  1805. R_PPC_REL16_HA = 252;
  1806. R_ARM_NONE = 0;
  1807. R_ARM_PC24 = 1;
  1808. R_ARM_ABS32 = 2;
  1809. R_ARM_CALL = 28;
  1810. R_ARM_JUMP24 = 29;
  1811. R_ARM_TARGET1 = 38;
  1812. R_ARM_V4BX = 40;
  1813. R_ARM_TARGET2 = 41;
  1814. R_ARM_PREL31 = 42;
  1815. R_ARM_MOVW_ABS_NC = 43;
  1816. R_ARM_MOVT_ABS = 44;
  1817. R_ARM_THM_CALL = 10;
  1818. R_ARM_THM_JUMP24 = 30;
  1819. R_ARM_THM_MOVW_ABS_NC = 47;
  1820. R_ARM_THM_MOVT_ABS = 48;
  1821. STT_NOTYPE = 0;
  1822. STT_OBJECT = 1;
  1823. STT_FUNC = 2;
  1824. STT_SECTION = 3;
  1825. STT_FILE = 4;
  1826. STT_LOPROC = 13;
  1827. STT_HIPROC = 15;
  1828. STB_LOCAL = 0;
  1829. STB_GLOBAL = 1;
  1830. STB_WEAK = 2;
  1831. STB_LOOS = 10;
  1832. STB_GNU_UNIQUE = 10;
  1833. STB_HIOS = 12;
  1834. STB_LOPROC = 13;
  1835. STB_HIPROC = 15;
  1836. SHN_UNDEF = 0;
  1837. SHN_LORESERVE = $ff00;
  1838. SHN_ABS = $fff1;
  1839. SHN_COMMON = $fff2;
  1840. SHN_XINDEX = $ffff;
  1841. SHN_HIRESERVE = $ffff;
  1842. SHF_WRITE = (1 shl 0);
  1843. SHF_ALLOC = (1 shl 1);
  1844. SHF_EXECINSTR = (1 shl 2);
  1845. // ELF_ST_TYPE(i) ((i) & 0x0F)
  1846. EI_VERSION = 6;
  1847. EV_CURRENT = 1;
  1848. EI_DATA = 5;
  1849. ELFDATA2LSB = 1;
  1850. ELFDATA2MSB = 2;
  1851. EI_CLASS = 4;
  1852. ELFCLASS32 = 1;
  1853. ELFCLASS64 = 2; //* 64-bit objects */
  1854. EI_OSABI = 7;
  1855. EI_ABIVERSION = 8;
  1856. ELFOSABI_AROS = 15;
  1857. PF_X = (1 shl 0);
  1858. ATTR_VERSION_CURRENT = $41;
  1859. type
  1860. PElfHeader = ^TELFHeader;
  1861. TElfHeader = record
  1862. Ident: array [0..16-1] of Byte;
  1863. Type_: Word;
  1864. Machine: Word;
  1865. Version: LongWord;
  1866. Entry: elf_ptr_t;
  1867. PhOff: elf_uintptr_t;
  1868. ShOff: elf_uintptr_t;
  1869. Flags: LongWord;
  1870. EhSize: Word;
  1871. PhentSize: Word;
  1872. PhNum: Word;
  1873. ShentSize: Word;
  1874. ShNum: Word;
  1875. ShStrndx: Word;
  1876. end;
  1877. PSHeader = ^TSHeader;
  1878. TSHeader = record
  1879. Name: LongWord;
  1880. Type_: LongWord;
  1881. Flags: elf_uintptr_t ;
  1882. Addr: elf_ptr_t ;
  1883. Offset: elf_uintptr_t ;
  1884. Size: elf_uintptr_t ;
  1885. Link: LongWord;
  1886. Info: LongWord;
  1887. AddrAlign: elf_uintptr_t ;
  1888. EntSize: elf_uintptr_t ;
  1889. end;
  1890. {$DEFINE PT_LOAD}
  1891. {$IFDEF ELF_64BIT}
  1892. TPHeader = record
  1893. Type_: LongWord;
  1894. Flags: LongWord;
  1895. Offset: elf_uintptr_t;
  1896. VAddr: elf_ptr_t;
  1897. PAddr: elf_ptr_t;
  1898. Filesz: elf_uintptr_t;
  1899. Memsz: elf_uintptr_t;
  1900. Align: elf_uintptr_t;
  1901. end;
  1902. TSymbol = record
  1903. Name: LongWord; // Offset of the name string in the string table
  1904. Info: Byte; // What kind of symbol is this ? (global, variable, etc)
  1905. Other: Byte; // undefined
  1906. ShIndex: Word; // In which section is the symbol defined ?
  1907. Value: elf_uintptr_t ; // Varies; eg. the offset of the symbol in its hunk
  1908. Size: elf_uintptr_t ; // How much memory does the symbol occupy
  1909. end;
  1910. // 209 #define ELF_R_SYM(i) (ULONG)((i) >> 32)
  1911. // 210 #define ELF_R_TYPE(i) (ULONG)((i) & 0xffffffffULL)
  1912. // 211 #define ELF_R_INFO(sym, type) (((UQUAD)(sym) << 32) + (type))
  1913. {$ELSE ELF_64BIT}
  1914. TPHeader = record
  1915. Type_: LongWord;
  1916. Offset: LongWord;
  1917. VAddr: elf_ptr_t;
  1918. PAddr: elf_ptr_t;
  1919. Filesz: LongWord;
  1920. Memsz: LongWord;
  1921. Flags: LongWord;
  1922. Align: LongWord;
  1923. end;
  1924. TSymbol = record
  1925. Name: LongWord; // Offset of the name string in the string table
  1926. Value: elf_uintptr_t; // Varies; eg. the offset of the symbol in its hunk
  1927. Size: elf_uintptr_t; // How much memory does the symbol occupy
  1928. Info: Byte; // What kind of symbol is this ? (global, variable, etc)
  1929. Other: Byte; // undefined
  1930. ShIndex: Word; // In which section is the symbol defined?
  1931. end;
  1932. // 237 #define ELF_R_SYM(val) ((val) >> 8)
  1933. // 238 #define ELF_R_TYPE(val) ((val) & 0xff)
  1934. // 239 #define ELF_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
  1935. {$ENDIF}
  1936. // 243 #define ELF_S_BIND(val) ((val) >> 4)
  1937. // 244 #define ELF_S_TYPE(val) ((val) & 0xF)
  1938. // 245 #define ELF_S_INFO(bind, type) (((bind) << 4) + ((type) & 0xF))
  1939. TRel = record
  1940. Offset: elf_uintptr_t; // Address of the relocation relative to the section it refers to
  1941. Info: elf_uintptr_t; // Type of the relocation
  1942. end;
  1943. TRelA = record
  1944. Offset: elf_uintptr_t; // Address of the relocation relative to the section it refers to
  1945. Info: elf_uintptr_t; // Type of the relocation
  1946. Addend: elf_uintptr_t; // Constant addend used to compute value
  1947. end;
  1948. (*
  1949. 260 /* Note: the conversion below is not in line with ELF specification and is fixed in GNU binutils since 2008
  1950. 261 * See: https://sourceware.org/bugzilla/show_bug.cgi?id=5900
  1951. 262 */
  1952. 263 /* convert section header number to array index */
  1953. 264 /*#define SHINDEX(n) \
  1954. 265 ((n) < SHN_LORESERVE ? (n) : ((n) <= SHN_HIRESERVE ? 0 : (n) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))*/
  1955. 266
  1956. 267 /* convert section header array index to section number */
  1957. 268 /*#define SHNUM(i) \
  1958. 269 ((i) < SHN_LORESERVE ? (i) : (i) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))*/
  1959. 270
  1960. 271 /* ARM-specific attributes section definitions follow */
  1961. 272
  1962. 273 #define
  1963. *)
  1964. TAttrs_Section = record
  1965. Size: LongWord;
  1966. Vendor: array[0..0] of char; // NULL-terminated name
  1967. end; // Vendor-specific subsections follow
  1968. TAttrs_SubSection = packed record
  1969. Tag: Byte;
  1970. Size: LongWord;
  1971. end;
  1972. const
  1973. Tag_File = 1;
  1974. Tag_Section = 2;
  1975. Tag_Symbol = 3;
  1976. Tag_CPU_raw_name = 4;
  1977. Tag_CPU_name = 5;
  1978. Tag_CPU_arch = 6;
  1979. Tag_FP_arch = 10;
  1980. Tag_compatibility = 32;
  1981. Tag_also_compatible_with = 65;
  1982. Tag_conformance = 67;
  1983. // Tag_CPU_arch values
  1984. ELF_CPU_PREv4 = 0;
  1985. ELF_CPU_ARMv4 = 1;
  1986. ELF_CPU_ARMv4T = 2;
  1987. ELF_CPU_ARMv5T = 3;
  1988. ELF_CPU_ARMv5TE = 4;
  1989. ELF_CPU_ARMv5TEJ = 5;
  1990. ELF_CPU_ARMv6 = 6;
  1991. ELF_CPU_ARMv6KZ = 7;
  1992. ELF_CPU_ARMv6T2 = 8;
  1993. ELF_CPU_ARMv6K = 9;
  1994. ELF_CPU_ARMv7 = 10;
  1995. ELF_CPU_ARM_v6M = 11;
  1996. ELF_CPU_ARMv6SM = 12;
  1997. ELF_CPU_ARMv7EM = 13;
  1998. //* Tag_FP_arch values */
  1999. ELF_FP_None = 0;
  2000. ELF_FP_v1 = 1;
  2001. ELF_FP_v2 = 2;
  2002. ELF_FP_v3 = 3;
  2003. ELF_FP_v3_Short = 4;
  2004. ELF_FP_v4 = 5;
  2005. ELF_FP_v4_Short = 6;
  2006. {$endif}
  2007. function DOSOpen(const Name: STRPTR; AccessMode: LongInt): BPTR; syscall AOS_DOSBase 5;
  2008. function DOSClose(File_: BPTR): LongBool; syscall AOS_DOSBase 6;
  2009. function DOSRead(File_: BPTR; Buffer: APTR; Length: LongInt): LongInt; syscall AOS_DOSBase 7;
  2010. function DOSWrite(File_: BPTR; Buffer: APTR; Length: LongInt): LongInt; syscall AOS_DOSBase 8;
  2011. function DOSInput: BPTR; syscall AOS_DOSBase 9;
  2012. function DOSOutput : BPTR; syscall AOS_DOSBase 10;
  2013. function DOSSeek(File_: BPTR; Position: LongInt; Mode: LongInt): LongInt; syscall AOS_DOSBase 11;
  2014. function DOSDeleteFile(const Name: STRPTR): LongBool; syscall AOS_DOSBase 12;
  2015. function DOSRename(const OldName: STRPTR; const NewName: STRPTR): LongBool; syscall AOS_DOSBase 13;
  2016. function Lock(const Name: STRPTR; AccessMode: LongInt): BPTR; syscall AOS_DOSBase 14;
  2017. function UnLock(Lock: BPTR): LongBool; syscall AOS_DOSBase 15;
  2018. function DupLock(Lock: BPTR): BPTR; syscall AOS_DOSBase 16;
  2019. function Examine(Lock: BPTR; FileInfoBlock: PFileInfoBlock): LongBool; syscall AOS_DOSBase 17;
  2020. function ExNext(Lock: BPTR; FileInfoBlock: PFileInfoBlock): LongBool; syscall AOS_DOSBase 18;
  2021. function Info(Lock: BPTR; ParameterBlock: PInfoData): LongBool; syscall AOS_DOSBase 19;
  2022. function DOSCreateDir(const Name: STRPTR): BPTR; syscall AOS_DOSBase 20;
  2023. function CurrentDir(Lock: BPTR): BPTR; syscall AOS_DOSBase 21;
  2024. function IoErr: LongInt; syscall AOS_DOSBase 22;
  2025. function CreateProc(const Name: STRPTR; Pri: LongInt; SegList: BPTR; StackSize: LongInt): PMsgPort; syscall AOS_DOSBase 23;
  2026. procedure DOSExit(ReturnCode: LongInt); syscall AOS_DOSBase 24;
  2027. function LoadSeg(const Name: STRPTR): BPTR; syscall AOS_DOSBase 25;
  2028. procedure UnLoadSeg(Seglist: BPTR); syscall AOS_DOSBase 26;
  2029. function DeviceProc(const Name: STRPTR): PMsgPort; syscall AOS_DOSBase 29;
  2030. function SetComment(const Name: STRPTR; const Comment: STRPTR): LongBool; syscall AOS_DOSBase 30;
  2031. function SetProtection(const Name: STRPTR; Protect: LongWord): LongBool; syscall AOS_DOSBase 31;
  2032. function DateStamp(Date: PDateStamp): PDateStamp; syscall AOS_DOSBase 32;
  2033. procedure DOSDelay(TimeOut: LongWord); syscall AOS_DOSBase 33;
  2034. function WaitForChar(File_: BPTR; TimeOut: LongInt): LongBool; syscall AOS_DOSBase 34;
  2035. function ParentDir(Lock: BPTR): BPTR; syscall AOS_DOSBase 35;
  2036. function IsInteractive(File_: BPTR): LongInt; syscall AOS_DOSBase 36;
  2037. function Execute(const String_: STRPTR; Input: BPTR; Output: BPTR): LongBool; syscall AOS_DOSBase 37;
  2038. function AllocDosObject(Type_: LongWord; const Tags: PTagItem): APTR; syscall AOS_DOSBase 38;
  2039. function AllocDosObjectTagList(Type_: LongWord; const Tags: PTagItem): APTR; syscall AOS_DOSBase 38;
  2040. procedure FreeDosObject(Type_: LongWord; Ptr: APTR); syscall AOS_DOSBase 39;
  2041. function DoPkt(Port: PMsgPort; Action: LongInt; Arg1, Arg2, Arg3, Arg4, Arg5: LongInt): LongInt; syscall AOS_DOSBase 40;
  2042. procedure SendPkt(Dp: PDosPacket; Port: PMsgPort; ReplyPort: PMsgPort); syscall AOS_DOSBase 41;
  2043. function WaitPkt: PDosPacket; syscall AOS_DOSBase 42;
  2044. procedure ReplyPkt(Dp: PDosPacket; Res1: LongInt; Res2: LongInt); syscall AOS_DOSBase 43;
  2045. procedure AbortPkt(Port: PMsgPort; Pkt: PDosPacket); syscall AOS_DOSBase 44;
  2046. function LockRecord(Fh: BPTR; Offset: LongWord; Length: LongWord; Mode: LongWord; Timeout: LongWord): LongBool; syscall AOS_DOSBase 45;
  2047. function LockRecords(RecArray: PRecordLock; TimeOut: LongWord): LongBool; syscall AOS_DOSBase 46;
  2048. function UnLockRecord(Fh: BPTR; Offset: LongWord; Length: LongWord): LongBool; syscall AOS_DOSBase 47;
  2049. function UnLockRecords(RecArray: PRecordLock): LongBool; syscall AOS_DOSBase 48;
  2050. function SelectInput(Fh: BPTR): BPTR; syscall AOS_DOSBase 49;
  2051. function SelectOutput(Fh: BPTR): BPTR; syscall AOS_DOSBase 50;
  2052. function FGetC(File_: BPTR): LongInt; syscall AOS_DOSBase 51;
  2053. function FPutC(File_: BPTR; Character: LongInt): LongInt; syscall AOS_DOSBase 52;
  2054. function UnGetC(File_: BPTR; Character: LongInt): LongInt; syscall AOS_DOSBase 53;
  2055. function FRead(Fh: BPTR; Block: APTR; Blocklen: LongWord; Number: LongWord): LongInt; syscall AOS_DOSBase 54;
  2056. function FWrite(Fh: BPTR; Block: APTR; Blocklen: LongWord; NumBlocks: LongWord): LongInt; syscall AOS_DOSBase 55;
  2057. function FGets(Fh: BPTR; Buf: STRPTR; BufLen: LongWord): STRPTR; syscall AOS_DOSBase 56;
  2058. function FPuts(File_: BPTR; const String_: STRPTR): LongInt; syscall AOS_DOSBase 57;
  2059. function VFWritef(Fh: BPTR; const Fmt: STRPTR; const ArgArray: PLongInt): LongInt; syscall AOS_DOSBase 58;
  2060. function VFPrintf(Fh: BPTR; const format: STRPTR; const ArgArray: PLongInt): LongInt; syscall AOS_DOSBase 59;
  2061. function DOSFlush(File_: BPTR): LongBool; syscall AOS_DOSBase 60;
  2062. function SetVBuf(File_: BPTR; Buff: STRPTR; Type_: LongInt; Size: LongInt): LongBool; syscall AOS_DOSBase 61;
  2063. function DupLockFromFH(Lock: BPTR): BPTR; syscall AOS_DOSBase 62;
  2064. function OpenFromLock(Lock: BPTR): BPTR; syscall AOS_DOSBase 63;
  2065. function ParentOfFH(Fh: BPTR): BPTR; syscall AOS_DOSBase 64;
  2066. function ExamineFH(Fh: BPTR; Fib: PFileInfoBlock): LongBool; syscall AOS_DOSBase 65;
  2067. function SetFileDate(const Name: STRPTR; Date: PDateStamp): LongBool; syscall AOS_DOSBase 66;
  2068. function NameFromLock(Lock: BPTR; Buffer: STRPTR; Length: LongInt): LongBool; syscall AOS_DOSBase 67;
  2069. function NameFromFH(Fh: BPTR; Buffer: STRPTR; Length: LongInt): LongBool; syscall AOS_DOSBase 68;
  2070. function SplitName(const Name: STRPTR; Seperator: LongWord; Buf: STRPTR; OldPos: LongInt; Size: LongInt): LongInt; syscall AOS_DOSBase 69;
  2071. function SameLock(Lock1: BPTR; Lock2: BPTR): LongInt; syscall AOS_DOSBase 70;
  2072. function SetMode(Fh: BPTR; Mode: LongInt): LongBool; syscall AOS_DOSBase 71;
  2073. function ExAll(Lock: BPTR; Buffer: PExAllData; Size: LongInt; Data: LongInt; Control: PExAllControl): LongBool; syscall AOS_DOSBase 72;
  2074. function ReadLink(Port: PMsgPort; Lock: LongInt; const Path: STRPTR; Buffer: STRPTR; Size: LongWord): LongBool; syscall AOS_DOSBase 73;
  2075. function MakeLink(const Name: STRPTR; Dest: APTR; Soft: LongInt): LongBool; syscall AOS_DOSBase 74;
  2076. function ChangeMode(Type_: LongWord; Object_: BPTR; NewMode: LongWord): LongBool; syscall AOS_DOSBase 75;
  2077. function SetFileSize(File_: BPTR; Offset: LongInt; Mode: LongInt): LongInt; syscall AOS_DOSBase 76;
  2078. function SetIoErr(Result_: LongInt): LongInt; syscall AOS_DOSBase 77;
  2079. function Fault(Code: LongInt; Header: STRPTR; Buffer: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 78;
  2080. function PrintFault(Code: LongInt; const Header: STRPTR): LongBool; syscall AOS_DOSBase 79;
  2081. function ErrorReport(Code: LongInt; Type_: LongInt; Arg1: IPTR; Device: PMsgPort): LongBool; syscall AOS_DOSBase 80;
  2082. function DisplayError(FormstStr: STRPTR; Flags: LongWord; Args: APTR): LongInt; syscall AOS_DOSBase 81;
  2083. function Cli: PCommandLineInterface; syscall AOS_DOSBase 82;
  2084. function CreateNewProc(const Tags: PTagItem): PProcess; syscall AOS_DOSBase 83;
  2085. function CreateNewProcTagList(const Tags: PTagItem): PProcess; syscall AOS_DOSBase 83;
  2086. function RunCommand(SegList: BPTR; StackSize: LongWord; const ArgPtr: STRPTR; ArgSize: LongWord): LongInt; syscall AOS_DOSBase 84;
  2087. function GetConsoleTask: PMsgPort; syscall AOS_DOSBase 85;
  2088. function SetConsoleTask(const Handler: PMsgPort): PMsgPort; syscall AOS_DOSBase 86;
  2089. function GetFileSysTask: PMsgPort; syscall AOS_DOSBase 87;
  2090. function SetFileSysTask(const Task: PMsgPort): PMsgPort; syscall AOS_DOSBase 88;
  2091. function GetArgStr: STRPTR; syscall AOS_DOSBase 89;
  2092. function SetArgStr(const String_: STRPTR): STRPTR; syscall AOS_DOSBase 90;
  2093. function FindCliProc(Num: LongWord): PProcess; syscall AOS_DOSBase 91;
  2094. function MaxCli: LongWord; syscall AOS_DOSBase 92;
  2095. function SetCurrentDirName(const Name: STRPTR): LongBool; syscall AOS_DOSBase 93;
  2096. function GetCurrentDirName(Buf: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 94;
  2097. function SetProgramName(const Name: STRPTR): LongBool; syscall AOS_DOSBase 95;
  2098. function GetProgramName(Buf: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 96;
  2099. function SetPrompt(const Name: STRPTR): LongBool; syscall AOS_DOSBase 97;
  2100. function GetPrompt(Buf: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 98;
  2101. function SetProgramDir(Lock: BPTR): BPTR; syscall AOS_DOSBase 99;
  2102. function GetProgramDir: BPTR; syscall AOS_DOSBase 100;
  2103. function SystemTagList(const Command: STRPTR; const Tags: PTagItem): LongInt; syscall AOS_DOSBase 101;
  2104. function DOSSystem(const Command: STRPTR; const Tags: PTagItem): LongInt; syscall AOS_DOSBase 101;
  2105. function AssignLock(const Name: STRPTR; Lock: BPTR): LongBool; syscall AOS_DOSBase 102;
  2106. function AssignLate(const Name: STRPTR; const Path: STRPTR): LongBool; syscall AOS_DOSBase 103;
  2107. function AssignPath(const Name: STRPTR; const Path: STRPTR): LongBool; syscall AOS_DOSBase 104;
  2108. function AssignAdd(const Name: STRPTR; Lock: BPTR): LongBool; syscall AOS_DOSBase 105;
  2109. function RemAssignList(const Name: STRPTR; Lock: BPTR): LongBool; syscall AOS_DOSBase 106;
  2110. function GetDeviceProc(const Name: STRPTR; Dp: PDevProc): PDevProc; syscall AOS_DOSBase 107;
  2111. procedure FreeDeviceProc(Dp: PDevProc); syscall AOS_DOSBase 108;
  2112. function LockDosList(Flags: LongWord): PDosList; syscall AOS_DOSBase 109;
  2113. procedure UnLockDosList(Flags: LongWord); syscall AOS_DOSBase 110;
  2114. function AttemptLockDosList(Flags: LongWord): PDosList; syscall AOS_DOSBase 111;
  2115. function RemDosEntry(DList: PDosList): LongBool; syscall AOS_DOSBase 112;
  2116. function AddDosEntry(DList: PDosList): LongBool; syscall AOS_DOSBase 113;
  2117. function FindDosEntry(const DList: PDosList; const Name: STRPTR; Flags: LongWord): PDosList; syscall AOS_DOSBase 114;
  2118. function NextDosEntry(const DList: PDosList; Flags: LongWord): PDosList; syscall AOS_DOSBase 115;
  2119. function MakeDosEntry(const Name: STRPTR; Type_: LongInt): PDosList; syscall AOS_DOSBase 116;
  2120. procedure FreeDosEntry(DList: PDosList); syscall AOS_DOSBase 117;
  2121. function IsFileSystem(const Name: STRPTR): LongBool; syscall AOS_DOSBase 118;
  2122. function Format(const DeviceName: STRPTR; const VolumeName: STRPTR; DosType: LongWord): LongBool; syscall AOS_DOSBase 119;
  2123. function Relabel(const Drive: STRPTR; const NewName: STRPTR): LongBool; syscall AOS_DOSBase 120;
  2124. function Inhibit(const Name: STRPTR; OnOff: LongInt): LongBool; syscall AOS_DOSBase 121;
  2125. function AddBuffers(const DeviceName: STRPTR; NumbBuffers: LongInt): LongBool; syscall AOS_DOSBase 122;
  2126. function CompareDates(const Date1: PDateStamp; const Date2: PDateStamp): LongInt; syscall AOS_DOSBase 123;
  2127. function DOSDateToStr(Datetime: _PDateTime): LongBool; syscall AOS_DOSBase 124;
  2128. function DOSStrToDate(DateTime: _PDateTime): LongBool; syscall AOS_DOSBase 125;
  2129. function InternalLoadSeg(Fh: BPTR; Table: BPTR; const FuncArray: PLongInt; var Stack: LongInt): BPTR; syscall AOS_DOSBase 126;
  2130. function InternalUnLoadSeg(SegList: BPTR; FreeFunc: TProcedure): LongBool; syscall AOS_DOSBase 127;
  2131. function NewLoadSeg(const File_: STRPTR; const Tags: PTagItem): BPTR; syscall AOS_DOSBase 128;
  2132. function NewLoadSegTagList(const File_: STRPTR; const Tags: PTagItem): BPTR; syscall AOS_DOSBase 128;
  2133. function AddSegment(const Name: STRPTR; Seg: BPTR; Type_: LongInt): LongBool; syscall AOS_DOSBase 129;
  2134. function FindSegment(const Name: STRPTR; const Seg: PSegment; System: LongBool): PSegment; syscall AOS_DOSBase 130;
  2135. function RemSegment(Seg: PSegment): LongBool; syscall AOS_DOSBase 131;
  2136. function CheckSignal(Mask: LongInt): LongInt; syscall AOS_DOSBase 132;
  2137. function ReadArgs(const Template: STRPTR; Array_: PIPTR; RdArgs: PRDArgs): PRDArgs; syscall AOS_DOSBase 133;
  2138. function FindArg(const Template: STRPTR; const KeyWord: STRPTR): LongInt; syscall AOS_DOSBase 134;
  2139. function ReadItem(const Buffer: STRPTR; MaxChars: LongInt; CSource: PCSource): LongInt; syscall AOS_DOSBase 135;
  2140. function StrToLong(const String_: STRPTR; var Value: LongInt): LongInt; syscall AOS_DOSBase 136;
  2141. function MatchFirst(const Pat: STRPTR; AP: PAnchorPath): LongInt; syscall AOS_DOSBase 137;
  2142. function MatchNext(AP: PAnchorPath): LongInt; syscall AOS_DOSBase 138;
  2143. procedure MatchEnd(AP: PAnchorPath); syscall AOS_DOSBase 139;
  2144. function ParsePattern(const Source: STRPTR; Dest: STRPTR; DestLength: LongInt): LongInt; syscall AOS_DOSBase 140;
  2145. function MatchPattern(const Pat: STRPTR; Str: STRPTR): LongBool; syscall AOS_DOSBase 141;
  2146. procedure FreeArgs(Args: PRDArgs); syscall AOS_DOSBase 143;
  2147. function FilePart(const Path: STRPTR): STRPTR; syscall AOS_DOSBase 145;
  2148. function PathPart(const Path: STRPTR): STRPTR; syscall AOS_DOSBase 146;
  2149. function AddPart(DirName: STRPTR; const FileName: STRPTR; Size: LongWord): LongBool; syscall AOS_DOSBase 147;
  2150. function StartNotify(Notify: PNotifyRequest): LongBool; syscall AOS_DOSBase 148;
  2151. procedure EndNotify(Notify: PNotifyRequest); syscall AOS_DOSBase 149;
  2152. function SetVar(const Name: STRPTR; Buffer: PChar; Size: LongInt; Flags: LongInt): LongBool; syscall AOS_DOSBase 150;
  2153. function GetVar(const Name: STRPTR; Buffer: STRPTR; Size: LongInt; Flags: LongInt): LongInt; syscall AOS_DOSBase 151;
  2154. function DeleteVar(const Name: STRPTR; Flags: LongWord): LongBool; syscall AOS_DOSBase 152;
  2155. function FindVar(const Name: STRPTR; Type_: LongWord): PLocalVar; syscall AOS_DOSBase 153;
  2156. function CliInit(Dp: PDosPacket): IPTR; syscall AOS_DOSBase 154;
  2157. function CliInitNewcli(Dp: PDosPacket): IPTR; syscall AOS_DOSBase 155;
  2158. function CliInitRun(Dp: PDosPacket): IPTR; syscall AOS_DOSBase 156;
  2159. function WriteChars(const Buf: STRPTR; BufLen: LongWord): LongInt; syscall AOS_DOSBase 157;
  2160. function PutStr(const String_: STRPTR): LongInt; syscall AOS_DOSBase 158;
  2161. function VPrintf(const Format: STRPTR; var ArgArray: IPTR): LongInt; syscall AOS_DOSBase 159;
  2162. function ParsePatternNoCase(const Source: STRPTR; Dest: STRPTR; DestLen: LongInt): LongInt; syscall AOS_DOSBase 161;
  2163. function MatchPatternNoCase(const Pat: STRPTR; Str: STRPTR): LongBool; syscall AOS_DOSBase 162;
  2164. function DosGetString(StringNum: LongInt): STRPTR; syscall AOS_DOSBase 163;
  2165. function SameDevice(Lock1: BPTR; Lock2: BPTR): LongBool; syscall AOS_DOSBase 164;
  2166. procedure ExAllEnd(Lock: BPTR; Buffer: PExAllData; Size: LongInt; Data: LongInt; Control: PExAllControl); syscall AOS_DOSBase 165;
  2167. function SetOwner(const Name: STRPTR; Owner_Info: LongWord): LongBool; syscall AOS_DOSBase 166;
  2168. function ScanVars(Hook: PHook; Flags: LongWord; UserData: APTR): LongInt; syscall AOS_DOSBase 167;
  2169. {$ifdef AROS_ABIv0}
  2170. function RunHandler(DevNode: PDeviceNode; Path: PChar): PMsgPort; syscall AOS_DOSBase 27;
  2171. function DosError(): BPTR; syscall AOS_DOSBase 142;
  2172. function SelectError(Fh: BPTR): BPTR; syscall AOS_DOSBase 144;
  2173. function Pipe(const Name: STRPTR; var Reader: BPTR; var Writer: BPTR): LongInt; syscall AOS_DOSBase 160;
  2174. {$endif}
  2175. {$ifdef AROS_ABIv1}
  2176. function DosError(): BPTR;
  2177. {$endif}
  2178. function ReadChar(): LongInt;
  2179. function WriteChar(c: LongInt): LongInt;
  2180. function UnReadChar(c: LongInt): LongInt;
  2181. // Special functions for var args
  2182. function AllocDosObjectTags(const Type_: LongWord; const Tags: array of PtrUInt): APTR;
  2183. function CreateNewProcTags(const Tags: array of PtrUInt): PProcess;
  2184. function NewLoadSegTags(const File_: STRPTR; const Tags: array of PtrUInt): BPTR;
  2185. function SystemTags(const Command: STRPTR; const Tags: array of PtrUInt): LongInt;
  2186. // elf.h
  2187. function ELF_ST_TYPE(i: LongWord): LongWord;
  2188. {$ifdef ELF_64BIT}
  2189. function ELF_R_SYM(i: QWord): QWord;
  2190. function ELF_R_TYPE(i: QWord): QWord;
  2191. function ELF_R_INFO(Sym: QWord; Type_: QWord): QWord;
  2192. {$else}
  2193. function ELF_R_SYM(i: LongWord): LongWord;
  2194. function ELF_R_TYPE(i: LongWord): LongWord;
  2195. function ELF_R_INFO(Sym: LongWord; Type_: LongWord): LongWord;
  2196. {$endif}
  2197. const
  2198. BNULL = nil;
  2199. function MKBADDR(a: APTR): BPTR;
  2200. function BADDR(a: BPTR): APTR;
  2201. implementation
  2202. function ELF_ST_TYPE(i: LongWord): LongWord; inline;
  2203. begin
  2204. ELF_ST_TYPE := i and $0F;
  2205. end;
  2206. {$ifdef ELF_64BIT}
  2207. function ELF_R_SYM(i: QWord): QWord; inline;
  2208. begin
  2209. ELF_R_SYM := i shr 32;
  2210. end;
  2211. function ELF_R_TYPE(i: QWord): QWord; inline;
  2212. begin
  2213. ELF_R_TYPE := i and $ffffffff;
  2214. end;
  2215. function ELF_R_INFO(Sym: QWord; Type_: QWord): QWord; inline;
  2216. begin
  2217. ELF_R_INFO := Sym shl 32 + Type_;
  2218. end;
  2219. {$else}
  2220. function ELF_R_SYM(i: LongWord): LongWord; inline;
  2221. begin
  2222. ELF_R_SYM := i shr 8;
  2223. end;
  2224. function ELF_R_TYPE(i: LongWord): LongWord; inline;
  2225. begin
  2226. ELF_R_TYPE := i and $ff;
  2227. end;
  2228. function ELF_R_INFO(Sym: LongWord; Type_: LongWord): LongWord; inline;
  2229. begin
  2230. ELF_R_INFO := Sym shl 8 + (Type_ and $ff);
  2231. end;
  2232. {$endif}
  2233. function AllocDosObjectTags(const Type_: LongWord; const Tags: array of PtrUInt): APTR; inline;
  2234. begin
  2235. AllocDosObjectTags := AllocDosObject(Type_, @Tags);
  2236. end;
  2237. function CreateNewProcTags(const Tags: array of PtrUInt): PProcess; inline;
  2238. begin
  2239. CreateNewProcTags := CreateNewProc(@Tags);
  2240. end;
  2241. function NewLoadSegTags(const File_: STRPTR; const Tags: array of PtrUInt): BPTR; inline;
  2242. begin
  2243. NewLoadSegTags := NewLoadSeg(File_, @Tags);
  2244. end;
  2245. function SystemTags(const Command: STRPTR; const Tags: array of PtrUInt): LongInt; inline;
  2246. begin
  2247. SystemTags := SystemTagList(Command, @Tags);
  2248. end;
  2249. function MKBADDR(a: APTR): BPTR; inline;
  2250. begin
  2251. {$ifdef AROS_FAST_BPTR}
  2252. MKBADDR := a;
  2253. {$else}
  2254. MKBADDR := APTR((IPTR(a)) shr 2);
  2255. {$endif}
  2256. end;
  2257. function BADDR(a: BPTR): APTR; inline;
  2258. begin
  2259. {$ifdef AROS_FAST_BPTR}
  2260. BADDR := a;
  2261. {$else}
  2262. BADDR := BPTR((IPTR(a)) shl 2);
  2263. {$endif}
  2264. end;
  2265. function ReadChar(): LongInt; inline;
  2266. begin
  2267. ReadChar := FGetC(DosInput());
  2268. end;
  2269. function WriteChar(c: LongInt): LongInt; inline;
  2270. begin
  2271. WriteChar := FPutC(DosOutput(), c);
  2272. end;
  2273. function UnReadChar(c: LongInt): LongInt; inline;
  2274. begin
  2275. UnReadChar := UnGetC(DosInput(),c);
  2276. end;
  2277. {$ifdef AROS_ABIv1}
  2278. function DosError(): BPTR;
  2279. var
  2280. P: PProcess;
  2281. begin
  2282. DosError := nil;
  2283. P := PProcess(FindTask(nil));
  2284. if Assigned(P) then
  2285. DosError := P^.pr_CES;
  2286. if DosError = nil then
  2287. DosError := DosOutput();
  2288. end;
  2289. {$endif}
  2290. end. (* UNIT DOS *)