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.
20 * asn_config.h - configures the ANSI/non ansi, defines
21 * decoder alloc routines and buffer routines
24 * Copyright (C) 1992 Michael Sample and the University of British Columbia
26 * This library is free software; you can redistribute it and/or
27 * modify it provided that this copyright/license information is retained
30 * If you modify this file, you must clearly indicate your changes.
32 * This source code is distributed in the hope that it will be
33 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
34 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
36 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/c-lib/inc/asn-config.h,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $
37 * $Log: asn-config.h,v $
38 * Revision 1.1.1.1 2001/05/18 23:14:08 mb
39 * Move from private repository to open source repository
41 * Revision 1.2 2001/05/05 00:59:22 rmurphy
42 * Adding darwin license headers
44 * Revision 1.1.1.1 1999/03/16 18:06:20 aram
45 * Originals from SMIME Free Library.
47 * Revision 1.6 1997/03/13 09:15:16 wan
48 * Improved dependency generation for stupid makedepends.
49 * Corrected PeekTag to peek into buffer only as far as necessary.
50 * Added installable error handler.
51 * Fixed small glitch in idl-code generator (Markku Savela <msa@msa.tte.vtt.fi>).
53 * Revision 1.5 1995/07/24 21:01:11 rj
54 * changed `_' to `-' in file names.
56 * Revision 1.4 1995/02/13 14:47:33 rj
57 * settings for IEEE_REAL_FMT/IEEE_REAL_LIB moved from {c_lib,c++_lib}/inc/asn_config.h to acconfig.h.
59 * Revision 1.3 1994/10/08 04:46:20 rj
60 * config.h -> snacc.h, which now is the toplevel config file.
62 * Revision 1.2 1994/08/31 23:53:05 rj
63 * redundant code moved into ../../config.h.bot
65 * Revision 1.1 1994/08/28 09:21:25 rj
66 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
70 #ifndef _asn_config_h_
71 #define _asn_config_h_
74 #include <setjmp.h> /* for jmp_buf type, setjmp and longjmp */
76 /* for pow() used in asn_real.c - must include to avoid casting err on pow */
82 /* used to test if optionals are present */
83 #define NOT_NULL( ptr) ((ptr) != NULL)
87 * Asn1Error (char *str) - configure error handler
89 void Asn1Error
PROTO ((char* str
));
93 * Asn1Warning (char *str) - configure warning mechanism
94 * (currently never called)
96 void Asn1Warning
PROTO ((char* str
));
99 * Asn1ErrorHandler - procedure to call upon Asn1Warning (severity 0)
100 * and Asn1Error (severity 1).
102 typedef void (*Asn1ErrorHandler
) PROTO ((char* str
, int severity
));
105 * Asn1InstallErrorHandler - installs new error handler, returns former one
107 Asn1ErrorHandler Asn1InstallErrorHandler
PROTO ((Asn1ErrorHandler handler
));
110 * configure memory scheme used by decoder to allocate memory
111 * for the decoded value.
112 * The Asn1Free will be called in the optionally generated
113 * hierachical free routines.
115 * nibble_alloc allocs from a single buffer and EVERYTHING
116 * is freed by a single fcn call. Individual elmts cannot be freed
119 #ifndef USE_NIBBLE_MEMORY
120 #define USE_NIBBLE_MEMORY 1
123 #if USE_NIBBLE_MEMORY
125 #include "nibble-alloc.h"
127 #define Asn1Alloc( size) NibbleAlloc (size)
128 #define Asn1Free( ptr) /* empty */
129 #define CheckAsn1Alloc( ptr, env) \
133 #else /* !USE_NIBBLE_MEMORY */
137 #define Asn1Alloc( size) Malloc (size)
138 #define Asn1Free( ptr) Free (ptr)
139 #define CheckAsn1Alloc( ptr, env) \
143 #endif /* USE_NIBBLE_MEMORY */
145 #define ENV_TYPE jmp_buf
148 * configure buffer routines that the encoders (write)
149 * and decoders (read) use. This config technique kind
150 * of bites but is allows efficient macro calls. The
151 * Generated code & lib routines call/use the "Buf????"
152 * version of the macro - you define their meaning here.
158 #define BUF_TYPE ExpBuf **
159 #define BufGetByte( b) ExpBufGetByte (b)
160 #define BufGetSeg( b, lenPtr) ExpBufGetSeg (b, lenPtr)
161 #define BufCopy( dst, b, len) ExpBufCopy (dst, b, len)
162 #define BufSkip( b, len) ExpBufSkip (b, len)
163 #define BufPeekByte( b) ExpBufPeekByte (b)
164 #define BufPutByteRvs( b, byte) ExpBufPutByteRvs (b, byte)
165 #define BufPutSegRvs( b, data, len) ExpBufPutSegRvs (b, data, len)
166 #define BufReadError( b) ExpBufReadError (b)
167 #define BufWriteError( b) ExpBufWriteError (b)
169 #else /* !USE_EXP_BUF */
175 #define BUF_TYPE char **
176 #define BufGetByte( b) MinBufGetByte (b)
177 #define BufGetSeg( b, lenPtr) MinBufGetSeg (b, lenPtr)
178 #define BufCopy( dst, b, len) MinBufCopy (dst, b, len)
179 #define BufSkip( b, len) MinBufSkip (b, len)
180 #define BufPeekByte( b) MinBufPeekByte (b)
181 #define BufPutByteRvs( b, byte) MinBufPutByteRvs (b, byte)
182 #define BufPutSegRvs( b, data, len) MinBufPutSegRvs (b, data, len)
183 #define BufReadError( b) MinBufReadError (b)
184 #define BufWriteError( b) MinBufWriteError (b)
186 #else /* !USE_EXP_BUF && !USE_MIN_BUF */
192 #define BUF_TYPE SBuf *
193 #define BufGetByte( b) SBufGetByte (b)
194 #define BufGetSeg( b, lenPtr) SBufGetSeg (b, lenPtr)
195 #define BufCopy( dst, b, len) SBufCopy (dst, b, len)
196 #define BufSkip( b, len) SBufSkip (b, len)
197 #define BufPeekByte( b) SBufPeekByte (b)
198 #define BufPutByteRvs( b, byte) SBufPutByteRvs (b, byte)
199 #define BufPutSegRvs( b, data, len) SBufPutSegRvs (b, data, len)
200 #define BufReadError( b) SBufReadError (b)
201 #define BufWriteError( b) SBufWriteError (b)
203 #else /* !USE_EXP_BUF && !USE_MIN_BUF && !USE_SBUF*/
208 * NOTE: for use with tables, I defined the (slower)
209 * GenBuf type that is more flexible (à la ISODE and XDR).
210 * This allows the encode/decode libs to support other
211 * buffer types dynamically instead of having different
212 * libs for each buffer type.
213 * The GenBufs are not provided for the compiled code
214 * (ie the c_lib directory) but could easily be added
215 * (I don't have time, tho). Tables tools are
216 * around 4x slower than the compiled version so a
217 * the GenBufs aren't such a big performance hit for table stuff.
222 #define BUF_TYPE GenBuf *
223 #define BufGetByte( b) GenBufGetByte (b)
224 #define BufGetSeg( b, lenPtr) GenBufGetSeg (b, lenPtr)
225 #define BufCopy( dst, b, len) GenBufCopy (dst, b, len)
226 #define BufSkip( b, len) GenBufSkip (b, len)
227 #define BufPeekByte( b) GenBufPeekByte (b)
228 #define BufPeekSeg( b, lenPtr) GenBufPeekSeg (b, lenPtr)
229 #define BufPeekCopy( dst, b, len) GenBufPeekCopy (dst, b, len)
230 #define BufPutByteRvs( b, byte) GenBufPutByteRvs (b, byte)
231 #define BufPutSegRvs( b, data, len) GenBufPutSegRvs (b, data, len)
232 #define BufReadError( b) GenBufReadError (b)
233 #define BufWriteError( b) GenBufWriteError (b)
238 #error "don't know what buffer type to use!"
241 #endif /* USE_GEN_BUF */
242 #endif /* USE_SBUF */
243 #endif /* USE_MIN_BUF */
244 #endif /* USE_EXP_BUF */
246 #include "print.h" /* for printing set up */
248 #endif /* conditional include */