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,1388 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.40 08/25/16 */
5
+ /* */
6
+ /* TEXT PROCESSING MODULE */
7
+ /*******************************************************/
8
+
9
+ /*************************************************************/
10
+ /* Purpose: */
11
+ /* */
12
+ /* Principal Programmer(s): */
13
+ /* Brian L. Dantes */
14
+ /* */
15
+ /* Contributing Programmer(s): */
16
+ /* Gary D. Riley */
17
+ /* */
18
+ /* Revision History: */
19
+ /* */
20
+ /* 6.23: Modified error messages so that they were */
21
+ /* directly printed rather than storing them in */
22
+ /* a string buffer which might not be large */
23
+ /* enough to contain the entire message. DR0855 */
24
+ /* Correction for FalseSymbol/TrueSymbol. DR0859 */
25
+ /* */
26
+ /* 6.24: Added get-region function. */
27
+ /* */
28
+ /* Added environment parameter to GenClose. */
29
+ /* Added environment parameter to GenOpen. */
30
+ /* */
31
+ /* 6.30: Removed HELP_FUNCTIONS compilation flag and */
32
+ /* associated functionality. */
33
+ /* */
34
+ /* Used genstrcpy and genstrncpy instead of */
35
+ /* strcpy and strncpy. */
36
+ /* */
37
+ /* Support for long long integers. */
38
+ /* */
39
+ /* Changed integer type/precision. */
40
+ /* */
41
+ /* Removed conditional code for unsupported */
42
+ /* compilers/operating systems (IBM_TBC). */
43
+ /* */
44
+ /* Added const qualifiers to remove C++ */
45
+ /* deprecation warnings. */
46
+ /* */
47
+ /* Added STDOUT and STDIN logical name */
48
+ /* definitions. */
49
+ /* */
50
+ /* 6.31: Fixed crash issue when using textpro functions */
51
+ /* on Windows with files having unix eol. */
52
+ /* */
53
+ /* 6.40: Pragma once and other inclusion changes. */
54
+ /* */
55
+ /* Added support for booleans with <stdbool.h>. */
56
+ /* */
57
+ /* Removed use of void pointers for specific */
58
+ /* data structures. */
59
+ /* */
60
+ /* UDF redesign. */
61
+ /* */
62
+ /*************************************************************/
63
+
64
+
65
+ /**************************************************************************/
66
+ /**************************************************************************/
67
+ /* LOOKUP TABLE FUNCTIONS */
68
+ /* */
69
+ /* The functions contained in this file set up and access a hierarchical */
70
+ /* lookup system for multiple files. */
71
+ /* */
72
+ /* For usage see external documentation. */
73
+ /**************************************************************************/
74
+ /**************************************************************************/
75
+
76
+ #include "setup.h"
77
+
78
+ #include <stdio.h>
79
+ #include <ctype.h>
80
+ #include <string.h>
81
+
82
+ #include "argacces.h"
83
+ #include "commline.h"
84
+ #include "envrnmnt.h"
85
+ #include "extnfunc.h"
86
+ #include "memalloc.h"
87
+ #include "prntutil.h"
88
+ #include "router.h"
89
+ #include "sysdep.h"
90
+ #include "utility.h"
91
+
92
+ #include "textpro.h"
93
+
94
+ #if TEXTPRO_FUNCTIONS
95
+
96
+ #define NAMESIZE 80
97
+ #define NULLCHAR '\0'
98
+ #define BLANK (' ')
99
+ #define TAB ('\t')
100
+ #define LNFEED ('\n')
101
+
102
+ /*=========================================================*/
103
+ /*Status returns for the file loading and lookup functions */
104
+ /*=========================================================*/
105
+ #define NORMAL 0 /*Entry information found in file */
106
+ #define NO_FILE -10 /*File not found for reference */
107
+ #define NEW_FILE -15 /*File loaded onto internal lookup table*/
108
+ #define OLD_FILE -20 /*File was already on the lookup table */
109
+
110
+ #define NO_TOPIC -25 /*No entry information was found in file*/
111
+ #define EXIT -30 /*Branch-up from root; exit lookup table*/
112
+ #define BRANCH_UP -35 /*Move up from subtopic entry to parent */
113
+ #define BRANCH_DOWN -40 /*Move down from main topic to subtopic */
114
+
115
+ /*=================*/
116
+ /*Entry data types */
117
+ /*=================*/
118
+ #define MENU -45 /*Entry has subtopics*/
119
+ #define INFO -50 /*Entry is a leaf; contains only information*/
120
+
121
+ /*==========================================*/
122
+ /*Entry node type for internal lookup table */
123
+ /*==========================================*/
124
+ struct entries
125
+ {
126
+ int level; /*Level of entry node in the lookup tree */
127
+ int type; /*Entry node data type : menu or info */
128
+ char name[NAMESIZE]; /*Entry node name */
129
+ long offset; /*Location of entry info in the file */
130
+ struct entries *child; /*Address of list of subtopic entries */
131
+ struct entries *parent; /*Address of parent topic entry */
132
+ struct entries *next; /*Address of next entry at the same level */
133
+ };
134
+
135
+ /*=========================================*/
136
+ /*File node type for internal lookup table */
137
+ /*=========================================*/
138
+ struct lists
139
+ {
140
+ char file[NAMESIZE]; /*File name */
141
+ struct entries *topics; /*Address of list of entry topics for file */
142
+ struct entries *curr_menu; /*Address of current main topic in file */
143
+ struct lists *next; /*Address of next file in the table */
144
+ };
145
+
146
+ /*==================================================*/
147
+ /*Delimeter strings for marking entries in the file */
148
+ /*==================================================*/
149
+ #define BDELIM "BEGIN-ENTRY-"
150
+ #define BDLEN 12
151
+ #define EDELIM "END-ENTRY"
152
+ #define EDLEN 9
153
+ #define BFORMAT "%d%1s%12s%s" /*Format string for sscanf*/
154
+ #define LIT_DELIM ('$')
155
+
156
+ #define OPEN_READ "r"
157
+ #define OPEN_READ_BINARY "rb"
158
+
159
+ #define TEXTPRO_DATA 8
160
+
161
+ struct textProcessingData
162
+ {
163
+ struct lists *headings;
164
+ struct entries *parent;
165
+ };
166
+
167
+ #define TextProcessingData(theEnv) ((struct textProcessingData *) GetEnvironmentData(theEnv,TEXTPRO_DATA))
168
+
169
+ /***************************************/
170
+ /* LOCAL INTERNAL FUNCTION DEFINITIONS */
171
+ /***************************************/
172
+
173
+ static int TextLookupFetch(Environment *,const char *);
174
+ static bool TextLookupToss(Environment *,const char *);
175
+ static FILE *GetEntries(Environment *,const char *,char **,char *,int *);
176
+ static FILE *GetCurrentMenu(Environment *,const char *,int *);
177
+ static char *GrabString(Environment *,FILE *,char *,int);
178
+
179
+ static int findstr(const char *,const char *);
180
+ static void upper(char *);
181
+ static struct lists *NewFetchFile(Environment *,const char *);
182
+ static struct entries *AllocateEntryNode(Environment *,FILE *,const char *,const char *,int);
183
+ static bool AttachLeaf(Environment *,struct lists *,struct entries *,FILE *,const char *,int);
184
+ static long LookupEntry(Environment *,const char *,char **,char *,int *);
185
+ static void TossFunction(Environment *,struct entries *);
186
+ static void DeallocateTextProcessingData(Environment *);
187
+
188
+ /******************************************************************************/
189
+ /*============================================================================*/
190
+ /* INTERNAL ROUTINES */
191
+ /*============================================================================*/
192
+ /******************************************************************************/
193
+
194
+ /****************************************************************************/
195
+ /*LOAD FUNCTION : */
196
+ /* Input : 1) name of file to be loaded into the lookup table */
197
+ /* 2) caller-allocated buffer to contain an error message (if any) */
198
+ /* 3) size of error message buffer */
199
+ /* Output : */
200
+ /* This function attempts to load the file's topic information into the */
201
+ /* lookup table according to the format below : */
202
+ /* */
203
+ /* <level-num><entry-type-code>BEGIN-ENTRY-<topic-name> */
204
+ /* . */
205
+ /* . */
206
+ /* Entry information in the form in which */
207
+ /* it is to be displayed when referenced. */
208
+ /* . */
209
+ /* . */
210
+ /* END-ENTRY */
211
+ /* */
212
+ /* The function returns the number of entries loaded if the entire file was */
213
+ /* was correctly formatted, else it returns -1. */
214
+ /****************************************************************************/
215
+ static int TextLookupFetch(
216
+ Environment *theEnv,
217
+ const char *file)
218
+ {
219
+ FILE *fp; /*Pointer into stream of input file */
220
+ char str[256]; /*Buffer for storing input file lines */
221
+ bool INFO_BEGIN, INFO_END; /*Flags used to check proper syntax */
222
+ struct lists *lnode; /*Used to store file node in list */
223
+ struct entries *enode; /*Used to store entry node in topic list */
224
+ int line_ct; /*Line count - used for error messages */
225
+ int entries_ct; /*Number of entries successfully loaded. */
226
+
227
+ fp = GenOpen(theEnv,file,OPEN_READ_BINARY);
228
+
229
+ if (fp == NULL)
230
+ {
231
+ PrintErrorID(theEnv,"TEXTPRO",1,false);
232
+ WriteString(theEnv,STDERR,"Could not open file '");
233
+ WriteString(theEnv,STDERR,file);
234
+ WriteString(theEnv,STDERR,"'.\n");
235
+ return -1;
236
+ }
237
+
238
+ if ((lnode = NewFetchFile(theEnv,file)) == NULL)
239
+ {
240
+ GenClose(theEnv,fp);
241
+
242
+ PrintErrorID(theEnv,"TEXTPRO",2,false);
243
+ WriteString(theEnv,STDERR,"File '");
244
+ WriteString(theEnv,STDERR,file);
245
+ WriteString(theEnv,STDERR,"' already loaded.\n");
246
+ return -1;
247
+ }
248
+
249
+ /*===========================*/
250
+ /*Store the file entry topics*/
251
+ /*===========================*/
252
+ line_ct = 0;
253
+ entries_ct = 0;
254
+
255
+ INFO_BEGIN = false;
256
+ INFO_END = true;
257
+ while (fgets(str,256,fp) != NULL)
258
+ {
259
+ line_ct++;
260
+
261
+ /*=============================================================*/
262
+ /*Forces the load function to ignore lines beginning with `$$' */
263
+ /*=============================================================*/
264
+
265
+ if ((str[0] != LIT_DELIM) || (str[1] != LIT_DELIM))
266
+ {
267
+ if (findstr(str,EDELIM) >= 0)
268
+ {
269
+ if (INFO_BEGIN == true)
270
+ {
271
+ INFO_BEGIN = false;
272
+ INFO_END = true;
273
+ entries_ct++;
274
+ }
275
+ else
276
+ {
277
+ GenClose(theEnv,fp);
278
+ TextLookupToss(theEnv,file);
279
+ PrintErrorID(theEnv,"TEXTPRO",8,false);
280
+ WriteString(theEnv,STDERR,"Line ");
281
+ WriteInteger(theEnv,STDERR,line_ct);
282
+ WriteString(theEnv,STDERR," : Unmatched end marker.\n");
283
+ return(-1);
284
+ }
285
+ }
286
+ else if (findstr(str,BDELIM) >= 0)
287
+ {
288
+ if (INFO_END == true)
289
+ {
290
+ INFO_END = false;
291
+ INFO_BEGIN = true;
292
+ }
293
+ else
294
+ {
295
+ GenClose(theEnv,fp);
296
+ TextLookupToss(theEnv,file);
297
+
298
+ PrintErrorID(theEnv,"TEXTPRO",4,false);
299
+ WriteString(theEnv,STDERR,"Line ");
300
+ WriteInteger(theEnv,STDERR,line_ct);
301
+ WriteString(theEnv,STDERR," : Previous entry not closed.\n");
302
+
303
+ return(-1);
304
+ }
305
+
306
+ if ((enode=AllocateEntryNode(theEnv,fp,file,str,line_ct))==NULL)
307
+ return(-1);
308
+
309
+ /*=================================*/
310
+ /*Store new entry node in the tree */
311
+ /*=================================*/
312
+ if (AttachLeaf(theEnv,lnode,enode,fp,file,line_ct) == false)
313
+ return(-1);
314
+ }
315
+ }
316
+ }
317
+ GenClose(theEnv,fp);
318
+ if (INFO_END == false)
319
+ {
320
+ TextLookupToss(theEnv,file);
321
+
322
+ PrintErrorID(theEnv,"TEXTPRO",4,false);
323
+ WriteString(theEnv,STDERR,"Line ");
324
+ WriteInteger(theEnv,STDERR,line_ct);
325
+ WriteString(theEnv,STDERR," : Previous entry not closed.\n");
326
+
327
+ return(-1);
328
+ }
329
+ if (entries_ct == 0)
330
+ TextLookupToss(theEnv,file);
331
+ return(entries_ct);
332
+ }
333
+
334
+ /******************************************************************************/
335
+ /*FUNCTION UNLOAD : */
336
+ /* Input : 1) name of file to be taken off the lookup table */
337
+ /* Output : This functions deletes a file and all entry-topics associated with*/
338
+ /* it from the lookup table and returns a boolean flag indicating */
339
+ /* failure or success. */
340
+ /******************************************************************************/
341
+ static bool TextLookupToss(
342
+ Environment *theEnv,
343
+ const char *file)
344
+ {
345
+ struct lists *plptr, *clptr;
346
+ int l_flag;
347
+
348
+ clptr = TextProcessingData(theEnv)->headings;
349
+ plptr = clptr;
350
+ if (clptr != NULL)
351
+ if (strcmp(clptr->file,file) != 0)
352
+ l_flag = 1;
353
+ else
354
+ l_flag = 0;
355
+ else
356
+ l_flag = 0;
357
+ while (l_flag > 0)
358
+ {
359
+ plptr = clptr;
360
+ clptr = clptr->next;
361
+ if (clptr != NULL)
362
+ if (strcmp(clptr->file,file) != 0)
363
+ l_flag = 1;
364
+ else
365
+ l_flag = 0;
366
+ else
367
+ l_flag = 0;
368
+ }
369
+ if (clptr == NULL)
370
+ return false;
371
+
372
+ TossFunction(theEnv,clptr->topics);
373
+
374
+ if (plptr == clptr)
375
+ TextProcessingData(theEnv)->headings = clptr->next;
376
+ else
377
+ plptr->next = clptr->next;
378
+ rm(theEnv,clptr,sizeof(struct lists));
379
+ return true;
380
+ }
381
+
382
+ /******************************************************************************/
383
+ /*FUNCTION GET_ENTRIES : */
384
+ /* Input : 1) name of file to be accessed for lookup of entry */
385
+ /* 2) caller allocated buffer for main topic name */
386
+ /* 3) name of the entry to be accessed in the file */
387
+ /* 4) caller allocated buffer for a status code (see LOOKUP). */
388
+ /* Output : 1) returns a pointer into the stream of the lookup file which */
389
+ /* indicates the starting position of the lookup information */
390
+ /* (NULL if the topic was not found) */
391
+ /* This function passes its input directly to LOOKUP. See its description */
392
+ /* for further detail. */
393
+ /* */
394
+ /******************************************************************************/
395
+ static FILE *GetEntries(
396
+ Environment *theEnv,
397
+ const char *file,
398
+ char **menu,
399
+ char *name,
400
+ int *code)
401
+ {
402
+ FILE *fp; /*Lookup file stream*/
403
+ long offset; /*Offset from beginning of file to beginning of topic*/
404
+
405
+ offset = LookupEntry(theEnv,file,menu,name,code);
406
+ if (offset < 0)
407
+ return NULL;
408
+ fp = GenOpen(theEnv,file,OPEN_READ_BINARY);
409
+ if (fp == NULL)
410
+ {
411
+ *code = NO_FILE;
412
+ return NULL;
413
+ }
414
+ if (fseek(fp,offset,0) < 0)
415
+ {
416
+ GenClose(theEnv,fp);
417
+ *code = NO_FILE;
418
+ return NULL;
419
+ }
420
+ return(fp);
421
+ }
422
+
423
+ /******************************************************************************/
424
+ /*FUNCTION GET_CURR_MENU : */
425
+ /* Input : 1) name of file to be accessed */
426
+ /* 2) caller allocated buffer for the current menu name */
427
+ /* 3) caller allocated buffer for status code : NO_FILE, NO_TOPIC, or */
428
+ /* NORMAL. */
429
+ /* Output : 1) returns a pointer into the file stream indicating the beginning*/
430
+ /* of the description of the current menu for the named file */
431
+ /* (returns NULL if there is no current menu) */
432
+ /******************************************************************************/
433
+ static FILE *GetCurrentMenu(
434
+ Environment *theEnv,
435
+ const char *file,
436
+ int *status)
437
+ {
438
+ struct lists *lptr; /*Used in searching the file list*/
439
+ FILE *fp; /*File stream*/
440
+ int l_flag; /*Used in looping through the file list*/
441
+
442
+ /*=====================================*/
443
+ /*Find the named file in the file list */
444
+ /*=====================================*/
445
+ lptr = TextProcessingData(theEnv)->headings;
446
+ if (lptr != NULL)
447
+ if (strcmp(lptr->file,file) != 0)
448
+ l_flag = 1;
449
+ else
450
+ l_flag = 0;
451
+ else
452
+ l_flag = 0;
453
+ while (l_flag > 0)
454
+ {
455
+ lptr = lptr->next;
456
+ if (lptr != NULL)
457
+ if (strcmp(lptr->file,file) != 0)
458
+ l_flag = 1;
459
+ else
460
+ l_flag = 0;
461
+ else
462
+ l_flag = 0;
463
+ }
464
+ if (lptr == NULL)
465
+ {
466
+ *status = NO_FILE;
467
+ return NULL;
468
+ }
469
+
470
+ /*============================================================*/
471
+ /*Position the pointer in the file stream to the current menu */
472
+ /*============================================================*/
473
+ if (lptr->curr_menu == NULL)
474
+ {
475
+ *status = NO_TOPIC;
476
+ return NULL;
477
+ }
478
+ if ((fp = GenOpen(theEnv,file,OPEN_READ_BINARY)) == NULL)
479
+ {
480
+ *status = NO_FILE;
481
+ return NULL;
482
+ }
483
+ if (fseek(fp,lptr->curr_menu->offset,0) < 0)
484
+ {
485
+ GenClose(theEnv,fp);
486
+ *status = NO_FILE;
487
+ return NULL;
488
+ }
489
+ *status = NORMAL;
490
+ return(fp);
491
+ }
492
+
493
+ /******************************************************************************/
494
+ /*FUNCTION GrabString : */
495
+ /* Input : 1) file stream pointer */
496
+ /* 2) caller allocated buffer for storage of read string */
497
+ /* 3) size of caller's buffer */
498
+ /* Output : This function grabs a line of text from the currently opened */
499
+ /* lookup file at the given file position in the stream. If it */
500
+ /* encounters EOF or the closing topic delimeter, it closes the file */
501
+ /* and returns NULL. Otherwise, the return value is simply the */
502
+ /* address of the caller's buffer. */
503
+ /* */
504
+ /* Notes : 1) This function expects a file pointer into a stream of a file */
505
+ /* already opened!! */
506
+ /* 2) The caller must close the file himself if he wishes to */
507
+ /* prematurely abort the complete reading of an entry. */
508
+ /******************************************************************************/
509
+ static char *GrabString(
510
+ Environment *theEnv,
511
+ FILE *fp,
512
+ char *buf,
513
+ int bufsize)
514
+ {
515
+ if (fgets(buf,bufsize,fp) == NULL)
516
+ {
517
+ GenClose(theEnv,fp);
518
+ return NULL;
519
+ }
520
+ if ((buf[0] == LIT_DELIM) && (buf[1] == LIT_DELIM))
521
+ {
522
+ buf[0] = BLANK;
523
+ buf[1] = BLANK;
524
+ }
525
+ else if (findstr(buf,EDELIM) >= 0)
526
+ {
527
+ buf = NULL;
528
+ GenClose(theEnv,fp);
529
+ }
530
+ return(buf);
531
+ }
532
+
533
+ /**************************************************************************/
534
+ /*FINDSTR FUNCTION : */
535
+ /* Input : 1) string to be searched */
536
+ /* 2) string to be found */
537
+ /* Output : 1) returns index of string-1 where string-2 started, if found */
538
+ /* 2) returns -1, if not found */
539
+ /**************************************************************************/
540
+ static int findstr(
541
+ const char *s,
542
+ const char *t)
543
+ {
544
+ int i,j,k;
545
+
546
+ for (i = 0; s[i] != '\0'; i++)
547
+ {
548
+ for (j = i, k = 0; t[k] != '\0' && s[j] == t[k]; j++, k++) ;
549
+ if ((t[k] == '\0') && (k != 0))
550
+ return(i);
551
+ }
552
+ return(-1);
553
+ }
554
+
555
+ /**********************************************************************/
556
+ /*UPPER FUNCTION : */
557
+ /* Input : 1) alphanumeric string */
558
+ /* Output : 1) all alphabetic characters of string are capitalized */
559
+ /**********************************************************************/
560
+ static void upper(
561
+ char *str)
562
+ {
563
+ int theIndex;
564
+
565
+ for (theIndex = 0 ; str[theIndex] != NULLCHAR; theIndex++)
566
+ if (islower(str[theIndex])) str[theIndex] = (char) toupper(str[theIndex]);
567
+ }
568
+
569
+ /******************************************************************************/
570
+ /*FILE_NODE FUNCTION : */
571
+ /* Input : 1) name of a file */
572
+ /* Output : 1) returns address of an initalized NewFetchFile, if the file was */
573
+ /* not already on the lookup table */
574
+ /* 2) returns the null address, if the file was already present */
575
+ /******************************************************************************/
576
+ static struct lists *NewFetchFile(
577
+ Environment *theEnv,
578
+ const char *file)
579
+ {
580
+ struct lists *lptr = NULL, *lnode;
581
+
582
+ if (TextProcessingData(theEnv)->headings != NULL)
583
+ {
584
+ lptr = TextProcessingData(theEnv)->headings;
585
+ while (lptr->next != NULL)
586
+ {
587
+ if (strcmp(lptr->file,file) == 0)
588
+ return NULL;
589
+ lptr = lptr->next;
590
+ }
591
+ if (strcmp(lptr->file,file) == 0)
592
+ return NULL;
593
+ }
594
+ lnode = (struct lists *) gm2(theEnv,sizeof(struct lists));
595
+ genstrcpy(lnode->file,file);
596
+ lnode->topics = NULL;
597
+ lnode->curr_menu = NULL;
598
+ lnode->next = NULL;
599
+ if (TextProcessingData(theEnv)->headings == NULL)
600
+ TextProcessingData(theEnv)->headings = lnode;
601
+ else
602
+ lptr->next = lnode;
603
+ return(lnode);
604
+ }
605
+
606
+ /******************************************************************************/
607
+ /*ENTRIES_NODE FUNCTION : */
608
+ /* Input : 1) file pointer */
609
+ /* 2) file name */
610
+ /* 3) input string from the file */
611
+ /* 4) buffer for error messages */
612
+ /* 5) size of the error message buffer */
613
+ /* 6) line count in the file */
614
+ /* Output : */
615
+ /*This function scans the input string for the appropriate topic entry */
616
+ /*delimeter and, if it finds this to be correct, allocates a new entry node, */
617
+ /*and initializes it, and returns the address to the calling routine. If an */
618
+ /*error is detected, the function writes an appropriate message to the */
619
+ /*caller's buffer, deallocates the node, deletes all previous nodes from the */
620
+ /*current file from the lookup table, closes the file, and returns the null */
621
+ /*address. */
622
+ /******************************************************************************/
623
+ static struct entries *AllocateEntryNode(
624
+ Environment *theEnv,
625
+ FILE *fp,
626
+ const char *file,
627
+ const char *str,
628
+ int line_ct)
629
+ {
630
+ struct entries *enode;
631
+ char bmarker[BDLEN+1], /*Entry topic delimiting strings */
632
+ t_code[2]; /*Type of entry flag : menu or info */
633
+
634
+
635
+ /*================================================================*/
636
+ /*Allocate a new node and scan the delimeter string for tree info */
637
+ /*================================================================*/
638
+
639
+ enode = (struct entries *) gm2(theEnv,sizeof(struct entries));
640
+ if (sscanf(str,BFORMAT,
641
+ &enode->level,t_code,bmarker,enode->name) != 4)
642
+ {
643
+ rm(theEnv,enode,sizeof(struct entries));
644
+ GenClose(theEnv,fp);
645
+ TextLookupToss(theEnv,file);
646
+
647
+ PrintErrorID(theEnv,"TEXTPRO",5,false);
648
+ WriteString(theEnv,STDERR,"Line ");
649
+ WriteInteger(theEnv,STDERR,line_ct);
650
+ WriteString(theEnv,STDERR," : Invalid delimeter string.\n");
651
+
652
+ return NULL;
653
+ }
654
+ if (t_code[0] == 'M')
655
+ enode->type = MENU;
656
+ else if (t_code[0] == 'I')
657
+ enode->type = INFO;
658
+ else
659
+ {
660
+ rm(theEnv,enode,sizeof(struct entries));
661
+ GenClose(theEnv,fp);
662
+ TextLookupToss(theEnv,file);
663
+
664
+ PrintErrorID(theEnv,"TEXTPRO",6,false);
665
+ WriteString(theEnv,STDERR,"Line ");
666
+ WriteInteger(theEnv,STDERR,line_ct);
667
+ WriteString(theEnv,STDERR," : Invalid entry type.\n");
668
+
669
+ return NULL;
670
+ }
671
+ if (strcmp(bmarker,BDELIM) != 0)
672
+ {
673
+ rm(theEnv,enode,sizeof(struct entries));
674
+ GenClose(theEnv,fp);
675
+ TextLookupToss(theEnv,file);
676
+
677
+ PrintErrorID(theEnv,"TEXTPRO",5,false);
678
+ WriteString(theEnv,STDERR,"Line ");
679
+ WriteInteger(theEnv,STDERR,line_ct);
680
+ WriteString(theEnv,STDERR," : Invalid delimeter string.\n");
681
+
682
+ return NULL;
683
+ }
684
+
685
+ /*===============================================================*/
686
+ /* For systems which have record file systems (such as VMS), */
687
+ /* the following statement is necessary to move the file pointer */
688
+ /* to the beginning of the next record. */
689
+ /*===============================================================*/
690
+
691
+ ungetc(getc(fp),fp);
692
+
693
+ enode->offset = ftell(fp);
694
+ enode->parent = NULL;
695
+ enode->child = NULL;
696
+ enode->next = NULL;
697
+ upper(enode->name);
698
+
699
+ return(enode);
700
+ }
701
+
702
+ /******************************************************************************/
703
+ /*FUNCTION ATTACH_LEAF : */
704
+ /* Input : 1) address of current NewFetchFile */
705
+ /* 2) address of current topic entry-node */
706
+ /* 3) file pointer */
707
+ /* 4) name of file */
708
+ /* 5) error message buffer */
709
+ /* 6) size of error message buffer */
710
+ /* 7) line count in the file */
711
+ /* Output : */
712
+ /*This function attaches the entry-node to its proper place in the tree of the*/
713
+ /*current file. The function returns a boolean flag indicating the success */
714
+ /*(or lack thereof) of this connection. In the case of an error, an error */
715
+ /*message is written to the caller's buffer, the file is closed, and the */
716
+ /*previous file entries are deleted from the lookup table. */
717
+ /******************************************************************************/
718
+ static bool AttachLeaf(
719
+ Environment *theEnv,
720
+ struct lists *lnode,
721
+ struct entries *enode,
722
+ FILE *fp,
723
+ const char *file,
724
+ int line_ct)
725
+ {
726
+ int p_flag; /*Used in searching the tree for a parent*/
727
+
728
+
729
+ /*====================*/
730
+ /*First topic for file*/
731
+ /*====================*/
732
+ if (lnode->topics == NULL)
733
+ lnode->topics = enode;
734
+
735
+ /*================================*/
736
+ /*Subtopic - branch down the tree */
737
+ /*================================*/
738
+ else if (enode->level > TextProcessingData(theEnv)->parent->level)
739
+ if (TextProcessingData(theEnv)->parent->type == MENU)
740
+ {
741
+ enode->parent = TextProcessingData(theEnv)->parent;
742
+ TextProcessingData(theEnv)->parent->child = enode;
743
+ }
744
+ else
745
+ {
746
+ rm(theEnv,enode,sizeof(struct entries));
747
+ GenClose(theEnv,fp);
748
+ TextLookupToss(theEnv,file);
749
+
750
+ PrintErrorID(theEnv,"TEXTPRO",7,false);
751
+ WriteString(theEnv,STDERR,"Line ");
752
+ WriteInteger(theEnv,STDERR,line_ct);
753
+ WriteString(theEnv,STDERR," : Non-menu entries cannot have subtopics.\n");
754
+
755
+ return false;
756
+ }
757
+ /*====================================*/
758
+ /*Brother-topic -- same level in tree */
759
+ /*====================================*/
760
+ else if (enode->level == TextProcessingData(theEnv)->parent->level)
761
+ {
762
+ enode->parent = TextProcessingData(theEnv)->parent->parent;
763
+ enode->next = TextProcessingData(theEnv)->parent->next;
764
+ TextProcessingData(theEnv)->parent->next = enode;
765
+ }
766
+
767
+ /*==========================================================*/
768
+ /*Topic is unrelated to previous topic - branch up the tree */
769
+ /*==========================================================*/
770
+ else
771
+ {
772
+ if (TextProcessingData(theEnv)->parent != NULL)
773
+ p_flag = 1;
774
+ else
775
+ p_flag = 0;
776
+ while (p_flag > 0)
777
+ {
778
+ TextProcessingData(theEnv)->parent = TextProcessingData(theEnv)->parent->parent;
779
+ if (TextProcessingData(theEnv)->parent != NULL)
780
+ if (enode->level < TextProcessingData(theEnv)->parent->level)
781
+ p_flag = 1;
782
+ else
783
+ p_flag = 0;
784
+ else
785
+ p_flag = 0;
786
+ }
787
+ if (TextProcessingData(theEnv)->parent != NULL)
788
+
789
+ /*========*/
790
+ /*Subtopic*/
791
+ /*========*/
792
+ if (TextProcessingData(theEnv)->parent->level < enode->level)
793
+ {
794
+ enode->parent = TextProcessingData(theEnv)->parent;
795
+ enode->next = TextProcessingData(theEnv)->parent->child;
796
+ TextProcessingData(theEnv)->parent->child = enode;
797
+ }
798
+
799
+ /*=============*/
800
+ /*Brother-topic*/
801
+ /*=============*/
802
+ else
803
+ {
804
+ enode->parent = TextProcessingData(theEnv)->parent->parent;
805
+ enode->next = TextProcessingData(theEnv)->parent->next;
806
+ TextProcessingData(theEnv)->parent->next = enode;
807
+ }
808
+
809
+ /*=========*/
810
+ /*Root Node*/
811
+ /*=========*/
812
+ else
813
+ {
814
+ enode->parent = NULL;
815
+ enode->next = lnode->topics;
816
+ lnode->topics = enode;
817
+ }
818
+ }
819
+ TextProcessingData(theEnv)->parent = enode;
820
+ return true;
821
+ }
822
+
823
+ /******************************************************************************/
824
+ /*FUNCTION LOOKUP : */
825
+ /* Input : 1) name of entry-topic file to be used for reference */
826
+ /* 2) caller allocated buffer to contain the main topic name */
827
+ /* 3) name of the entry-topic to be found */
828
+ /* 4) caller allocated buffer to store the return status */
829
+ /* Output : 1) offset from the beginning of the entry-topic file stream to the*/
830
+ /* beginning of the requested topic (-1 if the topic not found) */
831
+ /* 2) status code stored in caller's buffer indicating the result of */
832
+ /* the lookup : NO_FILE, NO_TOPIC, BRANCH_UP, BRANCH_DOWN, EXIT, */
833
+ /* or NORMAL. */
834
+ /* */
835
+ /* Notes : 1) If NULL is given as an entry-topic, the lookup routine branches */
836
+ /* up one level in the tree (status BRANCH_UP). If the current */
837
+ /* level of the tree is already the root, all paths are set to NULL*/
838
+ /* (status EXIT). */
839
+ /* 2) If an entry-topic is not found, the file position of the current*/
840
+ /* main topic (or menu) is returned (status NO_TOPIC). */
841
+ /******************************************************************************/
842
+ static long LookupEntry(
843
+ Environment *theEnv,
844
+ const char *file,
845
+ char **menu,
846
+ char *name,
847
+ int *code)
848
+ {
849
+ struct lists *lptr; /*Local pointers used to move through the tree*/
850
+ struct entries *eptr;
851
+ int l_flag, e_flag; /*Flags used in looping to find entry-topics*/
852
+
853
+ /*===============================*/
854
+ /*Find named file in lookup list */
855
+ /*===============================*/
856
+ lptr = TextProcessingData(theEnv)->headings;
857
+ if (lptr != NULL)
858
+ if (strcmp(lptr->file,file) != 0)
859
+ l_flag = 1;
860
+ else
861
+ l_flag = 0;
862
+ else
863
+ l_flag = 0;
864
+ while (l_flag > 0)
865
+ {
866
+ lptr = lptr->next;
867
+ if (lptr != NULL)
868
+ if (strcmp(lptr->file,file) != 0)
869
+ l_flag = 1;
870
+ else
871
+ l_flag = 0;
872
+ else
873
+ l_flag = 0;
874
+ }
875
+ if (lptr == NULL)
876
+ {
877
+ *code = NO_FILE;
878
+ return(-1);
879
+ }
880
+
881
+ /*==================================================================*/
882
+ /*If entry-topic was NULL, branch up one-level in the tree, or exit */
883
+ /*the tree if already at the root. */
884
+ /*==================================================================*/
885
+ if (name == NULL)
886
+ {
887
+ if (lptr->curr_menu == NULL)
888
+ {
889
+ *code = EXIT;
890
+ return(-1);
891
+ }
892
+ else
893
+ {
894
+ if (lptr->curr_menu->parent == NULL)
895
+ {
896
+ *code = EXIT;
897
+ lptr->curr_menu = NULL;
898
+ *menu = NULL;
899
+ return(-1);
900
+ }
901
+ lptr->curr_menu = lptr->curr_menu->parent;
902
+ *code = BRANCH_UP;
903
+ *menu = lptr->curr_menu->name;
904
+ return(lptr->curr_menu->offset);
905
+ }
906
+ }
907
+
908
+ /*========================================*/
909
+ /*Find the topic in the file's topic tree */
910
+ /*========================================*/
911
+ upper(name);
912
+ if (lptr->curr_menu != NULL)
913
+ eptr = lptr->curr_menu->child;
914
+ else
915
+ eptr = lptr->topics;
916
+ if (eptr != NULL)
917
+ if (findstr(eptr->name,name) == 0)
918
+ e_flag = 0;
919
+ else
920
+ e_flag = 1;
921
+ else
922
+ e_flag = 0;
923
+ while (e_flag > 0)
924
+ {
925
+ eptr = eptr->next;
926
+ if (eptr != NULL)
927
+ if (findstr(eptr->name,name) == 0)
928
+ e_flag = 0;
929
+ else
930
+ e_flag = 1;
931
+ else
932
+ e_flag = 0;
933
+ }
934
+
935
+ /*===================================================================*/
936
+ /*If the topic was not found, return the position of the current menu*/
937
+ /*===================================================================*/
938
+ if (eptr == NULL)
939
+ {
940
+ *code = NO_TOPIC;
941
+ if (lptr->curr_menu != NULL)
942
+ {
943
+ *menu = lptr->curr_menu->name;
944
+ return(lptr->curr_menu->offset);
945
+ }
946
+ return(-1);
947
+ }
948
+
949
+ /*===============================================================*/
950
+ /*If the requested topic has children, branch down to its level. */
951
+ /*===============================================================*/
952
+ if (eptr->type == MENU)
953
+ {
954
+ *code = BRANCH_DOWN;
955
+ lptr->curr_menu = eptr;
956
+ }
957
+ else
958
+ *code = NORMAL;
959
+
960
+ if (lptr->curr_menu != NULL)
961
+ *menu = lptr->curr_menu->name;
962
+ return(eptr->offset);
963
+ }
964
+
965
+ /******************************************************************************/
966
+ /*FUNCTION TOSS : */
967
+ /* Input : 1) entry-topic address */
968
+ /* Output : This function recursively deletes a node and all child nodes */
969
+ /******************************************************************************/
970
+ static void TossFunction(
971
+ Environment *theEnv,
972
+ struct entries *eptr)
973
+ {
974
+ struct entries *prev;
975
+
976
+ while (eptr != NULL)
977
+ {
978
+ if (eptr->child != NULL)
979
+ TossFunction(theEnv,eptr->child);
980
+ prev = eptr;
981
+ eptr = eptr->next;
982
+ rm(theEnv,prev,sizeof(struct entries));
983
+ }
984
+ }
985
+
986
+
987
+ /****************************************************************************/
988
+ /****************************************************************************/
989
+ /* TEXT PROCESSING FUNCTIONS */
990
+ /* */
991
+ /* The functions contained in this file can be called to handle */
992
+ /* external file referencing and accessing. FetchCommand() loads a file */
993
+ /* onto an internal run-time lookup table, TossCommand() removes the file, */
994
+ /* PrintRegionCommand accesses the loaded file to display a requested */
995
+ /* entry, and HelpFunction() provides an on-line help facility */
996
+ /* using the external help data file specified in the header file setup.h. */
997
+ /* For information on the format of the data file(s) required, see the */
998
+ /* internal documentation in LOOKUP.C and the external documentation. */
999
+ /* */
1000
+ /* For usage of these functions, see the external documentation. */
1001
+ /****************************************************************************/
1002
+ /****************************************************************************/
1003
+
1004
+ #define SCREEN_LN 22 /*Typical terminal screen length -- 22 lines*/
1005
+ /*Used for scrolling in the help facility */
1006
+
1007
+ /*==========================================*/
1008
+ /*Topic node for help facility's query list */
1009
+ /*==========================================*/
1010
+ struct topics
1011
+ {
1012
+ char name[NAMESIZE]; /*Name of the node */
1013
+ struct topics *end_list; /*Pointer to end of query list */
1014
+ struct topics *next; /*Pointer to next topic in the list*/
1015
+ };
1016
+
1017
+ /******************************************************************************/
1018
+ /*============================================================================*/
1019
+ /* FUNCTION DECLARATIONS */
1020
+ /*============================================================================*/
1021
+ /******************************************************************************/
1022
+
1023
+ static struct topics *GetCommandLineTopics(UDFContext *);
1024
+ static FILE *FindTopicInEntries(Environment *,const char *,struct topics *,char **,int *);
1025
+
1026
+ /******************************************************************************/
1027
+ /*============================================================================*/
1028
+ /* EXTERNAL ACCESS FUNCTIONS */
1029
+ /*============================================================================*/
1030
+ /******************************************************************************/
1031
+
1032
+ #if TEXTPRO_FUNCTIONS
1033
+
1034
+ /***************************************************************************/
1035
+ /*FUNCTION FetchCommand : (H/L function fetch) */
1036
+ /* Input : Name of the file to be stored in the lookup table - passed via */
1037
+ /* the argument "stack" and result buffer */
1038
+ /* Output : This function loads a file into the internal lookup table and */
1039
+ /* returns a (float) boolean flag indicating failure or success. */
1040
+ /***************************************************************************/
1041
+ void FetchCommand(
1042
+ Environment *theEnv,
1043
+ UDFContext *context,
1044
+ UDFValue *returnValue)
1045
+ {
1046
+ int load_ct; /*Number of entries loaded */
1047
+ UDFValue theArg;
1048
+
1049
+ returnValue->lexemeValue = FalseSymbol(theEnv);
1050
+
1051
+ if (! UDFFirstArgument(context,LEXEME_BITS,&theArg))
1052
+ { return; }
1053
+
1054
+ load_ct = TextLookupFetch(theEnv,theArg.lexemeValue->contents);
1055
+ if (load_ct <= 0)
1056
+ {
1057
+ if (load_ct == 0)
1058
+ {
1059
+ PrintErrorID(theEnv,"TEXTPRO",3,false);
1060
+ WriteString(theEnv,STDERR,"No entries found.\n");
1061
+ }
1062
+
1063
+ return;
1064
+ }
1065
+
1066
+ returnValue->integerValue = CreateInteger(theEnv,load_ct);
1067
+ }
1068
+
1069
+ /******************************************************************************/
1070
+ /*FUNCTION PrintRegionCommand : (H/L function print-region) */
1071
+ /* Input : Via the argument "stack", logical name for the output, the name of the */
1072
+ /* file to be accessed, and the name of the topic(s) to be looked up. */
1073
+ /* Output : This function accesses a previously loaded file and prints the */
1074
+ /* information of the topic entry requested to the screen. The tree */
1075
+ /* structure must currently be at the correct level in order for the */
1076
+ /* topic to be accessed. To branch down the tree, each topic in the */
1077
+ /* path to the one desired must be named. Multiple arguments are */
1078
+ /* allowed as in the help facility (see the external documentation.) */
1079
+ /* To branch up the tree, the special topic character `^' must be */
1080
+ /* specified for each upwards branch. Giving no topic name will */
1081
+ /* cause a single branch-up in the tree. The `?' character given at */
1082
+ /* the end of a path will return the current main topic menu. */
1083
+ /* */
1084
+ /* For usage, see the external documentation. */
1085
+ /******************************************************************************/
1086
+ void PrintRegionCommand(
1087
+ Environment *theEnv,
1088
+ UDFContext *context,
1089
+ UDFValue *returnValue)
1090
+ {
1091
+ struct topics *params, /*Lookup file and list of topic requests */
1092
+ *tptr; /*Used in deallocating the parameter list */
1093
+ char buf[256]; /*Buffer for the topic entry strings */
1094
+ FILE *fp; /*Stream for the input file */
1095
+ char *menu[1]; /*Buffer for the current menu name */
1096
+ int status; /*Lookup status return code */
1097
+ bool com_code; /*Completion flag */
1098
+
1099
+ params = GetCommandLineTopics(context);
1100
+ fp = FindTopicInEntries(theEnv,params->next->name,params->next->next,menu,&status);
1101
+ if ((status != NO_FILE) && (status != NO_TOPIC) && (status != EXIT))
1102
+ {
1103
+ if (strcmp(params->name,"t") == 0)
1104
+ genstrcpy(params->name,STDOUT);
1105
+ WriteString(theEnv,params->name,"\n");
1106
+ while (GrabString(theEnv,fp,buf,256) != NULL)
1107
+ WriteString(theEnv,params->name,buf);
1108
+ com_code = true;
1109
+ }
1110
+ else
1111
+ {
1112
+ /* ==================================================================
1113
+ On NO_TOPIC results, the file is left open to point to the current
1114
+ menu. This used as a check by the Help System. In the case of
1115
+ print-region, however, we need to always make sure the file is
1116
+ closed.
1117
+ ================================================================== */
1118
+ if (fp != NULL)
1119
+ GenClose(theEnv,fp);
1120
+ com_code = false;
1121
+ }
1122
+
1123
+ /* =======================================================
1124
+ Release any space used by the user's topic request list
1125
+ ======================================================= */
1126
+ while (params != NULL)
1127
+ {
1128
+ tptr = params;
1129
+ params = params->next;
1130
+ rm(theEnv,tptr,sizeof(struct topics));
1131
+ }
1132
+
1133
+ returnValue->lexemeValue = CreateBoolean(theEnv,com_code);
1134
+ }
1135
+
1136
+ /***********************************************/
1137
+ /* GetRegionCommand : (H/L functionget-region) */
1138
+ /***********************************************/
1139
+ void GetRegionCommand(
1140
+ Environment *theEnv,
1141
+ UDFContext *context,
1142
+ UDFValue *returnValue)
1143
+ {
1144
+ struct topics *params, /*Lookup file and list of topic requests */
1145
+ *tptr; /*Used in deallocating the parameter list */
1146
+ char buf[256]; /*Buffer for the topic entry strings */
1147
+ FILE *fp; /*Stream for the input file */
1148
+ char *menu[1]; /*Buffer for the current menu name */
1149
+ int status; /*Lookup status return code */
1150
+ char *theString = NULL;
1151
+ size_t oldPos = 0;
1152
+ size_t oldMax = 0;
1153
+ size_t sLength;
1154
+
1155
+ params = GetCommandLineTopics(context);
1156
+ fp = FindTopicInEntries(theEnv,params->name,params->next,menu,&status);
1157
+ if ((status != NO_FILE) && (status != NO_TOPIC) && (status != EXIT))
1158
+ {
1159
+ while (GrabString(theEnv,fp,buf,256) != NULL)
1160
+ theString = AppendToString(theEnv,buf,theString,&oldPos,&oldMax);
1161
+ }
1162
+ else
1163
+ {
1164
+ /* ==================================================================
1165
+ On NO_TOPIC results, the file is left open to point to the current
1166
+ menu. This used as a check by the Help System. In the case of
1167
+ print-region, however, we need to always make sure the file is
1168
+ closed.
1169
+ ================================================================== */
1170
+ if (fp != NULL)
1171
+ GenClose(theEnv,fp);
1172
+ }
1173
+
1174
+ /* =======================================================
1175
+ Release any space used by the user's topic request list
1176
+ ======================================================= */
1177
+ while (params != NULL)
1178
+ {
1179
+ tptr = params;
1180
+ params = params->next;
1181
+ rm(theEnv,tptr,sizeof(struct topics));
1182
+ }
1183
+
1184
+ if (theString == NULL)
1185
+ { returnValue->lexemeValue = CreateString(theEnv,""); }
1186
+ else
1187
+ {
1188
+ sLength = strlen(theString);
1189
+ if ((sLength > 0) &&
1190
+ (((theString[sLength-1] == '\r') && (theString[sLength-2] == '\n'))
1191
+ ||
1192
+ ((theString[sLength-1] == '\n') && (theString[sLength-2] == '\r'))))
1193
+ { theString[sLength-2] = 0; }
1194
+ returnValue->lexemeValue = CreateString(theEnv,theString);
1195
+ }
1196
+
1197
+ if (theString != NULL)
1198
+ { genfree(theEnv,theString,oldMax); }
1199
+ }
1200
+
1201
+ /***************************************************************************/
1202
+ /*FUNCTION TossCommand : (H/L function toss) */
1203
+ /* Input : Name of the file to be deleted from the lookup table (passed via*/
1204
+ /* the argument "stack") */
1205
+ /* Output : This function deletes the named file from the lookup table and */
1206
+ /* returns a (float) boolean flag indicating failure or success. */
1207
+ /***************************************************************************/
1208
+ void TossCommand(
1209
+ Environment *theEnv,
1210
+ UDFContext *context,
1211
+ UDFValue *returnValue)
1212
+ {
1213
+ const char *file; /*Name of the file */
1214
+ UDFValue theArg;
1215
+
1216
+ if (! UDFFirstArgument(context,LEXEME_BITS,&theArg))
1217
+ { return; }
1218
+
1219
+ file = theArg.lexemeValue->contents;
1220
+
1221
+ returnValue->lexemeValue = CreateBoolean(theEnv,TextLookupToss(theEnv,file));
1222
+ }
1223
+
1224
+ #endif
1225
+
1226
+ /******************************************************************************/
1227
+ /*============================================================================*/
1228
+ /* INTERNAL ROUTINES */
1229
+ /*============================================================================*/
1230
+ /******************************************************************************/
1231
+
1232
+ /******************************************************************************/
1233
+ /*FUNCTION CMD_LINE_TOPICS : */
1234
+ /* Input : None */
1235
+ /* Output : This function builds a linked list of topics requested by the */
1236
+ /* user at the H/L level using the argument "stack" routines, */
1237
+ /* num_args() and rstring(). It returns the address of the top of */
1238
+ /* the list or NULL if there were no command line topics. */
1239
+ /******************************************************************************/
1240
+ static struct topics *GetCommandLineTopics(
1241
+ UDFContext *context)
1242
+ {
1243
+ struct topics *head, /* Address of the top of the topic list */
1244
+ *tnode, /* Address of new topic node */
1245
+ *tptr; /* Used to attach new node to the list */
1246
+ UDFValue val; /* Unknown-type H/L data structure */
1247
+ Environment *theEnv = context->environment;
1248
+
1249
+ head = NULL;
1250
+
1251
+ while (UDFHasNextArgument(context))
1252
+ {
1253
+ tnode = (struct topics *) gm2(theEnv,sizeof(struct topics));
1254
+
1255
+ UDFNextArgument(context,ANY_TYPE_BITS,&val);
1256
+
1257
+ if ((val.header->type == SYMBOL_TYPE) || (val.header->type == STRING_TYPE))
1258
+ genstrncpy(tnode->name,val.lexemeValue->contents,NAMESIZE-1);
1259
+ else if (val.header->type == FLOAT_TYPE)
1260
+ genstrncpy(tnode->name,FloatToString(theEnv,val.floatValue->contents),NAMESIZE-1);
1261
+ else if (val.header->type == INTEGER_TYPE)
1262
+ genstrncpy(tnode->name,LongIntegerToString(theEnv,val.integerValue->contents),NAMESIZE-1);
1263
+ else
1264
+ genstrncpy(tnode->name,"***ERROR***",NAMESIZE-1);
1265
+
1266
+ tnode->next = NULL;
1267
+ tnode->end_list = NULL;
1268
+ if (head == NULL)
1269
+ head = tnode;
1270
+ else
1271
+ {
1272
+ tptr = head;
1273
+ while (tptr->next != NULL)
1274
+ tptr = tptr->next;
1275
+ tptr->next = tnode;
1276
+ }
1277
+ }
1278
+ return(head);
1279
+ }
1280
+
1281
+ /******************************************************************************/
1282
+ /*FUNCTION FIND_TOPIC : */
1283
+ /* Input : 1) File to be searched for topic request */
1284
+ /* 2) Address of topic request list */
1285
+ /* 3) Buffer for current menu name */
1286
+ /* 4) Lookup status return code */
1287
+ /* Output : This function flows through the user topic request path by */
1288
+ /* calling the lookup routines. When it reaches the last element, */
1289
+ /* it returns a pointer into the stream of the lookup file */
1290
+ /* indicating the beginning of the topic entry. If any topic in the */
1291
+ /* path is not found, the function aborts and returns the address of */
1292
+ /* of the current menu in the lookup tree for the file. The exact */
1293
+ /* nature of the final lookup is indicated in the status buffer. */
1294
+ /******************************************************************************/
1295
+ static FILE *FindTopicInEntries(
1296
+ Environment *theEnv,
1297
+ const char *file,
1298
+ struct topics *main_topic,
1299
+ char **menu,
1300
+ int *status)
1301
+ {
1302
+ FILE *fp = NULL; /*Input file stream */
1303
+ struct topics *tptr, /*Used to loop through the topic list */
1304
+ *end_list; /*Address of the end of the topic list */
1305
+
1306
+ if (main_topic != NULL)
1307
+ end_list = main_topic->end_list;
1308
+ else
1309
+ end_list = NULL;
1310
+ tptr = main_topic;
1311
+ if (tptr != end_list)
1312
+ do
1313
+ {
1314
+ if (fp != NULL)
1315
+ GenClose(theEnv,fp);
1316
+
1317
+ /*======================*/
1318
+ /*Branch up in the tree */
1319
+ /*======================*/
1320
+ if (strcmp(tptr->name,"^") == 0)
1321
+ fp = GetEntries(theEnv,file,menu,NULL,status);
1322
+
1323
+ /*=======================================================*/
1324
+ /*Return the current main topic menu of the lookup table */
1325
+ /*=======================================================*/
1326
+ else if ((strcmp(tptr->name,"?") == 0) && (tptr->next == end_list))
1327
+ fp = GetCurrentMenu(theEnv,file,status);
1328
+
1329
+ /*=====================*/
1330
+ /*Lookup topic request */
1331
+ /*=====================*/
1332
+ else
1333
+ fp = GetEntries(theEnv,file,menu,tptr->name,status);
1334
+
1335
+ if ((*status == NO_FILE) || (*status == NO_TOPIC))
1336
+ break;
1337
+ tptr = tptr->next;
1338
+ } while (tptr != end_list);
1339
+ else
1340
+ /*==================================================================*/
1341
+ /*An empty topic request list causes a single branch-up in the tree */
1342
+ /*==================================================================*/
1343
+ fp = GetEntries(theEnv,file,menu,NULL,status);
1344
+
1345
+ return(fp);
1346
+ }
1347
+
1348
+ /*******************************************/
1349
+ /* HelpFunctionDefinitions: */
1350
+ /*******************************************/
1351
+ void HelpFunctionDefinitions(
1352
+ Environment *theEnv)
1353
+ {
1354
+ AllocateEnvironmentData(theEnv,TEXTPRO_DATA,sizeof(struct textProcessingData),DeallocateTextProcessingData);
1355
+ #if ! RUN_TIME
1356
+ #if TEXTPRO_FUNCTIONS
1357
+ AddUDF(theEnv,"fetch","bl",1,1,"sy",FetchCommand,"FetchCommand",NULL);
1358
+ AddUDF(theEnv,"toss","b",1,1,"sy",TossCommand,"TossCommand",NULL);
1359
+ AddUDF(theEnv,"print-region","b",2,UNBOUNDED,"*;y;sy",PrintRegionCommand,"PrintRegionCommand",NULL);
1360
+ AddUDF(theEnv,"get-region","s",1,UNBOUNDED,"*;sy",GetRegionCommand,"GetRegionCommand", NULL);
1361
+ #endif
1362
+ #endif
1363
+ }
1364
+
1365
+ /*********************************************************/
1366
+ /* DeallocateTextProcessingData: Deallocates environment */
1367
+ /* data for text processing routines. */
1368
+ /*********************************************************/
1369
+ static void DeallocateTextProcessingData(
1370
+ Environment *theEnv)
1371
+ {
1372
+ struct lists *nextptr, *clptr;
1373
+
1374
+ clptr = TextProcessingData(theEnv)->headings;
1375
+ while (clptr != NULL)
1376
+ {
1377
+ nextptr = clptr->next;
1378
+
1379
+ TossFunction(theEnv,clptr->topics);
1380
+ rm(theEnv,clptr,sizeof(struct lists));
1381
+
1382
+ clptr = nextptr;
1383
+ }
1384
+ }
1385
+
1386
+
1387
+ #endif
1388
+