Back to index

openldap  2.4.31
lber.h
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
00016  * All rights reserved.
00017  *
00018  * Redistribution and use in source and binary forms are permitted
00019  * provided that this notice is preserved and that due credit is given
00020  * to the University of Michigan at Ann Arbor. The name of the University
00021  * may not be used to endorse or promote products derived from this
00022  * software without specific prior written permission. This software
00023  * is provided ``as is'' without express or implied warranty.
00024  */
00025 
00026 #ifndef _LBER_H
00027 #define _LBER_H
00028 
00029 #include <lber_types.h>
00030 #include <string.h>
00031 
00032 LDAP_BEGIN_DECL
00033 
00034 /*
00035  * ber_tag_t represents the identifier octets at the beginning of BER
00036  * elements.  OpenLDAP treats them as mere big-endian unsigned integers.
00037  *
00038  * Actually the BER identifier octets look like this:
00039  *
00040  *     Bits of 1st octet:
00041  *     ______
00042  *     8 7 | CLASS
00043  *     0 0 = UNIVERSAL
00044  *     0 1 = APPLICATION
00045  *     1 0 = CONTEXT-SPECIFIC
00046  *     1 1 = PRIVATE
00047  *            _____
00048  *            | 6 | DATA-TYPE
00049  *              0 = PRIMITIVE
00050  *              1 = CONSTRUCTED
00051  *                   ___________
00052  *                   | 5 ... 1 | TAG-NUMBER
00053  *
00054  *  For ASN.1 tag numbers >= 0x1F, TAG-NUMBER above is 0x1F and the next
00055  *  BER octets contain the actual ASN.1 tag number:  Big-endian, base
00056  *  128, 8.bit = 1 in all but the last octet, minimum number of octets.
00057  */
00058 
00059 /* BER classes and mask (in 1st identifier octet) */
00060 #define LBER_CLASS_UNIVERSAL       ((ber_tag_t) 0x00U)
00061 #define LBER_CLASS_APPLICATION     ((ber_tag_t) 0x40U)
00062 #define LBER_CLASS_CONTEXT         ((ber_tag_t) 0x80U)
00063 #define LBER_CLASS_PRIVATE         ((ber_tag_t) 0xc0U)
00064 #define LBER_CLASS_MASK                   ((ber_tag_t) 0xc0U)
00065 
00066 /* BER encoding type and mask (in 1st identifier octet) */
00067 #define LBER_PRIMITIVE                    ((ber_tag_t) 0x00U)
00068 #define LBER_CONSTRUCTED           ((ber_tag_t) 0x20U)
00069 #define LBER_ENCODING_MASK         ((ber_tag_t) 0x20U)
00070 
00071 #define LBER_BIG_TAG_MASK          ((ber_tag_t) 0x1fU)
00072 #define LBER_MORE_TAG_MASK         ((ber_tag_t) 0x80U)
00073 
00074 /*
00075  * LBER_ERROR and LBER_DEFAULT are values that can never appear
00076  * as valid BER tags, so it is safe to use them to report errors.
00077  * Valid tags have (tag & (ber_tag_t) 0xFF) != 0xFF.
00078  */
00079 #define LBER_ERROR                 ((ber_tag_t) -1)
00080 #define LBER_DEFAULT        ((ber_tag_t) -1)
00081 
00082 /* general BER types we know about */
00083 #define LBER_BOOLEAN        ((ber_tag_t) 0x01UL)
00084 #define LBER_INTEGER        ((ber_tag_t) 0x02UL)
00085 #define LBER_BITSTRING             ((ber_tag_t) 0x03UL)
00086 #define LBER_OCTETSTRING    ((ber_tag_t) 0x04UL)
00087 #define LBER_NULL                  ((ber_tag_t) 0x05UL)
00088 #define LBER_ENUMERATED            ((ber_tag_t) 0x0aUL)
00089 #define LBER_SEQUENCE              ((ber_tag_t) 0x30UL) /* constructed */
00090 #define LBER_SET                   ((ber_tag_t) 0x31UL) /* constructed */
00091 
00092 /* LBER BerElement options */
00093 #define LBER_USE_DER        0x01
00094 
00095 /* get/set options for BerElement */
00096 #define LBER_OPT_BER_OPTIONS                     0x01
00097 #define LBER_OPT_BER_DEBUG                       0x02
00098 #define LBER_OPT_BER_REMAINING_BYTES      0x03
00099 #define LBER_OPT_BER_TOTAL_BYTES          0x04
00100 #define LBER_OPT_BER_BYTES_TO_WRITE              0x05
00101 #define LBER_OPT_BER_MEMCTX                      0x06
00102 
00103 #define LBER_OPT_DEBUG_LEVEL       LBER_OPT_BER_DEBUG
00104 #define LBER_OPT_REMAINING_BYTES   LBER_OPT_BER_REMAINING_BYTES
00105 #define LBER_OPT_TOTAL_BYTES              LBER_OPT_BER_TOTAL_BYTES
00106 #define LBER_OPT_BYTES_TO_WRITE           LBER_OPT_BER_BYTES_TO_WRITE
00107 
00108 #define LBER_OPT_LOG_PRINT_FN      0x8001
00109 #define LBER_OPT_MEMORY_FNS        0x8002
00110 #define LBER_OPT_ERROR_FN          0x8003
00111 #define LBER_OPT_LOG_PRINT_FILE           0x8004
00112 
00113 /* get/set Memory Debug options */
00114 #define LBER_OPT_MEMORY_INUSE             0x8005 /* for memory debugging */
00115 #define LBER_OPT_LOG_PROC           0x8006  /* for external logging function */
00116 
00117 typedef int* (*BER_ERRNO_FN) LDAP_P(( void ));
00118 
00119 typedef void (*BER_LOG_PRINT_FN) LDAP_P(( LDAP_CONST char *buf ));
00120 
00121 typedef void* (BER_MEMALLOC_FN)    LDAP_P(( ber_len_t size, void *ctx ));
00122 typedef void* (BER_MEMCALLOC_FN)   LDAP_P(( ber_len_t n, ber_len_t size, void *ctx ));
00123 typedef void* (BER_MEMREALLOC_FN)  LDAP_P(( void *p, ber_len_t size, void *ctx ));
00124 typedef void  (BER_MEMFREE_FN)            LDAP_P(( void *p, void *ctx ));
00125 
00126 typedef struct lber_memory_fns {
00127        BER_MEMALLOC_FN      *bmf_malloc;
00128        BER_MEMCALLOC_FN *bmf_calloc;
00129        BER_MEMREALLOC_FN *bmf_realloc;
00130        BER_MEMFREE_FN *bmf_free;
00131 } BerMemoryFunctions;
00132 
00133 /* LBER Sockbuf_IO options */
00134 #define LBER_SB_OPT_GET_FD         1
00135 #define LBER_SB_OPT_SET_FD         2
00136 #define LBER_SB_OPT_HAS_IO         3
00137 #define LBER_SB_OPT_SET_NONBLOCK   4
00138 #define LBER_SB_OPT_GET_SSL        7
00139 #define LBER_SB_OPT_DATA_READY            8
00140 #define LBER_SB_OPT_SET_READAHEAD  9
00141 #define LBER_SB_OPT_DRAIN          10
00142 #define LBER_SB_OPT_NEEDS_READ            11
00143 #define LBER_SB_OPT_NEEDS_WRITE           12
00144 #define LBER_SB_OPT_GET_MAX_INCOMING      13
00145 #define LBER_SB_OPT_SET_MAX_INCOMING      14
00146 
00147 /* Only meaningful ifdef LDAP_PF_LOCAL_SENDMSG */
00148 #define LBER_SB_OPT_UNGET_BUF      15
00149 
00150 /* Largest option used by the library */
00151 #define LBER_SB_OPT_OPT_MAX        15
00152 
00153 /* LBER IO operations stacking levels */
00154 #define LBER_SBIOD_LEVEL_PROVIDER  10
00155 #define LBER_SBIOD_LEVEL_TRANSPORT 20
00156 #define LBER_SBIOD_LEVEL_APPLICATION      30
00157 
00158 /* get/set options for Sockbuf */
00159 #define LBER_OPT_SOCKBUF_DESC             0x1000
00160 #define LBER_OPT_SOCKBUF_OPTIONS   0x1001
00161 #define LBER_OPT_SOCKBUF_DEBUG            0x1002
00162 
00163 /* on/off values */
00164 LBER_V( char ) ber_pvt_opt_on;
00165 #define LBER_OPT_ON         ((void *) &ber_pvt_opt_on)
00166 #define LBER_OPT_OFF ((void *) 0)
00167 
00168 #define LBER_OPT_SUCCESS    (0)
00169 #define LBER_OPT_ERROR             (-1)
00170 
00171 typedef struct berelement BerElement;
00172 typedef struct sockbuf Sockbuf;
00173 
00174 typedef struct sockbuf_io Sockbuf_IO;
00175 
00176 /* Structure for LBER IO operarion descriptor */
00177 typedef struct sockbuf_io_desc {
00178        int                  sbiod_level;
00179        Sockbuf                     *sbiod_sb;
00180        Sockbuf_IO           *sbiod_io;
00181        void                 *sbiod_pvt;
00182        struct sockbuf_io_desc      *sbiod_next;
00183 } Sockbuf_IO_Desc;
00184 
00185 /* Structure for LBER IO operation functions */
00186 struct sockbuf_io {
00187        int (*sbi_setup)( Sockbuf_IO_Desc *sbiod, void *arg );
00188        int (*sbi_remove)( Sockbuf_IO_Desc *sbiod );
00189        int (*sbi_ctrl)( Sockbuf_IO_Desc *sbiod, int opt, void *arg);
00190 
00191        ber_slen_t (*sbi_read)( Sockbuf_IO_Desc *sbiod, void *buf,
00192               ber_len_t len );
00193        ber_slen_t (*sbi_write)( Sockbuf_IO_Desc *sbiod, void *buf,
00194               ber_len_t len );
00195 
00196        int (*sbi_close)( Sockbuf_IO_Desc *sbiod );
00197 };
00198 
00199 /* Helper macros for LBER IO functions */
00200 #define LBER_SBIOD_READ_NEXT( sbiod, buf, len ) \
00201        ( (sbiod)->sbiod_next->sbiod_io->sbi_read( (sbiod)->sbiod_next, \
00202               buf, len ) )
00203 #define LBER_SBIOD_WRITE_NEXT( sbiod, buf, len ) \
00204        ( (sbiod)->sbiod_next->sbiod_io->sbi_write( (sbiod)->sbiod_next, \
00205               buf, len ) )
00206 #define LBER_SBIOD_CTRL_NEXT( sbiod, opt, arg ) \
00207        ( (sbiod)->sbiod_next ? \
00208               ( (sbiod)->sbiod_next->sbiod_io->sbi_ctrl( \
00209               (sbiod)->sbiod_next, opt, arg ) ) : 0 )
00210 
00211 /* structure for returning a sequence of octet strings + length */
00212 typedef struct berval {
00213        ber_len_t     bv_len;
00214        char          *bv_val;
00215 } BerValue;
00216 
00217 typedef BerValue *BerVarray;       /* To distinguish from a single bv */
00218 
00219 /* this should be moved to lber-int.h */
00220 
00221 /*
00222  * in bprint.c:
00223  */
00224 LBER_F( void )
00225 ber_error_print LDAP_P((
00226        LDAP_CONST char *data ));
00227 
00228 LBER_F( void )
00229 ber_bprint LDAP_P((
00230        LDAP_CONST char *data, ber_len_t len ));
00231 
00232 LBER_F( void )
00233 ber_dump LDAP_P((
00234        BerElement *ber, int inout ));
00235 
00236 /*
00237  * in decode.c:
00238  */
00239 typedef int (*BERDecodeCallback) LDAP_P((
00240        BerElement *ber,
00241        void *data,
00242        int mode ));
00243 
00244 LBER_F( ber_tag_t )
00245 ber_get_tag LDAP_P((
00246        BerElement *ber ));
00247 
00248 LBER_F( ber_tag_t )
00249 ber_skip_tag LDAP_P((
00250        BerElement *ber,
00251        ber_len_t *len ));
00252 
00253 LBER_F( ber_tag_t )
00254 ber_peek_tag LDAP_P((
00255        BerElement *ber,
00256        ber_len_t *len ));
00257 
00258 LBER_F( ber_tag_t )
00259 ber_skip_element LDAP_P((
00260        BerElement *ber,
00261        struct berval *bv ));
00262 
00263 LBER_F( ber_tag_t )
00264 ber_peek_element LDAP_P((
00265        LDAP_CONST BerElement *ber,
00266        struct berval *bv ));
00267 
00268 LBER_F( ber_tag_t )
00269 ber_get_int LDAP_P((
00270        BerElement *ber,
00271        ber_int_t *num ));
00272 
00273 LBER_F( ber_tag_t )
00274 ber_get_enum LDAP_P((
00275        BerElement *ber,
00276        ber_int_t *num ));
00277 
00278 LBER_F( ber_tag_t )
00279 ber_get_stringb LDAP_P((
00280        BerElement *ber,
00281        char *buf,
00282        ber_len_t *len ));
00283 
00284 #define       LBER_BV_ALLOC 0x01   /* allocate/copy result, otherwise in-place */
00285 #define       LBER_BV_NOTERM       0x02   /* omit NUL-terminator if parsing in-place */
00286 #define       LBER_BV_STRING       0x04   /* fail if berval contains embedded \0 */
00287 /* LBER_BV_STRING currently accepts a terminating \0 in the berval, because
00288  * Active Directory sends that in at least the diagonsticMessage field.
00289  */
00290 
00291 LBER_F( ber_tag_t )
00292 ber_get_stringbv LDAP_P((
00293        BerElement *ber,
00294        struct berval *bv,
00295        int options ));
00296 
00297 LBER_F( ber_tag_t )
00298 ber_get_stringa LDAP_P((
00299        BerElement *ber,
00300        char **buf ));
00301 
00302 LBER_F( ber_tag_t )
00303 ber_get_stringal LDAP_P((
00304        BerElement *ber,
00305        struct berval **bv ));
00306 
00307 LBER_F( ber_tag_t )
00308 ber_get_bitstringa LDAP_P((
00309        BerElement *ber,
00310        char **buf,
00311        ber_len_t *len ));
00312 
00313 LBER_F( ber_tag_t )
00314 ber_get_null LDAP_P((
00315        BerElement *ber ));
00316 
00317 LBER_F( ber_tag_t )
00318 ber_get_boolean LDAP_P((
00319        BerElement *ber,
00320        ber_int_t *boolval ));
00321 
00322 LBER_F( ber_tag_t )
00323 ber_first_element LDAP_P((
00324        BerElement *ber,
00325        ber_len_t *len,
00326        char **last ));
00327 
00328 LBER_F( ber_tag_t )
00329 ber_next_element LDAP_P((
00330        BerElement *ber,
00331        ber_len_t *len,
00332        LDAP_CONST char *last ));
00333 
00334 LBER_F( ber_tag_t )
00335 ber_scanf LDAP_P((
00336        BerElement *ber,
00337        LDAP_CONST char *fmt,
00338        ... ));
00339 
00340 LBER_F( int )
00341 ber_decode_oid LDAP_P((
00342        struct berval *in,
00343        struct berval *out ));
00344 
00345 /*
00346  * in encode.c
00347  */
00348 LBER_F( int )
00349 ber_encode_oid LDAP_P((
00350        struct berval *in,
00351        struct berval *out ));
00352 
00353 typedef int (*BEREncodeCallback) LDAP_P((
00354        BerElement *ber,
00355        void *data ));
00356 
00357 LBER_F( int )
00358 ber_put_enum LDAP_P((
00359        BerElement *ber,
00360        ber_int_t num,
00361        ber_tag_t tag ));
00362 
00363 LBER_F( int )
00364 ber_put_int LDAP_P((
00365        BerElement *ber,
00366        ber_int_t num,
00367        ber_tag_t tag ));
00368 
00369 LBER_F( int )
00370 ber_put_ostring LDAP_P((
00371        BerElement *ber,
00372        LDAP_CONST char *str,
00373        ber_len_t len,
00374        ber_tag_t tag ));
00375 
00376 LBER_F( int )
00377 ber_put_berval LDAP_P((
00378        BerElement *ber,
00379        struct berval *bv,
00380        ber_tag_t tag ));
00381 
00382 LBER_F( int )
00383 ber_put_string LDAP_P((
00384        BerElement *ber,
00385        LDAP_CONST char *str,
00386        ber_tag_t tag ));
00387 
00388 LBER_F( int )
00389 ber_put_bitstring LDAP_P((
00390        BerElement *ber,
00391        LDAP_CONST char *str,
00392        ber_len_t bitlen,
00393        ber_tag_t tag ));
00394 
00395 LBER_F( int )
00396 ber_put_null LDAP_P((
00397        BerElement *ber,
00398        ber_tag_t tag ));
00399 
00400 LBER_F( int )
00401 ber_put_boolean LDAP_P((
00402        BerElement *ber,
00403        ber_int_t boolval,
00404        ber_tag_t tag ));
00405 
00406 LBER_F( int )
00407 ber_start_seq LDAP_P((
00408        BerElement *ber,
00409        ber_tag_t tag ));
00410 
00411 LBER_F( int )
00412 ber_start_set LDAP_P((
00413        BerElement *ber,
00414        ber_tag_t tag ));
00415 
00416 LBER_F( int )
00417 ber_put_seq LDAP_P((
00418        BerElement *ber ));
00419 
00420 LBER_F( int )
00421 ber_put_set LDAP_P((
00422        BerElement *ber ));
00423 
00424 LBER_F( int )
00425 ber_printf LDAP_P((
00426        BerElement *ber,
00427        LDAP_CONST char *fmt,
00428        ... ));
00429 
00430 
00431 /*
00432  * in io.c:
00433  */
00434 
00435 LBER_F( ber_slen_t )
00436 ber_skip_data LDAP_P((
00437        BerElement *ber,
00438        ber_len_t len ));
00439 
00440 LBER_F( ber_slen_t )
00441 ber_read LDAP_P((
00442        BerElement *ber,
00443        char *buf,
00444        ber_len_t len ));
00445 
00446 LBER_F( ber_slen_t )
00447 ber_write LDAP_P((
00448        BerElement *ber,
00449        LDAP_CONST char *buf,
00450        ber_len_t len,
00451        int zero ));  /* nonzero is unsupported from OpenLDAP 2.4.18 */
00452 
00453 LBER_F( void )
00454 ber_free LDAP_P((
00455        BerElement *ber,
00456        int freebuf ));
00457 
00458 LBER_F( void )
00459 ber_free_buf LDAP_P(( BerElement *ber ));
00460 
00461 LBER_F( int )
00462 ber_flush2 LDAP_P((
00463        Sockbuf *sb,
00464        BerElement *ber,
00465        int freeit ));
00466 #define LBER_FLUSH_FREE_NEVER             (0x0)  /* traditional behavior */
00467 #define LBER_FLUSH_FREE_ON_SUCCESS (0x1)  /* traditional behavior */
00468 #define LBER_FLUSH_FREE_ON_ERROR   (0x2)
00469 #define LBER_FLUSH_FREE_ALWAYS            (LBER_FLUSH_FREE_ON_SUCCESS|LBER_FLUSH_FREE_ON_ERROR)
00470 
00471 LBER_F( int )
00472 ber_flush LDAP_P((
00473        Sockbuf *sb,
00474        BerElement *ber,
00475        int freeit )); /* DEPRECATED */
00476 
00477 LBER_F( BerElement * )
00478 ber_alloc LDAP_P(( void )); /* DEPRECATED */
00479 
00480 LBER_F( BerElement * )
00481 der_alloc LDAP_P(( void )); /* DEPRECATED */
00482 
00483 LBER_F( BerElement * )
00484 ber_alloc_t LDAP_P((
00485        int beroptions ));
00486 
00487 LBER_F( BerElement * )
00488 ber_dup LDAP_P((
00489        BerElement *ber ));
00490 
00491 LBER_F( ber_tag_t )
00492 ber_get_next LDAP_P((
00493        Sockbuf *sb,
00494        ber_len_t *len,
00495        BerElement *ber ));
00496 
00497 LBER_F( void )
00498 ber_init2 LDAP_P((
00499        BerElement *ber,
00500        struct berval *bv,
00501        int options ));
00502 
00503 LBER_F( void )
00504 ber_init_w_nullc LDAP_P((   /* DEPRECATED */
00505        BerElement *ber,
00506        int options ));
00507 
00508 LBER_F( void )
00509 ber_reset LDAP_P((
00510        BerElement *ber,
00511        int was_writing ));
00512 
00513 LBER_F( BerElement * )
00514 ber_init LDAP_P((
00515        struct berval *bv ));
00516 
00517 LBER_F( int )
00518 ber_flatten LDAP_P((
00519        BerElement *ber,
00520        struct berval **bvPtr ));
00521 
00522 LBER_F( int )
00523 ber_flatten2 LDAP_P((
00524        BerElement *ber,
00525        struct berval *bv,
00526        int alloc ));
00527 
00528 LBER_F( int )
00529 ber_remaining LDAP_P((
00530        BerElement *ber ));
00531 
00532 /*
00533  * LBER ber accessor functions
00534  */
00535 
00536 LBER_F( int )
00537 ber_get_option LDAP_P((
00538        void *item,
00539        int option,
00540        void *outvalue));
00541 
00542 LBER_F( int )
00543 ber_set_option LDAP_P((
00544        void *item,
00545        int option,
00546        LDAP_CONST void *invalue));
00547 
00548 /*
00549  * LBER sockbuf.c
00550  */
00551 
00552 LBER_F( Sockbuf *  )
00553 ber_sockbuf_alloc LDAP_P((
00554        void ));
00555 
00556 LBER_F( void )
00557 ber_sockbuf_free LDAP_P((
00558        Sockbuf *sb ));
00559 
00560 LBER_F( int )
00561 ber_sockbuf_add_io LDAP_P((
00562        Sockbuf *sb,
00563        Sockbuf_IO *sbio,
00564        int layer,
00565        void *arg ));
00566 
00567 LBER_F( int )
00568 ber_sockbuf_remove_io LDAP_P((
00569        Sockbuf *sb,
00570        Sockbuf_IO *sbio,
00571        int layer ));
00572 
00573 LBER_F( int )
00574 ber_sockbuf_ctrl LDAP_P((
00575        Sockbuf *sb,
00576        int opt,
00577        void *arg ));
00578 
00579 LBER_V( Sockbuf_IO ) ber_sockbuf_io_tcp;
00580 LBER_V( Sockbuf_IO ) ber_sockbuf_io_readahead;
00581 LBER_V( Sockbuf_IO ) ber_sockbuf_io_fd;
00582 LBER_V( Sockbuf_IO ) ber_sockbuf_io_debug;
00583 LBER_V( Sockbuf_IO ) ber_sockbuf_io_udp;
00584 
00585 /*
00586  * LBER memory.c
00587  */
00588 LBER_F( void * )
00589 ber_memalloc LDAP_P((
00590        ber_len_t s ));
00591 
00592 LBER_F( void * )
00593 ber_memrealloc LDAP_P((
00594        void* p,
00595        ber_len_t s ));
00596 
00597 LBER_F( void * )
00598 ber_memcalloc LDAP_P((
00599        ber_len_t n,
00600        ber_len_t s ));
00601 
00602 LBER_F( void )
00603 ber_memfree LDAP_P((
00604        void* p ));
00605 
00606 LBER_F( void )
00607 ber_memvfree LDAP_P((
00608        void** vector ));
00609 
00610 LBER_F( void )
00611 ber_bvfree LDAP_P((
00612        struct berval *bv ));
00613 
00614 LBER_F( void )
00615 ber_bvecfree LDAP_P((
00616        struct berval **bv ));
00617 
00618 LBER_F( int )
00619 ber_bvecadd LDAP_P((
00620        struct berval ***bvec,
00621        struct berval *bv ));
00622 
00623 LBER_F( struct berval * )
00624 ber_dupbv LDAP_P((
00625        struct berval *dst, struct berval *src ));
00626 
00627 LBER_F( struct berval * )
00628 ber_bvdup LDAP_P((
00629        struct berval *src ));
00630 
00631 LBER_F( struct berval * )
00632 ber_mem2bv LDAP_P((
00633        LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv));
00634 
00635 LBER_F( struct berval * )
00636 ber_str2bv LDAP_P((
00637        LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv));
00638 
00639 #define       ber_bvstr(a)  ((ber_str2bv)((a), 0, 0, NULL))
00640 #define       ber_bvstrdup(a)      ((ber_str2bv)((a), 0, 1, NULL))
00641 
00642 LBER_F( char * )
00643 ber_strdup LDAP_P((
00644        LDAP_CONST char * ));
00645 
00646 LBER_F( ber_len_t )
00647 ber_strnlen LDAP_P((
00648        LDAP_CONST char *s, ber_len_t len ));
00649 
00650 LBER_F( char * )
00651 ber_strndup LDAP_P((
00652        LDAP_CONST char *s, ber_len_t l ));
00653 
00654 LBER_F( struct berval * )
00655 ber_bvreplace LDAP_P((
00656        struct berval *dst, LDAP_CONST struct berval *src ));
00657 
00658 LBER_F( void )
00659 ber_bvarray_free LDAP_P(( BerVarray p ));
00660 
00661 LBER_F( int )
00662 ber_bvarray_add LDAP_P(( BerVarray *p, BerValue *bv ));
00663 
00664 #define ber_bvcmp(v1,v2) \
00665        ((v1)->bv_len < (v2)->bv_len \
00666               ? -1 : ((v1)->bv_len > (v2)->bv_len \
00667                      ? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
00668 
00669 /*
00670  * error.c
00671  */
00672 LBER_F( int * ) ber_errno_addr LDAP_P((void));
00673 #define ber_errno (*(ber_errno_addr)())
00674 
00675 #define LBER_ERROR_NONE            0
00676 #define LBER_ERROR_PARAM    0x1
00677 #define LBER_ERROR_MEMORY   0x2
00678 
00679 LDAP_END_DECL
00680 
00681 #endif /* _LBER_H */