3 * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
8 * Public License. A copy of this license is available at
9 * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10 * top-level directory of the distribution.
13 * lber_pvt.h - Header for ber_pvt_ functions. These are meant to be used
14 * by the OpenLDAP distribution only.
24 /* for allocating aligned buffers (on the stack) */
25 #define LBER_ALIGNED_BUFFER(uname,size) \
28 /* force alignment */ \
36 #define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */
37 typedef LBER_ALIGNED_BUFFER(lber_berelement_u,LBER_ELEMENT_SIZEOF)
40 typedef struct sockbuf_buf {
50 LBER_V( BER_LOG_PRINT_FN ) ber_pvt_log_print;
53 ber_pvt_log_printf LDAP_P((
57 ... )) LDAP_GCCATTR((format(printf, 3, 4)));
63 ber_pvt_sb_do_write LDAP_P(( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out ));
66 ber_pvt_sb_buf_init LDAP_P(( Sockbuf_Buf *buf ));
69 ber_pvt_sb_buf_destroy LDAP_P(( Sockbuf_Buf *buf ));
72 ber_pvt_sb_grow_buffer LDAP_P(( Sockbuf_Buf *buf, ber_len_t minsize ));
75 ber_pvt_sb_copy_out LDAP_P(( Sockbuf_Buf *sbb, char *buf, ber_len_t len ));
78 ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
84 ber_memalloc_x LDAP_P((
85 ber_len_t s, void *ctx));
88 ber_memrealloc_x LDAP_P((
90 ber_len_t s, void *ctx ));
93 ber_memcalloc_x LDAP_P((
95 ber_len_t s, void *ctx ));
98 ber_memfree_x LDAP_P((
99 void* p, void *ctx ));
102 ber_memvfree_x LDAP_P((
103 void** vector, void *ctx ));
106 ber_bvfree_x LDAP_P((
107 struct berval *bv, void *ctx ));
110 ber_bvecfree_x LDAP_P((
111 struct berval **bv, void *ctx ));
114 ber_bvecadd_x LDAP_P((
115 struct berval ***bvec,
116 struct berval *bv, void *ctx ));
118 LBER_F( struct berval * )
120 struct berval *dst, struct berval *src, void *ctx ));
122 LBER_F( struct berval * )
123 ber_str2bv_x LDAP_P((
124 LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv, void *ctx));
126 LBER_F( struct berval * )
127 ber_mem2bv_x LDAP_P((
128 LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv, void *ctx));
131 ber_strdup_x LDAP_P((
132 LDAP_CONST char *, void *ctx ));
135 ber_bvarray_free_x LDAP_P(( BerVarray p, void *ctx ));
138 ber_bvarray_add_x LDAP_P(( BerVarray *p, BerValue *bv, void *ctx ));
141 #define ber_bvstrcmp(v1,v2) \
142 ((v1)->bv_len < (v2)->bv_len \
143 ? -1 : ((v1)->bv_len > (v2)->bv_len \
144 ? 1 : strncmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
146 /* avoid strncmp() */
147 #define ber_bvstrcmp(v1,v2) ber_bvcmp((v1),(v2))
150 #define ber_bvstrcasecmp(v1,v2) \
151 ((v1)->bv_len < (v2)->bv_len \
152 ? -1 : ((v1)->bv_len > (v2)->bv_len \
153 ? 1 : strncasecmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
155 #define ber_bvccmp(v1,c) \
156 ( (v1)->bv_len == 1 && (v1)->bv_val[0] == (c) )
158 #define ber_strccmp(s,c) \
159 ( (s)[0] == (c) && (s)[1] == '\0' )
161 #define ber_bvchr(bv,c) \
162 memchr( (bv)->bv_val, (c), (bv)->bv_len )
164 #define BER_BVC(x) { sizeof( (x) ) - 1, (x) }
165 #define BER_BVNULL { 0L, NULL }