Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

734 lines
19 KiB

  1. //
  2. // bsc.c -- manage queries on the database
  3. //
  4. // Copyright <C> 1988, Microsoft Corporation
  5. //
  6. // Revision History:
  7. //
  8. //
  9. #include <stdio.h>
  10. #include <io.h>
  11. #include <fcntl.h>
  12. #include <string.h>
  13. #include <stddef.h>
  14. #define LINT_ARGS
  15. #if defined(OS2)
  16. #define INCL_NOCOMMON
  17. #define INCL_DOSPROCESS
  18. #define INCL_DOSSEMAPHORES
  19. #define INCL_DOSFILEMGR
  20. #define INCL_DOSERRORS
  21. #define INCL_DOSMISC
  22. #include <os2.h>
  23. #include <dos.h>
  24. #else
  25. #include <windows.h>
  26. #endif
  27. #include "hungary.h"
  28. #include "mbrcache.h"
  29. #include "version.h"
  30. #include "sbrbsc.h"
  31. #include "bsc.h"
  32. #define LISTALLOC 50 // Browser max list size
  33. // static data
  34. static FILEHANDLE fhBSC = (FILEHANDLE)(-1); // .BSC file handle
  35. static BYTE fCase; // TRUE for case compare
  36. static BYTE MaxSymLen; // longest symbol length
  37. static WORD ModCnt; // count of modules
  38. static ISYM Unknown; // UNKNOWN symbol index
  39. static WORD ModSymCnt; // count of modsyms
  40. static WORD SymCnt; // count of symbols
  41. static WORD PropCnt; // count of properties
  42. static DWORD RefCnt; // count of references
  43. static WORD DefCnt; // count of definitions
  44. static WORD CalCnt; // count of calls
  45. static WORD CbyCnt; // count of called bys
  46. static WORD lastAtomPage; // last atom page #
  47. static WORD lastAtomCnt; // last atom page size
  48. static WORD cbModSymCnt; // size of list of modsyms
  49. static WORD cbSymCnt; // size of list of symbols
  50. static WORD cbPropCnt; // size of list of properties
  51. static WORD cbRefCnt; // size of list of references
  52. static WORD cbDefCnt; // size of list of definitions
  53. static WORD cbCalCnt; // size of list of calls
  54. static WORD cbCbyCnt; // size of list of called bys
  55. static WORD MaxModSymCnt; // max list of modsyms
  56. static WORD MaxSymCnt; // max list of symbols
  57. static WORD MaxPropCnt; // max list of properties
  58. static WORD MaxRefCnt; // max list of references
  59. static WORD MaxDefCnt; // max list of references
  60. static WORD MaxCalCnt; // max list of calls
  61. static WORD MaxCbyCnt; // max list of called bys
  62. static DWORD lbModSymList; // modsym list file start
  63. static DWORD lbSymList; // symbol list file start
  64. static DWORD lbPropList; // property list file start
  65. static DWORD lbRefList; // reference list file start
  66. static DWORD lbDefList; // def'n list file start
  67. static DWORD lbCalList; // calls list file start
  68. static DWORD lbCbyList; // call bys list file start
  69. static DWORD lbSbrList; // sbr list file start
  70. static DWORD lbAtomCache; // atom cache file start
  71. static WORD CurModSymPage = 0; // Current page of modsyms
  72. static WORD CurSymPage = 0; // Current page of symbols
  73. static WORD CurPropPage = 0; // Current page of properties
  74. static WORD CurRefPage = 0; // Current page of references
  75. static WORD CurDefPage = 0; // Current page of definitions
  76. static WORD CurCalPage = 0; // Current page of calls
  77. static WORD CurCbyPage = 0; // Current page of called bys
  78. static LSZ lszBSCName = NULL; // name of .bsc file
  79. static MODLIST far *pfModList = NULL; // module list cache start
  80. static MODSYMLIST far *pfModSymList = NULL; // modsym list cache start
  81. static SYMLIST far *pfSymList = NULL; // symbol list cache start
  82. static PROPLIST far *pfPropList = NULL; // property list cache start
  83. static REFLIST far *pfRefList = NULL; // reference list cache start
  84. static REFLIST far *pfDefList = NULL; // def'n list cache start
  85. static USELIST far *pfCalList = NULL; // calls list cache start
  86. static USELIST far *pfCbyList = NULL; // call bys list cache start
  87. static WORD AtomPageTblMac = 0; // last cache page used
  88. static CACHEPAGE AtomPageTbl[MAXATOMPAGETBL]; // Atom Cache table
  89. #define bMOD(imod) (pfModList[imod])
  90. #define bMODSYM(isym) (pfModSymList[isym])
  91. #define bSYM(isym) (pfSymList[isym])
  92. #define bPROP(iprop) (pfPropList[iprop])
  93. #define bREF(iref) (pfRefList[iref])
  94. #define bDEF(idef) (pfDefList[idef])
  95. #define bCAL(iuse) (pfCalList[iuse])
  96. #define bCBY(iuse) (pfCbyList[iuse])
  97. #define bUSE(iuse) (pfCalList[iuse])
  98. #define bUBY(iuse) (pfCbyList[iuse])
  99. // prototypes
  100. //
  101. #define BSCIn(v) ReadBSC(&v, sizeof(v));
  102. static VOID GetBSC (DWORD lpos, LPV lpv, WORD cb);
  103. static VOID ReadBSC(LPV lpv, WORD cb);
  104. static WORD SwapPAGE (DWORD, LPV, WORD, WORD, WORD *, DWORD);
  105. static LPCH GetAtomCache (WORD);
  106. static VOID
  107. ReadBSC(LPV lpv, WORD cb)
  108. // read a block of data from the BSC file
  109. //
  110. {
  111. if (BSCRead(fhBSC, lpv, cb) != cb)
  112. ReadError(lszBSCName);
  113. }
  114. static VOID
  115. GetBSC(DWORD lpos, LPV lpv, WORD cb)
  116. // Read a block of the specified size from the specified position
  117. //
  118. {
  119. #if defined (OS2)
  120. if (BSCSeek(fhBSC, lpos, SEEK_SET) == -1)
  121. #else
  122. if (BSCSeek(fhBSC, lpos, FILE_BEGIN) == -1)
  123. SeekError(lszBSCName);
  124. #endif
  125. if (BSCRead(fhBSC, lpv, cb) != cb)
  126. ReadError(lszBSCName);
  127. }
  128. static WORD
  129. SwapPAGE (DWORD lbuflist, LPV pfTABLE, WORD tblsiz,
  130. /* */ WORD lstsiz, WORD * pcurpage, DWORD idx)
  131. //
  132. //
  133. // SwapPAGE - Swap in the table page for the table pfTABLE[idx]
  134. // and return the table's new index in the page.
  135. {
  136. WORD page;
  137. WORD newidx;
  138. page = (WORD)(idx / lstsiz);
  139. newidx = (WORD)(idx % lstsiz);
  140. if (page == *pcurpage)
  141. return newidx;
  142. GetBSC(lbuflist+((long)tblsiz*(long)page), pfTABLE, tblsiz);
  143. *pcurpage = page;
  144. return newidx;
  145. }
  146. static WORD
  147. ModSymPAGE (IMOD imod)
  148. // Swap in the ModSym page for ModSym[imod]
  149. // return the ModSym's index in the page.
  150. //
  151. {
  152. return SwapPAGE (lbModSymList, pfModSymList,
  153. cbModSymCnt, MaxModSymCnt, &CurModSymPage, (IDX)imod);
  154. }
  155. static WORD
  156. SymPAGE (ISYM isym)
  157. // Swap in the Symbol page for symbol[isym]
  158. // return the Symbol's index in the page.
  159. //
  160. {
  161. return SwapPAGE (lbSymList, pfSymList,
  162. cbSymCnt, MaxSymCnt, &CurSymPage, (IDX)isym);
  163. }
  164. static WORD
  165. PropPAGE (IINST iinst)
  166. // Swap in the Property page for Property[idx]
  167. // return the Property's index in the page.
  168. //
  169. {
  170. return SwapPAGE (lbPropList, pfPropList,
  171. cbPropCnt, MaxPropCnt, &CurPropPage, (IDX)iinst);
  172. }
  173. static WORD
  174. RefPAGE (IREF iref)
  175. // Swap in the Reference page for Reference[idx]
  176. // return the Reference's index in the page.
  177. //
  178. {
  179. return SwapPAGE (lbRefList, pfRefList,
  180. cbRefCnt, MaxRefCnt, &CurRefPage, (IDX)iref);
  181. }
  182. static WORD
  183. DefPAGE (IDEF idef)
  184. // Swap in the Deference page for Definition[idef]
  185. // return the Definitions index in the page.
  186. //
  187. {
  188. return SwapPAGE (lbDefList, pfDefList,
  189. cbDefCnt, MaxDefCnt, &CurDefPage, (IDX)idef);
  190. }
  191. static WORD
  192. CalPAGE (IUSE iuse)
  193. // Swap in the Usage page for Usage[iuse] (cal/cby)
  194. // and return the Usage's index in the page.
  195. //
  196. {
  197. return SwapPAGE (lbCalList, pfCalList,
  198. cbCalCnt, MaxCalCnt, &CurCalPage, (IDX)iuse);
  199. }
  200. static WORD
  201. CbyPAGE (IUSE iuse)
  202. // Swap in the Usage page for Usage[iuse] (cal/cby)
  203. // and return the Usage's index in the page.
  204. //
  205. {
  206. return SwapPAGE (lbCbyList, pfCbyList,
  207. cbCbyCnt, MaxCbyCnt, &CurCbyPage, (IDX)iuse);
  208. }
  209. static LPCH
  210. GetAtomCache (WORD Page)
  211. // load the requested page into the cache
  212. //
  213. {
  214. register WORD ipg;
  215. WORD pagesize;
  216. LPCH pfAtomCsave;
  217. for (ipg = 0; ipg < AtomPageTblMac; ipg++) {
  218. if (AtomPageTbl[ipg].uPage == Page)
  219. return AtomPageTbl[ipg].pfAtomCache;
  220. }
  221. if (ipg != MAXATOMPAGETBL) {
  222. if (AtomPageTbl[ipg].pfAtomCache ||
  223. (AtomPageTbl[ipg].pfAtomCache = LpvAllocCb(ATOMALLOC)))
  224. AtomPageTblMac++;
  225. }
  226. pfAtomCsave = AtomPageTbl[AtomPageTblMac-1].pfAtomCache;
  227. for (ipg = AtomPageTblMac-1; ipg; ipg--)
  228. AtomPageTbl[ipg] = AtomPageTbl[ipg-1]; // move up
  229. AtomPageTbl[0].pfAtomCache = pfAtomCsave;
  230. AtomPageTbl[0].uPage = Page;
  231. if (Page == lastAtomPage)
  232. pagesize = lastAtomCnt;
  233. else
  234. pagesize = ATOMALLOC;
  235. GetBSC(lbAtomCache+ATOMALLOC*(long)Page,
  236. AtomPageTbl[0].pfAtomCache, pagesize);
  237. return AtomPageTbl[0].pfAtomCache;
  238. }
  239. LSZ BSC_API
  240. LszNameFrSym (ISYM isym)
  241. // Swap in the Atom page for the symbol isym
  242. // return the atom's address in the page.
  243. //
  244. {
  245. SYMLIST sym;
  246. sym = bSYM(isym);
  247. return GetAtomCache (sym.Page) + sym.Atom;
  248. }
  249. LSZ BSC_API
  250. LszNameFrMod (IMOD imod)
  251. // Swap in the Atom page for the module isym
  252. // return the atom's address in the page.
  253. //
  254. {
  255. return LszNameFrSym(bMOD(imod).ModName);
  256. }
  257. int BSC_API
  258. CaseCmp(LSZ lsz1, LSZ lsz2)
  259. //
  260. // think of lsz1 and lsz2 being in a list of things that are sorted
  261. // case insensitively and then case sensitively within that. This is
  262. // the case for browser symbols
  263. //
  264. // return -1, 0, or 1 if lsz1 before, at, or after lsz2 in the list
  265. //
  266. {
  267. int ret;
  268. // do case insensitive compare
  269. ret = _stricmp(lsz1, lsz2);
  270. // if this is good enough then use it, or if we are only doing
  271. // a case insensitive search then this is good enough
  272. if (ret || !fCase) return ret;
  273. // if we must, do the case sensitive compare
  274. return strcmp(lsz1, lsz2);
  275. }
  276. ISYM BSC_API
  277. IsymFrLsz (LSZ lszReqd)
  278. // find the symbol with the specifed name
  279. //
  280. {
  281. ISYM Lo, Hi, Mid;
  282. int Cmp;
  283. LSZ lszCur;
  284. Lo = 0;
  285. Hi = (ISYM)(SymCnt - 1);
  286. while (Lo <= Hi) {
  287. Mid = (ISYM)((Hi + Lo) / 2);
  288. lszCur = LszNameFrSym (Mid);
  289. Cmp = CaseCmp (lszReqd, lszCur);
  290. if (Cmp == 0)
  291. return Mid;
  292. if (Cmp < 0)
  293. Hi = (ISYM)(Mid - 1);
  294. else
  295. Lo = (ISYM)(Mid + 1);
  296. }
  297. return isymNil;
  298. }
  299. IMOD BSC_API
  300. ImodFrLsz (LSZ lszReqd)
  301. // find the module with the specifed name
  302. //
  303. {
  304. IMOD imod;
  305. for (imod = 0; imod < ModCnt; imod++) {
  306. if (_stricmp (lszReqd, LszNameFrSym (bMOD(imod).ModName)) == 0)
  307. return imod;
  308. }
  309. return imodNil;
  310. }
  311. ISYM BSC_API
  312. IsymMac()
  313. // return the biggest isym in this database
  314. //
  315. {
  316. return SymCnt;
  317. }
  318. IMOD BSC_API
  319. ImodMac()
  320. // return the biggest imod in this database
  321. //
  322. {
  323. return ModCnt;
  324. }
  325. IINST BSC_API
  326. IinstMac()
  327. // return the biggest iinst in this database
  328. //
  329. {
  330. return PropCnt;
  331. }
  332. VOID BSC_API
  333. MsRangeOfMod(IMOD imod, IMS *pimsFirst, IMS *pimsLast)
  334. // fill in the module information
  335. //
  336. {
  337. *pimsFirst = imod ? bMOD(imod-1).mSymEnd : 0;
  338. *pimsLast = bMOD(imod).mSymEnd;
  339. }
  340. IINST BSC_API
  341. IinstOfIms(IMS ims)
  342. // give the instance (PROP) index of the modsym
  343. //
  344. {
  345. return bMODSYM(ims).ModSymProp;
  346. }
  347. VOID BSC_API
  348. InstRangeOfSym(ISYM isym, IINST *piinstFirst, IINST *piinstLast)
  349. // fill in the range of inst values for this symbol
  350. //
  351. {
  352. *piinstFirst = isym ? bSYM(isym-1).PropEnd:0;
  353. *piinstLast = bSYM(isym).PropEnd;
  354. }
  355. VOID BSC_API
  356. InstInfo(IINST iinst, ISYM *pisymInst, TYP *pTyp, ATR *pAtr)
  357. // get the information that qualifies this instance
  358. //
  359. {
  360. *pisymInst = bPROP(iinst).PropName;
  361. *pAtr = bPROP(iinst).PropAttr & 0x3ff;
  362. *pTyp = (bPROP(iinst).PropAttr >> 11) & 0x1f;
  363. }
  364. VOID BSC_API
  365. RefRangeOfInst(IINST iinst, IREF *pirefFirst, IREF *pirefLast)
  366. // fill in the reference ranges from the inst
  367. //
  368. {
  369. *pirefFirst = iinst ? bPROP(iinst-1).RefEnd : 0;
  370. *pirefLast = bPROP(iinst).RefEnd;
  371. }
  372. VOID BSC_API
  373. DefRangeOfInst(IINST iinst, IDEF *pidefFirst, IDEF *pidefLast)
  374. // fill in the definition ranges from the inst
  375. //
  376. {
  377. *pidefFirst = iinst ? bPROP(iinst-1).DefEnd : 0;
  378. *pidefLast = bPROP(iinst).DefEnd;
  379. }
  380. VOID BSC_API
  381. UseRangeOfInst(IINST iinst, IUSE *piuseFirst, IUSE *piuseLast)
  382. // fill in the use ranges from the inst
  383. //
  384. {
  385. *piuseFirst = iinst ? bPROP(iinst-1).CalEnd : 0;
  386. *piuseLast = bPROP(iinst).CalEnd;
  387. }
  388. VOID BSC_API
  389. UbyRangeOfInst(IINST iinst, IUBY *piubyFirst, IUBY *piubyLast)
  390. // fill in the used by ranges from the inst
  391. //
  392. {
  393. *piubyFirst = iinst ? bPROP(iinst-1).CbyEnd : 0;
  394. *piubyLast = bPROP(iinst).CbyEnd;
  395. }
  396. VOID BSC_API
  397. UseInfo(IUSE iuse, IINST *piinst, WORD *pcnt)
  398. // fill in the information about this things which an inst uses
  399. //
  400. {
  401. *piinst = bUSE(iuse).UseProp;
  402. *pcnt = bUSE(iuse).UseCnt;
  403. }
  404. VOID BSC_API
  405. UbyInfo(IUBY iuby, IINST *piinst, WORD *pcnt)
  406. // fill in the information about this things which an inst is used by
  407. //
  408. {
  409. *piinst = bUBY(iuby).UseProp;
  410. *pcnt = bUBY(iuby).UseCnt;
  411. }
  412. VOID BSC_API
  413. RefInfo(IREF iref, LSZ *plszName, WORD *pline)
  414. // fill in the information about this reference
  415. //
  416. {
  417. *pline = bREF(iref).RefLin;
  418. *plszName = LszNameFrSym(bREF(iref).RefNam);
  419. }
  420. VOID BSC_API
  421. DefInfo(IDEF idef, LSZ *plszName, WORD *pline)
  422. // fill in the information about this definition
  423. //
  424. {
  425. *pline = bDEF(idef).RefLin;
  426. *plszName = LszNameFrSym(bDEF(idef).RefNam);
  427. }
  428. VOID BSC_API
  429. CloseBSC()
  430. // close database and free as much memory as possible
  431. //
  432. {
  433. int i;
  434. // close file if open
  435. if (fhBSC != (FILEHANDLE)(-1)) {
  436. BSCClose (fhBSC);
  437. fhBSC = (FILEHANDLE)(-1);
  438. }
  439. // free any memory we may have allocated
  440. if (pfModList) { FreeLpv (pfModList); pfModList = NULL; }
  441. if (pfModSymList) { FreeLpv (pfModSymList); pfModSymList = NULL; }
  442. if (pfSymList) { FreeLpv (pfSymList); pfSymList = NULL; }
  443. if (pfPropList) { FreeLpv (pfPropList); pfPropList = NULL; }
  444. if (pfRefList) { FreeLpv (pfRefList); pfRefList = NULL; }
  445. if (pfDefList) { FreeLpv (pfDefList); pfDefList = NULL; }
  446. if (pfCalList) { FreeLpv (pfCalList); pfCalList = NULL; }
  447. if (pfCbyList) { FreeLpv (pfCbyList); pfCbyList = NULL; }
  448. for (i=0; i < MAXATOMPAGETBL; i++) {
  449. if (AtomPageTbl[i].pfAtomCache) {
  450. FreeLpv (AtomPageTbl[i].pfAtomCache); // dispose Atom Cache
  451. AtomPageTbl[i].pfAtomCache = NULL;
  452. }
  453. }
  454. }
  455. BOOL BSC_API
  456. FOpenBSC (LSZ lszName)
  457. // Open the specified data base.
  458. // Allocate buffers for cache areas
  459. // Initialize the data cache from the data base.
  460. //
  461. // Return TRUE iff successful, FALSE if database can't be read
  462. //
  463. {
  464. WORD pagesize;
  465. BYTE MajorVer; // .bsc version (major)
  466. BYTE MinorVer; // .bsc version (minor)
  467. BYTE UpdatVer; // .bsc version (updat)
  468. WORD MaxModCnt; // max list of modules
  469. WORD cbModCnt; // size of list of modules
  470. DWORD lbModList; // module list file start
  471. int i;
  472. #define ABORT_OPEN CloseBSC(); return FALSE;
  473. lszBSCName = lszName;
  474. #if defined (OS2)
  475. fhBSC = BSCOpen(lszBSCName, O_BINARY|O_RDONLY);
  476. #else
  477. fhBSC = BSCOpen(lszBSCName, GENERIC_READ);
  478. #endif
  479. // if the .bsc file doesn't exist then we don't do any work
  480. // this is the cold compile case
  481. //
  482. if (fhBSC == (FILEHANDLE)(-1)) {ABORT_OPEN;}
  483. // read and check BSC version (major, minor and update)
  484. BSCIn(MajorVer);
  485. BSCIn(MinorVer);
  486. BSCIn(UpdatVer);
  487. BSCPrintf("Browser Data Base: %s ver %d.%d.%d\n\n",
  488. lszBSCName, MajorVer, MinorVer, UpdatVer);
  489. if ((MajorVer != BSC_MAJ) ||
  490. (MinorVer != BSC_MIN) ||
  491. (UpdatVer != BSC_UPD)) {
  492. CloseBSC();
  493. BadBSCVer(lszBSCName);
  494. return FALSE;
  495. }
  496. // read Case sense switch, max symbol length and Unknown module id
  497. BSCIn(fCase);
  498. BSCIn(MaxSymLen);
  499. BSCIn(Unknown);
  500. // this will make the formatting look more reasonable if there are
  501. // only very short names in the database
  502. if (MaxSymLen < 8 ) MaxSymLen = 8;
  503. // read counts (sizes) of each data area
  504. BSCIn(ModCnt);
  505. BSCIn(ModSymCnt);
  506. BSCIn(SymCnt);
  507. BSCIn(PropCnt);
  508. BSCIn(RefCnt);
  509. BSCIn(DefCnt);
  510. BSCIn(CalCnt);
  511. BSCIn(CbyCnt);
  512. BSCIn(lastAtomPage);
  513. BSCIn(lastAtomCnt);
  514. // read BSC data area offsets
  515. BSCIn(lbModList);
  516. BSCIn(lbModSymList);
  517. BSCIn(lbSymList);
  518. BSCIn(lbPropList);
  519. BSCIn(lbRefList);
  520. BSCIn(lbDefList);
  521. BSCIn(lbCalList);
  522. BSCIn(lbCbyList);
  523. BSCIn(lbAtomCache);
  524. BSCIn(lbSbrList);
  525. // determine data cache area sizes
  526. #define MIN(a,b) ((a)>(b) ? (b) : (a))
  527. MaxModCnt = ModCnt; // max list of modules
  528. MaxModSymCnt = ModSymCnt; // max list of modsyms
  529. MaxSymCnt = SymCnt+ModCnt; // max list of symbols
  530. MaxPropCnt = PropCnt; // max list of props
  531. MaxRefCnt = RefCnt; // max list of refs
  532. MaxDefCnt = DefCnt; // max list of defs
  533. MaxCalCnt = CalCnt; // max list of cals
  534. MaxCbyCnt = CbyCnt; // max list of cbys
  535. cbModCnt = sizeof(MODLIST) * MaxModCnt; // size of mods list
  536. cbModSymCnt = sizeof(MODSYMLIST) * MaxModSymCnt; // size of modsyms list
  537. cbSymCnt = sizeof(SYMLIST) * MaxSymCnt; // size of syms list
  538. cbPropCnt = sizeof(PROPLIST) * MaxPropCnt; // size of props list
  539. cbRefCnt = sizeof(REFLIST) * MaxRefCnt; // size of refs list
  540. cbDefCnt = sizeof(REFLIST) * MaxDefCnt; // size of defs list
  541. cbCalCnt = sizeof(USELIST) * MaxCalCnt; // size of cals list
  542. cbCbyCnt = sizeof(USELIST) * MaxCbyCnt; // size of cbys list
  543. // Allocate buffers for each of the object types
  544. if (!(pfModList = LpvAllocCb(cbModCnt))) { ABORT_OPEN; }
  545. if (!(pfModSymList = LpvAllocCb(cbModSymCnt))) { ABORT_OPEN; }
  546. if (!(pfSymList = LpvAllocCb(cbSymCnt))) { ABORT_OPEN; }
  547. if (!(pfPropList = LpvAllocCb(cbPropCnt))) { ABORT_OPEN; }
  548. if (!(pfRefList = LpvAllocCb(cbRefCnt))) { ABORT_OPEN; }
  549. if (!(pfDefList = LpvAllocCb(cbDefCnt))) { ABORT_OPEN; }
  550. if (!(pfCalList = LpvAllocCb(cbCalCnt))) { ABORT_OPEN; }
  551. if (!(pfCbyList = LpvAllocCb(cbCbyCnt))) { ABORT_OPEN; }
  552. // read data areas
  553. if (lastAtomPage == 0)
  554. pagesize = lastAtomCnt;
  555. else
  556. pagesize = ATOMALLOC;
  557. // clear out the atom cache
  558. // we must be able to allocate at least one page
  559. AtomPageTblMac = 0;
  560. for (i=0; i < MAXATOMPAGETBL; i++)
  561. AtomPageTbl[i].pfAtomCache = NULL;
  562. AtomPageTbl[0].uPage = 65535;
  563. AtomPageTbl[0].pfAtomCache = LpvAllocCb(pagesize);
  564. if (!AtomPageTbl[0].pfAtomCache) { ABORT_OPEN; }
  565. GetBSC(lbModList, pfModList, cbModCnt); // Init Mod cache
  566. GetBSC(lbModSymList, pfModSymList, cbModSymCnt); // Init ModSym cache
  567. GetBSC(lbSymList, pfSymList, cbSymCnt); // Init Sym cache
  568. GetBSC(lbPropList, pfPropList, cbPropCnt); // Init Prop cache
  569. GetBSC(lbRefList, pfRefList, cbRefCnt); // Init Ref cache
  570. GetBSC(lbDefList, pfDefList, cbDefCnt); // Init Def cache
  571. GetBSC(lbCalList, pfCalList, cbCalCnt); // Init Cal cache
  572. GetBSC(lbCbyList, pfCbyList, cbCbyCnt); // Init Cby cache
  573. // current page for all database items is now page zero
  574. CurModSymPage = 0;
  575. CurSymPage = 0;
  576. CurPropPage = 0;
  577. CurRefPage = 0;
  578. CurDefPage = 0;
  579. CurCalPage = 0;
  580. CurCbyPage = 0;
  581. GetAtomCache (0); // Init Atom cache
  582. return TRUE;
  583. }
  584. WORD BSC_API
  585. BSCMaxSymLen()
  586. // return the length of the largest symbol in the database
  587. //
  588. {
  589. return MaxSymLen;
  590. }
  591. BOOL BSC_API
  592. FCaseBSC()
  593. // is this database built with a case sensitive language?
  594. //
  595. {
  596. return fCase;
  597. }
  598. VOID BSC_API
  599. SetCaseBSC(BOOL fNewCase)
  600. // set case sensitivity of database
  601. //
  602. {
  603. fCase = (BYTE)!!fNewCase;
  604. }