]> git.saurik.com Git - apple/security.git/blame - SecuritySNACCRuntime/c-lib/inc/asn-config.h
Security-54.1.9.tar.gz
[apple/security.git] / SecuritySNACCRuntime / c-lib / inc / asn-config.h
CommitLineData
bac41a7b
A
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/*
20 * asn_config.h - configures the ANSI/non ansi, defines
21 * decoder alloc routines and buffer routines
22 *
23 * MS 91
24 * Copyright (C) 1992 Michael Sample and the University of British Columbia
25 *
26 * This library is free software; you can redistribute it and/or
27 * modify it provided that this copyright/license information is retained
28 * in original form.
29 *
30 * If you modify this file, you must clearly indicate your changes.
31 *
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.
bac41a7b
A
35 */
36
37#ifndef _asn_config_h_
38#define _asn_config_h_
39
40#include <stdio.h>
41#include <setjmp.h> /* for jmp_buf type, setjmp and longjmp */
42
43/* for pow() used in asn_real.c - must include to avoid casting err on pow */
44#include <math.h>
45
46#include "snacc.h"
47
48
49/* used to test if optionals are present */
50#define NOT_NULL( ptr) ((ptr) != NULL)
51
52
53/*
54 * Asn1Error (char *str) - configure error handler
55 */
56void Asn1Error PROTO ((char* str));
57
58
59/*
60 * Asn1Warning (char *str) - configure warning mechanism
61 * (currently never called)
62 */
63void Asn1Warning PROTO ((char* str));
64
65/*
66 * Asn1ErrorHandler - procedure to call upon Asn1Warning (severity 0)
67 * and Asn1Error (severity 1).
68 */
69typedef void (*Asn1ErrorHandler) PROTO ((char* str, int severity));
70
71/*
72 * Asn1InstallErrorHandler - installs new error handler, returns former one
73 */
74Asn1ErrorHandler Asn1InstallErrorHandler PROTO ((Asn1ErrorHandler handler));
75
76/*
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.
81 *
82 * nibble_alloc allocs from a single buffer and EVERYTHING
83 * is freed by a single fcn call. Individual elmts cannot be freed
84 */
85
86#ifndef USE_NIBBLE_MEMORY
87#define USE_NIBBLE_MEMORY 1
88#endif
89
90#if USE_NIBBLE_MEMORY
91
92#include "nibble-alloc.h"
93
94#define Asn1Alloc( size) NibbleAlloc (size)
95#define Asn1Free( ptr) /* empty */
96#define CheckAsn1Alloc( ptr, env) \
97 if ((ptr) == NULL)\
98 longjmp (env, -27)
99
100#else /* !USE_NIBBLE_MEMORY */
101
102#include "mem.h"
103
104#define Asn1Alloc( size) Malloc (size)
105#define Asn1Free( ptr) Free (ptr)
106#define CheckAsn1Alloc( ptr, env) \
107 if ((ptr) == NULL)\
108 longjmp (env, -27)
109
110#endif /* USE_NIBBLE_MEMORY */
111
112#define ENV_TYPE jmp_buf
113
114/*
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.
120 */
121#ifdef USE_EXP_BUF
122
123#include "exp-buf.h"
124
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)
135
136#else /* !USE_EXP_BUF */
137
138#ifdef USE_MIN_BUF
139
140#include "min-buf.h"
141
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)
152
153#else /* !USE_EXP_BUF && !USE_MIN_BUF */
154
155#ifdef USE_SBUF
156
157#include "sbuf.h"
158
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)
169
170#else /* !USE_EXP_BUF && !USE_MIN_BUF && !USE_SBUF*/
171
172#ifdef USE_GEN_BUF
173
174/*
175 * NOTE: for use with tables, I defined the (slower)
176