1 | /*
|
---|
2 | * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
|
---|
3 | * (Royal Institute of Technology, Stockholm, Sweden).
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * 1. Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | *
|
---|
13 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
14 | * notice, this list of conditions and the following disclaimer in the
|
---|
15 | * documentation and/or other materials provided with the distribution.
|
---|
16 | *
|
---|
17 | * 3. Neither the name of the Institute nor the names of its contributors
|
---|
18 | * may be used to endorse or promote products derived from this software
|
---|
19 | * without specific prior written permission.
|
---|
20 | *
|
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
---|
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
---|
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
31 | * SUCH DAMAGE.
|
---|
32 | */
|
---|
33 |
|
---|
34 | /* $Id$ */
|
---|
35 |
|
---|
36 | #ifndef _SYMBOL_H
|
---|
37 | #define _SYMBOL_H
|
---|
38 |
|
---|
39 | #include "asn1_queue.h"
|
---|
40 |
|
---|
41 | enum typetype {
|
---|
42 | TBitString,
|
---|
43 | TBoolean,
|
---|
44 | TChoice,
|
---|
45 | TEnumerated,
|
---|
46 | TGeneralString,
|
---|
47 | TGeneralizedTime,
|
---|
48 | TIA5String,
|
---|
49 | TInteger,
|
---|
50 | TNull,
|
---|
51 | TOID,
|
---|
52 | TOctetString,
|
---|
53 | TPrintableString,
|
---|
54 | TSequence,
|
---|
55 | TSequenceOf,
|
---|
56 | TSet,
|
---|
57 | TSetOf,
|
---|
58 | TTag,
|
---|
59 | TType,
|
---|
60 | TUTCTime,
|
---|
61 | TUTF8String,
|
---|
62 | TBMPString,
|
---|
63 | TUniversalString,
|
---|
64 | TVisibleString
|
---|
65 | };
|
---|
66 |
|
---|
67 | typedef enum typetype Typetype;
|
---|
68 |
|
---|
69 | struct type;
|
---|
70 |
|
---|
71 | struct value {
|
---|
72 | enum { booleanvalue,
|
---|
73 | nullvalue,
|
---|
74 | integervalue,
|
---|
75 | stringvalue,
|
---|
76 | objectidentifiervalue
|
---|
77 | } type;
|
---|
78 | union {
|
---|
79 | int booleanvalue;
|
---|
80 | int integervalue;
|
---|
81 | char *stringvalue;
|
---|
82 | struct objid *objectidentifiervalue;
|
---|
83 | } u;
|
---|
84 | };
|
---|
85 |
|
---|
86 | struct member {
|
---|
87 | char *name;
|
---|
88 | char *gen_name;
|
---|
89 | char *label;
|
---|
90 | int val;
|
---|
91 | int optional;
|
---|
92 | int ellipsis;
|
---|
93 | struct type *type;
|
---|
94 | ASN1_TAILQ_ENTRY(member) members;
|
---|
95 | struct value *defval;
|
---|
96 | };
|
---|
97 |
|
---|
98 | typedef struct member Member;
|
---|
99 |
|
---|
100 | ASN1_TAILQ_HEAD(memhead, member);
|
---|
101 |
|
---|
102 | struct symbol;
|
---|
103 |
|
---|
104 | struct tagtype {
|
---|
105 | int tagclass;
|
---|
106 | int tagvalue;
|
---|
107 | enum { TE_IMPLICIT, TE_EXPLICIT } tagenv;
|
---|
108 | };
|
---|
109 |
|
---|
110 | struct range {
|
---|
111 | int min;
|
---|
112 | int max;
|
---|
113 | };
|
---|
114 |
|
---|
115 | enum ctype { CT_CONTENTS, CT_USER } ;
|
---|
116 |
|
---|
117 | struct constraint_spec;
|
---|
118 |
|
---|
119 | struct type {
|
---|
120 | Typetype type;
|
---|
121 | struct memhead *members;
|
---|
122 | struct symbol *symbol;
|
---|
123 | struct type *subtype;
|
---|
124 | struct tagtype tag;
|
---|
125 | struct range *range;
|
---|
126 | struct constraint_spec *constraint;
|
---|
127 | };
|
---|
128 |
|
---|
129 | typedef struct type Type;
|
---|
130 |
|
---|
131 | struct constraint_spec {
|
---|
132 | enum ctype ctype;
|
---|
133 | union {
|
---|
134 | struct {
|
---|
135 | Type *type;
|
---|
136 | struct value *encoding;
|
---|
137 | } content;
|
---|
138 | } u;
|
---|
139 | };
|
---|
140 |
|
---|
141 | struct objid {
|
---|
142 | const char *label;
|
---|
143 | int value;
|
---|
144 | struct objid *next;
|
---|
145 | };
|
---|
146 |
|
---|
147 | struct symbol {
|
---|
148 | char *name;
|
---|
149 | char *gen_name;
|
---|
150 | enum { SUndefined, SValue, Stype } stype;
|
---|
151 | struct value *value;
|
---|
152 | Type *type;
|
---|
153 | };
|
---|
154 |
|
---|
155 | typedef struct symbol Symbol;
|
---|
156 |
|
---|
157 | void initsym (void);
|
---|
158 | Symbol *addsym (char *);
|
---|
159 | void output_name (char *);
|
---|
160 | int checkundefined(void);
|
---|
161 | #endif
|
---|