]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/c++/asn-null.cpp
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/src/asn-null.C
22 // Copyright (C) 1992 Michael Sample and the University of British Columbia
24 // This library is free software; you can redistribute it and/or
25 // modify it provided that this copyright/license information is retained
28 // If you modify this file, you must clearly indicate your changes.
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.
34 // $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/c++/Attic/asn-null.cpp,v 1.3 2002/03/21 05:38:44 dmitch Exp $
35 // $Log: asn-null.cpp,v $
36 // Revision 1.3 2002/03/21 05:38:44 dmitch
37 // Radar 2868524: no more setjmp/longjmp in SNACC-generated code.
39 // Revision 1.2.44.1 2002/03/20 00:36:49 dmitch
40 // Radar 2868524: SNACC-generated code now uses throw/catch instead of setjmp/longjmp.
42 // Revision 1.2 2001/06/27 23:09:14 dmitch
43 // Pusuant to Radar 2664258, avoid all cerr-based output in NDEBUG configuration.
45 // Revision 1.1.1.1 2001/05/18 23:14:06 mb
46 // Move from private repository to open source repository
48 // Revision 1.2 2001/05/05 00:59:17 rmurphy
49 // Adding darwin license headers
51 // Revision 1.1 2000/06/15 18:44:57 dmitch
52 // These snacc-generated source files are now checked in to allow cross-platform build.
54 // Revision 1.2 2000/06/08 20:05:35 dmitch
55 // Mods for X port. These files are actually machine generated and probably don't need to be in CVS....
57 // Revision 1.1.1.1 2000/03/09 01:00:06 rmurphy
58 // Base Fortissimo Tree
60 // Revision 1.2 1999/03/21 02:07:36 mb
61 // Added Copy to every AsnType.
63 // Revision 1.1 1999/02/25 05:21:52 mb
64 // Added snacc c++ library
66 // Revision 1.5 1995/08/17 15:38:19 rj
67 // set Tcl's errorCode variable
69 // Revision 1.4 1995/07/24 20:18:27 rj
70 // #if TCL ... #endif wrapped into #if META ... #endif
72 // call constructor with additional pdu and create arguments.
74 // changed `_' to `-' in file names.
76 // Revision 1.3 1994/10/08 04:18:26 rj
77 // code for meta structures added (provides information about the generated code itself).
79 // code for Tcl interface added (makes use of the above mentioned meta code).
81 // 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.
83 // made Print() const (and some other, mainly comparison functions).
85 // several `unsigned long int' turned into `size_t'.
87 // Revision 1.2 1994/08/28 10:01:15 rj
88 // comment leader fixed.
90 // Revision 1.1 1994/08/28 09:21:04 rj
91 // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
93 #include "asn-config.h"
99 AsnType
* AsnNull :: Clone () const
104 AsnType
* AsnNull :: Copy () const
106 return new AsnNull (* this );
109 void AsnNull :: BDecContent ( BUF_TYPE b
, AsnTag tagId
, AsnLen elmtLen
, AsnLen
& bytesDecoded
, ENV_TYPE env
)
113 Asn1Error
<< "AsnNull::BDecContent: ERROR - NULL values len is non-zero" << endl
;
114 #if SNACC_EXCEPTION_ENABLE
115 SnaccExcep :: throwMe (- 13 );
120 } /* AsnNull::BDecContent */
122 AsnLen
AsnNull :: BEnc ( BUF_TYPE b
)
126 BEncDefLenTo127 ( b
, l
);
128 l
+= BEncTag1 ( b
, UNIV
, PRIM
, NULLTYPE_TAG_CODE
);
132 void AsnNull :: BDec ( BUF_TYPE b
, AsnLen
& bytesDecoded
, ENV_TYPE env
)
135 if ( BDecTag ( b
, bytesDecoded
, env
) != MAKE_TAG_ID ( UNIV
, PRIM
, NULLTYPE_TAG_CODE
))
137 Asn1Error
<< "AsnNull::BDec: ERROR tag on NULL is wrong." << endl
;
138 #if SNACC_EXCEPTION_ENABLE
139 SnaccExcep :: throwMe (- 55 );
145 elmtLen
= BDecLen ( b
, bytesDecoded
, env
);
146 BDecContent ( b
, MAKE_TAG_ID ( UNIV
, PRIM
, NULLTYPE_TAG_CODE
), elmtLen
, bytesDecoded
, env
);
149 void AsnNull :: Print ( ostream
& os
) const
158 const AsnNullTypeDesc
AsnNull :: _desc ( NULL
, NULL
, false , AsnTypeDesc :: NUL_
, NULL
);
160 const AsnTypeDesc
* AsnNull :: _getdesc () const
167 int AsnNull :: TclGetVal ( Tcl_Interp
* interp
) const
172 int AsnNull :: TclSetVal ( Tcl_Interp
* interp
, const char * valstr
)
176 Tcl_AppendResult ( interp
, "illegal non-null value `" , valstr
, "' for type " , _getdesc ()-> getmodule ()-> name
, "." , _getdesc ()-> getname (), NULL
);
177 Tcl_SetErrorCode ( interp
, "SNACC" , "ILLNULL" , NULL
);