]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/inc/asn-any.h
1d55e40aa071e3e44677b5b44cb9a96117e8ba6e
[apple/security.git] / SecuritySNACCRuntime / c++-lib / inc / asn-any.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 // file: .../c++-lib/inc/asn-any.h - C++ class for any type
20 //
21 // MS 92
22 // Copyright (C) 1992 Michael Sample and the University of British Columbia
23 //
24 // This library is free software; you can redistribute it and/or
25 // modify it provided that this copyright/license information is retained
26 // in original form.
27 //
28 // If you modify this file, you must clearly indicate your changes.
29 //
30 // This source code is distributed in the hope that it will be
31 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
32 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
33 //
34 //
35 // ------------------------------------------------------------------------
36 // - J.G. Van Dyke & Associates, Inc. Modification History of SNACC 1.3 -
37 // ------------------------------------------------------------------------
38 //
39 // All modification are relative to the v1.3 of SNACC. We used SunOS 4.1.3's
40 // SCCS. The revision #'s start at 1.1, which is the original version from
41 // SNACC 1.3.
42 //
43 //
44 // ../SCCS/s.asn-any.h:
45 //
46 // D 1.2 98/05/01 13:46:36 pleonber 2 1 00008/00000/00099
47 // added destructor and copy for CSM_Buffer handling (cleans up memory).
48 //
49 // D 1.1 98/05/01 13:16:05 pleonber 1 0 00099/00000/00000
50 // date and time created 98/05/01 13:16:05 by pleonber
51 //
52 // ----------------------- End of VDA Modifications ---------------------------
53 //
54 //
55 //
56 // $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-any.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $
57 // $Log: asn-any.h,v $
58 // Revision 1.1.1.1 2001/05/18 23:14:06 mb
59 // Move from private repository to open source repository
60 //
61 // Revision 1.5 2001/05/05 00:59:17 rmurphy
62 // Adding darwin license headers
63 //
64 // Revision 1.4 2000/12/22 20:33:26 mb
65 // New Security framework fase 1 complete.
66 //
67 // Revision 1.3 2000/12/07 22:14:38 dmitch
68 // Thread-safe mods: made oidHashTbl and intHashTbl private.
69 //
70 // Revision 1.2 2000/06/15 18:48:25 dmitch
71 // Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime.
72 //
73 // Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy
74 // Base Fortissimo Tree
75 //
76 // Revision 1.4 1999/03/21 02:07:31 mb
77 // Added Copy to every AsnType.
78 //
79 // Revision 1.3 1999/03/18 22:35:26 mb
80 // Made all destructors virtual.
81 //
82 // Revision 1.2 1999/02/26 00:32:55 mb
83 // Fix bug when not building with VDADER_RULES defined.
84 //
85 // Revision 1.1 1999/02/25 05:21:40 mb
86 // Added snacc c++ library
87 //
88 // Revision 1.4 1997/01/02 08:39:42 rj
89 // missing prototype added
90 //
91 // Revision 1.3 1994/10/08 04:17:56 rj
92 // code for meta structures added (provides information about the generated code itself).
93 //
94 // code for Tcl interface added (makes use of the above mentioned meta code).
95 //
96 // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included.
97 //
98 // made Print() const (and some other, mainly comparison functions).
99 //
100 // several `unsigned long int' turned into `size_t'.
101 //
102 // Revision 1.2 1994/08/28 10:00:43 rj
103 // comment leader fixed.
104 //
105 // Revision 1.1 1994/08/28 09:20:24 rj
106 // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
107
108 #ifndef _asn_any_h_
109 #define _asn_any_h_
110
111 #ifdef _IBM_ENC_
112 #include "shmmgr.h" // Guido Grassel 4.8.93
113 #endif /* _IBM_ENC_ */
114
115 #include "hash.h"
116
117 #ifdef __APPLE__
118 #include <Security/threading.h> /* for Mutex */
119 #endif
120
121 /* this is put into the hash table with the int or oid as the key */
122 #ifndef _IBM_ENC_
123 class AnyInfo
124 #else
125 class AnyInfo: public MemMgr // Guido Grassel 4.8.93
126 #endif /* _IBM_ENC_ */
127 {
128 public:
129 int anyId; // will be a value from the AnyId enum
130 AsnOid oid; // will be zero len/null if intId is valid
131 AsnInt intId;
132 AsnType *typeToClone;
133 };
134
135 #if defined(macintosh) || defined(__APPLE__)
136 class CSM_Buffer;
137 #endif
138
139 class AsnAny: public AsnType
140 {
141 #ifdef __APPLE__
142 /* need a lock to protect these, declared as a static in the .cpp file.
143 *...plus, I have no idea why these
144 * were declared public. They are not used anywhere else.
145 */
146 private:
147 static Table *oidHashTbl; // all AsnAny class instances
148 static Table *intHashTbl; // share these tables
149 public:
150 #else
151 public:
152 static Table *oidHashTbl; // all AsnAny class instances
153 static Table *intHashTbl; // share these tables
154 #endif
155 AnyInfo *ai; // points to entry in hash tbl for this type
156 #if defined(macintosh) || defined(__APPLE__)
157 // FIXME - needs work
158 CSM_Buffer *value;
159 #else
160 AsnType *value;
161 #endif
162 AsnAny() { ai = NULL; value = NULL; }
163
164 // class level methods
165 static void InstallAnyByInt (AsnInt intId, int anyId, AsnType *type);
166 static void InstallAnyByOid (AsnOid &oid, int anyId, AsnType *type);
167
168 int GetId() const { return ai ? ai->anyId : -1; }
169 void SetTypeByInt (AsnInt id);
170 void SetTypeByOid (AsnOid &id);
171
172 virtual AsnType *Clone() const;
173 virtual AsnType *Copy() const;
174
175 AsnLen BEnc (BUF_TYPE b);
176 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
177
178 PDU_MEMBER_MACROS
179
180 void Print (ostream &) const;
181
182 #if 0
183 #if TCL
184 int TclGetDesc (Tcl_DString *) const;
185 int TclGetVal (Tcl_DString *) const;
186 int TclSetVal (Tcl_Interp *, const char *val);
187 int TclUnSetVal (Tcl_Interp *, const char *member);
188 #endif /* TCL */
189 #endif
190
191 #ifdef VDADER_RULES
192 virtual ~AsnAny();
193 AsnAny &operator = (const AsnAny &o);
194 };
195
196 // AnyDefinedBy is currently the same as AsnAny:
197 typedef AsnAny AsnAnyDefinedBy;
198
199 #else
200 };
201 #endif /* _conditional_include_ */
202
203 #endif /* _asn_any_h_ */