1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/* pepsy.h */
/*
* isode/h/pepsy.h
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
#ifndef PEPSY_DEFINITIONS
#define PEPSY_DEFINITIONS
#ifndef PEPYPARM
#define PEPYPARM char *
#endif
/*
* Definitions for pep tables
*/
#ifdef notdef
typedef struct {
int pe_type; /* Type of entry */
integer pe_ucode; /* index to user's code if any */
int pe_tag; /* Tag of this entry if any */
int pe_flags; /* Flags */
} tpe;
#define NULLTPE ((tpe *)0)
#endif
typedef struct {
int pe_type; /* Type of entry */
integer pe_ucode; /* index to user's code if any */
int pe_tag; /* Tag of this entry if any */
int pe_flags; /* Flags */
char **pe_typename; /* User defined name of variable */
} ptpe;
#define tpe ptpe
#define NULLTPE ((tpe *)0)
#define NULLPTPE ((ptpe *)0)
/* extract a pointer from the pointer table */
#define GPTR(mod, ind, type) ((type )(mod)->md_ptrtab[ind])
/* tricky situation with the "type" - it must not contain the brackets of the
* cast because we supply them here
*/
/* macros for getting values of default flexibly */
#define IVAL(mod, x) ((x)->pe_ucode) /* Integer value */
#define PVAL(mod, x) (GPTR(mod, (x)->pe_tag, char *)) /* (char *) */
#define TVAL(mod, x) ((x)->pe_flags) /* Type - Integer value */
#define RVAL(mod, x) (*GPTR(mod, (x)->pe_tag, double *)) /* double */
/* macros for getting the function pointer (for a FN_CALL entry) */
#define FN_PTR(mod, x) (*GPTR(mod, (x)->pe_ucode, IFP )) /* function ptr */
/* macros for getting other more general pointers transparently */
#define EXT2MOD(mod, x) (GPTR(mod, (x)->pe_ucode, modtyp *))
/* Types */
#define PE_START (-1)
#define PE_END 0
#define XOBJECT 3
#define UCODE 6
#define MEMALLOC 7
#define SCTRL 8
#define CH_ACT 9
#define OPTL 10 /* Optionals field offset */
#define BOPTIONAL 11 /* optional test for next */
#define FFN_CALL 12 /* call the free function */
#define FREE_ONLY 13 /* the next item is only for freeing code */
/* types that generate data */
#define TYPE_DATA 20
#define ANY (TYPE_DATA + 0)
#define INTEGER (TYPE_DATA + 1)
#define BOOLEAN (TYPE_DATA + 2)
#define OBJECT (TYPE_DATA + 3) /* This generates data */
#define BITSTRING (TYPE_DATA + 4)
#define OCTETSTRING (TYPE_DATA + 5)
#define SET_START (TYPE_DATA + 6)
#define SEQ_START (TYPE_DATA + 7)
#define SEQOF_START (TYPE_DATA + 8)
#define SETOF_START (TYPE_DATA + 9)
#define CHOICE_START (TYPE_DATA + 10)
#define REALTYPE (TYPE_DATA + 11) /* ASN.1 Real */
#define T_NULL (TYPE_DATA + 12)
#define T_OID (TYPE_DATA + 13)
#define ETAG (TYPE_DATA + 14) /*so set_find in pr_set is executed*/
#define IMP_OBJ (TYPE_DATA + 15) /*so set_find in pr_set is executed*/
#define EXTOBJ (TYPE_DATA + 16) /* External reference object */
#define EXTMOD (TYPE_DATA + 17) /* External module for above object */
#define OBJID (TYPE_DATA + 18) /* Object Identifier */
#define DFLT_F (TYPE_DATA + 19)/* Default value for following entry */
#define DFLT_B (TYPE_DATA + 20)/* default value for previous entry */
#define T_STRING (TYPE_DATA + 21)/* [[ s ptr ]] supporting entry */
#define OCTET_PTR (TYPE_DATA + 22)/* [[ o ptr $ len]] str entry */
#define OCTET_LEN (TYPE_DATA + 23)/* [[ o ptr $ len]] len entry */
#define BITSTR_PTR (TYPE_DATA + 24)/* [[ x ptr $ len]] str entry */
#define BITSTR_LEN (TYPE_DATA + 25)/* [[ x ptr $ len]] len entry */
#define FN_CALL (TYPE_DATA + 26)/* call a function to do the work */
#if PEPSY_VERSION >= 2
#define STYPE_DATA (TYPE_DATA + 50) /* Below here are the S* items */
#else
#define STYPE_DATA (TYPE_DATA + 30) /* Below here are the S* items */
#endif
/* Optimised - No indirection to cope with ISODE optimisation */
#define SBITSTRING (STYPE_DATA + 0) /* No offset */
#define SOBJID (STYPE_DATA + 1) /* Object Identifier - No offset */
#define SREALTYPE (STYPE_DATA + 2) /* ASN.1 Real */
#define SANY (STYPE_DATA + 3)
#define SEXTOBJ (STYPE_DATA + 4) /* External reference object */
#define SOBJECT (STYPE_DATA + 5) /* This generates data */
#define SOCTETSTRING (STYPE_DATA + 6) /* No offset */
#define SEXTERNAL (STYPE_DATA + 7) /* External to be encoded */
#define SSEQ_START (STYPE_DATA + 8) /* SEQUENCE don't indirect */
#define SSET_START (STYPE_DATA + 9) /* SET don't do an indirection */
#define SSEQOF_START (STYPE_DATA + 10) /* SEQOF - no indirection */
#define SSETOF_START (STYPE_DATA + 11) /* SETOF - no indirection */
#define SCHOICE_START (STYPE_DATA + 12) /* CHOICE - no indirection */
#define ISDTYPE(p) (p->pe_type >= TYPE_DATA)
/* User code indexes */
#define NONE 0 /* No User code */
/* Standard Tags */
#define T_BOOL 1
#define T_INTEGER 2
#define T_OCTETSTRING 4
#define T_OBJIDENT 6
#define T_EXTERNAL 8
#define T_REAL 9
#define T_ENUMERATED 10
#define T_SEQ 16
#define T_SET 17
#define T_IA5 22
#define T_GRAPHIC 25
/* Flags */
/* Use values 0-3 bottom two bits at the moment */
/* This has to be changed if the values for the 4 below are changed in ISODE */
#define FL_CLASS 0xf
/* Class specification */
#define FL_UNIVERSAL PE_CLASS_UNIV
#define FL_APPLICATION PE_CLASS_APPL
#define FL_CONTEXT PE_CLASS_CONT
#define FL_PRIVATE PE_CLASS_PRIV
#define FL_IMPLICIT 0100
#define FL_DEFAULT 0200
#define FL_OPTIONAL 0400
#define OPTIONAL(p) ((p)->pe_flags & FL_OPTIONAL)
#define DEFAULT(p) ((p)->pe_flags & FL_DEFAULT)
#define FL_PRTAG 01000 /* only for printing - print the tag */
#define PRINT_TAG(p) ((p)->pe_flags & FL_PRTAG)
#define FL_USELECT 02000 /* user code selects */
#define IF_USELECT(p) ((p) -> pe_flags & FL_USELECT)
#define CLASS(p) ((PElementClass)((p)->pe_flags & FL_CLASS))
#define TAG(p) ((PElementID)((p)->pe_tag))
/* signed version of above - needed for tag == -1 */
#define STAG(p) ((p)->pe_tag)
#define TESTBIT(p, bit) ((p) & (1 << (bit)))
#define SETBIT(p, bit) ((p) |= (1 << (bit)))
#define CLRBIT(p, bit) ((p) &= ~(1 << (bit)))
/* To support the OPTIONAL << field $ bitno >> construct */
#define BITTEST(p, bit) (((p)[(bit)/8]) & (0x80 >> (bit) % 8))
#define BITSET(p, bit) (((p)[(bit)/8]) |= (0x80 >> (bit) % 8))
#define BITCLR(p, bit) (((p)[(bit)/8]) &= ~(0x80 >> (bit) % 8))
/* compute the number of char's required to support x bits */
#define NBITS2NCHARS(x) (((x) + 7)/8)
/*
* The module table. One per module which gives access to everything one needs
* to know about the modules types
*/
typedef struct {
char *md_name; /* Name of this module */
int md_nentries; /* Number of entries */
tpe **md_etab; /* Pointer to encoding tables */
tpe **md_dtab; /* Pointer to decoding tables */
ptpe **md_ptab; /* Pointer to printing tables */
int (*md_eucode)(); /* User code for encoding */
int (*md_ducode)(); /* User code for decoding */
int (*md_pucode)(); /* User code for printing */
caddr_t *md_ptrtab; /* pointer table */
} modtyp;
#define NULLMODTYP ((modtyp *)0)
#define LOTSOFBITS 128
int enc_f (), dec_f (), fre_obj ();
#endif
|