xref: /illumos-gate/usr/src/lib/libkmf/ber_der/inc/kmfber_int.h (revision fbb63b428340370268557fdc3b3f35e789a0445e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
23  *
24  * The contents of this file are subject to the Netscape Public License
25  * Version 1.0 (the "NPL"); you may not use this file except in
26  * compliance with the NPL.  You may obtain a copy of the NPL at
27  * http://www.mozilla.org/NPL/
28  *
29  * Software distributed under the NPL is distributed on an "AS IS" basis,
30  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
31  * for the specific language governing rights and limitations under the
32  * NPL.
33  *
34  * The Initial Developer of the Original Code is Netscape
35  * Communications Corporation. Portions created by Netscape are
36  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
37  * Rights Reserved.
38  */
39 
40 /*
41  * Copyright (c) 1990 Regents of the University of Michigan.
42  * All rights reserved.
43  *
44  * Redistribution and use in source and binary forms are permitted
45  * provided that this notice is preserved and that due credit is given
46  * to the University of Michigan at Ann Arbor. The name of the University
47  * may not be used to endorse or promote products derived from this
48  * software without specific prior written permission. This software
49  * is provided ``as is'' without express or implied warranty.
50  */
51 /*
52  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
53  * Use is subject to license terms.
54  */
55 
56 #pragma ident	"%Z%%M%	%I%	%E% SMI"
57 
58 
59 
60 #ifndef _KMFBER_INT_H
61 #define	_KMFBER_INT_H
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 #include <stdio.h>
68 #include <ctype.h>
69 #include <stdarg.h>
70 #include <stdlib.h>
71 
72 #include <malloc.h>
73 #include <errno.h>
74 #include <sys/types.h>
75 #include <unistd.h>
76 
77 #include <memory.h>
78 #include <string.h>
79 
80 typedef struct seqorset {
81 	ber_len_t	sos_clen;
82 	ber_tag_t	sos_tag;
83 	char		*sos_first;
84 	char		*sos_ptr;
85 	struct seqorset	*sos_next;
86 } Seqorset;
87 #define	NULLSEQORSET	((Seqorset *) 0)
88 
89 #define	SOS_STACK_SIZE 8 /* depth of the pre-allocated sos structure stack */
90 
91 struct berelement {
92 	char		*ber_buf;
93 	char		*ber_ptr;
94 	char		*ber_end;
95 	struct seqorset	*ber_sos;
96 	ber_tag_t	ber_tag;
97 	ber_len_t	ber_len;
98 	int		ber_usertag;
99 	char		ber_options;
100 	char		*ber_rwptr;
101 	BERTranslateProc ber_encode_translate_proc;
102 	BERTranslateProc ber_decode_translate_proc;
103 	int		ber_flags;
104 #define	KMFBER_FLAG_NO_FREE_BUFFER	1	/* don't free ber_buf */
105 	int		ber_sos_stack_posn;
106 	Seqorset	ber_sos_stack[SOS_STACK_SIZE];
107 };
108 
109 /* function prototypes */
110 void ber_err_print(char *data);
111 
112 #define	THEMEMCPY(d, s, n)	memmove(d, s, n)
113 
114 #ifdef SAFEMEMCPY
115 #undef SAFEMEMCPY
116 #define	SAFEMEMCPY(d, s, n) memmove(d, s, n);
117 #endif
118 
119 /* allow the library to access the debug variable */
120 
121 #ifdef KMFBER_DEBUG
122 extern int kmfber_debug;
123 #endif
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 #endif /* _KMFBER_INT_H */
129