No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / openldap / dist / include / lber_pvt.h
blobbd915b5c331c682091cde5071dbea13f4af3ee00
1 /* $OpenLDAP: pkg/ldap/include/lber_pvt.h,v 1.35.2.5 2008/03/21 00:43:00 hyc Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2008 The OpenLDAP Foundation.
5 * All rights reserved.
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.
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
17 * lber_pvt.h - Header for ber_pvt_ functions.
18 * These are meant to be internal to OpenLDAP Software.
21 #ifndef _LBER_PVT_H
22 #define _LBER_PVT_H 1
24 #include <lber.h>
26 LDAP_BEGIN_DECL
28 /* for allocating aligned buffers (on the stack) */
29 #define LBER_ALIGNED_BUFFER(uname,size) \
30 union uname { \
31 char buffer[size]; \
32 /* force alignment */ \
33 int ialign; \
34 long lalign; \
35 float falign; \
36 double dalign; \
37 char* palign; \
40 #define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */
41 typedef LBER_ALIGNED_BUFFER(lber_berelement_u,LBER_ELEMENT_SIZEOF)
42 BerElementBuffer;
44 typedef struct sockbuf_buf {
45 ber_len_t buf_size;
46 ber_len_t buf_ptr;
47 ber_len_t buf_end;
48 char *buf_base;
49 } Sockbuf_Buf;
52 * bprint.c
54 LBER_V( BER_LOG_PRINT_FN ) ber_pvt_log_print;
56 LBER_F( int )
57 ber_pvt_log_printf LDAP_P((
58 int errlvl,
59 int loglvl,
60 const char *fmt,
61 ... )) LDAP_GCCATTR((format(printf, 3, 4)));
64 * sockbuf.c
66 LBER_F( ber_slen_t )
67 ber_pvt_sb_do_write LDAP_P(( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out ));
69 LBER_F( void )
70 ber_pvt_sb_buf_init LDAP_P(( Sockbuf_Buf *buf ));
72 LBER_F( void )
73 ber_pvt_sb_buf_destroy LDAP_P(( Sockbuf_Buf *buf ));
75 LBER_F( int )
76 ber_pvt_sb_grow_buffer LDAP_P(( Sockbuf_Buf *buf, ber_len_t minsize ));
78 LBER_F( ber_len_t )
79 ber_pvt_sb_copy_out LDAP_P(( Sockbuf_Buf *sbb, char *buf, ber_len_t len ));
81 LBER_F( int )
82 ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
85 * memory.c
87 LBER_F( void * )
88 ber_memalloc_x LDAP_P((
89 ber_len_t s, void *ctx));
91 LBER_F( void * )
92 ber_memrealloc_x LDAP_P((
93 void* p,
94 ber_len_t s, void *ctx ));
96 LBER_F( void * )
97 ber_memcalloc_x LDAP_P((
98 ber_len_t n,
99 ber_len_t s, void *ctx ));
101 LBER_F( void )
102 ber_memfree_x LDAP_P((
103 void* p, void *ctx ));
105 LBER_F( void )
106 ber_memvfree_x LDAP_P((
107 void** vector, void *ctx ));
109 LBER_F( void )
110 ber_bvfree_x LDAP_P((
111 struct berval *bv, void *ctx ));
113 LBER_F( void )
114 ber_bvecfree_x LDAP_P((
115 struct berval **bv, void *ctx ));
117 LBER_F( int )
118 ber_bvecadd_x LDAP_P((
119 struct berval ***bvec,
120 struct berval *bv, void *ctx ));
122 LBER_F( struct berval * )
123 ber_dupbv_x LDAP_P((
124 struct berval *dst, struct berval *src, void *ctx ));
126 LBER_F( struct berval * )
127 ber_str2bv_x LDAP_P((
128 LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv, void *ctx));
130 LBER_F( struct berval * )
131 ber_mem2bv_x LDAP_P((
132 LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv, void *ctx));
134 LBER_F( char * )
135 ber_strdup_x LDAP_P((
136 LDAP_CONST char *, void *ctx ));
138 LBER_F( struct berval * )
139 ber_bvreplace_x LDAP_P((
140 struct berval *dst, LDAP_CONST struct berval *src, void *ctx ));
142 LBER_F( void )
143 ber_bvarray_free_x LDAP_P(( BerVarray p, void *ctx ));
145 LBER_F( int )
146 ber_bvarray_add_x LDAP_P(( BerVarray *p, BerValue *bv, void *ctx ));
148 LBER_F( int )
149 ber_bvarray_dup_x LDAP_P(( BerVarray *dst, BerVarray src, void *ctx ));
151 #if 0
152 #define ber_bvstrcmp(v1,v2) \
153 ((v1)->bv_len < (v2)->bv_len \
154 ? -1 : ((v1)->bv_len > (v2)->bv_len \
155 ? 1 : strncmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
156 #else
157 /* avoid strncmp() */
158 #define ber_bvstrcmp(v1,v2) ber_bvcmp((v1),(v2))
159 #endif
161 #define ber_bvstrcasecmp(v1,v2) \
162 ((v1)->bv_len < (v2)->bv_len \
163 ? -1 : ((v1)->bv_len > (v2)->bv_len \
164 ? 1 : strncasecmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
166 #define ber_bvccmp(v1,c) \
167 ( (v1)->bv_len == 1 && (v1)->bv_val[0] == (c) )
169 #define ber_strccmp(s,c) \
170 ( (s)[0] == (c) && (s)[1] == '\0' )
172 #define ber_bvchr(bv,c) \
173 ((char *) memchr( (bv)->bv_val, (c), (bv)->bv_len ))
175 #define ber_bvrchr(bv,c) \
176 ((char *) memrchr( (bv)->bv_val, (c), (bv)->bv_len ))
178 #define ber_bvchr_post(dst,bv,c) \
179 do { \
180 (dst)->bv_val = memchr( (bv)->bv_val, (c), (bv)->bv_len ); \
181 (dst)->bv_len = (dst)->bv_val ? (bv)->bv_len - ((dst)->bv_val - (bv)->bv_val) : 0; \
182 } while (0)
184 #define ber_bvchr_pre(dst,bv,c) \
185 do { \
186 (dst)->bv_val = memchr( (bv)->bv_val, (c), (bv)->bv_len ); \
187 (dst)->bv_len = (dst)->bv_val ? ((dst)->bv_val - (bv)->bv_val) : (bv)->bv_len; \
188 (dst)->bv_val = (bv)->bv_val; \
189 } while (0)
191 #define ber_bvrchr_post(dst,bv,c) \
192 do { \
193 (dst)->bv_val = memrchr( (bv)->bv_val, (c), (bv)->bv_len ); \
194 (dst)->bv_len = (dst)->bv_val ? (bv)->bv_len - ((dst)->bv_val - (bv)->bv_val) : 0; \
195 } while (0)
197 #define ber_bvrchr_pre(dst,bv,c) \
198 do { \
199 (dst)->bv_val = memrchr( (bv)->bv_val, (c), (bv)->bv_len ); \
200 (dst)->bv_len = (dst)->bv_val ? ((dst)->bv_val - (bv)->bv_val) : (bv)->bv_len; \
201 (dst)->bv_val = (bv)->bv_val; \
202 } while (0)
204 #define BER_BVC(s) { STRLENOF(s), (char *)(s) }
205 #define BER_BVNULL { 0L, NULL }
206 #define BER_BVZERO(bv) \
207 do { \
208 (bv)->bv_len = 0; \
209 (bv)->bv_val = NULL; \
210 } while (0)
211 #define BER_BVSTR(bv,s) \
212 do { \
213 (bv)->bv_len = STRLENOF(s); \
214 (bv)->bv_val = (s); \
215 } while (0)
216 #define BER_BVISNULL(bv) ((bv)->bv_val == NULL)
217 #define BER_BVISEMPTY(bv) ((bv)->bv_len == 0)
219 LDAP_END_DECL
221 #endif