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.
37 #ifndef _asn_config_h_
38 #define _asn_config_h_
41 #include <setjmp.h> /* for jmp_buf type, setjmp and longjmp */
43 /* for pow() used in asn_real.c - must include to avoid casting err on pow */
49 /* used to test if optionals are present */
50 #define NOT_NULL( ptr) ((ptr) != NULL)
54 * Asn1Error (char *str) - configure error handler
56 void Asn1Error
PROTO ((char* str
));
60 * Asn1Warning (char *str) - configure warning mechanism
61 * (currently never called)
63 void Asn1Warning
PROTO ((char* str
));
66 * Asn1ErrorHandler - procedure to call upon Asn1Warning (severity 0)
67 * and Asn1Error (severity 1).
69 typedef void (*Asn1ErrorHandler
) PROTO ((char* str
, int severity
));
72 * Asn1InstallErrorHandler - installs new error handler, returns former one
74 Asn1ErrorHandler Asn1InstallErrorHandler
PROTO ((Asn1ErrorHandler handler
));
77 * configure memory scheme used by decoder to allocate memory
78 * for the decoded value.
79 * The Asn1Free will be called in the optionally generated
80 * hierachical free routines.
82 * nibble_alloc allocs from a single buffer and EVERYTHING
83 * is freed by a single fcn call. Individual elmts cannot be freed
86 #ifndef USE_NIBBLE_MEMORY
87 #define USE_NIBBLE_MEMORY 1
92 #include "nibble-alloc.h"
94 #define Asn1Alloc( size) NibbleAlloc (size)
95 #define Asn1Free( ptr) /* empty */
96 #define CheckAsn1Alloc( ptr, env) \
100 #else /* !USE_NIBBLE_MEMORY */
104 #define Asn1Alloc( size) Malloc (size)
105 #define Asn1Free( ptr) Free (ptr)
106 #define CheckAsn1Alloc( ptr, env) \
110 #endif /* USE_NIBBLE_MEMORY */
112 #define ENV_TYPE jmp_buf
115 * configure buffer routines that the encoders (write)
116 * and decoders (read) use. This config technique kind
117 * of bites but is allows efficient macro calls. The
118 * Generated code & lib routines call/use the "Buf????"
119 * version of the macro - you define their meaning here.
125 #define BUF_TYPE ExpBuf **
126 #define BufGetByte( b) ExpBufGetByte (b)
127 #define BufGetSeg( b, lenPtr) ExpBufGetSeg (b, lenPtr)
128 #define BufCopy( dst, b, len) ExpBufCopy (dst, b, len)
129 #define BufSkip( b, len) ExpBufSkip (b, len)
130 #define BufPeekByte( b) ExpBufPeekByte (b)
131 #define BufPutByteRvs( b, byte) ExpBufPutByteRvs (b, byte)
132 #define BufPutSegRvs( b, data, len) ExpBufPutSegRvs (b, data, len)
133 #define BufReadError( b) ExpBufReadError (b)
134 #define BufWriteError( b) ExpBufWriteError (b)
136 #else /* !USE_EXP_BUF */
142 #define BUF_TYPE char **
143 #define BufGetByte( b) MinBufGetByte (b)
144 #define BufGetSeg( b, lenPtr) MinBufGetSeg (b, lenPtr)
145 #define BufCopy( dst, b, len) MinBufCopy (dst, b, len)
146 #define BufSkip( b, len) MinBufSkip (b, len)
147 #define BufPeekByte( b) MinBufPeekByte (b)
148 #define BufPutByteRvs( b, byte) MinBufPutByteRvs (b, byte)
149 #define BufPutSegRvs( b, data, len) MinBufPutSegRvs (b, data, len)
150 #define BufReadError( b) MinBufReadError (b)
151 #define BufWriteError( b) MinBufWriteError (b)
153 #else /* !USE_EXP_BUF && !USE_MIN_BUF */
159 #define BUF_TYPE SBuf *
160 #define BufGetByte( b) SBufGetByte (b)
161 #define BufGetSeg( b, lenPtr) SBufGetSeg (b, lenPtr)
162 #define BufCopy( dst, b, len) SBufCopy (dst, b, len)
163 #define BufSkip( b, len) SBufSkip (b, len)
164 #define BufPeekByte( b) SBufPeekByte (b)
165 #define BufPutByteRvs( b, byte) SBufPutByteRvs (b, byte)
166 #define BufPutSegRvs( b, data, len) SBufPutSegRvs (b, data, len)
167 #define BufReadError( b) SBufReadError (b)
168 #define BufWriteError( b) SBufWriteError (b)
170 #else /* !USE_EXP_BUF && !USE_MIN_BUF && !USE_SBUF*/
175 * NOTE: for use with tables, I defined the (slower)
176 * GenBuf type that is more flexible (à la ISODE and XDR).
177 * This allows the encode/decode libs to support other
178 * buffer types dynamically instead of having different
179 * libs for each buffer type.
180 * The GenBufs are not provided for the compiled code
181 * (ie the c_lib directory) but could easily be added
182 * (I don't have time, tho). Tables tools are
183 * around 4x slower than the compiled version so a
184 * the GenBufs aren't such a big performance hit for table stuff.
189 #define BUF_TYPE GenBuf *
190 #define BufGetByte( b) GenBufGetByte (b)
191 #define BufGetSeg( b, lenPtr) GenBufGetSeg (b, lenPtr)
192 #define BufCopy( dst, b, len) GenBufCopy (dst, b, len)
193 #define BufSkip( b, len) GenBufSkip (b, len)
194 #define BufPeekByte( b) GenBufPeekByte (b)
195 #define BufPeekSeg( b, lenPtr) GenBufPeekSeg (b, lenPtr)
196 #define BufPeekCopy( dst, b, len) GenBufPeekCopy (dst, b, len)
197 #define BufPutByteRvs( b, byte) GenBufPutByteRvs (b, byte)
198 #define BufPutSegRvs( b, data, len) GenBufPutSegRvs (b, data, len)
199 #define BufReadError( b) GenBufReadError (b)
200 #define BufWriteError( b) GenBufWriteError (b)
205 #error "don't know what buffer type to use!"
208 #endif /* USE_GEN_BUF */
209 #endif /* USE_SBUF */
210 #endif /* USE_MIN_BUF */
211 #endif /* USE_EXP_BUF */
213 #include "print.h" /* for printing set up */
216 * Enables throw/catch as replacement for setjmp/longjmp in C++ lib.
217 * BDecPdu still returns int (1 = OK, 0 = fail) in either config.
218 * The compiler gets this symbol from this file; runtime support uses
219 * the same symbol in c++_lib/inc/asn-config.h There is currently no
220 * straightforward way to have one symbol used in both environments.
222 #define SNACC_EXCEPTION_ENABLE 1
225 * Enable BEncPdu, BDecPdu. Same remarks apply as above w.r.t the
228 #define SNACC_ENABLE_PDU 0
230 #endif /* conditional include */