LOCKS.LST 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. Listing:
  2. 1 IMPLEMENTATION MODULE Locks;
  3. 2
  4. 3 (*
  5. 4 * ModBase
  6. 5 * Release 3.0
  7. 6 * (c) Copyright 1991 John McMonagle
  8. 7 * P.O. Box 8402
  9. 8 * Green Bay Wi 53308
  10. 9 * All Rights Reserved
  11. 10 *
  12. 11 *)
  13. 12
  14. 13 FROM StringIO IMPORT PrintMessage,ErrorMessage;
  15. 14 IMPORT FAPI,FAPI,ErrorManager,KbdInput,BigSets;
  16. ***** ^ duplicate identifier
  17. 15 IMPORT SYSTEM,ErrStrgs,M2Strings,StrEdit,StringIO;
  18. ***** ^ duplicate identifier
  19. 16 CONST
  20. 17 Nil=SYSTEM.ADDRESS(VAL(LONGINT,0));
  21. ***** ^ not supported yet
  22. ***** ^ not supported yet
  23. ***** ^ undeclared identifier
  24. ***** ^ not supported yet
  25. 18
  26. 19 VAR
  27. 20 AllRange:RangeRec;
  28. ***** ^ undeclared identifier
  29. 21
  30. 22 PROCEDURE AskError(code:CARDINAL;FileName:ARRAY OF CHAR):BOOLEAN;
  31. ***** ^ not supported yet
  32. 23 VAR
  33. 24 st:ARRAY[0..63] OF CHAR;
  34. ***** ^ not supported yet
  35. ***** ^ not supported yet
  36. 25 str:ARRAY[0..127] OF CHAR;
  37. ***** ^ not supported yet
  38. ***** ^ not supported yet
  39. 26 BEGIN
  40. 27 M2Strings.Concat('Unable to access file ',FileName,str);
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. ***** ^ not supported yet
  44. ***** ^ not supported yet
  45. ***** ^ not supported yet
  46. 28 StrEdit.Append(str,'. Error is:');
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. 29 ErrStrgs.NumToStr(code,st);
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. ***** ^ not supported yet
  55. 30 StrEdit.Append(str,st);
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. ***** ^ not supported yet
  59. ***** ^ not supported yet
  60. 31 RETURN AbortRetryIgnore(str) ;
  61. ***** ^ undeclared identifier
  62. ***** ^ not supported yet
  63. 32 END AskError;
  64. ***** ^ not supported yet
  65. 33
  66. 34 PROCEDURE Lock(FileHandle : CARDINAL; range:RangeRec) : ErrorMessage;
  67. ***** ^ undeclared identifier
  68. 35 BEGIN
  69. 36 RETURN FAPI.DOSFILELOCKS(FileHandle,Nil,SYSTEM.ADR(range));
  70. ***** ^ not supported yet
  71. ***** ^ not supported yet
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. ***** ^ not supported yet
  75. 37 END Lock;
  76. ***** ^ not supported yet
  77. 38
  78. 39 PROCEDURE LockRetry(FileHandle : CARDINAL; range:RangeRec;
  79. ***** ^ undeclared identifier
  80. 40 Retries:CARDINAL; VAR FileName:ARRAY OF CHAR) : ErrorMessage;
  81. ***** ^ not supported yet
  82. 41 VAR
  83. 42 count,
  84. 43 code:CARDINAL;
  85. 44 BEGIN
  86. 45 count:=0;
  87. 46 LOOP
  88. 47 code:=FAPI.DOSFILELOCKS(FileHandle,Nil,SYSTEM.ADR(range));
  89. ***** ^ not supported yet
  90. ***** ^ not supported yet
  91. ***** ^ not supported yet
  92. ***** ^ not supported yet
  93. ***** ^ not supported yet
  94. 48 IF (code=0) THEN RETURN code END;
  95. ***** ^ bad RETURN
  96. 49 IF (count>Retries) THEN
  97. 50 IF NOT AskError(code,FileName)
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. 51 THEN
  101. 52 RETURN code
  102. ***** ^ bad RETURN
  103. 53 END;
  104. 54 count:=0
  105. 55 END;
  106. 56 INC(count);
  107. ***** ^ undeclared identifier
  108. ***** ^ not supported yet
  109. 57 Pause(55);
  110. ***** ^ undeclared identifier
  111. ***** ^ not supported yet
  112. 58 END;
  113. 59 END LockRetry;
  114. ***** ^ not supported yet
  115. 60
  116. 61 PROCEDURE UnLock(FileHandle : CARDINAL; range:RangeRec) : ErrorMessage;
  117. ***** ^ undeclared identifier
  118. 62 BEGIN
  119. 63 RETURN FAPI.DOSFILELOCKS(FileHandle,SYSTEM.ADR(range),Nil);
  120. ***** ^ not supported yet
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 64 END UnLock;
  127. ***** ^ not supported yet
  128. 65
  129. 66 PROCEDURE LockFile(FileHandle : CARDINAL) : ErrorMessage;
  130. 67 BEGIN
  131. 68 RETURN FAPI.DOSFILELOCKS(FileHandle,Nil,SYSTEM.ADR(AllRange));
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. ***** ^ not supported yet
  135. ***** ^ not supported yet
  136. ***** ^ not supported yet
  137. 69 END LockFile;
  138. ***** ^ not supported yet
  139. 70
  140. 71 PROCEDURE LockFileRetry(FileHandle : CARDINAL;
  141. 72 Retries:CARDINAL; VAR FileName:ARRAY OF CHAR) : ErrorMessage;
  142. ***** ^ not supported yet
  143. 73 BEGIN
  144. 74 RETURN LockRetry(FileHandle,AllRange,Retries,FileName);
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. ***** ^ not supported yet
  148. 75 END LockFileRetry;
  149. ***** ^ not supported yet
  150. 76
  151. 77 PROCEDURE UnLockFile(FileHandle : CARDINAL) : ErrorMessage;
  152. 78 BEGIN
  153. 79 RETURN FAPI.DOSFILELOCKS(FileHandle,SYSTEM.ADR(AllRange),Nil);
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. ***** ^ not supported yet
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. ***** ^ not supported yet
  160. 80 END UnLockFile;
  161. ***** ^ not supported yet
  162. 81
  163. 82
  164. 83
  165. 84 (* used to pause between retries should give give control to the
  166. 85 operating system if possible *)
  167. 86 PROCEDURE Pause(Msec:CARDINAL);
  168. 87 VAR
  169. 88 code:CARDINAL;
  170. 89 mode:SYSTEM.BYTE;
  171. ***** ^ not supported yet
  172. 90 BEGIN
  173. 91 code:=FAPI.DOSSLEEP(VAL(LONGINT,Msec));
  174. ***** ^ not supported yet
  175. ***** ^ not supported yet
  176. ***** ^ undeclared identifier
  177. ***** ^ not supported yet
  178. 92 END Pause;
  179. ***** ^ not supported yet
  180. 93
  181. 94 PROCEDURE NoLocking(handle:CARDINAL):BOOLEAN;
  182. 95 VAR
  183. 96 code:CARDINAL;
  184. 97 BEGIN
  185. 98 code:=LockFile(handle);
  186. ***** ^ not supported yet
  187. ***** ^ not supported yet
  188. 99 CASE code OF
  189. 100 0:
  190. 101 code:=LockFile(handle);
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. 102 PrintMessage(UnLockFile(handle));
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. ***** ^ not supported yet
  197. 103 RETURN code#33;
  198. 104 | 1: RETURN TRUE;
  199. 105 |33:RETURN FALSE;
  200. 106 ELSE
  201. 107 PrintMessage(code);
  202. ***** ^ not supported yet
  203. ***** ^ not supported yet
  204. 108 RETURN TRUE;
  205. 109 END;
  206. 110 END NoLocking;
  207. ***** ^ not supported yet
  208. 111
  209. 112 PROCEDURE ReadRetry(FileHandle : CARDINAL; ptr : SYSTEM.ADDRESS; size,Retries :
  210. ***** ^ not supported yet
  211. 113 CARDINAL;VAR FileName:ARRAY OF CHAR) : CARDINAL;
  212. ***** ^ not supported yet
  213. 114 VAR
  214. 115 ErrorReturn,
  215. 116 BytesRead,
  216. 117 count: CARDINAL;
  217. 118 BEGIN
  218. 119 count:=0;
  219. 120 LOOP
  220. 121 ErrorReturn := FAPI.DOSREAD( FileHandle, ptr, size, SYSTEM.ADR(BytesRead) );
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. ***** ^ not supported yet
  226. ***** ^ not supported yet
  227. 122 (* Looks like something may be wrong here. *)
  228. 123 IF ErrorReturn=0 THEN
  229. 124 IF BytesRead < size THEN
  230. 125 IF BytesRead = 0 THEN
  231. 126 RETURN (StringIO.EndOfFile);
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. 127 ELSE
  235. 128 RETURN (StringIO.PartialRead);
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. 129 END;
  239. 130 END;
  240. 131 RETURN ErrorReturn;
  241. 132 END;
  242. 133 IF count>Retries THEN
  243. 134 IF NOT AskError(ErrorReturn,FileName)
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. 135 THEN
  247. 136 RETURN ErrorReturn
  248. 137 END;
  249. 138 count:=0;
  250. 139 END;
  251. 140 END;
  252. 141 END ReadRetry;
  253. ***** ^ not supported yet
  254. 142
  255. 143 PROCEDURE DefaultMessage( TheMessage: ARRAY OF CHAR ): BOOLEAN;
  256. ***** ^ not supported yet
  257. 144 VAR
  258. 145 c:CARDINAL;
  259. 146 set:KbdInput.KeyNumSet;
  260. ***** ^ not supported yet
  261. 147 BEGIN
  262. 148 BigSets.InitSet(set);
  263. ***** ^ not supported yet
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. 149 BigSets.AppendSet(set,"{'A','a','r','R','I','i'}");
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. 150 StringIO.WriteEol( StringIO.ErrorOutp, TheMessage );
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. ***** ^ not supported yet
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. 151 StringIO.WriteEol( StringIO.ErrorOutp,
  278. ***** ^ not supported yet
  279. ***** ^ not supported yet
  280. ***** ^ not supported yet
  281. ***** ^ not supported yet
  282. 152 ' Press A to Abort,R to Retry, and I to Ignore.' );
  283. ***** ^ not supported yet
  284. 153 c:= KbdInput.CAPkey( KbdInput.KeyHit(set) );
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. ***** ^ not supported yet
  288. ***** ^ not supported yet
  289. ***** ^ not supported yet
  290. 154 IF c=ORD('R') THEN
  291. ***** ^ undeclared identifier
  292. ***** ^ not supported yet
  293. 155 RETURN TRUE
  294. 156 ELSIF c=ORD('I') THEN
  295. ***** ^ undeclared identifier
  296. ***** ^ not supported yet
  297. 157 RETURN FALSE
  298. 158 ELSE
  299. 159 ErrorManager.DoTermProcs();
  300. ***** ^ not supported yet
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. 160 HALT;
  304. ***** ^ undeclared identifier
  305. 161 END
  306. 162 END DefaultMessage;
  307. ***** ^ not supported yet
  308. 163
  309. 164
  310. 165 BEGIN
  311. 166 AllRange.FileOffset:=VAL(LONGINT,0);
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. ***** ^ undeclared identifier
  315. ***** ^ not supported yet
  316. 167 AllRange.RangeLength:=MAX(LONGINT);
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. ***** ^ undeclared identifier
  320. ***** ^ not supported yet
  321. 168 AbortRetryIgnore:=DefaultMessage;
  322. ***** ^ undeclared identifier
  323. ***** ^ not supported yet
  324. 169 ExclusiveOnly:=FALSE;
  325. ***** ^ undeclared identifier
  326. 170 END Locks.
  327. ***** ^ not supported yet
  328. 156 errors