clipsruby 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clipsruby/agenda.c +1373 -0
  3. data/ext/clipsruby/agenda.h +169 -0
  4. data/ext/clipsruby/analysis.c +1142 -0
  5. data/ext/clipsruby/analysis.h +61 -0
  6. data/ext/clipsruby/argacces.c +526 -0
  7. data/ext/clipsruby/argacces.h +77 -0
  8. data/ext/clipsruby/bload.c +884 -0
  9. data/ext/clipsruby/bload.h +94 -0
  10. data/ext/clipsruby/bmathfun.c +557 -0
  11. data/ext/clipsruby/bmathfun.h +66 -0
  12. data/ext/clipsruby/bsave.c +634 -0
  13. data/ext/clipsruby/bsave.h +130 -0
  14. data/ext/clipsruby/classcom.c +976 -0
  15. data/ext/clipsruby/classcom.h +115 -0
  16. data/ext/clipsruby/classexm.c +1376 -0
  17. data/ext/clipsruby/classexm.h +97 -0
  18. data/ext/clipsruby/classfun.c +1392 -0
  19. data/ext/clipsruby/classfun.h +164 -0
  20. data/ext/clipsruby/classinf.c +1245 -0
  21. data/ext/clipsruby/classinf.h +94 -0
  22. data/ext/clipsruby/classini.c +843 -0
  23. data/ext/clipsruby/classini.h +75 -0
  24. data/ext/clipsruby/classpsr.c +957 -0
  25. data/ext/clipsruby/classpsr.h +73 -0
  26. data/ext/clipsruby/clips.h +133 -0
  27. data/ext/clipsruby/clipsruby.c +619 -0
  28. data/ext/clipsruby/clsltpsr.c +931 -0
  29. data/ext/clipsruby/clsltpsr.h +72 -0
  30. data/ext/clipsruby/commline.c +1217 -0
  31. data/ext/clipsruby/commline.h +131 -0
  32. data/ext/clipsruby/conscomp.c +1593 -0
  33. data/ext/clipsruby/conscomp.h +150 -0
  34. data/ext/clipsruby/constant.h +264 -0
  35. data/ext/clipsruby/constrct.c +1090 -0
  36. data/ext/clipsruby/constrct.h +216 -0
  37. data/ext/clipsruby/constrnt.c +554 -0
  38. data/ext/clipsruby/constrnt.h +132 -0
  39. data/ext/clipsruby/crstrtgy.c +1088 -0
  40. data/ext/clipsruby/crstrtgy.h +85 -0
  41. data/ext/clipsruby/cstrcbin.c +185 -0
  42. data/ext/clipsruby/cstrcbin.h +61 -0
  43. data/ext/clipsruby/cstrccmp.h +43 -0
  44. data/ext/clipsruby/cstrccom.c +1791 -0
  45. data/ext/clipsruby/cstrccom.h +115 -0
  46. data/ext/clipsruby/cstrcpsr.c +835 -0
  47. data/ext/clipsruby/cstrcpsr.h +97 -0
  48. data/ext/clipsruby/cstrnbin.c +282 -0
  49. data/ext/clipsruby/cstrnbin.h +55 -0
  50. data/ext/clipsruby/cstrnchk.c +826 -0
  51. data/ext/clipsruby/cstrnchk.h +91 -0
  52. data/ext/clipsruby/cstrncmp.c +238 -0
  53. data/ext/clipsruby/cstrncmp.h +57 -0
  54. data/ext/clipsruby/cstrnops.c +1176 -0
  55. data/ext/clipsruby/cstrnops.h +47 -0
  56. data/ext/clipsruby/cstrnpsr.c +1394 -0
  57. data/ext/clipsruby/cstrnpsr.h +88 -0
  58. data/ext/clipsruby/cstrnutl.c +564 -0
  59. data/ext/clipsruby/cstrnutl.h +54 -0
  60. data/ext/clipsruby/default.c +454 -0
  61. data/ext/clipsruby/default.h +57 -0
  62. data/ext/clipsruby/defins.c +971 -0
  63. data/ext/clipsruby/defins.h +127 -0
  64. data/ext/clipsruby/developr.c +677 -0
  65. data/ext/clipsruby/developr.h +69 -0
  66. data/ext/clipsruby/dffctbin.c +477 -0
  67. data/ext/clipsruby/dffctbin.h +76 -0
  68. data/ext/clipsruby/dffctbsc.c +308 -0
  69. data/ext/clipsruby/dffctbsc.h +72 -0
  70. data/ext/clipsruby/dffctcmp.c +297 -0
  71. data/ext/clipsruby/dffctcmp.h +44 -0
  72. data/ext/clipsruby/dffctdef.c +364 -0
  73. data/ext/clipsruby/dffctdef.h +104 -0
  74. data/ext/clipsruby/dffctpsr.c +179 -0
  75. data/ext/clipsruby/dffctpsr.h +49 -0
  76. data/ext/clipsruby/dffnxbin.c +520 -0
  77. data/ext/clipsruby/dffnxbin.h +67 -0
  78. data/ext/clipsruby/dffnxcmp.c +378 -0
  79. data/ext/clipsruby/dffnxcmp.h +54 -0
  80. data/ext/clipsruby/dffnxexe.c +241 -0
  81. data/ext/clipsruby/dffnxexe.h +58 -0
  82. data/ext/clipsruby/dffnxfun.c +1192 -0
  83. data/ext/clipsruby/dffnxfun.h +155 -0
  84. data/ext/clipsruby/dffnxpsr.c +514 -0
  85. data/ext/clipsruby/dffnxpsr.h +57 -0
  86. data/ext/clipsruby/dfinsbin.c +509 -0
  87. data/ext/clipsruby/dfinsbin.h +66 -0
  88. data/ext/clipsruby/dfinscmp.c +345 -0
  89. data/ext/clipsruby/dfinscmp.h +48 -0
  90. data/ext/clipsruby/drive.c +1191 -0
  91. data/ext/clipsruby/drive.h +65 -0
  92. data/ext/clipsruby/emathfun.c +1213 -0
  93. data/ext/clipsruby/emathfun.h +99 -0
  94. data/ext/clipsruby/engine.c +1568 -0
  95. data/ext/clipsruby/engine.h +203 -0
  96. data/ext/clipsruby/entities.h +276 -0
  97. data/ext/clipsruby/envrnbld.c +514 -0
  98. data/ext/clipsruby/envrnbld.h +40 -0
  99. data/ext/clipsruby/envrnmnt.c +257 -0
  100. data/ext/clipsruby/envrnmnt.h +112 -0
  101. data/ext/clipsruby/evaluatn.c +1736 -0
  102. data/ext/clipsruby/evaluatn.h +211 -0
  103. data/ext/clipsruby/expressn.c +494 -0
  104. data/ext/clipsruby/expressn.h +154 -0
  105. data/ext/clipsruby/exprnbin.c +538 -0
  106. data/ext/clipsruby/exprnbin.h +60 -0
  107. data/ext/clipsruby/exprnops.c +564 -0
  108. data/ext/clipsruby/exprnops.h +67 -0
  109. data/ext/clipsruby/exprnpsr.c +1112 -0
  110. data/ext/clipsruby/exprnpsr.h +98 -0
  111. data/ext/clipsruby/extconf.rb +2 -0
  112. data/ext/clipsruby/extnfunc.c +1015 -0
  113. data/ext/clipsruby/extnfunc.h +157 -0
  114. data/ext/clipsruby/factbin.c +447 -0
  115. data/ext/clipsruby/factbin.h +56 -0
  116. data/ext/clipsruby/factbld.c +1035 -0
  117. data/ext/clipsruby/factbld.h +63 -0
  118. data/ext/clipsruby/factcmp.c +386 -0
  119. data/ext/clipsruby/factcmp.h +46 -0
  120. data/ext/clipsruby/factcom.c +759 -0
  121. data/ext/clipsruby/factcom.h +80 -0
  122. data/ext/clipsruby/factfile.c +1761 -0
  123. data/ext/clipsruby/factfile.h +54 -0
  124. data/ext/clipsruby/factfun.c +682 -0
  125. data/ext/clipsruby/factfun.h +77 -0
  126. data/ext/clipsruby/factgen.c +1305 -0
  127. data/ext/clipsruby/factgen.h +229 -0
  128. data/ext/clipsruby/facthsh.c +438 -0
  129. data/ext/clipsruby/facthsh.h +81 -0
  130. data/ext/clipsruby/factlhs.c +250 -0
  131. data/ext/clipsruby/factlhs.h +54 -0
  132. data/ext/clipsruby/factmch.c +905 -0
  133. data/ext/clipsruby/factmch.h +68 -0
  134. data/ext/clipsruby/factmngr.c +3373 -0
  135. data/ext/clipsruby/factmngr.h +325 -0
  136. data/ext/clipsruby/factprt.c +498 -0
  137. data/ext/clipsruby/factprt.h +60 -0
  138. data/ext/clipsruby/factqpsr.c +796 -0
  139. data/ext/clipsruby/factqpsr.h +61 -0
  140. data/ext/clipsruby/factqury.c +1267 -0
  141. data/ext/clipsruby/factqury.h +112 -0
  142. data/ext/clipsruby/factrete.c +978 -0
  143. data/ext/clipsruby/factrete.h +70 -0
  144. data/ext/clipsruby/factrhs.c +667 -0
  145. data/ext/clipsruby/factrhs.h +55 -0
  146. data/ext/clipsruby/filecom.c +353 -0
  147. data/ext/clipsruby/filecom.h +137 -0
  148. data/ext/clipsruby/filertr.c +481 -0
  149. data/ext/clipsruby/filertr.h +94 -0
  150. data/ext/clipsruby/fileutil.c +1020 -0
  151. data/ext/clipsruby/fileutil.h +50 -0
  152. data/ext/clipsruby/generate.c +1079 -0
  153. data/ext/clipsruby/generate.h +57 -0
  154. data/ext/clipsruby/genrcbin.c +902 -0
  155. data/ext/clipsruby/genrcbin.h +69 -0
  156. data/ext/clipsruby/genrccmp.c +640 -0
  157. data/ext/clipsruby/genrccmp.h +59 -0
  158. data/ext/clipsruby/genrccom.c +2017 -0
  159. data/ext/clipsruby/genrccom.h +119 -0
  160. data/ext/clipsruby/genrcexe.c +737 -0
  161. data/ext/clipsruby/genrcexe.h +73 -0
  162. data/ext/clipsruby/genrcfun.c +890 -0
  163. data/ext/clipsruby/genrcfun.h +185 -0
  164. data/ext/clipsruby/genrcpsr.c +1618 -0
  165. data/ext/clipsruby/genrcpsr.h +80 -0
  166. data/ext/clipsruby/globlbin.c +458 -0
  167. data/ext/clipsruby/globlbin.h +71 -0
  168. data/ext/clipsruby/globlbsc.c +361 -0
  169. data/ext/clipsruby/globlbsc.h +83 -0
  170. data/ext/clipsruby/globlcmp.c +330 -0
  171. data/ext/clipsruby/globlcmp.h +52 -0
  172. data/ext/clipsruby/globlcom.c +289 -0
  173. data/ext/clipsruby/globlcom.h +63 -0
  174. data/ext/clipsruby/globldef.c +1087 -0
  175. data/ext/clipsruby/globldef.h +151 -0
  176. data/ext/clipsruby/globlpsr.c +530 -0
  177. data/ext/clipsruby/globlpsr.h +59 -0
  178. data/ext/clipsruby/immthpsr.c +431 -0
  179. data/ext/clipsruby/immthpsr.h +55 -0
  180. data/ext/clipsruby/incrrset.c +530 -0
  181. data/ext/clipsruby/incrrset.h +73 -0
  182. data/ext/clipsruby/inherpsr.c +850 -0
  183. data/ext/clipsruby/inherpsr.h +52 -0
  184. data/ext/clipsruby/inscom.c +2076 -0
  185. data/ext/clipsruby/inscom.h +182 -0
  186. data/ext/clipsruby/insfile.c +1764 -0
  187. data/ext/clipsruby/insfile.h +96 -0
  188. data/ext/clipsruby/insfun.c +1451 -0
  189. data/ext/clipsruby/insfun.h +134 -0
  190. data/ext/clipsruby/insmngr.c +2550 -0
  191. data/ext/clipsruby/insmngr.h +125 -0
  192. data/ext/clipsruby/insmoddp.c +1041 -0
  193. data/ext/clipsruby/insmoddp.h +91 -0
  194. data/ext/clipsruby/insmult.c +804 -0
  195. data/ext/clipsruby/insmult.h +62 -0
  196. data/ext/clipsruby/inspsr.c +602 -0
  197. data/ext/clipsruby/inspsr.h +60 -0
  198. data/ext/clipsruby/insquery.c +1278 -0
  199. data/ext/clipsruby/insquery.h +115 -0
  200. data/ext/clipsruby/insqypsr.c +729 -0
  201. data/ext/clipsruby/insqypsr.h +63 -0
  202. data/ext/clipsruby/iofun.c +2045 -0
  203. data/ext/clipsruby/iofun.h +116 -0
  204. data/ext/clipsruby/lgcldpnd.c +644 -0
  205. data/ext/clipsruby/lgcldpnd.h +75 -0
  206. data/ext/clipsruby/main.c +112 -0
  207. data/ext/clipsruby/match.h +142 -0
  208. data/ext/clipsruby/memalloc.c +481 -0
  209. data/ext/clipsruby/memalloc.h +197 -0
  210. data/ext/clipsruby/miscfun.c +1801 -0
  211. data/ext/clipsruby/miscfun.h +132 -0
  212. data/ext/clipsruby/modulbin.c +607 -0
  213. data/ext/clipsruby/modulbin.h +84 -0
  214. data/ext/clipsruby/modulbsc.c +347 -0
  215. data/ext/clipsruby/modulbsc.h +67 -0
  216. data/ext/clipsruby/modulcmp.c +499 -0
  217. data/ext/clipsruby/modulcmp.h +54 -0
  218. data/ext/clipsruby/moduldef.c +817 -0
  219. data/ext/clipsruby/moduldef.h +271 -0
  220. data/ext/clipsruby/modulpsr.c +1150 -0
  221. data/ext/clipsruby/modulpsr.h +69 -0
  222. data/ext/clipsruby/modulutl.c +1036 -0
  223. data/ext/clipsruby/modulutl.h +84 -0
  224. data/ext/clipsruby/msgcom.c +1221 -0
  225. data/ext/clipsruby/msgcom.h +125 -0
  226. data/ext/clipsruby/msgfun.c +1076 -0
  227. data/ext/clipsruby/msgfun.h +118 -0
  228. data/ext/clipsruby/msgpass.c +1441 -0
  229. data/ext/clipsruby/msgpass.h +103 -0
  230. data/ext/clipsruby/msgpsr.c +698 -0
  231. data/ext/clipsruby/msgpsr.h +73 -0
  232. data/ext/clipsruby/multifld.c +1404 -0
  233. data/ext/clipsruby/multifld.h +130 -0
  234. data/ext/clipsruby/multifun.c +2182 -0
  235. data/ext/clipsruby/multifun.h +102 -0
  236. data/ext/clipsruby/network.h +142 -0
  237. data/ext/clipsruby/objbin.c +1522 -0
  238. data/ext/clipsruby/objbin.h +79 -0
  239. data/ext/clipsruby/objcmp.c +1507 -0
  240. data/ext/clipsruby/objcmp.h +71 -0
  241. data/ext/clipsruby/object.h +260 -0
  242. data/ext/clipsruby/objrtbin.c +701 -0
  243. data/ext/clipsruby/objrtbin.h +79 -0
  244. data/ext/clipsruby/objrtbld.c +2393 -0
  245. data/ext/clipsruby/objrtbld.h +66 -0
  246. data/ext/clipsruby/objrtcmp.c +734 -0
  247. data/ext/clipsruby/objrtcmp.h +66 -0
  248. data/ext/clipsruby/objrtfnx.c +1330 -0
  249. data/ext/clipsruby/objrtfnx.h +222 -0
  250. data/ext/clipsruby/objrtgen.c +736 -0
  251. data/ext/clipsruby/objrtgen.h +63 -0
  252. data/ext/clipsruby/objrtmch.c +1524 -0
  253. data/ext/clipsruby/objrtmch.h +160 -0
  254. data/ext/clipsruby/parsefun.c +415 -0
  255. data/ext/clipsruby/parsefun.h +67 -0
  256. data/ext/clipsruby/pattern.c +1265 -0
  257. data/ext/clipsruby/pattern.h +163 -0
  258. data/ext/clipsruby/pprint.c +328 -0
  259. data/ext/clipsruby/pprint.h +79 -0
  260. data/ext/clipsruby/prccode.c +1478 -0
  261. data/ext/clipsruby/prccode.h +145 -0
  262. data/ext/clipsruby/prcdrfun.c +640 -0
  263. data/ext/clipsruby/prcdrfun.h +95 -0
  264. data/ext/clipsruby/prcdrpsr.c +1068 -0
  265. data/ext/clipsruby/prcdrpsr.h +79 -0
  266. data/ext/clipsruby/prdctfun.c +869 -0
  267. data/ext/clipsruby/prdctfun.h +77 -0
  268. data/ext/clipsruby/prntutil.c +878 -0
  269. data/ext/clipsruby/prntutil.h +125 -0
  270. data/ext/clipsruby/proflfun.c +827 -0
  271. data/ext/clipsruby/proflfun.h +118 -0
  272. data/ext/clipsruby/reorder.c +2082 -0
  273. data/ext/clipsruby/reorder.h +172 -0
  274. data/ext/clipsruby/reteutil.c +1732 -0
  275. data/ext/clipsruby/reteutil.h +111 -0
  276. data/ext/clipsruby/retract.c +710 -0
  277. data/ext/clipsruby/retract.h +74 -0
  278. data/ext/clipsruby/router.c +737 -0
  279. data/ext/clipsruby/router.h +147 -0
  280. data/ext/clipsruby/rulebin.c +1136 -0
  281. data/ext/clipsruby/rulebin.h +153 -0
  282. data/ext/clipsruby/rulebld.c +1328 -0
  283. data/ext/clipsruby/rulebld.h +62 -0
  284. data/ext/clipsruby/rulebsc.c +517 -0
  285. data/ext/clipsruby/rulebsc.h +91 -0
  286. data/ext/clipsruby/rulecmp.c +733 -0
  287. data/ext/clipsruby/rulecmp.h +63 -0
  288. data/ext/clipsruby/rulecom.c +1583 -0
  289. data/ext/clipsruby/rulecom.h +116 -0
  290. data/ext/clipsruby/rulecstr.c +892 -0
  291. data/ext/clipsruby/rulecstr.h +53 -0
  292. data/ext/clipsruby/ruledef.c +559 -0
  293. data/ext/clipsruby/ruledef.h +179 -0
  294. data/ext/clipsruby/ruledlt.c +599 -0
  295. data/ext/clipsruby/ruledlt.h +58 -0
  296. data/ext/clipsruby/rulelhs.c +1216 -0
  297. data/ext/clipsruby/rulelhs.h +52 -0
  298. data/ext/clipsruby/rulepsr.c +1073 -0
  299. data/ext/clipsruby/rulepsr.h +61 -0
  300. data/ext/clipsruby/scanner.c +856 -0
  301. data/ext/clipsruby/scanner.h +112 -0
  302. data/ext/clipsruby/setup.h +488 -0
  303. data/ext/clipsruby/sortfun.c +433 -0
  304. data/ext/clipsruby/sortfun.h +55 -0
  305. data/ext/clipsruby/strngfun.c +1173 -0
  306. data/ext/clipsruby/strngfun.h +96 -0
  307. data/ext/clipsruby/strngrtr.c +523 -0
  308. data/ext/clipsruby/strngrtr.h +97 -0
  309. data/ext/clipsruby/symblbin.c +648 -0
  310. data/ext/clipsruby/symblbin.h +64 -0
  311. data/ext/clipsruby/symblcmp.c +893 -0
  312. data/ext/clipsruby/symblcmp.h +61 -0
  313. data/ext/clipsruby/symbol.c +1961 -0
  314. data/ext/clipsruby/symbol.h +243 -0
  315. data/ext/clipsruby/sysdep.c +894 -0
  316. data/ext/clipsruby/sysdep.h +164 -0
  317. data/ext/clipsruby/textpro.c +1388 -0
  318. data/ext/clipsruby/textpro.h +77 -0
  319. data/ext/clipsruby/tmpltbin.c +609 -0
  320. data/ext/clipsruby/tmpltbin.h +108 -0
  321. data/ext/clipsruby/tmpltbsc.c +327 -0
  322. data/ext/clipsruby/tmpltbsc.h +87 -0
  323. data/ext/clipsruby/tmpltcmp.c +450 -0
  324. data/ext/clipsruby/tmpltcmp.h +57 -0
  325. data/ext/clipsruby/tmpltdef.c +584 -0
  326. data/ext/clipsruby/tmpltdef.h +155 -0
  327. data/ext/clipsruby/tmpltfun.c +2477 -0
  328. data/ext/clipsruby/tmpltfun.h +122 -0
  329. data/ext/clipsruby/tmpltlhs.c +379 -0
  330. data/ext/clipsruby/tmpltlhs.h +50 -0
  331. data/ext/clipsruby/tmpltpsr.c +819 -0
  332. data/ext/clipsruby/tmpltpsr.h +59 -0
  333. data/ext/clipsruby/tmpltrhs.c +595 -0
  334. data/ext/clipsruby/tmpltrhs.h +55 -0
  335. data/ext/clipsruby/tmpltutl.c +637 -0
  336. data/ext/clipsruby/tmpltutl.h +82 -0
  337. data/ext/clipsruby/userdata.c +156 -0
  338. data/ext/clipsruby/userdata.h +72 -0
  339. data/ext/clipsruby/userfunctions.c +70 -0
  340. data/ext/clipsruby/usrsetup.h +7 -0
  341. data/ext/clipsruby/utility.c +1594 -0
  342. data/ext/clipsruby/utility.h +250 -0
  343. data/ext/clipsruby/watch.c +865 -0
  344. data/ext/clipsruby/watch.h +124 -0
  345. data/lib/clipsruby.rb +1 -0
  346. metadata +388 -0
@@ -0,0 +1,1020 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.41 12/02/22 */
5
+ /* */
6
+ /* FILE UTILITY MODULE */
7
+ /*******************************************************/
8
+
9
+ /*************************************************************/
10
+ /* Purpose: Contains the code for file commands including */
11
+ /* batch, dribble-on, dribble-off, save, load, bsave, and */
12
+ /* bload. */
13
+ /* */
14
+ /* Principal Programmer(s): */
15
+ /* Gary D. Riley */
16
+ /* Brian L. Dantes */
17
+ /* */
18
+ /* Contributing Programmer(s): */
19
+ /* Bebe Ly */
20
+ /* */
21
+ /* Revision History: */
22
+ /* */
23
+ /* 6.31: Fixed error in AppendDribble for older */
24
+ /* compilers not allowing variable definition */
25
+ /* within for statement. */
26
+ /* */
27
+ /* Fixed line count issue when using Windows */
28
+ /* line endings in Unix. */
29
+ /* */
30
+ /* 6.40: Split from filecom.c */
31
+ /* */
32
+ /* Fix for the batch* command so that the last */
33
+ /* command will execute if there is not a crlf. */
34
+ /* */
35
+ /* 6.41: Fixed compiler warning when compiling with */
36
+ /* RUN_TIME set to 1. */
37
+ /* */
38
+ /*************************************************************/
39
+
40
+ #include <stdio.h>
41
+ #include <string.h>
42
+
43
+ #include "setup.h"
44
+
45
+ #include "argacces.h"
46
+ #include "commline.h"
47
+ #include "cstrcpsr.h"
48
+ #include "memalloc.h"
49
+ #include "prcdrfun.h"
50
+ #include "pprint.h"
51
+ #include "prntutil.h"
52
+ #include "router.h"
53
+ #include "scanner.h"
54
+ #include "strngrtr.h"
55
+ #include "sysdep.h"
56
+ #include "filecom.h"
57
+ #include "utility.h"
58
+
59
+ #include "fileutil.h"
60
+
61
+ /***************************************/
62
+ /* LOCAL INTERNAL FUNCTION DEFINITIONS */
63
+ /***************************************/
64
+
65
+ #if DEBUGGING_FUNCTIONS
66
+ static bool QueryDribbleCallback(Environment *,const char *,void *);
67
+ static int ReadDribbleCallback(Environment *,const char *,void *);
68
+ static int UnreadDribbleCallback(Environment *,const char *,int,void *);
69
+ static void ExitDribbleCallback(Environment *,int,void *);
70
+ static void WriteDribbleCallback(Environment *,const char *,const char *,void *);
71
+ static void PutcDribbleBuffer(Environment *,int);
72
+ #endif
73
+ static bool QueryBatchCallback(Environment *,const char *,void *);
74
+ static int ReadBatchCallback(Environment *,const char *,void *);
75
+ static int UnreadBatchCallback(Environment *,const char *,int,void *);
76
+ static void ExitBatchCallback(Environment *,int,void *);
77
+ static void AddBatch(Environment *,bool,FILE *,const char *,int,const char *,const char *);
78
+
79
+ #if DEBUGGING_FUNCTIONS
80
+ /****************************************/
81
+ /* QueryDribbleCallback: Query callback */
82
+ /* for the dribble router. */
83
+ /****************************************/
84
+ static bool QueryDribbleCallback(
85
+ Environment *theEnv,
86
+ const char *logicalName,
87
+ void *context)
88
+ {
89
+ #if MAC_XCD
90
+ #pragma unused(theEnv,context)
91
+ #endif
92
+
93
+ if ( (strcmp(logicalName,STDOUT) == 0) ||
94
+ (strcmp(logicalName,STDIN) == 0) ||
95
+ (strcmp(logicalName,STDERR) == 0) ||
96
+ (strcmp(logicalName,STDWRN) == 0) )
97
+ { return true; }
98
+
99
+ return false;
100
+ }
101
+
102
+ /******************/
103
+ /* AppendDribble: */
104
+ /******************/
105
+ void AppendDribble(
106
+ Environment *theEnv,
107
+ const char *str)
108
+ {
109
+ int i;
110
+
111
+ if (! DribbleActive(theEnv)) return;
112
+
113
+ for (i = 0 ; str[i] != EOS ; i++)
114
+ { PutcDribbleBuffer(theEnv,str[i]); }
115
+ }
116
+
117
+ /****************************************/
118
+ /* WriteDribbleCallback: Write callback */
119
+ /* for the dribble router. */
120
+ /****************************************/
121
+ static void WriteDribbleCallback(
122
+ Environment *theEnv,
123
+ const char *logicalName,
124
+ const char *str,
125
+ void *context)
126
+ {
127
+ int i;
128
+
129
+ /*======================================*/
130
+ /* Send the output to the dribble file. */
131
+ /*======================================*/
132
+
133
+ for (i = 0 ; str[i] != EOS ; i++)
134
+ { PutcDribbleBuffer(theEnv,str[i]); }
135
+
136
+ /*===========================================================*/
137
+ /* Send the output to any routers interested in printing it. */
138
+ /*===========================================================*/
139
+
140
+ DeactivateRouter(theEnv,"dribble");
141
+ WriteString(theEnv,logicalName,str);
142
+ ActivateRouter(theEnv,"dribble");
143
+ }
144
+
145
+ /**************************************/
146
+ /* ReadDribbleCallback: Read callback */
147
+ /* for the dribble router. */
148
+ /**************************************/
149
+ static int ReadDribbleCallback(
150
+ Environment *theEnv,
151
+ const char *logicalName,
152
+ void *context)
153
+ {
154
+ int rv;
155
+
156
+ /*===========================================*/
157
+ /* Deactivate the dribble router and get the */
158
+ /* character from another active router. */
159
+ /*===========================================*/
160
+
161
+ DeactivateRouter(theEnv,"dribble");
162
+ rv = ReadRouter(theEnv,logicalName);
163
+ ActivateRouter(theEnv,"dribble");
164
+
165
+ /*==========================================*/
166
+ /* Put the character retrieved from another */
167
+ /* router into the dribble buffer. */
168
+ /*==========================================*/
169
+
170
+ PutcDribbleBuffer(theEnv,rv);
171
+
172
+ /*=======================*/
173
+ /* Return the character. */
174
+ /*=======================*/
175
+
176
+ return(rv);
177
+ }
178
+
179
+ /***********************************************************/
180
+ /* PutcDribbleBuffer: Putc routine for the dribble router. */
181
+ /***********************************************************/
182
+ static void PutcDribbleBuffer(
183
+ Environment *theEnv,
184
+ int rv)
185
+ {
186
+ /*===================================================*/
187
+ /* Receiving an end-of-file character will cause the */
188
+ /* contents of the dribble buffer to be flushed. */
189
+ /*===================================================*/
190
+
191
+ if (rv == EOF)
192
+ {
193
+ if (FileCommandData(theEnv)->DribbleCurrentPosition > 0)
194
+ {
195
+ fprintf(FileCommandData(theEnv)->DribbleFP,"%s",FileCommandData(theEnv)->DribbleBuffer);
196
+ FileCommandData(theEnv)->DribbleCurrentPosition = 0;
197
+ FileCommandData(theEnv)->DribbleBuffer[0] = EOS;
198
+ }
199
+ }
200
+
201
+ /*===========================================================*/
202
+ /* If we aren't receiving command input, then the character */
203
+ /* just received doesn't need to be placed in the dribble */
204
+ /* buffer--It can be written directly to the file. This will */
205
+ /* occur for example when the command prompt is being */
206
+ /* printed (the AwaitingInput variable will be false because */
207
+ /* command input has not been receivied yet). Before writing */
208
+ /* the character to the file, the dribble buffer is flushed. */
209
+ /*===========================================================*/
210
+
211
+ else if (RouterData(theEnv)->AwaitingInput == false)
212
+ {
213
+ if (FileCommandData(theEnv)->DribbleCurrentPosition > 0)
214
+ {
215
+ fprintf(FileCommandData(theEnv)->DribbleFP,"%s",FileCommandData(theEnv)->DribbleBuffer);
216
+ FileCommandData(theEnv)->DribbleCurrentPosition = 0;
217
+ FileCommandData(theEnv)->DribbleBuffer[0] = EOS;
218
+ }
219
+
220
+ fputc(rv,FileCommandData(theEnv)->DribbleFP);
221
+ }
222
+
223
+ /*=====================================================*/
224
+ /* Otherwise, add the character to the dribble buffer. */
225
+ /*=====================================================*/
226
+
227
+ else
228
+ {
229
+ FileCommandData(theEnv)->DribbleBuffer = ExpandStringWithChar(theEnv,rv,FileCommandData(theEnv)->DribbleBuffer,
230
+ &FileCommandData(theEnv)->DribbleCurrentPosition,
231
+ &FileCommandData(theEnv)->DribbleMaximumPosition,
232
+ FileCommandData(theEnv)->DribbleMaximumPosition+BUFFER_SIZE);
233
+ }
234
+ }
235
+
236
+ /******************************************/
237
+ /* UnreadDribbleCallback: Unread callback */
238
+ /* for the dribble router. */
239
+ /******************************************/
240
+ static int UnreadDribbleCallback(
241
+ Environment *theEnv,
242
+ const char *logicalName,
243
+ int ch,
244
+ void *context)
245
+ {
246
+ int rv;
247
+
248
+ /*===============================================*/
249
+ /* Remove the character from the dribble buffer. */
250
+ /*===============================================*/
251
+
252
+ if (FileCommandData(theEnv)->DribbleCurrentPosition > 0) FileCommandData(theEnv)->DribbleCurrentPosition--;
253
+ FileCommandData(theEnv)->DribbleBuffer[FileCommandData(theEnv)->DribbleCurrentPosition] = EOS;
254
+
255
+ /*=============================================*/
256
+ /* Deactivate the dribble router and pass the */
257
+ /* ungetc request to the other active routers. */
258
+ /*=============================================*/
259
+
260
+ DeactivateRouter(theEnv,"dribble");
261
+ rv = UnreadRouter(theEnv,logicalName,ch);
262
+ ActivateRouter(theEnv,"dribble");
263
+
264
+ /*==========================================*/
265
+ /* Return the result of the ungetc request. */
266
+ /*==========================================*/
267
+
268
+ return(rv);
269
+ }
270
+
271
+ /**************************************/
272
+ /* ExitDribbleCallback: Exit callback */
273
+ /* for the dribble router. */
274
+ /**************************************/
275
+ static void ExitDribbleCallback(
276
+ Environment *theEnv,
277
+ int num,
278
+ void *context)
279
+ {
280
+ #if MAC_XCD
281
+ #pragma unused(num)
282
+ #endif
283
+
284
+ if (FileCommandData(theEnv)->DribbleCurrentPosition > 0)
285
+ { fprintf(FileCommandData(theEnv)->DribbleFP,"%s",FileCommandData(theEnv)->DribbleBuffer); }
286
+
287
+ if (FileCommandData(theEnv)->DribbleFP != NULL) GenClose(theEnv,FileCommandData(theEnv)->DribbleFP);
288
+ }
289
+
290
+ /*********************************/
291
+ /* DribbleOn: C access routine */
292
+ /* for the dribble-on command. */
293
+ /*********************************/
294
+ bool DribbleOn(
295
+ Environment *theEnv,
296
+ const char *fileName)
297
+ {
298
+ /*==============================*/
299
+ /* If a dribble file is already */
300
+ /* open, then close it. */
301
+ /*==============================*/
302
+
303
+ if (FileCommandData(theEnv)->DribbleFP != NULL)
304
+ { DribbleOff(theEnv); }
305
+
306
+ /*========================*/
307
+ /* Open the dribble file. */
308
+ /*========================*/
309
+
310
+ FileCommandData(theEnv)->DribbleFP = GenOpen(theEnv,fileName,"w");
311
+ if (FileCommandData(theEnv)->DribbleFP == NULL)
312
+ {
313
+ OpenErrorMessage(theEnv,"dribble-on",fileName);
314
+ return false;
315
+ }
316
+
317
+ /*============================*/
318
+ /* Create the dribble router. */
319
+ /*============================*/
320
+
321
+ AddRouter(theEnv,"dribble",40,
322
+ QueryDribbleCallback,WriteDribbleCallback,
323
+ ReadDribbleCallback,UnreadDribbleCallback,
324
+ ExitDribbleCallback,NULL);
325
+
326
+ FileCommandData(theEnv)->DribbleCurrentPosition = 0;
327
+
328
+ /*================================================*/
329
+ /* Call the dribble status function. This is used */
330
+ /* by some of the machine specific interfaces to */
331
+ /* do things such as changing the wording of menu */
332
+ /* items from "Turn Dribble On..." to */
333
+ /* "Turn Dribble Off..." */
334
+ /*================================================*/
335
+
336
+ if (FileCommandData(theEnv)->DribbleStatusFunction != NULL)
337
+ { (*FileCommandData(theEnv)->DribbleStatusFunction)(theEnv,true); }
338
+
339
+ /*=====================================*/
340
+ /* Return true to indicate the dribble */
341
+ /* file was successfully opened. */
342
+ /*=====================================*/
343
+
344
+ return true;
345
+ }
346
+
347
+ /**********************************************/
348
+ /* DribbleActive: Returns true if the dribble */
349
+ /* router is active, otherwise false. */
350
+ /**********************************************/
351
+ bool DribbleActive(
352
+ Environment *theEnv)
353
+ {
354
+ if (FileCommandData(theEnv)->DribbleFP != NULL) return true;
355
+
356
+ return false;
357
+ }
358
+
359
+ /**********************************/
360
+ /* DribbleOff: C access routine */
361
+ /* for the dribble-off command. */
362
+ /**********************************/
363
+ bool DribbleOff(
364
+ Environment *theEnv)
365
+ {
366
+ bool rv = false;
367
+
368
+ /*================================================*/
369
+ /* Call the dribble status function. This is used */
370
+ /* by some of the machine specific interfaces to */
371
+ /* do things such as changing the wording of menu */
372
+ /* items from "Turn Dribble On..." to */
373
+ /* "Turn Dribble Off..." */
374
+ /*================================================*/
375
+
376
+ if (FileCommandData(theEnv)->DribbleStatusFunction != NULL)
377
+ { (*FileCommandData(theEnv)->DribbleStatusFunction)(theEnv,false); }
378
+
379
+ /*=======================================*/
380
+ /* Close the dribble file and deactivate */
381
+ /* the dribble router. */
382
+ /*=======================================*/
383
+
384
+ if (FileCommandData(theEnv)->DribbleFP != NULL)
385
+ {
386
+ if (FileCommandData(theEnv)->DribbleCurrentPosition > 0)
387
+ { fprintf(FileCommandData(theEnv)->DribbleFP,"%s",FileCommandData(theEnv)->DribbleBuffer); }
388
+ DeleteRouter(theEnv,"dribble");
389
+ if (GenClose(theEnv,FileCommandData(theEnv)->DribbleFP) == 0) rv = true;
390
+ }
391
+ else
392
+ { rv = true; }
393
+
394
+ FileCommandData(theEnv)->DribbleFP = NULL;
395
+
396
+ /*============================================*/
397
+ /* Free the space used by the dribble buffer. */
398
+ /*============================================*/
399
+
400
+ if (FileCommandData(theEnv)->DribbleBuffer != NULL)
401
+ {
402
+ rm(theEnv,FileCommandData(theEnv)->DribbleBuffer,FileCommandData(theEnv)->DribbleMaximumPosition);
403
+ FileCommandData(theEnv)->DribbleBuffer = NULL;
404
+ }
405
+
406
+ FileCommandData(theEnv)->DribbleCurrentPosition = 0;
407
+ FileCommandData(theEnv)->DribbleMaximumPosition = 0;
408
+
409
+ /*============================================*/
410
+ /* Return true if the dribble file was closed */
411
+ /* without error, otherwise return false. */
412
+ /*============================================*/
413
+
414
+ return(rv);
415
+ }
416
+
417
+ #endif /* DEBUGGING_FUNCTIONS */
418
+
419
+ /**************************************/
420
+ /* QueryBatchCallback: Query callback */
421
+ /* for the batch router. */
422
+ /**************************************/
423
+ static bool QueryBatchCallback(
424
+ Environment *theEnv,
425
+ const char *logicalName,
426
+ void *context)
427
+ {
428
+ #if MAC_XCD
429
+ #pragma unused(theEnv)
430
+ #endif
431
+
432
+ if (strcmp(logicalName,STDIN) == 0)
433
+ { return true; }
434
+
435
+ return false;
436
+ }
437
+
438
+ /************************************/
439
+ /* ReadBatchCallback: Read callback */
440
+ /* for the batch router. */
441
+ /************************************/
442
+ static int ReadBatchCallback(
443
+ Environment *theEnv,
444
+ const char *logicalName,
445
+ void *context)
446
+ {
447
+ return(LLGetcBatch(theEnv,logicalName,false));
448
+ }
449
+
450
+ /***************************************************/
451
+ /* LLGetcBatch: Lower level routine for retrieving */
452
+ /* a character when a batch file is active. */
453
+ /***************************************************/
454
+ int LLGetcBatch(
455
+ Environment *theEnv,
456
+ const char *logicalName,
457
+ bool returnOnEOF)
458
+ {
459
+ int rv = EOF, flag = 1;
460
+
461
+ /*=================================================*/
462
+ /* Get a character until a valid character appears */
463
+ /* or no more batch files are left. */
464
+ /*=================================================*/
465
+
466
+ while ((rv == EOF) && (flag == 1))
467
+ {
468
+ if (FileCommandData(theEnv)->BatchType == FILE_BATCH)
469
+ { rv = getc(FileCommandData(theEnv)->BatchFileSource); }
470
+ else
471
+ { rv = ReadRouter(theEnv,FileCommandData(theEnv)->BatchLogicalSource); }
472
+
473
+ if (rv == EOF)
474
+ {
475
+ if (FileCommandData(theEnv)->BatchCurrentPosition > 0) WriteString(theEnv,STDOUT,(char *) FileCommandData(theEnv)->BatchBuffer);
476
+ flag = RemoveBatch(theEnv);
477
+ }
478
+ }
479
+
480
+ /*=========================================================*/
481
+ /* If the character retrieved is an end-of-file character, */
482
+ /* then there are no batch files with character input */
483
+ /* remaining. Remove the batch router. */
484
+ /*=========================================================*/
485
+
486
+ if (rv == EOF)
487
+ {
488
+ if (FileCommandData(theEnv)->BatchCurrentPosition > 0) WriteString(theEnv,STDOUT,(char *) FileCommandData(theEnv)->BatchBuffer);
489
+ DeleteRouter(theEnv,"batch");
490
+ RemoveBatch(theEnv);
491
+ if (returnOnEOF == true)
492
+ { return (EOF); }
493
+ else
494
+ { return ReadRouter(theEnv,logicalName); }
495
+ }
496
+
497
+ /*========================================*/
498
+ /* Add the character to the batch buffer. */
499
+ /*========================================*/
500
+
501
+ if (RouterData(theEnv)->InputUngets == 0)
502
+ {
503
+ FileCommandData(theEnv)->BatchBuffer = ExpandStringWithChar(theEnv,(char) rv,FileCommandData(theEnv)->BatchBuffer,&FileCommandData(theEnv)->BatchCurrentPosition,
504
+ &FileCommandData(theEnv)->BatchMaximumPosition,FileCommandData(theEnv)->BatchMaximumPosition+BUFFER_SIZE);
505
+ }
506
+
507
+ /*======================================*/
508
+ /* If a carriage return is encountered, */
509
+ /* then flush the batch buffer. */
510
+ /*======================================*/
511
+
512
+ if ((char) rv == '\n')
513
+ {
514
+ WriteString(theEnv,STDOUT,(char *) FileCommandData(theEnv)->BatchBuffer);
515
+ FileCommandData(theEnv)->BatchCurrentPosition = 0;
516
+ if ((FileCommandData(theEnv)->BatchBuffer != NULL) && (FileCommandData(theEnv)->BatchMaximumPosition > BUFFER_SIZE))
517
+ {
518
+ rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition);
519
+ FileCommandData(theEnv)->BatchMaximumPosition = 0;
520
+ FileCommandData(theEnv)->BatchBuffer = NULL;
521
+ }
522
+ }
523
+
524
+ /*=============================*/
525
+ /* Increment the line counter. */
526
+ /*=============================*/
527
+
528
+ if ((char) rv == '\n')
529
+ { IncrementLineCount(theEnv); }
530
+
531
+ /*=====================================================*/
532
+ /* Return the character retrieved from the batch file. */
533
+ /*=====================================================*/
534
+
535
+ return(rv);
536
+ }
537
+
538
+ /****************************************/
539
+ /* UnreadBatchCallback: Unread callback */
540
+ /* for the batch router. */
541
+ /****************************************/
542
+ static int UnreadBatchCallback(
543
+ Environment *theEnv,
544
+ const char *logicalName,
545
+ int ch,
546
+ void *context)
547
+ {
548
+ #if MAC_XCD
549
+ #pragma unused(logicalName)
550
+ #endif
551
+
552
+ if (FileCommandData(theEnv)->BatchCurrentPosition > 0) FileCommandData(theEnv)->BatchCurrentPosition--;
553
+ if (FileCommandData(theEnv)->BatchBuffer != NULL) FileCommandData(theEnv)->BatchBuffer[FileCommandData(theEnv)->BatchCurrentPosition] = EOS;
554
+ if (FileCommandData(theEnv)->BatchType == FILE_BATCH)
555
+ { return ungetc(ch,FileCommandData(theEnv)->BatchFileSource); }
556
+
557
+ return UnreadRouter(theEnv,FileCommandData(theEnv)->BatchLogicalSource,ch);
558
+ }
559
+
560
+ /************************************/
561
+ /* ExitBatchCallback: Exit callback */
562
+ /* for the batch router. */
563
+ /************************************/
564
+ static void ExitBatchCallback(
565
+ Environment *theEnv,
566
+ int num,
567
+ void *context)
568
+ {
569
+ #if MAC_XCD
570
+ #pragma unused(num,context)
571
+ #endif
572
+ CloseAllBatchSources(theEnv);
573
+ }
574
+
575
+ /**************************************************/
576
+ /* Batch: C access routine for the batch command. */
577
+ /**************************************************/
578
+ bool Batch(
579
+ Environment *theEnv,
580
+ const char *fileName)
581
+ { return(OpenBatch(theEnv,fileName,false)); }
582
+
583
+ /***********************************************/
584
+ /* OpenBatch: Adds a file to the list of files */
585
+ /* opened with the batch command. */
586
+ /***********************************************/
587
+ bool OpenBatch(
588
+ Environment *theEnv,
589
+ const char *fileName,
590
+ bool placeAtEnd)
591
+ {
592
+ FILE *theFile;
593
+
594
+ /*======================*/
595
+ /* Open the batch file. */
596
+ /*======================*/
597
+
598
+ theFile = GenOpen(theEnv,fileName,"r");
599
+
600
+ if (theFile == NULL)
601
+ {
602
+ OpenErrorMessage(theEnv,"batch",fileName);
603
+ return false;
604
+ }
605
+
606
+ /*============================*/
607
+ /* Create the batch router if */
608
+ /* it doesn't already exist. */
609
+ /*============================*/
610
+
611
+ if (FileCommandData(theEnv)->TopOfBatchList == NULL)
612
+ {
613
+ AddRouter(theEnv,"batch",20,QueryBatchCallback,NULL,
614
+ ReadBatchCallback,UnreadBatchCallback,
615
+ ExitBatchCallback,NULL);
616
+ }
617
+
618
+ /*===============================================================*/
619
+ /* If a batch file is already open, save its current line count. */
620
+ /*===============================================================*/
621
+
622
+ if (FileCommandData(theEnv)->TopOfBatchList != NULL)
623
+ { FileCommandData(theEnv)->TopOfBatchList->lineNumber = GetLineCount(theEnv); }
624
+
625
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
626
+
627
+ /*========================================================================*/
628
+ /* If this is the first batch file, remember the prior parsing file name. */
629
+ /*========================================================================*/
630
+
631
+ if (FileCommandData(theEnv)->TopOfBatchList == NULL)
632
+ { FileCommandData(theEnv)->batchPriorParsingFile = CopyString(theEnv,GetParsingFileName(theEnv)); }
633
+
634
+ /*=======================================================*/
635
+ /* Create the error capture router if it does not exist. */
636
+ /*=======================================================*/
637
+
638
+ SetParsingFileName(theEnv,fileName);
639
+ SetLineCount(theEnv,0);
640
+
641
+ CreateErrorCaptureRouter(theEnv);
642
+ #endif
643
+
644
+ /*====================================*/
645
+ /* Add the newly opened batch file to */
646
+ /* the list of batch files opened. */
647
+ /*====================================*/
648
+
649
+ AddBatch(theEnv,placeAtEnd,theFile,NULL,FILE_BATCH,NULL,fileName);
650
+
651
+ /*===================================*/
652
+ /* Return true to indicate the batch */
653
+ /* file was successfully opened. */
654
+ /*===================================*/
655
+
656
+ return true;
657
+ }
658
+
659
+ /*****************************************************************/
660
+ /* OpenStringBatch: Opens a string source for batch processing. */
661
+ /* The memory allocated for the argument stringName must be */
662
+ /* deallocated by the user. The memory allocated for theString */
663
+ /* will be deallocated by the batch routines when batch */
664
+ /* processing for the string is completed. */
665
+ /*****************************************************************/
666
+ bool OpenStringBatch(
667
+ Environment *theEnv,
668
+ const char *stringName,
669
+ const char *theString,
670
+ bool placeAtEnd)
671
+ {
672
+ if (OpenStringSource(theEnv,stringName,theString,0) == false)
673
+ { return false; }
674
+
675
+ if (FileCommandData(theEnv)->TopOfBatchList == NULL)
676
+ {
677
+ AddRouter(theEnv,"batch", 20,
678
+ QueryBatchCallback,NULL,
679
+ ReadBatchCallback,UnreadBatchCallback,
680
+ ExitBatchCallback,NULL);
681
+ }
682
+
683
+ AddBatch(theEnv,placeAtEnd,NULL,stringName,STRING_BATCH,theString,NULL);
684
+
685
+ return true;
686
+ }
687
+
688
+ /*******************************************************/
689
+ /* AddBatch: Creates the batch file data structure and */
690
+ /* adds it to the list of opened batch files. */
691
+ /*******************************************************/
692
+ static void AddBatch(
693
+ Environment *theEnv,
694
+ bool placeAtEnd,
695
+ FILE *theFileSource,
696
+ const char *theLogicalSource,
697
+ int type,
698
+ const char *theString,
699
+ const char *theFileName)
700
+ {
701
+ struct batchEntry *bptr;
702
+
703
+ /*=========================*/
704
+ /* Create the batch entry. */
705
+ /*=========================*/
706
+
707
+ bptr = get_struct(theEnv,batchEntry);
708
+ bptr->batchType = type;
709
+ bptr->fileSource = theFileSource;
710
+ bptr->logicalSource = CopyString(theEnv,theLogicalSource);
711
+ bptr->theString = theString;
712
+ bptr->fileName = CopyString(theEnv,theFileName);
713
+ bptr->lineNumber = 0;
714
+ bptr->next = NULL;
715
+
716
+ /*============================*/
717
+ /* Add the entry to the list. */
718
+ /*============================*/
719
+
720
+ if (FileCommandData(theEnv)->TopOfBatchList == NULL)
721
+ {
722
+ FileCommandData(theEnv)->TopOfBatchList = bptr;
723
+ FileCommandData(theEnv)->BottomOfBatchList = bptr;
724
+ FileCommandData(theEnv)->BatchType = type;
725
+ FileCommandData(theEnv)->BatchFileSource = theFileSource;
726
+ FileCommandData(theEnv)->BatchLogicalSource = bptr->logicalSource;
727
+ FileCommandData(theEnv)->BatchCurrentPosition = 0;
728
+ }
729
+ else if (placeAtEnd == false)
730
+ {
731
+ bptr->next = FileCommandData(theEnv)->TopOfBatchList;
732
+ FileCommandData(theEnv)->TopOfBatchList = bptr;
733
+ FileCommandData(theEnv)->BatchType = type;
734
+ FileCommandData(theEnv)->BatchFileSource = theFileSource;
735
+ FileCommandData(theEnv)->BatchLogicalSource = bptr->logicalSource;
736
+ FileCommandData(theEnv)->BatchCurrentPosition = 0;
737
+ }
738
+ else
739
+ {
740
+ FileCommandData(theEnv)->BottomOfBatchList->next = bptr;
741
+ FileCommandData(theEnv)->BottomOfBatchList = bptr;
742
+ }
743
+ }
744
+
745
+ /******************************************************************/
746
+ /* RemoveBatch: Removes the top entry on the list of batch files. */
747
+ /******************************************************************/
748
+ bool RemoveBatch(
749
+ Environment *theEnv)
750
+ {
751
+ struct batchEntry *bptr;
752
+ bool rv;
753
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
754
+ bool fileBatch = false;
755
+ #endif
756
+ if (FileCommandData(theEnv)->TopOfBatchList == NULL) return false;
757
+
758
+ /*==================================================*/
759
+ /* Close the source from which batch input is read. */
760
+ /*==================================================*/
761
+
762
+ if (FileCommandData(theEnv)->TopOfBatchList->batchType == FILE_BATCH)
763
+ {
764
+ GenClose(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileSource);
765
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
766
+ fileBatch = true;
767
+ FlushParsingMessages(theEnv);
768
+ DeleteErrorCaptureRouter(theEnv);
769
+ #endif
770
+ }
771
+ else
772
+ {
773
+ CloseStringSource(theEnv,FileCommandData(theEnv)->TopOfBatchList->logicalSource);
774
+ rm(theEnv,(void *) FileCommandData(theEnv)->TopOfBatchList->theString,
775
+ strlen(FileCommandData(theEnv)->TopOfBatchList->theString) + 1);
776
+ }
777
+
778
+ /*=================================*/
779
+ /* Remove the entry from the list. */
780
+ /*=================================*/
781
+
782
+ DeleteString(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileName);
783
+ bptr = FileCommandData(theEnv)->TopOfBatchList;
784
+ FileCommandData(theEnv)->TopOfBatchList = FileCommandData(theEnv)->TopOfBatchList->next;
785
+
786
+ DeleteString(theEnv,bptr->logicalSource);
787
+ rtn_struct(theEnv,batchEntry,bptr);
788
+
789
+ /*========================================================*/
790
+ /* If there are no batch files remaining to be processed, */
791
+ /* then free the space used by the batch buffer. */
792
+ /*========================================================*/
793
+
794
+ if (FileCommandData(theEnv)->TopOfBatchList == NULL)
795
+ {
796
+ FileCommandData(theEnv)->BottomOfBatchList = NULL;
797
+ FileCommandData(theEnv)->BatchFileSource = NULL;
798
+ FileCommandData(theEnv)->BatchLogicalSource = NULL;
799
+ if (FileCommandData(theEnv)->BatchBuffer != NULL)
800
+ {
801
+ rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition);
802
+ FileCommandData(theEnv)->BatchBuffer = NULL;
803
+ }
804
+ FileCommandData(theEnv)->BatchCurrentPosition = 0;
805
+ FileCommandData(theEnv)->BatchMaximumPosition = 0;
806
+ rv = false;
807
+
808
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
809
+ if (fileBatch)
810
+ {
811
+ SetParsingFileName(theEnv,FileCommandData(theEnv)->batchPriorParsingFile);
812
+ DeleteString(theEnv,FileCommandData(theEnv)->batchPriorParsingFile);
813
+ FileCommandData(theEnv)->batchPriorParsingFile = NULL;
814
+ }
815
+ #endif
816
+ }
817
+
818
+ /*===========================================*/
819
+ /* Otherwise move on to the next batch file. */
820
+ /*===========================================*/
821
+
822
+ else
823
+ {
824
+ FileCommandData(theEnv)->BatchType = FileCommandData(theEnv)->TopOfBatchList->batchType;
825
+ FileCommandData(theEnv)->BatchFileSource = FileCommandData(theEnv)->TopOfBatchList->fileSource;
826
+ FileCommandData(theEnv)->BatchLogicalSource = FileCommandData(theEnv)->TopOfBatchList->logicalSource;
827
+ FileCommandData(theEnv)->BatchCurrentPosition = 0;
828
+ rv = true;
829
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
830
+ if (FileCommandData(theEnv)->TopOfBatchList->batchType == FILE_BATCH)
831
+ { SetParsingFileName(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileName); }
832
+
833
+ SetLineCount(theEnv,FileCommandData(theEnv)->TopOfBatchList->lineNumber);
834
+ #endif
835
+ }
836
+
837
+ /*====================================================*/
838
+ /* Return true if a batch file if there are remaining */
839
+ /* batch files to be processed, otherwise false. */
840
+ /*====================================================*/
841
+
842
+ return(rv);
843
+ }
844
+
845
+ /****************************************/
846
+ /* BatchActive: Returns true if a batch */
847
+ /* file is open, otherwise false. */
848
+ /****************************************/
849
+ bool BatchActive(
850
+ Environment *theEnv)
851
+ {
852
+ if (FileCommandData(theEnv)->TopOfBatchList != NULL) return true;
853
+
854
+ return false;
855
+ }
856
+
857
+ /******************************************************/
858
+ /* CloseAllBatchSources: Closes all open batch files. */
859
+ /******************************************************/
860
+ void CloseAllBatchSources(
861
+ Environment *theEnv)
862
+ {
863
+ /*================================================*/
864
+ /* Free the batch buffer if it contains anything. */
865
+ /*================================================*/
866
+
867
+ if (FileCommandData(theEnv)->BatchBuffer != NULL)
868
+ {
869
+ if (FileCommandData(theEnv)->BatchCurrentPosition > 0) WriteString(theEnv,STDOUT,(char *) FileCommandData(theEnv)->BatchBuffer);
870
+ rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition);
871
+ FileCommandData(theEnv)->BatchBuffer = NULL;
872
+ FileCommandData(theEnv)->BatchCurrentPosition = 0;
873
+ FileCommandData(theEnv)->BatchMaximumPosition = 0;
874
+ }
875
+
876
+ /*==========================*/
877
+ /* Delete the batch router. */
878
+ /*==========================*/
879
+
880
+ DeleteRouter(theEnv,"batch");
881
+
882
+ /*=====================================*/
883
+ /* Close each of the open batch files. */
884
+ /*=====================================*/
885
+
886
+ while (RemoveBatch(theEnv))
887
+ { /* Do Nothing */ }
888
+ }
889
+
890
+ #if ! RUN_TIME
891
+
892
+ /*******************************************************/
893
+ /* BatchStar: C access routine for the batch* command. */
894
+ /*******************************************************/
895
+ bool BatchStar(
896
+ Environment *theEnv,
897
+ const char *fileName)
898
+ {
899
+ int inchar;
900
+ bool done = false;
901
+ FILE *theFile;
902
+ char *theString = NULL;
903
+ size_t position = 0;
904
+ size_t maxChars = 0;
905
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
906
+ char *oldParsingFileName;
907
+ long oldLineCountValue;
908
+ #endif
909
+ /*======================*/
910
+ /* Open the batch file. */
911
+ /*======================*/
912
+
913
+ theFile = GenOpen(theEnv,fileName,"r");
914
+
915
+ if (theFile == NULL)
916
+ {
917
+ OpenErrorMessage(theEnv,"batch",fileName);
918
+ return false;
919
+ }
920
+
921
+ /*======================================*/
922
+ /* Setup for capturing errors/warnings. */
923
+ /*======================================*/
924
+
925
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
926
+ oldParsingFileName = CopyString(theEnv,GetParsingFileName(theEnv));
927
+ SetParsingFileName(theEnv,fileName);
928
+
929
+ CreateErrorCaptureRouter(theEnv);
930
+
931
+ oldLineCountValue = SetLineCount(theEnv,1);
932
+ #endif
933
+
934
+ /*=====================================*/
935
+ /* If embedded, clear the error flags. */
936
+ /*=====================================*/
937
+
938
+ if (EvaluationData(theEnv)->CurrentExpression == NULL)
939
+ { ResetErrorFlags(theEnv); }
940
+
941
+ /*=============================================*/
942
+ /* Evaluate commands from the file one by one. */
943
+ /*=============================================*/
944
+
945
+ while (! done)
946
+ {
947
+ inchar = getc(theFile);
948
+ if (inchar == EOF)
949
+ {
950
+ inchar = '\n';
951
+ done = true;
952
+ }
953
+
954
+ theString = ExpandStringWithChar(theEnv,inchar,theString,&position,
955
+ &maxChars,maxChars+80);
956
+
957
+ if (CompleteCommand(theString) != 0)
958
+ {
959
+ FlushPPBuffer(theEnv);
960
+ SetPPBufferStatus(theEnv,false);
961
+ RouteCommand(theEnv,theString,false);
962
+ FlushPPBuffer(theEnv);
963
+ SetHaltExecution(theEnv,false);
964
+ SetEvaluationError(theEnv,false);
965
+ FlushBindList(theEnv,NULL);
966
+ genfree(theEnv,theString,maxChars);
967
+ theString = NULL;
968
+ maxChars = 0;
969
+ position = 0;
970
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
971
+ FlushParsingMessages(theEnv);
972
+ #endif
973
+ }
974
+
975
+ if (inchar == '\n')
976
+ { IncrementLineCount(theEnv); }
977
+ }
978
+
979
+ if (theString != NULL)
980
+ { genfree(theEnv,theString,maxChars); }
981
+
982
+ /*=======================*/
983
+ /* Close the batch file. */
984
+ /*=======================*/
985
+
986
+ GenClose(theEnv,theFile);
987
+
988
+ /*========================================*/
989
+ /* Cleanup for capturing errors/warnings. */
990
+ /*========================================*/
991
+
992
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
993
+ FlushParsingMessages(theEnv);
994
+ DeleteErrorCaptureRouter(theEnv);
995
+
996
+ SetLineCount(theEnv,oldLineCountValue);
997
+
998
+ SetParsingFileName(theEnv,oldParsingFileName);
999
+ DeleteString(theEnv,oldParsingFileName);
1000
+ #endif
1001
+
1002
+ return true;
1003
+ }
1004
+
1005
+ #else
1006
+
1007
+ /***********************************************/
1008
+ /* BatchStar: This is the non-functional stub */
1009
+ /* provided for use with a run-time version. */
1010
+ /***********************************************/
1011
+ bool BatchStar(
1012
+ Environment *theEnv,
1013
+ const char *fileName)
1014
+ {
1015
+ PrintErrorID(theEnv,"FILECOM",1,false);
1016
+ WriteString(theEnv,STDERR,"Function batch* does not work in run time modules.\n");
1017
+ return false;
1018
+ }
1019
+
1020
+ #endif