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.

1531 lines
47 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  3. #ifndef _ASN1C_DEFS_H_
  4. #define _ASN1C_DEFS_H_
  5. typedef struct Assignment_s Assignment_t;
  6. typedef struct UndefinedSymbol_s UndefinedSymbol_t;
  7. typedef struct AssignedObjId_s AssignedObjId_t;
  8. typedef struct AssignedModules_s AssignedModules_t;
  9. typedef struct Type_s Type_t;
  10. typedef struct Tag_s Tag_t;
  11. typedef struct EndPoint_s EndPoint_t;
  12. typedef struct ElementSetSpec_s ElementSetSpec_t;
  13. typedef struct SubtypeElement_s SubtypeElement_t;
  14. typedef struct ObjectSetElement_s ObjectSetElement_t;
  15. typedef struct Constraint_s Constraint_t;
  16. typedef struct NamedConstraint_s NamedConstraint_t;
  17. typedef struct PERConstraint_s PERConstraint_t;
  18. typedef struct PERConstraints_s PERConstraints_t;
  19. typedef struct ValueConstraint_s ValueConstraint_t;
  20. typedef struct NamedNumber_s NamedNumber_t;
  21. typedef struct NamedType_s NamedType_t;
  22. typedef struct NamedValue_s NamedValue_t;
  23. typedef struct Component_s Component_t;
  24. typedef struct Value_s Value_t;
  25. typedef struct ValueSet_s ValueSet_t;
  26. typedef struct Macro_s Macro_t;
  27. typedef struct MacroProduction_s MacroProduction_t;
  28. typedef struct NamedMacroProduction_s NamedMacroProduction_t;
  29. typedef struct MacroLocalAssignment_s MacroLocalAssignment_t;
  30. typedef struct Quadruple_s Quadruple_t;
  31. typedef struct Tuple_s Tuple_t;
  32. typedef struct Directive_s Directive_t;
  33. typedef struct ModuleIdentifier_s ModuleIdentifier_t;
  34. typedef struct NamedObjIdValue_s NamedObjIdValue_t;
  35. typedef struct ObjectClass_s ObjectClass_t;
  36. typedef struct Object_s Object_t;
  37. typedef struct ObjectSet_s ObjectSet_t;
  38. typedef struct Optionality_s Optionality_t;
  39. typedef struct FieldSpec_s FieldSpec_t;
  40. typedef struct SyntaxSpec_s SyntaxSpec_t;
  41. typedef struct Setting_s Setting_t;
  42. typedef struct String_s String_t;
  43. typedef struct StringModule_s StringModule_t;
  44. typedef struct PERSimpleTypeInfo_s PERSimpleTypeInfo_t;
  45. typedef struct PERTypeInfo_s PERTypeInfo_t;
  46. typedef struct BERTypeInfo_s BERTypeInfo_t;
  47. typedef struct Arguments_s Arguments_t;
  48. typedef Assignment_t *AssignmentList_t;
  49. typedef AssignedObjId_t *AssignedObjIdList_t;
  50. typedef Tag_t *TagList_t;
  51. typedef NamedConstraint_t *NamedConstraintList_t;
  52. typedef NamedNumber_t *NamedNumberList_t;
  53. typedef ValueConstraint_t *ValueConstraintList_t;
  54. typedef Component_t *ComponentList_t;
  55. typedef NamedValue_t *NamedValueList_t;
  56. typedef Directive_t *DirectiveList_t;
  57. typedef Setting_t *SettingList_t;
  58. typedef SyntaxSpec_t *SyntaxSpecList_t;
  59. typedef FieldSpec_t *FieldSpecList_t;
  60. typedef UndefinedSymbol_t *UndefinedSymbolList_t;
  61. typedef NamedObjIdValue_t *NamedObjIdValueList_t;
  62. typedef Value_t *ValueList_t;
  63. typedef NamedMacroProduction_t *NamedMacroProductionList_t;
  64. typedef MacroLocalAssignment_t *MacroLocalAssignmentList_t;
  65. typedef String_t *StringList_t;
  66. typedef StringModule_t *StringModuleList_t;
  67. /* --- undefined element --- */
  68. #define UNDEFINED_VALUE 1UL
  69. #define UNDEFINED(_ptr) ((unsigned long)(_ptr) == UNDEFINED_VALUE)
  70. #define DEFINED(_ptr) ((_ptr) && !UNDEFINED(_ptr))
  71. /* --- Tag --- */
  72. typedef enum {
  73. eTagType_Implicit,
  74. eTagType_Explicit,
  75. eTagType_Automatic,
  76. eTagType_Unknown
  77. } TagType_e;
  78. typedef enum {
  79. eTagClass_Universal = 0x00,
  80. eTagClass_Application = 0x40,
  81. eTagClass_Unknown = 0x80,
  82. eTagClass_Private = 0xc0
  83. } TagClass_e;
  84. struct Tag_s {
  85. TagList_t Next;
  86. TagType_e Type;
  87. TagClass_e Class;
  88. Value_t *Tag;
  89. };
  90. Tag_t *NewTag(TagType_e type);
  91. Tag_t *DupTag(Tag_t *src);
  92. /* --- Extension --- */
  93. typedef enum {
  94. eExtension_Unconstrained,
  95. eExtension_Unextended,
  96. eExtension_Extendable,
  97. eExtension_Extended
  98. } Extension_e;
  99. /* --- Assignment --- */
  100. typedef enum {
  101. eAssignment_Undefined,
  102. eAssignment_ModuleIdentifier,
  103. eAssignment_Type,
  104. eAssignment_Value,
  105. eAssignment_ObjectClass,
  106. eAssignment_Object,
  107. eAssignment_ObjectSet,
  108. eAssignment_Macro,
  109. eAssignment_Reference,
  110. eAssignment_NextPass
  111. } Assignment_e;
  112. typedef enum {
  113. eAssignmentFlags_Exported = 1,
  114. eAssignmentFlags_LongName = 2
  115. } AssignmentFlags_e;
  116. struct Assignment_s {
  117. AssignmentList_t Next;
  118. char *Identifier;
  119. ModuleIdentifier_t *Module;
  120. Assignment_e Type;
  121. AssignmentFlags_e Flags;
  122. int fImportedLocalDuplicate;
  123. int fGhost;
  124. TagType_e eDefTagType;
  125. union {
  126. struct {
  127. Type_t *Type;
  128. } Type;
  129. struct {
  130. Value_t *Value;
  131. } Value;
  132. struct {
  133. ObjectClass_t *ObjectClass;
  134. } ObjectClass;
  135. struct {
  136. Object_t *Object;
  137. } Object;
  138. struct {
  139. ObjectSet_t *ObjectSet;
  140. } ObjectSet;
  141. struct {
  142. Macro_t *Macro;
  143. } Macro;
  144. struct {
  145. char *Identifier;
  146. ModuleIdentifier_t *Module;
  147. } Reference;
  148. } U;
  149. };
  150. Assignment_t *NewAssignment(Assignment_e type);
  151. Assignment_t *DupAssignment(Assignment_t *src);
  152. Assignment_t *FindAssignment(AssignmentList_t a, Assignment_e type, char *ide, ModuleIdentifier_t *mod);
  153. Assignment_t *FindExportedAssignment(AssignmentList_t a, Assignment_e type, char *ide, ModuleIdentifier_t *mod);
  154. Assignment_t *FindAssignmentInCurrentPass(AssignmentList_t a, char *ide, ModuleIdentifier_t *mod);
  155. Assignment_t *GetAssignment(AssignmentList_t ass, Assignment_t *a);
  156. Assignment_e GetAssignmentType(AssignmentList_t ass, Assignment_t *a);
  157. int AssignType(AssignmentList_t *ass, Type_t *lhs, Type_t *rhs);
  158. int AssignValue(AssignmentList_t *ass, Value_t *lhs, Value_t *rhs);
  159. int AssignModuleIdentifier(AssignmentList_t *ass, ModuleIdentifier_t *module);
  160. /* --- AssignedObjIds --- */
  161. struct AssignedObjId_s {
  162. AssignedObjIdList_t Next;
  163. StringList_t Names;
  164. uint32_t Number;
  165. AssignedObjId_t *Child;
  166. };
  167. AssignedObjId_t *NewAssignedObjId(void);
  168. AssignedObjId_t *DupAssignedObjId(AssignedObjId_t *src);
  169. typedef struct DefinedObjectID_s
  170. {
  171. struct DefinedObjectID_s *next;
  172. char *pszName;
  173. Value_t *pValue;
  174. }
  175. DefinedObjectID_t;
  176. extern DefinedObjectID_t *g_pDefinedObjectIDs;
  177. Value_t *GetDefinedOIDValue ( char *pszName );
  178. void AddDefinedOID ( char *pszName, Value_t *pValue );
  179. /* --- TypeRules --- */
  180. typedef enum {
  181. eTypeRules_Normal = 0x00,
  182. eTypeRules_Pointer = 0x01, // lonchanc: don't know what it is
  183. eTypeRules_SinglyLinkedList = 0x02, // --<LINKED>--
  184. eTypeRules_DoublyLinkedList = 0x04,
  185. eTypeRules_LengthPointer = 0x08, // --<UNBOUNDED>--
  186. eTypeRules_FixedArray = 0x10, // default
  187. eTypeRules_PointerToElement = 0x20, // --<POINTER>--
  188. eTypeRules_ZeroTerminated = 0x40,
  189. eTypeRules_LinkedListMask = (eTypeRules_SinglyLinkedList | eTypeRules_DoublyLinkedList),
  190. eTypeRules_PointerArrayMask = (eTypeRules_LengthPointer | eTypeRules_FixedArray),
  191. eTypeRules_PointerMask = (eTypeRules_LengthPointer | eTypeRules_PointerToElement),
  192. eTypeRules_IndirectMask = (eTypeRules_Pointer | eTypeRules_LinkedListMask | eTypeRules_PointerMask),
  193. } TypeRules_e;
  194. /* --- TypeFlags --- */
  195. typedef enum {
  196. eTypeFlags_Null = 1, /* type is not present in C, 'cause it's NULL */
  197. eTypeFlags_NullChoice = 2, /* type is CHOICE with NULL-alternatives */
  198. eTypeFlags_ExtensionMarker = 4, /* type is extended */
  199. eTypeFlags_Simple = 8, /* type has empty freefn, memcpy copyfn */
  200. eTypeFlags_Done = 0x10,
  201. eTypeFlags_GenType = 0x20, /* generate a type */
  202. eTypeFlags_GenEncode = 0x40, /* generate an encoding fn */
  203. eTypeFlags_GenDecode = 0x80, /* generate a decoding fn */
  204. eTypeFlags_GenFree = 0x100, /* generate a free fn */
  205. eTypeFlags_GenCheck = 0x200, /* generate a check fn */
  206. eTypeFlags_GenCompare = 0x400,/* generate a cmp fn */
  207. eTypeFlags_GenCopy = 0x800, /* generate a copy fn */
  208. eTypeFlags_GenPrint = 0x1000, /* generate a print fn */
  209. eTypeFlags_GenPdu = 0x2000, /* generate a pdu number */
  210. eTypeFlags_GenAll = 0x20+0x40+0x80+0x100+0x400+0x2000,
  211. eTypeFlags_GenSimple = 0x20+0x40+0x80+0x400+0x2000,
  212. eTypeFlags_MiddlePDU = 0x8000,
  213. } TypeFlags_e;
  214. /* ------ hack directives ------ */
  215. typedef struct PrivateDirectives_s
  216. {
  217. char *pszTypeName;
  218. char *pszFieldName;
  219. char *pszValueName;
  220. int fSLinked;
  221. int fDLinked;
  222. int fPublic;
  223. int fLenPtr;
  224. int fPointer; // pointer to fixed array, in PER SeqOf/SetOf only
  225. int fArray;
  226. int fIntx;
  227. int fNoCode;
  228. int fNoMemCopy;
  229. int fOidPacked;
  230. int fOidArray;
  231. } PrivateDirectives_t;
  232. void PropagatePrivateDirectives ( Type_t *pDst, PrivateDirectives_t *pSrc );
  233. void PropagateReferenceTypePrivateDirectives ( Type_t *pDst, PrivateDirectives_t *pSrc );
  234. char *GetPrivateValueName(PrivateDirectives_t *pPrivateDirectives, char *pszDefValueName);
  235. /* --- ExtensionType --- */
  236. typedef enum {
  237. eExtensionType_Automatic,
  238. eExtensionType_None
  239. } ExtensionType_e;
  240. /* --- PERConstraint --- */
  241. struct PERConstraint_s {
  242. Extension_e Type;
  243. ValueConstraintList_t Root;
  244. ValueConstraintList_t Additional;
  245. };
  246. /* --- PERConstraints --- */
  247. struct PERConstraints_s {
  248. PERConstraint_t Value;
  249. PERConstraint_t Size;
  250. PERConstraint_t PermittedAlphabet;
  251. };
  252. /* --- PERSimpleTypeInfo --- */
  253. typedef enum {
  254. ePERSTIConstraint_Unconstrained,
  255. ePERSTIConstraint_Semiconstrained,
  256. ePERSTIConstraint_Upperconstrained,
  257. ePERSTIConstraint_Constrained
  258. } PERSTIConstraint_e;
  259. typedef enum {
  260. ePERSTIAlignment_BitAligned,
  261. ePERSTIAlignment_OctetAligned
  262. } PERSTIAlignment_e;
  263. typedef enum {
  264. ePERSTIData_Null,
  265. ePERSTIData_Boolean,
  266. ePERSTIData_Unsigned,
  267. ePERSTIData_Integer,
  268. ePERSTIData_Real,
  269. ePERSTIData_BitString,
  270. ePERSTIData_RZBBitString,
  271. ePERSTIData_OctetString,
  272. ePERSTIData_UTF8String,
  273. ePERSTIData_SequenceOf,
  274. ePERSTIData_SetOf,
  275. ePERSTIData_ObjectIdentifier,
  276. ePERSTIData_NormallySmall,
  277. ePERSTIData_String,
  278. ePERSTIData_TableString,
  279. ePERSTIData_ZeroString,
  280. ePERSTIData_ZeroTableString,
  281. ePERSTIData_Reference,
  282. ePERSTIData_Extension,
  283. ePERSTIData_External,
  284. ePERSTIData_EmbeddedPdv,
  285. ePERSTIData_MultibyteString,
  286. ePERSTIData_UnrestrictedString,
  287. ePERSTIData_GeneralizedTime,
  288. ePERSTIData_UTCTime,
  289. ePERSTIData_Open
  290. } PERSTIData_e;
  291. typedef enum {
  292. ePERSTILength_NoLength,
  293. ePERSTILength_Length,
  294. ePERSTILength_BitLength,
  295. ePERSTILength_SmallLength,
  296. ePERSTILength_InfiniteLength
  297. } PERSTILength_e;
  298. struct PERSimpleTypeInfo_s {
  299. PERSTIData_e Data; /* data type of value */
  300. char *TableIdentifier; /* name of stringtable to use */
  301. ValueConstraintList_t Table; /* stringtable values */
  302. Type_t *SubType; /* subtype */
  303. char *SubIdentifier; /* name of subtype */
  304. NamedValue_t *Identification; /* identification of EMB.PDV/CH.STR */
  305. PERSTIConstraint_e Constraint; /* constraint of type values */
  306. intx_t LowerVal; /* lower bound of type values */
  307. intx_t UpperVal; /* upper bound of type values */
  308. uint32_t NBits; /* number of bits to use */
  309. PERSTIAlignment_e Alignment; /* alignment for encoded value */
  310. PERSTILength_e Length; /* type of length encoding */
  311. PERSTIConstraint_e LConstraint; /* constraint of length */
  312. uint32_t LLowerVal; /* lower bound of length */
  313. uint32_t LUpperVal; /* upper bound of length */
  314. uint32_t LNBits; /* number of bits to use for length */
  315. PERSTIAlignment_e LAlignment; /* alignment for encoded length */
  316. uint32_t cbFixedSizeBitString; // number of bits in the bit string of fixed size
  317. };
  318. /* --- PERTypeInfo --- */
  319. typedef enum {
  320. eBERSTIData_Null,
  321. eBERSTIData_Boolean,
  322. eBERSTIData_Unsigned,
  323. eBERSTIData_Integer,
  324. eBERSTIData_Real,
  325. eBERSTIData_BitString,
  326. eBERSTIData_RZBBitString,
  327. eBERSTIData_OctetString,
  328. eBERSTIData_UTF8String,
  329. eBERSTIData_SequenceOf,
  330. eBERSTIData_SetOf,
  331. eBERSTIData_Choice,
  332. eBERSTIData_Sequence,
  333. eBERSTIData_Set,
  334. eBERSTIData_ObjectIdentifier,
  335. eBERSTIData_ObjectIdEncoded,
  336. eBERSTIData_String,
  337. eBERSTIData_ZeroString,
  338. eBERSTIData_Reference,
  339. eBERSTIData_External,
  340. eBERSTIData_EmbeddedPdv,
  341. eBERSTIData_MultibyteString,
  342. eBERSTIData_UnrestrictedString,
  343. eBERSTIData_GeneralizedTime,
  344. eBERSTIData_UTCTime,
  345. eBERSTIData_Open
  346. } BERSTIData_e;
  347. struct PERTypeInfo_s {
  348. char *Identifier; /* the complete name of the type */
  349. TypeFlags_e Flags; /* encoding flags */
  350. TypeRules_e Rules; /* encoding directive rules */
  351. intx_t **EnumerationValues; /* values of enumeration */
  352. int32_t NOctets; /* size of string chars/integer type */
  353. Extension_e Type; /* extension type */
  354. PERSimpleTypeInfo_t Root; /* info for the extension root */
  355. PERSimpleTypeInfo_t Additional; /* info for the extensions */
  356. PrivateDirectives_t *pPrivateDirectives;
  357. };
  358. /* --- BERTypeInfo --- */
  359. struct BERTypeInfo_s {
  360. char *Identifier; /* the complete name of the type */
  361. TypeFlags_e Flags; /* encoding flags */
  362. TypeRules_e Rules; /* encoding directive rules */
  363. int32_t NOctets; /* size of string chars/integer type */
  364. BERSTIData_e Data; /* data type of value */
  365. Type_t *SubType; /* subtype */
  366. char *SubIdentifier; /* name of subtype */
  367. TagList_t Tags; /* tags of this type */
  368. PrivateDirectives_t *pPrivateDirectives;
  369. };
  370. /* --- Type --- */
  371. /* bit 0..4: universal tag;
  372. bit 14: internal bit to distingish types using same universal tag;
  373. bit 15: set for internal types */
  374. typedef enum {
  375. eType_Boolean = 0x0001,
  376. eType_Integer = 0x0002,
  377. eType_BitString = 0x0003,
  378. eType_OctetString = 0x0004,
  379. eType_Null = 0x0005,
  380. eType_ObjectIdentifier = 0x0006,
  381. eType_ObjectDescriptor = 0x0007,
  382. eType_External = 0x0008,
  383. eType_InstanceOf = 0x4008,
  384. eType_Real = 0x0009,
  385. eType_Enumerated = 0x000a,
  386. eType_EmbeddedPdv = 0x000b,
  387. eType_UTF8String = 0x000c,
  388. eType_Sequence = 0x0010,
  389. eType_SequenceOf = 0x4010,
  390. eType_Set = 0x0011,
  391. eType_SetOf = 0x4011,
  392. eType_NumericString = 0x0012,
  393. eType_PrintableString = 0x0013,
  394. eType_TeletexString = 0x0014,
  395. eType_T61String = 0x4014,
  396. eType_VideotexString = 0x0015,
  397. eType_IA5String = 0x0016,
  398. eType_UTCTime = 0x0017,
  399. eType_GeneralizedTime = 0x0018,
  400. eType_GraphicString = 0x0019,
  401. eType_VisibleString = 0x001a,
  402. eType_ISO646String = 0x401a,
  403. eType_GeneralString = 0x001b,
  404. eType_UniversalString = 0x001c,
  405. eType_CharacterString = 0x001d,
  406. eType_BMPString = 0x001e,
  407. eType_Choice = 0x8000,
  408. eType_Selection = 0x8001,
  409. eType_Reference = 0x8002,
  410. eType_FieldReference = 0x8003,
  411. eType_RestrictedString = 0x8004,
  412. eType_Open = 0x8005,
  413. eType_Undefined = 0x8006,
  414. eType_Macro = 0x8007
  415. } Type_e;
  416. struct Type_s {
  417. TagList_t Tags;
  418. TagList_t AllTags;
  419. TagList_t FirstTags;
  420. Constraint_t *Constraints;
  421. DirectiveList_t Directives;
  422. Type_e Type;
  423. TypeFlags_e Flags;
  424. TypeRules_e Rules;
  425. PERConstraints_t PERConstraints;
  426. PERTypeInfo_t PERTypeInfo;
  427. BERTypeInfo_t BERTypeInfo;
  428. TagType_e TagDefault;
  429. ExtensionType_e ExtensionDefault;
  430. PrivateDirectives_t PrivateDirectives;
  431. union {
  432. struct {
  433. NamedNumberList_t NamedNumbers;
  434. } Integer, Enumerated, BitString, IEB;
  435. struct {
  436. ComponentList_t Components;
  437. uint32_t Optionals; /* not for Choice */
  438. uint32_t Alternatives; /* only for Choice */
  439. uint32_t Extensions;
  440. uint8_t Autotag[2];
  441. } Sequence, Set, Choice, SSC,
  442. Real, External, EmbeddedPdv, CharacterString, InstanceOf;
  443. struct {
  444. Type_t *Type;
  445. DirectiveList_t Directives;
  446. } SequenceOf, SetOf, SS;
  447. struct {
  448. char *Identifier;
  449. Type_t *Type;
  450. } Selection;
  451. struct {
  452. ModuleIdentifier_t *Module;
  453. char *Identifier;
  454. } Reference;
  455. struct {
  456. ObjectClass_t *ObjectClass;
  457. char *Identifier;
  458. } FieldReference;
  459. struct {
  460. Macro_t *Macro;
  461. MacroLocalAssignmentList_t LocalAssignments;
  462. } Macro;
  463. } U;
  464. };
  465. #define UndefType ((Type_t *)UNDEFINED_VALUE)
  466. Type_t *NewType(Type_e type);
  467. Type_t *DupType(Type_t *src);
  468. Assignment_t *GetAssignedExternalType(AssignmentList_t *a, ModuleIdentifier_t *module, char *identifier);
  469. Type_t *GetType(AssignmentList_t ass, Type_t *type);
  470. Type_e GetTypeType(AssignmentList_t ass, Type_t *type);
  471. TypeRules_e GetTypeRules(AssignmentList_t ass, Type_t *type);
  472. int IsRestrictedString(Type_e type);
  473. int IsStructuredType(Type_t *type);
  474. int IsSequenceType(Type_t *type);
  475. int IsReferenceType(Type_t *type);
  476. Type_t *GetReferencedType(AssignmentList_t a, Type_t *type);
  477. /* --- EndPoint --- */
  478. typedef enum {
  479. eEndPoint_Min = 1,
  480. eEndPoint_Max = 2,
  481. eEndPoint_Open = 4
  482. } EndPoint_e;
  483. struct EndPoint_s {
  484. EndPoint_e Flags;
  485. Value_t *Value;
  486. };
  487. EndPoint_t *NewEndPoint();
  488. EndPoint_t *GetLowerEndPoint(AssignmentList_t ass, EndPoint_t *e);
  489. EndPoint_t *GetUpperEndPoint(AssignmentList_t ass, EndPoint_t *e);
  490. int CmpLowerEndPoint(AssignmentList_t ass, EndPoint_t *v1, EndPoint_t *v2);
  491. int CmpUpperEndPoint(AssignmentList_t ass, EndPoint_t *v1, EndPoint_t *v2);
  492. int CmpLowerUpperEndPoint(AssignmentList_t ass, EndPoint_t *v1, EndPoint_t *v2);
  493. int CheckEndPointsJoin(AssignmentList_t ass, EndPoint_t *v1, EndPoint_t *v2);
  494. /* --- Constraint --- */
  495. struct Constraint_s {
  496. Extension_e Type;
  497. ElementSetSpec_t *Root;
  498. ElementSetSpec_t *Additional;
  499. /*XXX exception spec */
  500. };
  501. Constraint_t *NewConstraint();
  502. Constraint_t *DupConstraint(Constraint_t *src);
  503. void IntersectConstraints(Constraint_t **ret, Constraint_t *c1, Constraint_t *c2);
  504. /* --- ElementSetSpec --- */
  505. typedef enum {
  506. eElementSetSpec_AllExcept,
  507. eElementSetSpec_Union,
  508. eElementSetSpec_Intersection,
  509. eElementSetSpec_Exclusion,
  510. eElementSetSpec_SubtypeElement,
  511. eElementSetSpec_ObjectSetElement
  512. } ElementSetSpec_e;
  513. struct ElementSetSpec_s {
  514. ElementSetSpec_e Type;
  515. union {
  516. struct {
  517. ElementSetSpec_t *Elements;
  518. } AllExcept;
  519. struct {
  520. ElementSetSpec_t *Elements1;
  521. ElementSetSpec_t *Elements2;
  522. } Union, Intersection, Exclusion, UIE;
  523. struct {
  524. SubtypeElement_t *SubtypeElement;
  525. } SubtypeElement;
  526. struct {
  527. ObjectSetElement_t *ObjectSetElement;
  528. } ObjectSetElement;
  529. } U;
  530. };
  531. ElementSetSpec_t *NewElementSetSpec(ElementSetSpec_e type);
  532. ElementSetSpec_t *DupElementSetSpec(ElementSetSpec_t *src);
  533. /* --- SubtypeElement --- */
  534. typedef enum {
  535. eSubtypeElement_ValueRange,
  536. eSubtypeElement_Size,
  537. eSubtypeElement_SingleValue,
  538. eSubtypeElement_PermittedAlphabet,
  539. eSubtypeElement_ContainedSubtype,
  540. eSubtypeElement_Type,
  541. eSubtypeElement_SingleType,
  542. eSubtypeElement_FullSpecification,
  543. eSubtypeElement_PartialSpecification,
  544. eSubtypeElement_ElementSetSpec
  545. } SubtypeElement_e;
  546. struct SubtypeElement_s {
  547. SubtypeElement_e Type;
  548. union {
  549. struct {
  550. EndPoint_t Lower;
  551. EndPoint_t Upper;
  552. } ValueRange;
  553. struct {
  554. Constraint_t *Constraints;
  555. } Size, PermittedAlphabet, SingleType, SPS;
  556. struct {
  557. Value_t *Value;
  558. } SingleValue;
  559. struct {
  560. Type_t *Type;
  561. } ContainedSubtype;
  562. struct {
  563. Type_t *Type;
  564. } Type;
  565. struct {
  566. NamedConstraintList_t NamedConstraints;
  567. } FullSpecification, PartialSpecification, FP;
  568. struct {
  569. ElementSetSpec_t *ElementSetSpec;
  570. } ElementSetSpec;
  571. } U;
  572. };
  573. SubtypeElement_t *NewSubtypeElement(SubtypeElement_e type);
  574. SubtypeElement_t *DupSubtypeElement(SubtypeElement_t *src);
  575. /* --- ObjectSetElement --- */
  576. typedef enum {
  577. eObjectSetElement_Object,
  578. eObjectSetElement_ObjectSet,
  579. eObjectSetElement_ElementSetSpec
  580. } ObjectSetElement_e;
  581. struct ObjectSetElement_s {
  582. ObjectSetElement_e Type;
  583. union {
  584. struct {
  585. Object_t *Object;
  586. } Object;
  587. struct {
  588. ObjectSet_t *ObjectSet;
  589. } ObjectSet;
  590. struct {
  591. ElementSetSpec_t *ElementSetSpec;
  592. } ElementSetSpec;
  593. } U;
  594. };
  595. ObjectSetElement_t *NewObjectSetElement(ObjectSetElement_e type);
  596. ObjectSetElement_t *DupObjectSetElement(ObjectSetElement_t *src);
  597. /* --- NamedConstraints --- */
  598. typedef enum {
  599. ePresence_Present,
  600. ePresence_Absent,
  601. ePresence_Optional,
  602. ePresence_Normal
  603. } Presence_e;
  604. struct NamedConstraint_s {
  605. NamedConstraintList_t Next;
  606. char *Identifier;
  607. Constraint_t *Constraint;
  608. Presence_e Presence;
  609. };
  610. NamedConstraint_t *NewNamedConstraint(void);
  611. NamedConstraint_t *DupNamedConstraint(NamedConstraint_t *src);
  612. /* --- NamedNumber --- */
  613. typedef enum {
  614. eNamedNumber_Normal,
  615. eNamedNumber_ExtensionMarker
  616. } NamedNumbers_e;
  617. struct NamedNumber_s {
  618. NamedNumberList_t Next;
  619. NamedNumbers_e Type;
  620. union {
  621. struct {
  622. char *Identifier;
  623. Value_t *Value;
  624. } Normal;
  625. struct {
  626. int dummy; /* ExceptionSpec */
  627. } ExtensionMarker;
  628. } U;
  629. };
  630. NamedNumber_t *NewNamedNumber(NamedNumbers_e type);
  631. NamedNumber_t *DupNamedNumber(NamedNumber_t *src);
  632. NamedNumber_t *FindNamedNumber(NamedNumberList_t numbers, char *identifier);
  633. /* --- ValueConstraints --- */
  634. struct ValueConstraint_s {
  635. ValueConstraintList_t Next;
  636. EndPoint_t Lower;
  637. EndPoint_t Upper;
  638. };
  639. ValueConstraint_t *NewValueConstraint();
  640. ValueConstraint_t *DupValueConstraint(ValueConstraint_t *src);
  641. int CountValues(AssignmentList_t ass, ValueConstraintList_t v, intx_t *n);
  642. int HasNoValueConstraint(ValueConstraintList_t v);
  643. int HasNoSizeConstraint(AssignmentList_t ass, ValueConstraintList_t v);
  644. int HasNoPermittedAlphabetConstraint(AssignmentList_t ass, ValueConstraintList_t v);
  645. NamedValue_t *GetFixedIdentification(AssignmentList_t ass, Constraint_t *constraints);
  646. /* --- NamedType --- */
  647. struct NamedType_s {
  648. char *Identifier;
  649. Type_t *Type;
  650. };
  651. NamedType_t *NewNamedType(char *identifier, Type_t *type);
  652. NamedType_t *DupNamedType(NamedType_t *src);
  653. /* --- Components --- */
  654. typedef enum {
  655. eComponent_Normal,
  656. eComponent_Optional,
  657. eComponent_Default,
  658. eComponent_ComponentsOf,
  659. eComponent_ExtensionMarker
  660. } Components_e;
  661. struct Component_s {
  662. ComponentList_t Next;
  663. Components_e Type;
  664. union {
  665. struct {
  666. NamedType_t *NamedType;
  667. Value_t *Value; /* only Default */
  668. } Normal, Optional, Default, NOD;
  669. struct {
  670. Type_t *Type;
  671. } ComponentsOf;
  672. struct {
  673. int dummy; /* ExceptionSpec */
  674. } ExtensionMarker;
  675. } U;
  676. };
  677. Component_t *NewComponent(Components_e type);
  678. Component_t *DupComponent(Component_t *src);
  679. Component_t *FindComponent(AssignmentList_t ass, ComponentList_t components, char *identifier);
  680. /* --- NamedValues --- */
  681. struct NamedValue_s {
  682. NamedValueList_t Next;
  683. char *Identifier;
  684. Value_t *Value;
  685. };
  686. NamedValue_t *NewNamedValue(char *identifier, Value_t *value);
  687. NamedValue_t *DupNamedValue(NamedValue_t *src);
  688. NamedValue_t *FindNamedValue(NamedValueList_t namedValues, char *identifier);
  689. /* --- NamedObjIdValue --- */
  690. typedef enum {
  691. eNamedObjIdValue_NameForm,
  692. eNamedObjIdValue_NumberForm,
  693. eNamedObjIdValue_NameAndNumberForm
  694. } NamedObjIdValue_e;
  695. struct NamedObjIdValue_s {
  696. NamedObjIdValueList_t Next;
  697. NamedObjIdValue_e Type;
  698. char *Name;
  699. uint32_t Number;
  700. };
  701. NamedObjIdValue_t *NewNamedObjIdValue(NamedObjIdValue_e type);
  702. NamedObjIdValue_t *DupNamedObjIdValue(NamedObjIdValue_t *src);
  703. int GetAssignedObjectIdentifier(AssignedObjIdList_t *aoi, Value_t *parent, NamedObjIdValueList_t named, Value_t **val);
  704. /* --- asn1c_objectidentifier_t --- */
  705. typedef struct asn1c_objectidentifier_s
  706. {
  707. ASN1uint32_t length;
  708. objectnumber_t *value;
  709. } asn1c_objectidentifier_t;
  710. /* --- Value --- */
  711. typedef enum {
  712. eValueFlags_GenValue = 1, /* generate value definition */
  713. eValueFlags_GenExternValue = 2, /* generate external value declaration */
  714. eValueFlags_GenAll = 3,
  715. eValueFlags_Done = 4 /* examination done */
  716. } ValueFlags_e;
  717. struct Value_s {
  718. Value_t *Next;
  719. Type_t *Type;
  720. ValueFlags_e Flags;
  721. union {
  722. struct {
  723. uint32_t Value;
  724. } Boolean;
  725. struct {
  726. intx_t Value;
  727. } Integer;
  728. struct {
  729. uint32_t Value;
  730. } Enumerated;
  731. struct {
  732. real_t Value;
  733. } Real;
  734. struct {
  735. bitstring_t Value;
  736. } BitString;
  737. struct {
  738. octetstring_t Value;
  739. } OctetString;
  740. struct {
  741. ASN1wstring_t Value;
  742. } UTF8String;
  743. struct {
  744. NamedValueList_t NamedValues;
  745. } Sequence, Set, Choice, SSC,
  746. External, EmbeddedPdv, CharacterString, InstanceOf;
  747. struct {
  748. ValueList_t Values;
  749. } SequenceOf, SetOf, SS;
  750. struct {
  751. asn1c_objectidentifier_t Value;
  752. } ObjectIdentifier;
  753. struct {
  754. char32string_t Value;
  755. } RestrictedString, ObjectDescriptor;
  756. struct {
  757. generalizedtime_t Value;
  758. } GeneralizedTime;
  759. struct {
  760. utctime_t Value;
  761. } UTCTime;
  762. struct {
  763. ModuleIdentifier_t *Module;
  764. char *Identifier;
  765. } Reference;
  766. } U;
  767. };
  768. #define UndefValue ((Value_t *)UNDEFINED_VALUE)
  769. Value_t *NewValue(AssignmentList_t ass, Type_t *type);
  770. Value_t *DupValue(Value_t *src);
  771. Value_t *GetValue(AssignmentList_t ass, Value_t *value);
  772. Assignment_t *GetAssignedExternalValue(AssignmentList_t *a, ModuleIdentifier_t *module, char *identifier);
  773. int CmpValue(AssignmentList_t ass, Value_t *v1, Value_t *v2);
  774. int SubstractValues(AssignmentList_t ass, intx_t *dst, Value_t *src1, Value_t *src2);
  775. /* --- ValueSet --- */
  776. struct ValueSet_s {
  777. ElementSetSpec_t *Elements;
  778. Type_t *Type;
  779. };
  780. ValueSet_t *NewValueSet();
  781. ValueSet_t *DupValueSet(ValueSet_t *src);
  782. /* --- Macro --- */
  783. typedef enum {
  784. eMacro_Macro,
  785. eMacro_Reference
  786. } Macro_e;
  787. struct Macro_s {
  788. Macro_e Type;
  789. union {
  790. struct {
  791. MacroProduction_t *TypeProduction;
  792. MacroProduction_t *ValueProduction;
  793. NamedMacroProductionList_t SupportingProductions;
  794. } Macro;
  795. struct {
  796. ModuleIdentifier_t *Module;
  797. char *Identifier;
  798. } Reference;
  799. } U;
  800. };
  801. Macro_t *NewMacro(Macro_e type);
  802. Macro_t *DupMacro(Macro_t *src);
  803. Macro_t *GetMacro(AssignmentList_t ass, Macro_t *src);
  804. /* --- MacroProduction --- */
  805. typedef enum {
  806. eMacroProduction_Alternative,
  807. eMacroProduction_Sequence,
  808. eMacroProduction_AString,
  809. eMacroProduction_ProductionReference,
  810. eMacroProduction_String,
  811. eMacroProduction_Identifier,
  812. eMacroProduction_Number,
  813. eMacroProduction_Empty,
  814. eMacroProduction_Type,
  815. eMacroProduction_Value,
  816. eMacroProduction_LocalTypeAssignment,
  817. eMacroProduction_LocalValueAssignment
  818. } MacroProduction_e;
  819. struct MacroProduction_s {
  820. MacroProduction_e Type;
  821. union {
  822. struct {
  823. MacroProduction_t *Production1;
  824. MacroProduction_t *Production2;
  825. } Alternative, Sequence;
  826. struct {
  827. char *String;
  828. } AString;
  829. struct {
  830. char *Reference;
  831. } ProductionReference;
  832. struct {
  833. char *LocalTypeReference;
  834. } Type;
  835. struct {
  836. char *LocalValueReference;
  837. char *LocalTypeReference;
  838. Type_t *Type;
  839. } Value;
  840. struct {
  841. char *LocalTypeReference;
  842. Type_t *Type;
  843. } LocalTypeAssignment;
  844. struct {
  845. char *LocalValueReference;
  846. Value_t *Value;
  847. } LocalValueAssignment;
  848. } U;
  849. };
  850. #define UndefProduction ((MacroProduction_t *)UNDEFINED_VALUE)
  851. MacroProduction_t *NewMacroProduction(MacroProduction_e type);
  852. MacroProduction_t *DupMacroProduction(MacroProduction_t *src);
  853. /* --- NamedMacroProduction --- */
  854. struct NamedMacroProduction_s {
  855. NamedMacroProductionList_t Next;
  856. char *Identifier;
  857. MacroProduction_t *Production;
  858. };
  859. NamedMacroProduction_t *NewNamedMacroProduction();
  860. NamedMacroProduction_t *DupNamedMacroProduction(NamedMacroProduction_t *src);
  861. /* --- MacroLocalAssignment --- */
  862. typedef enum {
  863. eMacroLocalAssignment_Type,
  864. eMacroLocalAssignment_Value
  865. } MacroLocalAssignment_e;
  866. struct MacroLocalAssignment_s {
  867. MacroLocalAssignmentList_t Next;
  868. char *Identifier;
  869. MacroLocalAssignment_e Type;
  870. union {
  871. Type_t *Type;
  872. Value_t *Value;
  873. } U;
  874. };
  875. MacroLocalAssignment_t *NewMacroLocalAssignment(MacroLocalAssignment_e type);
  876. MacroLocalAssignment_t *DupMacroLocalAssignment(MacroLocalAssignment_t *src);
  877. MacroLocalAssignment_t *FindMacroLocalAssignment(MacroLocalAssignmentList_t la, char *ide);
  878. /* --- Quadruple --- */
  879. struct Quadruple_s {
  880. uint32_t Group;
  881. uint32_t Plane;
  882. uint32_t Row;
  883. uint32_t Cell;
  884. };
  885. /* --- Tuple --- */
  886. struct Tuple_s {
  887. uint32_t Column;
  888. uint32_t Row;
  889. };
  890. /* --- Directive --- */
  891. typedef enum {
  892. eDirective_None,
  893. eDirective_FixedArray,
  894. eDirective_DoublyLinkedList,
  895. eDirective_SinglyLinkedList,
  896. eDirective_LengthPointer,
  897. eDirective_ZeroTerminated,
  898. eDirective_Pointer,
  899. eDirective_NoPointer
  900. } Directives_e;
  901. struct Directive_s {
  902. DirectiveList_t Next;
  903. Directives_e Type;
  904. /* may be extended in future ... */
  905. };
  906. Directive_t *NewDirective(Directives_e type);
  907. Directive_t *DupDirective(Directive_t *src);
  908. /* --- ModuleIdentifier --- */
  909. struct ModuleIdentifier_s {
  910. char *Identifier;
  911. Value_t *ObjectIdentifier;
  912. };
  913. ModuleIdentifier_t *NewModuleIdentifier(void);
  914. ModuleIdentifier_t *DupModuleIdentifier(ModuleIdentifier_t *src);
  915. int CmpModuleIdentifier(AssignmentList_t ass, ModuleIdentifier_t *mod1, ModuleIdentifier_t *mod2);
  916. /* --- ObjectClass --- */
  917. typedef enum {
  918. eObjectClass_ObjectClass,
  919. eObjectClass_Reference,
  920. eObjectClass_FieldReference
  921. } ObjectClass_e;
  922. struct ObjectClass_s {
  923. ObjectClass_e Type;
  924. union {
  925. struct {
  926. FieldSpecList_t FieldSpec;
  927. SyntaxSpecList_t SyntaxSpec;
  928. } ObjectClass;
  929. struct {
  930. ModuleIdentifier_t *Module;
  931. char *Identifier;
  932. } Reference;
  933. struct {
  934. ObjectClass_t *ObjectClass;
  935. char *Identifier;
  936. } FieldReference;
  937. } U;
  938. };
  939. ObjectClass_t *NewObjectClass(ObjectClass_e type);
  940. ObjectClass_t *DupObjectClass(ObjectClass_t *src);
  941. ObjectClass_t *GetObjectClass(AssignmentList_t ass, ObjectClass_t *oc);
  942. int AssignObjectClass(AssignmentList_t *ass, ObjectClass_t *lhs, ObjectClass_t *rhs);
  943. Assignment_t *GetAssignedExternalObjectClass(ModuleIdentifier_t *module, char *identifier);
  944. /* --- Object --- */
  945. typedef enum {
  946. eObject_Object,
  947. eObject_Reference
  948. } Object_e;
  949. struct Object_s {
  950. Object_e Type;
  951. union {
  952. struct {
  953. ObjectClass_t *ObjectClass;
  954. SettingList_t Settings;
  955. } Object;
  956. struct {
  957. ModuleIdentifier_t *Module;
  958. char *Identifier;
  959. } Reference;
  960. } U;
  961. };
  962. Object_t *NewObject(Object_e type);
  963. Object_t *DupObject(Object_t *src);
  964. Object_t *GetObject(AssignmentList_t ass, Object_t *src);
  965. int AssignObject(AssignmentList_t *ass, Object_t *lhs, Object_t *rhs);
  966. Assignment_t *GetAssignedExternalObject(ModuleIdentifier_t *module, char *identifier);
  967. /* --- ObjectSet --- */
  968. typedef enum {
  969. eObjectSet_ObjectSet,
  970. eObjectSet_Reference,
  971. eObjectSet_ExtensionMarker
  972. } ObjectSet_e;
  973. struct ObjectSet_s {
  974. ObjectSet_e Type;
  975. union {
  976. struct {
  977. ObjectClass_t *ObjectClass;
  978. ElementSetSpec_t *Elements; /* only for ObjectSet */
  979. } ObjectSet, ExtensionMarker, OE;
  980. struct {
  981. ModuleIdentifier_t *Module;
  982. char *Identifier;
  983. } Reference;
  984. } U;
  985. };
  986. ObjectSet_t *NewObjectSet(ObjectSet_e type);
  987. ObjectSet_t *DupObjectSet(ObjectSet_t *src);
  988. ObjectSet_t *GetObjectSet(AssignmentList_t ass, ObjectSet_t *src);
  989. int AssignObjectSet(AssignmentList_t *ass, ObjectSet_t *lhs, ObjectSet_t *rhs);
  990. Assignment_t *GetAssignedExternalObjectSet(ModuleIdentifier_t *module, char *identifier);
  991. /* --- Settings --- */
  992. typedef enum {
  993. eSetting_Type,
  994. eSetting_Value,
  995. eSetting_ValueSet,
  996. eSetting_Object,
  997. eSetting_ObjectSet,
  998. eSetting_Undefined
  999. } Settings_e;
  1000. struct Setting_s {
  1001. SettingList_t Next;
  1002. Settings_e Type;
  1003. char *Identifier;
  1004. union {
  1005. struct {
  1006. Type_t *Type;
  1007. } Type;
  1008. struct {
  1009. Value_t *Value;
  1010. } Value;
  1011. struct {
  1012. ValueSet_t *ValueSet;
  1013. } ValueSet;
  1014. struct {
  1015. Object_t *Object;
  1016. } Object;
  1017. struct {
  1018. ObjectSet_t *ObjectSet;
  1019. } ObjectSet;
  1020. } U;
  1021. };
  1022. Setting_t *NewSetting(Settings_e type);
  1023. Setting_t *DupSetting(Setting_t *src);
  1024. Settings_e GetSettingType(Setting_t *src);
  1025. Setting_t *FindSetting(SettingList_t se, char *identifier);
  1026. /* --- SyntaxSpec --- */
  1027. typedef enum {
  1028. eSyntaxSpec_Literal,
  1029. eSyntaxSpec_Field,
  1030. eSyntaxSpec_Optional
  1031. } SyntaxSpecs_e;
  1032. struct SyntaxSpec_s {
  1033. SyntaxSpecList_t Next;
  1034. SyntaxSpecs_e Type;
  1035. union {
  1036. struct {
  1037. char *Literal;
  1038. } Literal;
  1039. struct {
  1040. char *Field;
  1041. } Field;
  1042. struct {
  1043. SyntaxSpecList_t SyntaxSpec;
  1044. } Optional;
  1045. } U;
  1046. };
  1047. #define UndefSyntaxSpecs ((SyntaxSpec_t *)UNDEFINED_VALUE)
  1048. SyntaxSpec_t *NewSyntaxSpec(SyntaxSpecs_e type);
  1049. SyntaxSpec_t *DupSyntaxSpec(SyntaxSpec_t *src);
  1050. /* --- Optionality --- */
  1051. typedef enum {
  1052. eOptionality_Normal,
  1053. eOptionality_Optional,
  1054. eOptionality_Default_Type,
  1055. eOptionality_Default_Value,
  1056. eOptionality_Default_ValueSet,
  1057. eOptionality_Default_Object,
  1058. eOptionality_Default_ObjectSet
  1059. } Optionality_e;
  1060. struct Optionality_s {
  1061. Optionality_e Type;
  1062. union {
  1063. Type_t *Type; /* only for Default_Type */
  1064. Value_t *Value; /* only for Default_Value */
  1065. ValueSet_t *ValueSet; /* only for Default_ValueSet */
  1066. Object_t *Object; /* only for Default_Object */
  1067. ObjectSet_t *ObjectSet; /* only for Default_ObjectSet */
  1068. } U;
  1069. };
  1070. Optionality_t *NewOptionality(Optionality_e opt);
  1071. Optionality_t *DupOptionality(Optionality_t *src);
  1072. /* --- FieldSpec --- */
  1073. typedef enum {
  1074. eFieldSpec_Type,
  1075. eFieldSpec_FixedTypeValue,
  1076. eFieldSpec_VariableTypeValue,
  1077. eFieldSpec_FixedTypeValueSet,
  1078. eFieldSpec_VariableTypeValueSet,
  1079. eFieldSpec_Object,
  1080. eFieldSpec_ObjectSet,
  1081. eFieldSpec_Undefined
  1082. } FieldSpecs_e;
  1083. struct FieldSpec_s {
  1084. FieldSpecList_t Next;
  1085. FieldSpecs_e Type;
  1086. char *Identifier;
  1087. union {
  1088. struct {
  1089. Optionality_t *Optionality;
  1090. } Type;
  1091. struct {
  1092. Type_t *Type;
  1093. uint32_t Unique;
  1094. Optionality_t *Optionality;
  1095. } FixedTypeValue;
  1096. struct {
  1097. StringList_t Fields;
  1098. Optionality_t *Optionality;
  1099. } VariableTypeValue;
  1100. struct {
  1101. Type_t *Type;
  1102. Optionality_t *Optionality;
  1103. } FixedTypeValueSet;
  1104. struct {
  1105. StringList_t Fields;
  1106. Optionality_t *Optionality;
  1107. } VariableTypeValueSet;
  1108. struct {
  1109. ObjectClass_t *ObjectClass;
  1110. Optionality_t *Optionality;
  1111. } Object;
  1112. struct {
  1113. ObjectClass_t *ObjectClass;
  1114. Optionality_t *Optionality;
  1115. } ObjectSet;
  1116. } U;
  1117. };
  1118. FieldSpec_t *NewFieldSpec(FieldSpecs_e type);
  1119. FieldSpec_t *DupFieldSpec(FieldSpec_t *src);
  1120. FieldSpec_t *GetFieldSpec(AssignmentList_t ass, FieldSpec_t *fs);
  1121. FieldSpecs_e GetFieldSpecType(AssignmentList_t ass, FieldSpec_t *fs);
  1122. FieldSpec_t *FindFieldSpec(FieldSpecList_t fs, char *identifier);
  1123. /* --- UndefinedSymbol --- */
  1124. typedef enum {
  1125. eUndefinedSymbol_SymbolNotDefined,
  1126. eUndefinedSymbol_SymbolNotExported,
  1127. eUndefinedSymbol_FieldNotDefined,
  1128. eUndefinedSymbol_FieldNotExported
  1129. } UndefinedSymbol_e;
  1130. struct UndefinedSymbol_s {
  1131. UndefinedSymbolList_t Next;
  1132. UndefinedSymbol_e Type;
  1133. union {
  1134. struct {
  1135. char *Identifier;
  1136. ModuleIdentifier_t *Module;
  1137. Assignment_e ReferenceType;
  1138. } Symbol;
  1139. struct {
  1140. char *Identifier;
  1141. ModuleIdentifier_t *Module;
  1142. Settings_e ReferenceFieldType;
  1143. ObjectClass_t *ObjectClass;
  1144. } Field;
  1145. } U;
  1146. };
  1147. UndefinedSymbol_t *NewUndefinedSymbol(UndefinedSymbol_e type, Assignment_e reftype);
  1148. UndefinedSymbol_t *NewUndefinedField(UndefinedSymbol_e type, ObjectClass_t *oc, Settings_e reffieldtype);
  1149. int CmpUndefinedSymbol(AssignmentList_t ass, UndefinedSymbol_t *u1, UndefinedSymbol_t *u2);
  1150. int CmpUndefinedSymbolList(AssignmentList_t ass, UndefinedSymbolList_t u1, UndefinedSymbolList_t u2);
  1151. UndefinedSymbol_t *FindUndefinedSymbol(AssignmentList_t ass, UndefinedSymbolList_t a, Assignment_e type, char *ide, ModuleIdentifier_t *mod);
  1152. UndefinedSymbol_t *FindUndefinedField(AssignmentList_t ass, UndefinedSymbolList_t u, Settings_e fieldtype, ObjectClass_t *oc, char *ide, ModuleIdentifier_t *mod);
  1153. /* --- String --- */
  1154. struct String_s {
  1155. StringList_t Next;
  1156. char *String;
  1157. };
  1158. String_t *NewString(void);
  1159. String_t *DupString(String_t *src);
  1160. String_t *FindString(StringList_t list, char *str);
  1161. #define EXPORT_ALL ((String_t *)1)
  1162. /* --- StringModule --- */
  1163. struct StringModule_s {
  1164. StringModuleList_t Next;
  1165. char *String;
  1166. ModuleIdentifier_t *Module;
  1167. };
  1168. StringModule_t *NewStringModule(void);
  1169. StringModule_t *DupStringModule(StringModule_t *src);
  1170. StringModule_t *FindStringModule(AssignmentList_t ass, StringModuleList_t list, char *str, ModuleIdentifier_t *module);
  1171. #define IMPORT_ALL ((StringModule_t *)1)
  1172. /* --- Language --- */
  1173. typedef enum {
  1174. eLanguage_C,
  1175. eLanguage_Cpp
  1176. } Language_e;
  1177. /* --- Alignment --- */
  1178. typedef enum {
  1179. eAlignment_Unaligned,
  1180. eAlignment_Aligned
  1181. } Alignment_e;
  1182. /* --- Encoding --- */
  1183. typedef enum {
  1184. eEncoding_Basic,
  1185. eEncoding_Packed
  1186. } Encoding_e;
  1187. /* --- SubEncoding --- */
  1188. typedef enum {
  1189. eSubEncoding_Basic = 'B',
  1190. eSubEncoding_Canonical = 'C',
  1191. eSubEncoding_Distinguished = 'D'
  1192. } SubEncoding_e;
  1193. /* --- generation entities --- */
  1194. typedef enum { eStringTable, eEncode, eDecode, eCheck, ePrint, eFree, eCompare, eCopy } TypeFunc_e;
  1195. typedef enum { eDecl, eDefh, eDefn, eInit, eFinit } ValueFunc_e;
  1196. struct Arguments_s {
  1197. char *enccast;
  1198. char *encfunc;
  1199. char *Pencfunc;
  1200. char *deccast;
  1201. char *decfunc;
  1202. char *Pdecfunc;
  1203. char *freecast;
  1204. char *freefunc;
  1205. char *Pfreefunc;
  1206. char *cmpcast;
  1207. char *cmpfunc;
  1208. char *Pcmpfunc;
  1209. };
  1210. /* --- ghost file --- */
  1211. typedef struct GhostFile_s {
  1212. char *pszFileName;
  1213. char *pszModuleName;
  1214. }
  1215. GhostFile_t;
  1216. /* --- utility functions --- */
  1217. char *GetIntType(AssignmentList_t ass, EndPoint_t *lower, EndPoint_t *upper, int32_t *sign);
  1218. char *GetIntegerType(AssignmentList_t ass, Type_t *type, int32_t *sign);
  1219. char *GetRealType(Type_t *type);
  1220. char *GetBooleanType(void);
  1221. char *GetEnumeratedType(AssignmentList_t ass, Type_t *type, int32_t *sign);
  1222. char *GetChoiceType(Type_t *type);
  1223. char *GetStringType(AssignmentList_t ass, Type_t *type, int32_t *noctets, uint32_t *zero);
  1224. uint32_t GetIntBits(intx_t *range);
  1225. void GetPERConstraints(AssignmentList_t ass, Constraint_t *constraints, PERConstraints_t *per);
  1226. char *Identifier2C(char *identifier);
  1227. char *Reference(char *expression);
  1228. char *Dereference(char *expression);
  1229. extern int ForceAllTypes;
  1230. extern char *IntegerRestriction;
  1231. extern char *UIntegerRestriction;
  1232. extern char *RealRestriction;
  1233. extern int Has64Bits;
  1234. extern Language_e g_eProgramLanguage;
  1235. extern Encoding_e g_eEncodingRule;
  1236. extern Alignment_e Alignment;
  1237. extern SubEncoding_e g_eSubEncodingRule;
  1238. int GetUndefined(AssignmentList_t ass, UndefinedSymbol_t *undef);
  1239. void UndefinedError(AssignmentList_t ass, UndefinedSymbolList_t undef, UndefinedSymbolList_t baddef);
  1240. extern FILE *g_finc, *g_fout;
  1241. void InitBuiltin();
  1242. void InitBuiltinASN1CharacterModule();
  1243. void Examination(AssignmentList_t *ass, ModuleIdentifier_t *mainmodule);
  1244. void GenInc(AssignmentList_t ass, FILE *finc, char *module);
  1245. void GenPrg(AssignmentList_t ass, FILE *fprg, char *module, char *incfilename);
  1246. void GenFuncSequenceSetDefaults(AssignmentList_t ass, char *valref, ComponentList_t components, char *obuf, TypeFunc_e et);
  1247. void GenFuncSequenceSetOptionals(AssignmentList_t ass, char *valref, ComponentList_t components, uint32_t optionals, uint32_t extensions, char *obuf, TypeFunc_e et);
  1248. void GenPERHeader();
  1249. void GenPERInit(AssignmentList_t ass, char *module);
  1250. void GenPERFuncType(AssignmentList_t ass, char *module, Assignment_t *at, TypeFunc_e et);
  1251. void GenBERHeader();
  1252. void GenBERInit(AssignmentList_t ass, char *module);
  1253. void GenBERFuncType(AssignmentList_t ass, char *module, Assignment_t *at, TypeFunc_e et);
  1254. void GetMinMax(AssignmentList_t ass, ValueConstraintList_t constraints,
  1255. EndPoint_t *lower, EndPoint_t *upper);
  1256. char *GetTypeName(AssignmentList_t ass, Type_t *type);
  1257. char *PGetTypeName(AssignmentList_t ass, Type_t *type);
  1258. char *GetValueName(AssignmentList_t ass, Value_t *value);
  1259. char *GetObjectClassName(AssignmentList_t ass, ObjectClass_t *oc);
  1260. char *GetName(Assignment_t *a);
  1261. char *PGetName(AssignmentList_t ass, Assignment_t *a);
  1262. Tag_t *GetTag(AssignmentList_t ass, Type_t *type);
  1263. int32_t GetOctets(char *inttype);
  1264. void AutotagType(AssignmentList_t ass, Type_t *type);
  1265. void SortAssignedTypes(AssignmentList_t *ass);
  1266. void ExamineBER(AssignmentList_t ass);
  1267. void ExaminePER(AssignmentList_t ass);
  1268. void GetBERPrototype(Arguments_t *args);
  1269. void GetPERPrototype(Arguments_t *args);
  1270. int String2GeneralizedTime(generalizedtime_t *time, char32string_t *string);
  1271. int String2UTCTime(utctime_t *time, char32string_t *string);
  1272. FieldSpec_t *GetObjectClassField(AssignmentList_t ass, ObjectClass_t *oc, char *field);
  1273. FieldSpec_t *GetFieldSpecFromObjectClass(AssignmentList_t ass, ObjectClass_t *oc, StringList_t fields);
  1274. Setting_t *GetSettingFromObject(AssignmentList_t ass, Object_t *o, StringList_t sl);
  1275. Setting_t *GetSettingFromSettings(AssignmentList_t ass, SettingList_t se, StringList_t sl);
  1276. ObjectClass_t *GetObjectClassFromElementSetSpec(AssignmentList_t ass, ElementSetSpec_t *elems);
  1277. Value_t *GetValueFromObject(AssignmentList_t ass, Object_t *o, StringList_t sl);
  1278. ValueSet_t *GetValueSetFromObject(AssignmentList_t ass, Object_t *o, StringList_t sl);
  1279. Type_t *GetTypeFromObject(AssignmentList_t ass, Object_t *o, StringList_t sl);
  1280. Object_t *GetObjectFromObject(AssignmentList_t ass, Object_t *o, StringList_t sl);
  1281. ObjectSet_t *GetObjectSetFromObject(AssignmentList_t ass, Object_t *o, StringList_t sl);
  1282. ElementSetSpec_t *ConvertElementSetSpecToElementSetSpec(AssignmentList_t ass, ElementSetSpec_t *elems, StringList_t sl, ElementSetSpec_t *(*fn)(AssignmentList_t ass, Object_t *o, StringList_t sl));
  1283. ElementSetSpec_t *ConvertObjectSetToElementSetSpec(AssignmentList_t ass, ObjectSet_t *os, StringList_t sl, ElementSetSpec_t *(*fn)(AssignmentList_t ass, Object_t *o, StringList_t sl));
  1284. ValueSet_t *GetValueSetFromObjectSet(AssignmentList_t ass, ObjectSet_t *os, StringList_t sl);
  1285. ObjectSet_t *GetObjectSetFromObjectSet(AssignmentList_t ass, ObjectSet_t *os, StringList_t sl);
  1286. Type_t *GetTypeOfValueSet(AssignmentList_t ass, ValueSet_t *vs);
  1287. int IsPSetOfType(AssignmentList_t ass, Assignment_t *a);
  1288. // --- The following is added by Microsoft ---
  1289. int IsReservedWord ( char *psz );
  1290. void KeepEnumNames ( char *pszEnumName );
  1291. void KeepOptNames ( char *pszOptName );
  1292. void KeepChoiceNames ( char *pszChoiceName );
  1293. int DoesEnumNameConflict ( char *pszEnumName );
  1294. int DoesOptNameConflict ( char *pszOptName );
  1295. int DoesChoiceNameConflict ( char *pszChoiceName );
  1296. void SetDirective(char *psz);
  1297. void PrintVerbatim(void);
  1298. /* ------ char.c ------ */
  1299. int ASN1is16space(ASN1char16_t c);
  1300. int ASN1str16len(ASN1char16_t *p);
  1301. int ASN1is32space(ASN1char32_t c);
  1302. int ASN1str32len(ASN1char32_t *p);
  1303. int IsImportedLocalDuplicate(AssignmentList_t ass, ModuleIdentifier_t *pMainModule, Assignment_t *curr);
  1304. extern TagType_e g_eDefTagType;
  1305. extern TypeRules_e g_eDefTypeRuleSS_NonSized;
  1306. extern TypeRules_e g_eDefTypeRuleSS_Sized;
  1307. extern int g_fOidArray;
  1308. extern char *g_pszOrigModuleNameLowerCase;
  1309. extern int g_fLongNameForImported;
  1310. extern int g_fExtraStructPtrTypeSS;
  1311. extern int g_fMicrosoftExtensions;
  1312. extern int g_chDirectiveBegin;
  1313. extern int g_chDirectiveEnd;
  1314. extern int g_chDirectiveAND;
  1315. extern char *g_pszApiPostfix;
  1316. extern char *g_pszChoicePostfix;
  1317. extern char *g_pszOptionPostfix;
  1318. extern char *g_pszOptionValue;
  1319. extern void StripModuleName(char *pszDst, char *pszSrc);
  1320. extern int g_cGhostFiles;
  1321. extern GhostFile_t g_aGhostFiles[16];
  1322. #endif // _ASN1C_DEFS_H_