home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / BSC32.ZIP / BSC.H next >
C/C++ Source or Header  |  1993-07-14  |  8KB  |  268 lines

  1.  
  2. // bsc.h
  3. //
  4.  
  5. #include <stdarg.h>
  6.  
  7. //////////////////////////////////////////////////////////////////////
  8. // you must define the following callbacks for the library to use
  9. // to avoid dependancy on the C standard io library.  If you don't
  10. // define these then you accept the defaults which call C runtime
  11. //
  12.  
  13. // malloc and free workalikes
  14.  
  15. LPV  BSC_API LpvAllocCb(WORD cb);
  16. VOID BSC_API FreeLpv(LPV lpv);
  17.  
  18. // open, read, close, seek workalikes
  19.  
  20. int  BSC_API BSCOpen(LSZ lszFileName, int mode);
  21. int  BSC_API BSCRead(int handle, LPCH lpchBuf, WORD cb);
  22. int  BSC_API BSCSeek(int handle, long lPos, int mode);
  23. int  BSC_API BSCClose(int handle);
  24.  
  25. // ascii text output routine
  26.  
  27. VOID BSC_API BSCOutput(LSZ lsz);
  28.  
  29. #ifdef DEBUG
  30. VOID BSC_API BSCDebugOut(LSZ lsz);
  31. VOID BSCDebug(LSZ lszFormat, ...);
  32. #endif
  33.  
  34. // error handling routines
  35. //
  36. VOID BSC_API SeekError(LSZ lszFileName);    // (may choose to not return)
  37. VOID BSC_API ReadError(LSZ lszFileName);    // (may choose to not return)
  38. VOID BSC_API BadBSCVer(LSZ lszFileName);    // (may choose to not return)
  39.  
  40. // end of callbacks
  41. //
  42. ///////////////////////////////////////////////////////////////////////
  43.  
  44. // an IDX is guaranteed to be big enough to hold any of the 
  45. // database index types, i.e. it is a generic index
  46.  
  47. typedef DWORD IDX;
  48.  
  49. #define idxNil     0xffffffffL
  50. #define isymNil  (ISYM)(idxNil)
  51. #define imodNil  (IMOD)(idxNil)
  52. #define iinstNil (IINST)(idxNil)
  53.  
  54. // definition and prototypes for use with the bsc library
  55. //
  56. typedef WORD IMOD;
  57. typedef WORD IMS;
  58. typedef WORD ISYM;
  59. typedef WORD IINST;
  60. typedef DWORD IREF;
  61. typedef WORD IDEF;
  62. typedef DWORD IUSE;
  63. typedef DWORD IUBY;
  64. typedef WORD IBASE;
  65. typedef WORD IDERV;
  66. typedef WORD IFRIN;
  67. typedef WORD IFROUT;
  68.  
  69. typedef WORD ATR;    // instance flags
  70. typedef WORD TYP;    // instance flags
  71.  
  72. //  Open the specified data base.
  73. //  Return TRUE iff successful, FALSE if database can't be read
  74. //
  75. BOOL BSC_API FOpenBSC (LSZ lszName);
  76.  
  77. // close database and free as much memory as possible
  78. //
  79. VOID BSC_API CloseBSC(VOID);
  80.  
  81. // return the length of the largest symbol in the database
  82. //
  83. WORD BSC_API BSCMaxSymLen(VOID);
  84.  
  85. // is this database built with a case sensitive language?
  86. //
  87. BOOL BSC_API FCaseBSC(VOID);
  88.  
  89. // override the case sensitivity of the database, symbol lookups become
  90. // case (in)sensistive as specified
  91. //
  92. VOID BSC_API SetCaseBSC(BOOL fCaseSensitive);
  93.  
  94. // do a case insenstive compare qualified by a case sensitive compare
  95. // if fCase is true -- this is the order of symbols in the symbol list
  96. int BSC_API CaseCmp(LSZ lsz1, LSZ lsz2);
  97.  
  98. // nearly identical to CaseCmp except only the prefix is compared of the
  99. // two strings
  100. int BSC_API CaseCmpPrefix(LSZ lszprefix, LSZ lszdecor);
  101.  
  102. // return the name of the given symbol
  103. //
  104. LSZ BSC_API LszNameFrSym (ISYM isym);
  105.  
  106. // return the name of the given module
  107. //
  108. LSZ BSC_API LszNameFrMod (IMOD imod);
  109.  
  110. // return the imod with the given name -- imodNil if none
  111. //
  112. IMOD BSC_API ImodFrLsz(LSZ lszModName);
  113.  
  114. // return the isym with the given name -- isymNil if none
  115. //
  116. ISYM BSC_API IsymFrLsz(LSZ lszSymName);
  117.  
  118. // find the smallest ISYM whose value is greater or equal to the given LSZ
  119. //
  120. ISYM BSC_API IsymSupLsz(LSZ lszSymName);
  121.  
  122. // return the biggest isym in this database, isyms run from 0 to this value - 1
  123. //
  124. ISYM BSC_API IsymMac(VOID);
  125.  
  126. // return the biggest imod in this database, imods run from 0 to this value - 1
  127. //
  128. IMOD BSC_API ImodMac(VOID);
  129.  
  130. // return the biggest iinst in this database, iinsts run from 0 to the value -1
  131. IINST BSC_API IinstMac(VOID);
  132.  
  133. // fill in the range of MS items valid for this module
  134. //
  135. VOID BSC_API MsRangeOfMod(IMOD imod, IMS FAR *pims, IMS FAR *pimsMac);
  136.  
  137. // give the instance index of the module symbol (MS)
  138. //
  139. IINST BSC_API IinstOfIms(IMS ims);
  140.  
  141. // fill in the range of inst values for this symbol
  142. //
  143. VOID BSC_API InstRangeOfSym(ISYM isym, IINST FAR *piinst, IINST FAR *piinstMac);
  144.  
  145. // get the information that qualifies this instance
  146. //
  147. VOID BSC_API InstInfo(IINST iinst, ISYM FAR *pisymInst, TYP FAR *ptyp, ATR FAR *patr);
  148.  
  149. // fill in the reference ranges from the inst
  150. //
  151. VOID BSC_API RefRangeOfInst(IINST iinst, IREF FAR *piref, IREF FAR *pirefMac);
  152.  
  153. // fill in the definition ranges from the inst
  154. //
  155. VOID BSC_API DefRangeOfInst(IINST iinst, IDEF FAR *pidef, IDEF FAR *pidefMac);
  156.  
  157. // fill in the use ranges from the inst
  158. //
  159. VOID BSC_API UseRangeOfInst(IINST iinst, IUSE FAR *piuse, IUSE FAR *piuseMac);
  160.  
  161. // fill in the used by ranges from the inst
  162. //
  163. VOID BSC_API UbyRangeOfInst(IINST iinst, IUBY FAR *piuby, IUBY FAR *piubyMac);
  164.  
  165. // fill in the base class ranges from the inst
  166. //
  167. VOID BSC_API BaseRangeOfInst(IINST iinst, IBASE FAR *pibase, IBASE FAR *pibaseMac);
  168.  
  169. // fill in the dervived class ranges from the inst
  170. //
  171. VOID BSC_API DervRangeOfInst(IINST iinst, IDERV FAR *piderv, IDERV FAR *pidervMac);
  172.  
  173. // fill in the incoming friend ranges from the inst
  174. //
  175. VOID BSC_API FrinRangeOfInst(IINST iinst, IFRIN FAR *pifrin, IFRIN FAR *pifrinMac);
  176.  
  177. // fill in the outgoing friend ranges from the inst
  178. //
  179. VOID BSC_API FroutRangeOfInst(IINST, IFROUT FAR *, IFROUT FAR *);
  180.  
  181. // fill in the information about this things which an inst uses
  182. //
  183. VOID BSC_API UseInfo(IUSE iuse, IINST FAR *piinst, WORD FAR *pcnt);
  184.  
  185. // fill in the information about this things which an inst is used by
  186. //
  187. VOID BSC_API UbyInfo(IUBY iuby, IINST FAR *piinst, WORD FAR *pcnt);
  188.  
  189. // get the information about a base class (mode is inheritance mode)
  190. //
  191. VOID BSC_API BaseInfo(IBASE ibase, IINST FAR *piinst, WORD FAR *pmode);
  192.  
  193. // get the information about a derived class (mode is inheritance mode)
  194. //
  195. VOID BSC_API DervInfo(IDERV iderv, IINST FAR *piinst, WORD FAR *pmode);
  196.  
  197. // get the information about an incoming friend
  198. //
  199. VOID BSC_API FrinInfo(IFRIN ifrin, IINST FAR *piinst);
  200.  
  201. // get the information about an outgoing friend
  202. //
  203. VOID BSC_API FroutInfo(IFROUT ifrout, IINST FAR *piinst);
  204.  
  205. // fill in the information about this reference
  206. //
  207. VOID BSC_API RefInfo(IREF iref, LSZ FAR *plszName, WORD FAR *pline);
  208.  
  209. // fill in the information about this definition
  210. //
  211. VOID BSC_API DefInfo(IDEF idef, LSZ FAR *plszName, WORD FAR *pline);
  212.  
  213. // these are the bit values for the InstInfo() call InstFlags WORD
  214. //
  215. //
  216.  
  217. // this is the type part of the field, it describes what sort of object
  218. // we are talking about.  Note the values are sequential -- the item will
  219. // be exactly one of these things
  220. //
  221.  
  222. #define INST_TYP_FUNCTION     0x01
  223. #define INST_TYP_LABEL        0x02
  224. #define INST_TYP_PARAMETER    0x03
  225. #define INST_TYP_VARIABLE     0x04
  226. #define INST_TYP_CONSTANT     0x05
  227. #define INST_TYP_MACRO        0x06
  228. #define INST_TYP_TYPEDEF      0x07
  229. #define INST_TYP_STRUCNAM     0x08
  230. #define INST_TYP_ENUMNAM      0x09
  231. #define INST_TYP_ENUMMEM      0x0A
  232. #define INST_TYP_UNIONNAM     0x0B
  233. #define INST_TYP_SEGMENT      0x0C
  234. #define INST_TYP_GROUP        0x0D
  235. #define INST_TYP_PROGRAM      0x0E
  236. #define INST_TYP_CLASSNAM     0x0F
  237. #define INST_TYP_MEMFUNC      0x10
  238. #define INST_TYP_MEMVAR       0x11
  239.  
  240. // this is the attribute part of the field, it describes the storage
  241. // class and/or scope of the instance.  Any combination of the bits
  242. // might be set by some language compiler, but there are some combinations
  243. // that done make sense.
  244.  
  245. #define INST_ATR_LOCAL       0x001
  246. #define INST_ATR_STATIC      0x002
  247. #define INST_ATR_SHARED      0x004
  248. #define INST_ATR_NEAR        0x008
  249. #define INST_ATR_COMMON      0x010
  250. #define INST_ATR_DECL_ONLY   0x020
  251. #define INST_ATR_PUBLIC      0x040
  252. #define INST_ATR_NAMED       0x080
  253. #define INST_ATR_MODULE      0x100
  254. #define INST_ATR_VIRTUAL     0x200
  255. #define INST_ATR_PRIVATE     0x400
  256. #define INST_ATR_PROTECT     0x800
  257.  
  258. #define IMODE_VIRTUAL         0x001
  259. #define IMODE_PRIVATE         0x002
  260. #define IMODE_PUBLIC         0x004
  261. #define IMODE_PROTECT         0x008
  262.  
  263. // simple minded printf replacements, only %d, %s supported -- SMALL
  264.  
  265. VOID BSC_API BSCFormat(LPCH lpchOut, LSZ lszFormat, va_list va);
  266. VOID BSC_API BSCSprintf(LPCH lpchOut, LSZ lszFormat, ...);
  267. VOID BSC_API BSCPrintf(LSZ lszFormat, ...);
  268.