]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/inc/asn-bits.h
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/asn-bits.h - ASN.1 BIT STRING type
23 // Copyright (C) 1992 Michael Sample and the University of British Columbia
25 // This library is free software; you can redistribute it and/or
26 // modify it provided that this copyright/license information is retained
29 // If you modify this file, you must clearly indicate your changes.
31 // This source code is distributed in the hope that it will be
32 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
33 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35 // $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-bits.h,v 1.2 2001/06/28 23:36:11 dmitch Exp $
36 // $Log: asn-bits.h,v $
37 // Revision 1.2 2001/06/28 23:36:11 dmitch
38 // Removed SccsId statics. numToHexCharTblG table now const. Radar 2705410.
40 // Revision 1.1.1.1 2001/05/18 23:14:06 mb
41 // Move from private repository to open source repository
43 // Revision 1.5 2001/05/05 00:59:17 rmurphy
44 // Adding darwin license headers
46 // Revision 1.4 2000/12/07 22:29:50 dmitch
47 // Thread-safe mods: added strStkG, strStkUnusedBitsG arguments to FillBitStringStk .
49 // Revision 1.3 2000/08/24 20:00:25 dmitch
50 // Added BitOcts() accessor.
52 // Revision 1.2 2000/06/15 18:48:22 dmitch
53 // Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime.
55 // 2000/8/24 dmitch at Apple
56 // Added BitOcts() accessor.
58 // Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy
59 // Base Fortissimo Tree
61 // Revision 1.3 1999/03/21 02:07:31 mb
62 // Added Copy to every AsnType.
64 // Revision 1.2 1999/03/18 22:35:27 mb
65 // Made all destructors virtual.
67 // Revision 1.1 1999/02/25 05:21:40 mb
68 // Added snacc c++ library
70 // Revision 1.6 1997/02/16 20:25:33 rj
71 // check-in of a few cosmetic changes
73 // Revision 1.5 1995/07/24 17:53:51 rj
74 // #if TCL ... #endif wrapped into #if META ... #endif
76 // changed `_' to `-' in file names.
78 // Revision 1.4 1995/02/18 19:26:18 rj
79 // remove const from arguments that are passed by value.
81 // Revision 1.3 1994/10/08 04:17:57 rj
82 // code for meta structures added (provides information about the generated code itself).
84 // code for Tcl interface added (makes use of the above mentioned meta code).
86 // 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.
88 // made Print() const (and some other, mainly comparison functions).
90 // several `unsigned long int' turned into `size_t'.
92 // Revision 1.2 1994/08/28 10:00:44 rj
93 // comment leader fixed.
95 // Revision 1.1 1994/08/28 09:20:25 rj
96 // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
105 extern const char numToHexCharTblG
[];
107 #define TO_HEX( fourBits) (numToHexCharTblG[(fourBits) & 0x0F])
109 class AsnBits
: public AsnType
112 bool BitsEquiv ( const AsnBits
& ab
) const ;
113 void BDecConsBits ( BUF_TYPE b
, AsnLen elmtLen
, AsnLen
& bytesDecoded
, ENV_TYPE env
);
115 void FillBitStringStk ( BUF_TYPE b
, AsnLen elmtLen0
,
116 AsnLen
& bytesDecoded
, ENV_TYPE env
,
117 StrStk
& strStkG
, unsigned short int & strStkUnusedBitsG
);
119 void FillBitStringStk ( BUF_TYPE b
, AsnLen elmtLen0
,
120 AsnLen
& bytesDecoded
, ENV_TYPE env
);
129 AsnBits () { bits
= NULL
; bitLen
= 0 ; }
130 AsnBits ( size_t numBits
) { Set ( numBits
); }
131 AsnBits ( const char * bitOcts
, size_t numBits
)
132 { Set ( bitOcts
, numBits
); }
133 AsnBits ( const AsnBits
& b
) { Set ( b
); }
137 virtual ~ AsnBits () { mem_mgr_ptr
-> Put (( void *) bits
); } // Guido Grassel, 11.8.93
138 #endif /* _IBM_ENC_ */
140 virtual AsnType
* Clone () const ;
141 virtual AsnType
* Copy () const ;
143 AsnBits
& operator = ( const AsnBits
& b
) { ReSet ( b
); return * this ; }
145 // overwrite existing bits and bitLen values
146 void Set ( size_t numBits
);
147 void Set ( const char * bitOcts
, size_t numBits
);
148 void Set ( const AsnBits
& b
);
150 // free old bits value, the reset bits and bitLen values
151 void ReSet ( size_t numBits
);
152 void ReSet ( const char * bitOcts
, size_t numBits
);
153 void ReSet ( const AsnBits
& b
);
155 bool operator == ( const AsnBits
& ab
) const { return BitsEquiv ( ab
); }
156 bool operator != ( const AsnBits
& ab
) const { return ! BitsEquiv ( ab
); }
158 void SetBit ( size_t );
159 void ClrBit ( size_t );
160 bool GetBit ( size_t ) const ;
162 // Apple addenda: this is just too useful to exclude.
163 const char * BitOcts () const { return bits
; }
165 size_t BitLen () const { return bitLen
; }
167 AsnLen
BEncContent ( BUF_TYPE b
);
168 void BDecContent ( BUF_TYPE b
, AsnTag tagId
, AsnLen elmtLen
, AsnLen
& bytesDecoded
, ENV_TYPE env
);
169 AsnLen
BEnc ( BUF_TYPE b
);
170 void BDec ( BUF_TYPE b
, AsnLen
& bytesDecoded
, ENV_TYPE env
);
174 void Print ( ostream
&) const ;
177 static const AsnBitsTypeDesc _desc
;
179 const AsnTypeDesc
* _getdesc () const ;
182 int TclGetVal ( Tcl_Interp
*) const ;
183 int TclSetVal ( Tcl_Interp
*, const char * val
);
188 #endif /* conditional include */