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 #ifndef _KMFBER_INT_H
37 #define	_KMFBER_INT_H
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <stdio.h>
44 #include <ctype.h>
45 #include <stdarg.h>
46 #include <stdlib.h>
47 
48 #include <malloc.h>
49 #include <errno.h>
50 #include <sys/types.h>
51 #include <unistd.h>
52 
53 #include <memory.h>
54 #include <string.h>
55 
56 typedef struct seqorset {
57 	ber_len_t	sos_clen;
58 	ber_tag_t	sos_tag;
59 	char		*sos_first;
60 	char		*sos_ptr;
61 	struct seqorset	*sos_next;
62 } Seqorset;
63 #define	NULLSEQORSET	((Seqorset *) 0)
64 
65 #define	SOS_STACK_SIZE 8 /* depth of the pre-allocated sos structure stack */
66 
67 struct berelement {
68 	char		*ber_buf;
69 	char		*ber_ptr;
70 	char		*ber_end;
71 	struct seqorset	*ber_sos;
72 	ber_tag_t	ber_tag;
73 	ber_len_t	ber_len;
74 	int		ber_usertag;
75 	char		ber_options;
76 	char		*ber_rwptr;
77 	BERTranslateProc ber_encode_translate_proc;
78 	BERTranslateProc ber_decode_translate_proc;
79 	int		ber_flags;
80 #define	KMFBER_FLAG_NO_FREE_BUFFER	1	/* don't free ber_buf */
81 	int		ber_sos_stack_posn;
82 	Seqorset	ber_sos_stack[SOS_STACK_SIZE];
83 };
84 
85 /* function prototypes */
86 void ber_err_print(char *data);
87 
88 #define	THEMEMCPY(d, s, n)	memmove(d, s, n)
89 
90 #ifdef SAFEMEMCPY
91 #undef SAFEMEMCPY
92 #define	SAFEMEMCPY(d, s, n) memmove(d, s, n);
93 #endif
94 
95 /* allow the library to access the debug variable */
96 
97 #ifdef KMFBER_DEBUG
98 extern int kmfber_debug;
99 #endif
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 #endif /* _KMFBER_INT_H */
105