2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
19 // file: .../c++-lib/inc/meta.h
21 // $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/meta.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $
23 // Revision 1.1.1.1 2001/05/18 23:14:06 mb
24 // Move from private repository to open source repository
26 // Revision 1.3 2001/05/05 00:59:18 rmurphy
27 // Adding darwin license headers
29 // Revision 1.2 2000/06/15 18:48:25 dmitch
30 // Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime.
32 // Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy
33 // Base Fortissimo Tree
35 // Revision 1.1 1999/02/25 05:21:47 mb
36 // Added snacc c++ library
38 // Revision 1.6 1997/02/28 13:39:43 wan
39 // Modifications collected for new version 1.3: Bug fixes, tk4.2.
41 // Revision 1.5 1995/09/07 18:50:04 rj
42 // long int replaced by newly introduced AsnIntType.
43 // it shall provide a 32 bit integer type on all platforms.
45 // Revision 1.4 1995/08/17 15:23:47 rj
46 // introducing an AsnEnumTypeDesc class with its own TclGetDesc2 function that returns the value names but omits the numeric values.
47 // utility function AsnSe_TypeDesc::mandatmemberr added.
55 const char *const name
;
56 const AsnIntType value
;
61 struct AsnMemberDesc
// description of CHOICE member; base class for AsnSe_MemberDesc
63 const char *const name
;
64 const AsnTypeDesc
*const desc
;
66 AsnMemberDesc (const char *, const AsnTypeDesc
*);
70 virtual int TclGetDesc (Tcl_DString
*) const;
71 virtual int TclGetDesc2 (Tcl_DString
*) const;
75 struct AsnSe_MemberDesc
: AsnMemberDesc
// _ == t/quence; description of SET or SEQUENCE member
79 AsnSe_MemberDesc (const char *, const AsnTypeDesc
*, bool);
83 int TclGetDesc2 (Tcl_DString
*) const;
87 typedef AsnMemberDesc AsnChoiceMemberDesc
;
88 typedef AsnSe_MemberDesc AsnSetMemberDesc
;
89 typedef AsnSe_MemberDesc AsnSequenceMemberDesc
;
97 const AsnModuleDesc
*module;
98 const char *const name
; // NULL for basic types
100 const enum Type
// NOTE: keep this enum in sync with the typenames[]
107 NUL_
, // sic! (can't fight the ubiquitous NULL #define)
122 AsnType
*(*create
)();
124 static const char *const typenames
[];
126 AsnTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)());
128 virtual const AsnModuleDesc
*getmodule() const;
129 virtual const char *getname() const;
130 virtual bool ispdu() const;
131 virtual Type
gettype() const;
132 virtual const AsnNameDesc
*getnames() const;
133 //virtual const AsnMemberDesc *getmembers() const;
136 virtual int TclGetDesc (Tcl_DString
*) const;
137 virtual int TclGetDesc2 (Tcl_DString
*) const;
141 struct AsnNamesTypeDesc
: AsnTypeDesc
143 const AsnNameDesc
*const names
;
145 AsnNamesTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)(), const AsnNameDesc
*);
147 const AsnNameDesc
*getnames() const;
150 int TclGetDesc (Tcl_DString
*) const;
151 // for BIT STRING and INTEGER, ENUMERATED has its own:
152 int TclGetDesc2 (Tcl_DString
*) const;
156 struct AsnEnumTypeDesc
: AsnNamesTypeDesc
158 AsnEnumTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)(), const AsnNameDesc
*);
161 int TclGetDesc2 (Tcl_DString
*) const;
165 struct AsnMembersTypeDesc
: AsnTypeDesc
167 AsnMembersTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)());
170 int TclGetDesc (Tcl_DString
*) const;
174 struct AsnChoiceTypeDesc
: AsnMembersTypeDesc
176 const AsnChoiceMemberDesc
*const members
;
178 AsnChoiceTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)(), const AsnChoiceMemberDesc
*);
180 int choicebyname (const char *name
) const;
181 const char *choicebyvalue (int value
) const;
184 int TclGetDesc2 (Tcl_DString
*) const;
188 struct AsnSe_TypeDesc
: AsnMembersTypeDesc
190 const AsnSe_MemberDesc
*const members
;
192 AsnSe_TypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)(), const AsnSe_MemberDesc
*);
195 int mandatmemberr (Tcl_Interp
*interp
, const char *membername
) const;
196 int TclGetDesc2 (Tcl_DString
*) const;
200 struct AsnListTypeDesc
: AsnTypeDesc
202 const AsnTypeDesc
*const base
;
204 AsnListTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)(), const AsnTypeDesc
*);
207 int TclGetDesc (Tcl_DString
*) const;
211 struct AsnAliasTypeDesc
: AsnTypeDesc
213 const AsnTypeDesc
*const alias
;
215 AsnAliasTypeDesc (const AsnModuleDesc
*, const char *, bool ispdu
, Type
, AsnType
*(*create
)(), const AsnTypeDesc
*);
217 const AsnModuleDesc
*getmodule() const;
218 const char *getname() const;
220 Type
gettype() const;
222 const AsnNameDesc
*getnames() const;
223 //const AsnMemberDesc *getmembers() const;
226 int TclGetDesc (Tcl_DString
*) const;
230 typedef AsnTypeDesc AsnRealTypeDesc
;
231 typedef AsnTypeDesc AsnNullTypeDesc
;
232 typedef AsnTypeDesc AsnBoolTypeDesc
;
233 typedef AsnNamesTypeDesc AsnIntTypeDesc
;
234 typedef AsnNamesTypeDesc AsnBitsTypeDesc
;
235 typedef AsnTypeDesc AsnOctsTypeDesc
;
236 typedef AsnTypeDesc AsnOidTypeDesc
;
237 typedef AsnSe_TypeDesc AsnSetTypeDesc
;
238 typedef AsnSe_TypeDesc AsnSequenceTypeDesc
;
242 const char *const name
;
243 const AsnTypeDesc
**const types
;
246 extern const AsnModuleDesc
*asnModuleDescs
[];
250 //\[sep]----------------------------------------------------------------------------------------------------------------------------
251 // designed to be used with Tcl_SplitList(): argument list that automagically frees itself when it goes out of scope:
262 //\[sep]----------------------------------------------------------------------------------------------------------------------------
263 // file that automagically closes itself when it goes out of scope:
270 TmpFD (int _fd
) { fd
= _fd
; }
271 ~TmpFD() { if (fd
> 0) ::close (fd
); }
273 int operator = (int _fd
){ return fd
= _fd
; }
274 // operator int() { return fd; }
277 //\[sep]----------------------------------------------------------------------------------------------------------------------------
278 // hack to cope with Tcl's inability to handle binary strings:
280 extern int debinify (Tcl_Interp
*interp
, const char *in
, size_t len
);
281 extern int binify (Tcl_Interp
*interp
, const char *str
, char *buf
, size_t *len
);
283 //\[sep]----------------------------------------------------------------------------------------------------------------------------