2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2005 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
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>.
15 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
16 * All rights reserved.
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.
32 #include "ldap_queue.h"
36 typedef void (*BER_LOG_FN)(FILE *file,
37 const char *subsys, int level, const char *fmt, ... );
39 LBER_V (BER_ERRNO_FN) ber_int_errno_fn;
43 unsigned short lbo_options;
48 LBER_F( int ) ber_pvt_log_output(
49 const char *subsystem,
51 const char *fmt, ... );
53 #define LBER_UNINITIALIZED 0x0
54 #define LBER_INITIALIZED 0x1
55 #define LBER_VALID_BERELEMENT 0x2
56 #define LBER_VALID_SOCKBUF 0x3
58 LBER_V (struct lber_options) ber_int_options;
59 #define ber_int_debug ber_int_options.lbo_debug
62 struct lber_options ber_opts;
63 #define ber_valid ber_opts.lbo_valid
64 #define ber_options ber_opts.lbo_options
65 #define ber_debug ber_opts.lbo_debug
67 /* Do not change the order of these 3 fields! see ber_get_next */
70 ber_tag_t ber_usertag;
76 struct seqorset *ber_sos;
80 #define LBER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
82 #define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
83 #define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf)
84 #define ber_pvt_ber_write(ber) ((ber)->ber_ptr - (ber)->ber_buf)
87 struct lber_options sb_opts;
88 Sockbuf_IO_Desc *sb_iod; /* I/O functions */
89 #define sb_valid sb_opts.lbo_valid
90 #define sb_options sb_opts.lbo_options
91 #define sb_debug sb_opts.lbo_debug
93 unsigned int sb_trans_needs_read:1;
94 unsigned int sb_trans_needs_write:1;
95 ber_len_t sb_max_incoming;
98 #define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
106 struct seqorset *sos_next;
118 LBER_F (char *) ber_start LDAP_P(( BerElement * ));
119 LBER_F (int) ber_len LDAP_P(( BerElement * ));
120 LBER_F (int) ber_ptrlen LDAP_P(( BerElement * ));
121 LBER_F (void) ber_rewind LDAP_P(( BerElement * ));
126 #define ber_log_printf ber_pvt_log_printf
129 ber_log_bprint LDAP_P((
136 ber_log_dump LDAP_P((
143 ber_log_sos_dump LDAP_P((
148 LBER_V (BER_LOG_FN) ber_int_log_proc;
149 LBER_V (FILE *) ber_pvt_err_file;
152 /* simple macros to realloc for now */
153 LBER_V (BerMemoryFunctions *) ber_int_memory_fns;
154 LBER_F (char *) ber_strndup( LDAP_CONST char *, ber_len_t );
155 LBER_F (char *) ber_strndup_x( LDAP_CONST char *, ber_len_t, void *ctx );
157 #define LBER_MALLOC(s) ber_memalloc((s))
158 #define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
159 #define LBER_REALLOC(p,s) ber_memrealloc((p),(s))
160 #define LBER_FREE(p) ber_memfree((p))
161 #define LBER_VFREE(v) ber_memvfree((void**)(v))
162 #define LBER_STRDUP(s) ber_strdup((s))
163 #define LBER_STRNDUP(s,l) ber_strndup((s),(l))
168 ber_int_sb_init LDAP_P(( Sockbuf *sb ));
171 ber_int_sb_close LDAP_P(( Sockbuf *sb ));
174 ber_int_sb_destroy LDAP_P(( Sockbuf *sb ));
177 ber_int_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
180 ber_int_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
184 #endif /* _LBER_INT_H */