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.

277 lines
8.1 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  3. #include "precomp.h"
  4. /* print all undefined/unexported symbols and terminate */
  5. void
  6. UndefinedError(AssignmentList_t ass, UndefinedSymbolList_t undef, UndefinedSymbol_t *bad)
  7. {
  8. UndefinedSymbol_t *u;
  9. char *type;
  10. int undefined = 0, unexported = 0;
  11. char *identifier;
  12. /* count undefined and unexported symbols */
  13. for (u = undef; u; u = u->Next) {
  14. switch (u->Type) {
  15. case eUndefinedSymbol_SymbolNotDefined:
  16. case eUndefinedSymbol_SymbolNotExported:
  17. if (FindUndefinedSymbol(ass, bad, u->U.Symbol.ReferenceType,
  18. u->U.Symbol.Identifier, u->U.Symbol.Module))
  19. continue;
  20. break;
  21. case eUndefinedSymbol_FieldNotDefined:
  22. case eUndefinedSymbol_FieldNotExported:
  23. if (FindUndefinedField(ass, bad, u->U.Field.ReferenceFieldType,
  24. u->U.Field.ObjectClass, u->U.Field.Identifier,
  25. u->U.Field.Module))
  26. continue;
  27. break;
  28. }
  29. switch (u->Type) {
  30. case eUndefinedSymbol_SymbolNotDefined:
  31. case eUndefinedSymbol_FieldNotDefined:
  32. undefined = 1;
  33. break;
  34. case eUndefinedSymbol_SymbolNotExported:
  35. case eUndefinedSymbol_FieldNotExported:
  36. unexported = 1;
  37. break;
  38. }
  39. }
  40. /* print the undefined symbols */
  41. if (undefined) {
  42. fprintf(stderr, "Following symbols are undefined:\n");
  43. for (u = undef; u; u = u->Next) {
  44. if (u->Type == eUndefinedSymbol_SymbolNotExported ||
  45. u->Type == eUndefinedSymbol_FieldNotExported)
  46. continue;
  47. if (u->Type == eUndefinedSymbol_SymbolNotDefined &&
  48. FindUndefinedSymbol(ass, bad, u->U.Symbol.ReferenceType,
  49. u->U.Symbol.Identifier, u->U.Symbol.Module))
  50. continue;
  51. if (u->Type == eUndefinedSymbol_FieldNotDefined &&
  52. FindUndefinedField(ass, bad, u->U.Field.ReferenceFieldType,
  53. u->U.Field.ObjectClass, u->U.Field.Identifier,
  54. u->U.Field.Module))
  55. continue;
  56. if (u->Type == eUndefinedSymbol_SymbolNotDefined) {
  57. switch (u->U.Symbol.ReferenceType) {
  58. case eAssignment_Type:
  59. type = "type";
  60. break;
  61. case eAssignment_Value:
  62. type = "value";
  63. break;
  64. case eAssignment_ObjectClass:
  65. type = "object class";
  66. break;
  67. case eAssignment_Object:
  68. type = "object";
  69. break;
  70. case eAssignment_ObjectSet:
  71. type = "object set";
  72. break;
  73. case eAssignment_Macro:
  74. type = "macro";
  75. break;
  76. case eAssignment_Undefined:
  77. if (isupper(*u->U.Symbol.Identifier))
  78. type = "type?";
  79. else if (islower(*u->U.Symbol.Identifier))
  80. type = "value?";
  81. else
  82. type = "?";
  83. break;
  84. default:
  85. MyAbort();
  86. /*NOTREACHED*/
  87. }
  88. identifier = u->U.Symbol.Identifier ?
  89. u->U.Symbol.Identifier : "<unnamed>";
  90. if (u->U.Symbol.Module) {
  91. fprintf(stderr, "%s.%s (%s)\n",
  92. u->U.Symbol.Module->Identifier, identifier, type);
  93. } else {
  94. fprintf(stderr, "%s (%s)\n", identifier, type);
  95. }
  96. } else {
  97. switch (u->U.Field.ReferenceFieldType) {
  98. case eSetting_Type:
  99. type = "type field";
  100. break;
  101. case eSetting_Value:
  102. type = "value field";
  103. break;
  104. case eSetting_ValueSet:
  105. type = "value set field";
  106. break;
  107. case eSetting_Object:
  108. type = "object field";
  109. break;
  110. case eSetting_ObjectSet:
  111. type = "object set field";
  112. break;
  113. case eAssignment_Macro:
  114. type = "macro";
  115. break;
  116. default:
  117. MyAbort();
  118. /*NOTREACHED*/
  119. }
  120. identifier = u->U.Field.Identifier ?
  121. u->U.Field.Identifier : "<unnamed>";
  122. if (u->U.Field.Module) {
  123. fprintf(stderr, "%s.%s.%s (%s)\n",
  124. u->U.Field.Module->Identifier,
  125. u->U.Field.ObjectClass->U.Reference.Identifier,
  126. identifier, type);
  127. } else {
  128. fprintf(stderr, "%s.%s (%s)\n",
  129. u->U.Field.ObjectClass->U.Reference.Identifier,
  130. identifier, type);
  131. }
  132. }
  133. }
  134. }
  135. /* print the unexported symbols */
  136. if (unexported) {
  137. fprintf(stderr, "Following symbols have not been exported:\n");
  138. for (u = undef; u; u = u->Next) {
  139. if (u->Type == eUndefinedSymbol_SymbolNotDefined ||
  140. u->Type == eUndefinedSymbol_FieldNotDefined)
  141. continue;
  142. if (u->Type == eUndefinedSymbol_SymbolNotExported &&
  143. FindUndefinedSymbol(ass, bad, u->U.Symbol.ReferenceType,
  144. u->U.Symbol.Identifier, u->U.Symbol.Module))
  145. continue;
  146. if (u->Type == eUndefinedSymbol_FieldNotExported &&
  147. FindUndefinedField(ass, bad, u->U.Field.ReferenceFieldType,
  148. u->U.Field.ObjectClass, u->U.Field.Identifier,
  149. u->U.Field.Module))
  150. continue;
  151. if (u->Type == eUndefinedSymbol_SymbolNotExported) {
  152. switch (u->U.Symbol.ReferenceType) {
  153. case eAssignment_Type:
  154. type = "type";
  155. break;
  156. case eAssignment_Value:
  157. type = "value";
  158. break;
  159. case eAssignment_ObjectClass:
  160. type = "object class";
  161. break;
  162. case eAssignment_Object:
  163. type = "object";
  164. break;
  165. case eAssignment_ObjectSet:
  166. type = "object set";
  167. break;
  168. case eAssignment_Macro:
  169. type = "macro";
  170. break;
  171. case eAssignment_Undefined:
  172. if (isupper(*u->U.Symbol.Identifier))
  173. type = "type?";
  174. else if (islower(*u->U.Symbol.Identifier))
  175. type = "value?";
  176. else
  177. type = "?";
  178. break;
  179. default:
  180. MyAbort();
  181. /*NOTREACHED*/
  182. }
  183. identifier = u->U.Symbol.Identifier ?
  184. u->U.Symbol.Identifier : "<unnamed>";
  185. if (u->U.Symbol.Module) {
  186. fprintf(stderr, "%s.%s (%s)\n",
  187. u->U.Symbol.Module->Identifier, identifier, type);
  188. } else {
  189. fprintf(stderr, "%s (%s)\n", identifier, type);
  190. }
  191. } else {
  192. switch (u->U.Field.ReferenceFieldType) {
  193. case eSetting_Type:
  194. type = "type field";
  195. break;
  196. case eSetting_Value:
  197. type = "value field";
  198. break;
  199. case eSetting_ValueSet:
  200. type = "value set field";
  201. break;
  202. case eSetting_Object:
  203. type = "object field";
  204. break;
  205. case eSetting_ObjectSet:
  206. type = "object set field";
  207. break;
  208. case eAssignment_Macro:
  209. type = "macro";
  210. break;
  211. default:
  212. MyAbort();
  213. /*NOTREACHED*/
  214. }
  215. identifier = u->U.Field.Identifier ?
  216. u->U.Field.Identifier : "<unnamed>";
  217. if (u->U.Field.Module) {
  218. fprintf(stderr, "%s.%s.%s (%s)\n",
  219. u->U.Field.Module->Identifier,
  220. u->U.Field.ObjectClass->U.Reference.Identifier,
  221. identifier, type);
  222. } else {
  223. fprintf(stderr, "%s.%s (%s)\n",
  224. u->U.Field.ObjectClass->U.Reference.Identifier,
  225. identifier, type);
  226. }
  227. }
  228. }
  229. }
  230. MyExit(1);
  231. }
  232. /* compare two undefined symbol entries */
  233. /* return 0 if equal */
  234. int CmpUndefinedSymbol(AssignmentList_t ass, UndefinedSymbol_t *u1, UndefinedSymbol_t *u2) {
  235. if (u1->Type != u2->Type)
  236. return 1;
  237. switch (u1->Type) {
  238. case eUndefinedSymbol_SymbolNotExported:
  239. case eUndefinedSymbol_SymbolNotDefined:
  240. return strcmp(u1->U.Symbol.Identifier, u2->U.Symbol.Identifier) ||
  241. u1->U.Symbol.Module && !u2->U.Symbol.Module ||
  242. !u1->U.Symbol.Module && u2->U.Symbol.Module ||
  243. u1->U.Symbol.Module && u2->U.Symbol.Module &&
  244. CmpModuleIdentifier(ass, u1->U.Symbol.Module, u2->U.Symbol.Module);
  245. case eUndefinedSymbol_FieldNotExported:
  246. case eUndefinedSymbol_FieldNotDefined:
  247. return strcmp(u1->U.Field.Identifier, u2->U.Field.Identifier) ||
  248. strcmp(u1->U.Field.ObjectClass->U.Reference.Identifier,
  249. u2->U.Field.ObjectClass->U.Reference.Identifier) ||
  250. CmpModuleIdentifier(ass,
  251. u1->U.Field.ObjectClass->U.Reference.Module,
  252. u2->U.Field.ObjectClass->U.Reference.Module) ||
  253. u1->U.Field.Module && !u2->U.Field.Module ||
  254. !u1->U.Field.Module && u2->U.Field.Module ||
  255. u1->U.Field.Module && u2->U.Field.Module &&
  256. CmpModuleIdentifier(ass, u1->U.Field.Module, u2->U.Field.Module);
  257. default:
  258. MyAbort();
  259. /*NOTREACHED*/
  260. }
  261. return 1; // not equal
  262. }
  263. /* compare two lists of undefined symbols */
  264. int CmpUndefinedSymbolList(AssignmentList_t ass, UndefinedSymbolList_t u1, UndefinedSymbolList_t u2) {
  265. for (; u1 && u2; u1 = u1->Next, u2 = u2->Next) {
  266. if (CmpUndefinedSymbol(ass, u1, u2))
  267. return 1;
  268. }
  269. return u1 || u2;
  270. }