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