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