sysos.inc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. This file implements all the base types and limits required
  5. for a minimal POSIX compliant subset required to port the compiler
  6. to a new OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {*****************************************************************************
  14. AmigaOS structures
  15. *****************************************************************************}
  16. {$include execd.inc}
  17. {$include timerd.inc}
  18. {$include doslibd.inc}
  19. {*****************************************************************************
  20. AmigaOS functions
  21. *****************************************************************************}
  22. { exec.library functions }
  23. {$include execf.inc}
  24. {$include doslibf.inc}
  25. {$IFDEF AMIGAOS4}
  26. // Required to allow opening of utility library interface...
  27. {$include utilf.inc}
  28. {$ENDIF}
  29. {*****************************************************************************
  30. System Dependent Structures/Consts
  31. *****************************************************************************}
  32. const
  33. CTRL_C = 20; { Error code on CTRL-C press }
  34. { Used for CTRL_C checking in I/O calls }
  35. procedure checkCTRLC;
  36. begin
  37. if BreakOn then begin
  38. if (SetSignal(0,0) And SIGBREAKF_CTRL_C)<>0 then begin
  39. { Clear CTRL-C signal }
  40. SetSignal(0,SIGBREAKF_CTRL_C);
  41. Halt(CTRL_C);
  42. end;
  43. end;
  44. end;
  45. { Converts a AmigaOS dos.library error code to a TP compatible error code }
  46. { Based on 1.0.x Amiga RTL }
  47. procedure dosError2InOut(errno: LongInt);
  48. begin
  49. case errno of
  50. ERROR_BAD_NUMBER,
  51. ERROR_ACTION_NOT_KNOWN,
  52. ERROR_NOT_IMPLEMENTED : InOutRes := 1;
  53. ERROR_OBJECT_NOT_FOUND : InOutRes := 2;
  54. ERROR_DIR_NOT_FOUND : InOutRes := 3;
  55. ERROR_DISK_WRITE_PROTECTED : InOutRes := 150;
  56. ERROR_OBJECT_WRONG_TYPE : InOutRes := 151;
  57. ERROR_OBJECT_EXISTS,
  58. ERROR_DELETE_PROTECTED,
  59. ERROR_WRITE_PROTECTED,
  60. ERROR_READ_PROTECTED,
  61. ERROR_OBJECT_IN_USE,
  62. ERROR_DIRECTORY_NOT_EMPTY : InOutRes := 5;
  63. ERROR_NO_MORE_ENTRIES : InOutRes := 18;
  64. ERROR_RENAME_ACROSS_DEVICES : InOutRes := 17;
  65. ERROR_DISK_FULL : InOutRes := 101;
  66. ERROR_INVALID_RESIDENT_LIBRARY : InoutRes := 153;
  67. ERROR_BAD_HUNK : InOutRes := 153;
  68. ERROR_NOT_A_DOS_DISK : InOutRes := 157;
  69. ERROR_NO_DISK,
  70. ERROR_DISK_NOT_VALIDATED,
  71. ERROR_DEVICE_NOT_MOUNTED : InOutRes := 152;
  72. ERROR_SEEK_ERROR : InOutRes := 156;
  73. ERROR_LOCK_COLLISION,
  74. ERROR_LOCK_TIMEOUT,
  75. ERROR_UNLOCK_ERROR,
  76. ERROR_INVALID_LOCK,
  77. ERROR_INVALID_COMPONENT_NAME,
  78. ERROR_BAD_STREAM_NAME,
  79. ERROR_FILE_NOT_OBJECT : InOutRes := 6;
  80. else
  81. InOutRes := errno;
  82. end;
  83. end;
  84. { Converts an Unix-like path to Amiga-like path }
  85. function PathConv(path: string): string; alias: 'PATHCONV'; [public];
  86. var tmppos: longint;
  87. begin
  88. { check for short paths }
  89. if length(path)<=2 then begin
  90. if (path='.') or (path='./') then path:='' else
  91. if path='..' then path:='/' else
  92. if path='*' then path:='#?';
  93. end else begin
  94. { convert parent directories }
  95. tmppos:=pos('../',path);
  96. while tmppos<>0 do begin
  97. { delete .. to have / as parent dir sign }
  98. delete(path,tmppos,2);
  99. tmppos:=pos('../',path);
  100. end;
  101. { convert current directories }
  102. tmppos:=pos('./',path);
  103. while tmppos<>0 do begin
  104. { delete ./ since we doesn't need to sign current directory }
  105. delete(path,tmppos,2);
  106. tmppos:=pos('./',path);
  107. end;
  108. { convert wildstar to #? }
  109. tmppos:=pos('*',path);
  110. while tmppos<>0 do begin
  111. delete(path,tmppos,1);
  112. insert('#?',path,tmppos);
  113. tmppos:=pos('*',path);
  114. end;
  115. end;
  116. PathConv:=path;
  117. end;
  118. { Converts an Unix-like path to Amiga-like path }
  119. function PathConv(const path: rawbytestring): rawbytestring; alias: 'PATHCONVRBS'; [public];
  120. var tmppos: longint;
  121. begin
  122. { check for short paths }
  123. if length(path)<=2 then begin
  124. if (path='.') or (path='./') then PathConv:='' else
  125. if path='..' then PathConv:='/' else
  126. if path='*' then PathConv:='#?'
  127. else PathConv:=path;
  128. end else begin
  129. { convert parent directories }
  130. PathConv:=path;
  131. tmppos:=pos('../',PathConv);
  132. while tmppos<>0 do begin
  133. { delete .. to have / as parent dir sign }
  134. delete(PathConv,tmppos,2);
  135. tmppos:=pos('../',PathConv);
  136. end;
  137. { convert current directories }
  138. tmppos:=pos('./',PathConv);
  139. while tmppos<>0 do begin
  140. { delete ./ since we doesn't need to sign current directory }
  141. delete(PathConv,tmppos,2);
  142. tmppos:=pos('./',PathConv);
  143. end;
  144. { convert wildstar to #? }
  145. tmppos:=pos('*',PathConv);
  146. while tmppos<>0 do begin
  147. delete(PathConv,tmppos,1);
  148. insert('#?',PathConv,tmppos);
  149. tmppos:=pos('*',PathConv);
  150. end;
  151. end;
  152. end;