versadac  1
versadac - Scalable Recorder Firmware
lber-int.h
1 /* $OpenLDAP: pkg/ldap/libraries/liblber/lber-int.h,v 1.68.2.3 2008/02/11 23:26:41 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2008 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms are permitted
19  * provided that this notice is preserved and that due credit is given
20  * to the University of Michigan at Ann Arbor. The name of the University
21  * may not be used to endorse or promote products derived from this
22  * software without specific prior written permission. This software
23  * is provided ``as is'' without express or implied warranty.
24  */
25 
26 #ifndef _LBER_INT_H
27 #define _LBER_INT_H
28 
29 #include "lber.h"
30 #include "ldap_log.h"
31 #include "lber_pvt.h"
32 #include "ldap_queue.h"
33 
34 LDAP_BEGIN_DECL
35 
36 typedef void (*BER_LOG_FN)(FILE *file,
37  const char *subsys, int level, const char *fmt, ... );
38 
39 LBER_V (BER_ERRNO_FN) ber_int_errno_fn;
40 
41 #ifdef LDAP_MEMORY_TRACE
42 # ifndef LDAP_MEMORY_DEBUG
43 # define LDAP_MEMORY_DEBUG 1
44 # endif
45 #endif
46 
47 #ifdef LDAP_MEMORY_DEBUG
48 LBER_V (long) ber_int_meminuse;
49 #endif
50 #if defined(LDAP_MEMORY_DEBUG) && ((LDAP_MEMORY_DEBUG +0) & 2)
51 # define LDAP_MEMORY_DEBUG_ASSERT assert
52 #else
53 # define LDAP_MEMORY_DEBUG_ASSERT(expr) ((void) 0)
54 #endif
55 
56 struct lber_options {
57  short lbo_valid;
58  unsigned short lbo_options;
59  int lbo_debug;
60 };
61 
62 LBER_F( int ) ber_pvt_log_output(
63  const char *subsystem,
64  int level,
65  const char *fmt, ... );
66 
67 #define LBER_UNINITIALIZED 0x0
68 #define LBER_INITIALIZED 0x1
69 #define LBER_VALID_BERELEMENT 0x2
70 #define LBER_VALID_SOCKBUF 0x3
71 
72 LBER_V (struct lber_options) ber_int_options;
73 #define ber_int_debug ber_int_options.lbo_debug
74 
75 struct berelement {
76  struct lber_options ber_opts;
77 #define ber_valid ber_opts.lbo_valid
78 #define ber_options ber_opts.lbo_options
79 #define ber_debug ber_opts.lbo_debug
80 
81  /* Do not change the order of these 3 fields! see ber_get_next */
82  ber_tag_t ber_tag;
83  ber_len_t ber_len;
84  ber_tag_t ber_usertag;
85 
86  char *ber_buf;
87  char *ber_ptr;
88  char *ber_end;
89 
90  struct seqorset *ber_sos;
91  char *ber_rwptr;
92  void *ber_memctx;
93 };
94 #define LBER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
95 
96 #define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
97 #define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf)
98 #define ber_pvt_ber_write(ber) ((ber)->ber_ptr - (ber)->ber_buf)
99 
100 #ifdef VXWORKS_BUILD
101 #define sockbuf lber_sockbuf
102 struct lber_sockbuf {
103 #else
104 struct sockbuf {
105 #endif
106  struct lber_options sb_opts;
107  Sockbuf_IO_Desc *sb_iod; /* I/O functions */
108 #define sb_valid sb_opts.lbo_valid
109 #define sb_options sb_opts.lbo_options
110 #define sb_debug sb_opts.lbo_debug
111  ber_socket_t sb_fd;
112  ber_len_t sb_max_incoming;
113  unsigned int sb_trans_needs_read:1;
114  unsigned int sb_trans_needs_write:1;
115 #ifdef LDAP_PF_LOCAL_SENDMSG
116  char sb_ungetlen;
117  char sb_ungetbuf[8];
118 #endif
119 };
120 
121 #define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
122 
123 struct seqorset {
124  BerElement *sos_ber;
125  ber_len_t sos_clen;
126  ber_tag_t sos_tag;
127  char *sos_first;
128  char *sos_ptr;
129  struct seqorset *sos_next;
130 };
131 
132 
133 /*
134  * decode.c, encode.c
135  */
136 
137 /* Simplest OID max-DER-component to implement in both decode and encode */
138 #define LBER_OID_COMPONENT_MAX ((unsigned long)-1 - 128)
139 
140 
141 /*
142  * io.c
143  */
144 LBER_F( int )
145 ber_realloc LDAP_P((
146  BerElement *ber,
147  ber_len_t len ));
148 
149 LBER_F (char *) ber_start LDAP_P(( BerElement * ));
150 LBER_F (int) ber_len LDAP_P(( BerElement * ));
151 LBER_F (int) ber_ptrlen LDAP_P(( BerElement * ));
152 LBER_F (void) ber_rewind LDAP_P(( BerElement * ));
153 
154 /*
155  * bprint.c
156  */
157 #define ber_log_printf ber_pvt_log_printf
158 
159 LBER_F( int )
160 ber_log_bprint LDAP_P((
161  int errlvl,
162  int loglvl,
163  const char *data,
164  ber_len_t len ));
165 
166 LBER_F( int )
167 ber_log_dump LDAP_P((
168  int errlvl,
169  int loglvl,
170  BerElement *ber,
171  int inout ));
172 
173 LBER_F( int )
174 ber_log_sos_dump LDAP_P((
175  int errlvl,
176  int loglvl,
177  Seqorset *sos ));
178 
179 LBER_V (BER_LOG_FN) ber_int_log_proc;
180 LBER_V (FILE *) ber_pvt_err_file;
181 
182 /* memory.c */
183  /* simple macros to realloc for now */
184 LBER_V (BerMemoryFunctions *) ber_int_memory_fns;
185 LBER_F (char *) ber_strndup( LDAP_CONST char *, ber_len_t );
186 LBER_F (char *) ber_strndup_x( LDAP_CONST char *, ber_len_t, void *ctx );
187 
188 #define LBER_MALLOC(s) ber_memalloc((s))
189 #define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
190 #define LBER_REALLOC(p,s) ber_memrealloc((p),(s))
191 #define LBER_FREE(p) ber_memfree((p))
192 #define LBER_VFREE(v) ber_memvfree((void**)(v))
193 #define LBER_STRDUP(s) ber_strdup((s))
194 #define LBER_STRNDUP(s,l) ber_strndup((s),(l))
195 
196 /* sockbuf.c */
197 
198 LBER_F( int )
199 ber_int_sb_init LDAP_P(( Sockbuf *sb ));
200 
201 LBER_F( int )
202 ber_int_sb_close LDAP_P(( Sockbuf *sb ));
203 
204 LBER_F( int )
205 ber_int_sb_destroy LDAP_P(( Sockbuf *sb ));
206 
207 LBER_F( ber_slen_t )
208 ber_int_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
209 
210 LBER_F( ber_slen_t )
211 ber_int_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
212 
213 LDAP_END_DECL
214 
215 #endif /* _LBER_INT_H */
Definition: lber-int.h:104
Definition: lber-int.h:56
Definition: lber.h:121
Definition: lber-int.h:123
Definition: lber.h:177
Definition: lber-int.h:75