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.

246 lines
6.6 KiB

  1. #define MAXSYMPTRTBLSIZ 4095 // max symbol pointer table size
  2. #define PATH_BUF 512 // path buffer size
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <malloc.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #if defined (OS2)
  9. #define INCL_NOCOMMON
  10. #define INCL_DOSPROCESS
  11. #define INCL_DOSSEMAPHORES
  12. #define INCL_DOSFILEMGR
  13. #define INCL_DOSERRORS
  14. #define INCL_DOSMISC
  15. #include <os2.h>
  16. #else
  17. #include <windows.h>
  18. #endif
  19. #include "hungary.h"
  20. #include "vm.h"
  21. #include "list.h"
  22. #include "errors.h"
  23. // rjsa 10/22/90
  24. // Some runtime library functions are broken, so intrinsics have
  25. // to be used.
  26. // BUGBUG
  27. //#pragma intrinsic (memset, memcpy, memcmp)
  28. //#pragma intrinsic (strset, strcpy, strcmp, strcat, strlen)
  29. #ifndef LINT_PROTO
  30. #include "sbrproto.h"
  31. #endif
  32. #pragma pack(1)
  33. #if rjsa
  34. extern void far * cdecl _fmalloc(unsigned int);
  35. extern void cdecl _ffree(void far *);
  36. extern char * cdecl getenv(const char *);
  37. extern char * cdecl mktemp(char *);
  38. extern char * cdecl strdup(const char *);
  39. #endif
  40. // typedef char flagType;
  41. typedef struct {
  42. VA vaNextMod; // next module
  43. VA vaNameSym; // name Symbol
  44. VA vaFirstModSym; // first ModSym for this file
  45. VA vaLastModSym; // last ModSym for this file
  46. WORD csyms; // symbol count
  47. } MOD;
  48. typedef struct {
  49. VA vaNextModSym; // next symbol
  50. VA vaFirstProp; // first prop entry for this symbol
  51. } MODSYM;
  52. typedef struct {
  53. VA vaNextSym; // next symbol
  54. VA vaFirstProp; // first prop entry for this symbol
  55. VA vaNameText; // the text of this symbol
  56. WORD cprop; // Property count
  57. WORD isym; // this symbol index
  58. } SYM;
  59. typedef struct {
  60. VA vaNextProp; // next property
  61. WORD iprp; // this property index
  62. WORD sattr; // attribute
  63. WORD cref;
  64. VA vaNameSym; // symbol name ptr
  65. VA vaDefList; // def chain
  66. VP vpFirstRef; // ref head
  67. VP vpLastRef; // ref tail
  68. VA vaCalList; // cal chain
  69. VA vaCbyList; // cby chain
  70. VA vaHintRef; // last ref we found by searching
  71. } PROP;
  72. typedef struct {
  73. VA vaFileSym; // file name Symbol ptr
  74. WORD deflin; // def line #
  75. WORD isbr; // sbr file owning this DEF
  76. } DEF;
  77. typedef struct {
  78. VP vpNextRef; // next ref in list
  79. VP vpFileSym; // file name Symbol ptr
  80. WORD reflin; // ref line #
  81. WORD isbr; // sbr file owning this REF
  82. } REF;
  83. typedef struct {
  84. VA vaCalProp; // prop called/used
  85. WORD calcnt; // times called
  86. WORD isbr; // sbr file owning this CAL
  87. } CAL;
  88. typedef struct {
  89. VA vaCbyProp; // prop calling/using
  90. WORD cbycnt; // times calling/using
  91. WORD isbr; // sbr file owning this CBY
  92. } CBY;
  93. typedef struct {
  94. VA vaNextOrd; // next ord
  95. VA vaOrdProp; // prop item alias goes to
  96. WORD aliasord; // ordinal
  97. } ORD;
  98. typedef struct {
  99. VA vaNextSbr; // next sbr
  100. WORD isbr; // index for this SBR file
  101. BOOL fUpdate; // is this SBR file being updated?
  102. char szName[1]; // name
  103. } SBR;
  104. typedef struct {
  105. VA vaOcrProp; // prop occurring
  106. WORD isbr; // SBR file it occurs in
  107. } OCR;
  108. typedef struct exclink {
  109. struct exclink FAR *xnext; // next exclusion
  110. LPCH pxfname; // exclude file name
  111. } EXCLINK, FAR *LPEXCL;
  112. #include "extern.h"
  113. // macros to 'g'et an item of the specified type from VM space
  114. #ifdef SWAP_INFO
  115. #define gMOD(va) (*(iVMGrp = grpMod, modRes = LpvFromVa(va,1)))
  116. #define gMODSYM(va) (*(iVMGrp = grpModSym, modsymRes = LpvFromVa(va,2)))
  117. #define gSYM(va) (*(iVMGrp = grpSym, symRes = LpvFromVa(va,3)))
  118. #define gPROP(va) (*(iVMGrp = grpProp, propRes = LpvFromVa(va,4)))
  119. #define gDEF(va) (*(iVMGrp = grpDef, defRes = LpvFromVa(va,5)))
  120. #define gREF(va) (*(iVMGrp = grpRef, refRes = LpvFromVa(va,6)))
  121. #define gCAL(va) (*(iVMGrp = grpCal, calRes = LpvFromVa(va,7)))
  122. #define gCBY(va) (*(iVMGrp = grpCby, cbyRes = LpvFromVa(va,8)))
  123. #define gORD(va) (*(iVMGrp = grpOrd, ordRes = LpvFromVa(va,9)))
  124. #define gSBR(va) (*(iVMGrp = grpSbr, sbrRes = LpvFromVa(va,13)))
  125. #define gTEXT(va) ((iVMGrp = grpText, textRes = LpvFromVa(va,12)))
  126. #define gOCR(va) (*(iVMGrp = grpOcr, ocrRes = LpvFromVa(va,14)))
  127. #else
  128. #define gMOD(va) (*(modRes = LpvFromVa(va,1)))
  129. #define gMODSYM(va) (*(modsymRes = LpvFromVa(va,2)))
  130. #define gSYM(va) (*(symRes = LpvFromVa(va,3)))
  131. #define gPROP(va) (*(propRes = LpvFromVa(va,4)))
  132. #define gDEF(va) (*(defRes = LpvFromVa(va,5)))
  133. #define gREF(va) (*(refRes = LpvFromVa(va,6)))
  134. #define gCAL(va) (*(calRes = LpvFromVa(va,7)))
  135. #define gCBY(va) (*(cbyRes = LpvFromVa(va,8)))
  136. #define gORD(va) (*(ordRes = LpvFromVa(va,9)))
  137. #define gSBR(va) (*(sbrRes = LpvFromVa(va,13)))
  138. #define gTEXT(va) ((textRes = LpvFromVa(va,12)))
  139. #define gOCR(va) (*(ocrRes = LpvFromVa(va,14)))
  140. #endif
  141. // macros to 'p'ut an item of the specified type to VM space
  142. #define pMOD(va) DirtyVa(va)
  143. #define pMODSYM(va) DirtyVa(va)
  144. #define pSYM(va) DirtyVa(va)
  145. #define pPROP(va) DirtyVa(va)
  146. #define pDEF(va) DirtyVa(va)
  147. #define pREF(va) DirtyVa(va)
  148. #define pCAL(va) DirtyVa(va)
  149. #define pCBY(va) DirtyVa(va)
  150. #define pORD(va) DirtyVa(va)
  151. #define pSBR(va) DirtyVa(va)
  152. #define pTEXT(va) DirtyVa(va)
  153. #define pOCR(va) DirtyVa(va)
  154. // these macros allow access to the 'c'urrent visible item
  155. #define cMOD (*modRes)
  156. #define cMODSYM (*modsymRes)
  157. #define cSYM (*symRes)
  158. #define cPROP (*propRes)
  159. #define cDEF (*defRes)
  160. #define cREF (*refRes)
  161. #define cCAL (*calRes)
  162. #define cCBY (*cbyRes)
  163. #define cORD (*ordRes)
  164. #define cSBR (*sbrRes)
  165. #define cTEXT (textRes)
  166. #define cOCR (*ocrRes)
  167. #define grpSym 0
  168. #define grpMod 1
  169. #define grpOrd 2
  170. #define grpProp 3
  171. #define grpModSym 4
  172. #define grpDef 5
  173. #define grpRef 6
  174. #define grpCal 7
  175. #define grpCby 8
  176. #define grpList 9
  177. #define grpText 10
  178. #define grpSbr 11
  179. #define grpOcr 12
  180. #define SBR_OLD (1<<0) // this .sbr file used to exist
  181. #define SBR_NEW (1<<1) // this .sbr file currently exists
  182. #define SBR_UPDATE (1<<2) // this .sbr file is to be updated
  183. //
  184. // this is used to add items to the tail of the lists in a property group
  185. //
  186. // things being added type m
  187. // ------------------ ---- ---
  188. // Refs Ref REF
  189. // Defs Def DEF
  190. // Calls/Uses Cal CAL
  191. // Called by/Used By Cby CBY
  192. //
  193. #define AddTail(type, m) \
  194. { \
  195. VP vpT; \
  196. VA vaT; \
  197. MkVpVa(vpT, va##type); \
  198. vaT = VaFrVp(cPROP.vpLast##type); \
  199. if (vaT) { \
  200. g##m(vaT).vpNext##type = vpT; \
  201. p##m(vaT); \
  202. } \
  203. else { \
  204. cPROP.vpFirst##type = vpT; \
  205. } \
  206. cPROP.vpLast##type = vpT; \
  207. }