]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/compiler/core/snacc-util.h
Security-28.tar.gz
[apple/security.git] / SecuritySNACCRuntime / compiler / core / snacc-util.h
1 /*
2 * compiler/core/snacc_util.h
3 *
4 * Copyright (C) 1992 Michael Sample and the University of British Columbia
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/core/snacc-util.h,v 1.1 2001/06/20 21:27:59 dmitch Exp $
12 * $Log: snacc-util.h,v $
13 * Revision 1.1 2001/06/20 21:27:59 dmitch
14 * Adding missing snacc compiler files.
15 *
16 * Revision 1.1.1.1 1999/03/16 18:06:52 aram
17 * Originals from SMIME Free Library.
18 *
19 * Revision 1.3 1995/07/25 19:41:46 rj
20 * changed `_' to `-' in file names.
21 *
22 * Revision 1.2 1994/09/01 00:46:41 rj
23 * snacc_config.h's 2nd last macro, PrintErrLoc(), got here.
24 *
25 * Revision 1.1 1994/08/28 09:49:41 rj
26 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
27 *
28 */
29
30 #define PrintErrLoc( fileName, lineNo)\
31 fprintf (stderr, "file \"%s\", line %d: ", fileName, lineNo)
32
33 /*
34 * macro to allocate room for str & null & put in give STR*
35 */
36 #define SETUP_STR( strPtr, string)\
37 (strPtr)->str = Malloc (strlen (string) + 1);\
38 strcpy ((strPtr)->str, string);\
39 (strPtr)->len = strlen (string) + 1
40
41
42 /*
43 * Create a new list type such that each elmt has space
44 * to hold a pointer
45 */
46 #define NEWLIST() AsnListNew (sizeof (void *))
47
48 /*
49 * macro to append an element to the end of linked list
50 * - helps on left recursion when order must be maintained
51 *
52 * be careful of calling context if list is null
53 * that is, make sure the change to list is not lost.
54 */
55 #define APPEND( elmt, list) \
56 {\
57 void **tmpPtr;\
58 if ((list) == NULL)\
59 (list) = NEWLIST();\
60 tmpPtr = (void **) AsnListAppend ((AsnList *)list);\
61 *tmpPtr = (void *) (elmt);\
62 }
63
64 /*
65 * like APPEND except puts elmt at head of list
66 */
67 #define PREPEND( elmt, list) \
68 {\
69 void **tmpPtr;\
70 if ((list) == NULL)\
71 (list) = NEWLIST();\
72 tmpPtr = (void **)AsnListPrepend ((AsnList *)list);\
73 *tmpPtr = (void *) (elmt);\
74 }
75
76 void SetupType PROTO ((Type **t, enum BasicTypeChoiceId typeId, unsigned long lineNum));
77
78 void SetupMacroType PROTO ((Type **t, enum MacroTypeChoiceId macroTypeId, unsigned long lineNum));
79
80 void SetupValue PROTO ((Value **v, enum BasicValueChoiceId valId, unsigned long lineNum));
81
82
83 void AddPrivateImportElmt PROTO ((Module *m, char *name, char *refModuleName, long int lineNo));
84
85 ImportElmt *LookupImportElmtInModule PROTO ((Module *m, char *name, ImportModule **importModule));
86
87 ImportElmt *LookupImportElmtInImportElmtList PROTO ((ImportElmtList *importElmtList, char *name));
88
89 ImportModule *LookupImportModule PROTO ((Module *m, char *importModuleName));
90
91 TypeDef *LookupType PROTO ((TypeDefList *t, char *typeName));
92
93 Module *LookupModule PROTO ((ModuleList *m, char *modName, OID *oid));
94
95 NamedType *LookupFieldInType PROTO ((Type *t, char *fieldName));
96
97 Type *GetType PROTO ((Type *t));
98
99 Type *ParanoidGetType PROTO ((Type *t));
100
101 enum BasicTypeChoiceId GetBuiltinType PROTO ((Type *t));
102
103 NamedNumberList *GetNamedElmts PROTO ((Type *t));
104
105 NamedNumberList *GetAllNamedElmts PROTO ((Type *t));
106
107 Type *GetParent PROTO ((Type *ancestor, Type *child));
108
109 ValueDef *LookupValue PROTO ((ValueDefList *v, char *valueName));
110
111 Value *GetValue PROTO ((Value *v));
112
113 int CompareOids PROTO ((OID *oid1, OID *oid2));
114
115 int HasNamedElmts PROTO ((Type *t));
116
117 int TagsAreIdentical PROTO ((TagList *t1, TagList *t2));
118
119 int HasDefaultTag PROTO ((Type *t));
120
121 int IsPrimitiveByDefOrRef PROTO ((Type *t));
122
123 int IsPrimitiveByDef PROTO ((Type *t));
124
125 int IsDefinedByLibraryType PROTO ((Type *t));
126
127 int IsTypeRef PROTO ((Type *t));
128
129 int IsNewType PROTO ((Type *t));
130
131 int IsTailOptional PROTO ((NamedTypeList *e));
132
133 int NextIsTailOptional PROTO ((NamedTypeList *e));
134
135 int AllElmtsOptional PROTO ((NamedTypeList *e));
136
137 AnyRefList **GetAnyRefListHndl PROTO ((Type *t));
138
139 void AppendSubtype PROTO ((Subtype **s, Subtype *newSubtype, enum SubtypeChoiceId op));