| 1 | /* $NetBSD: lber.h,v 1.1.1.6 2018/02/06 01:53:05 christos Exp $ */ |
| 2 | |
| 3 | /* $OpenLDAP$ */ |
| 4 | /* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
| 5 | * |
| 6 | * Copyright 1998-2017 The OpenLDAP Foundation. |
| 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted only as authorized by the OpenLDAP |
| 11 | * Public License. |
| 12 | * |
| 13 | * A copy of this license is available in file LICENSE in the |
| 14 | * top-level directory of the distribution or, alternatively, at |
| 15 | * <http://www.OpenLDAP.org/license.html>. |
| 16 | */ |
| 17 | /* Portions Copyright (c) 1990 Regents of the University of Michigan. |
| 18 | * All rights reserved. |
| 19 | * |
| 20 | * Redistribution and use in source and binary forms are permitted |
| 21 | * provided that this notice is preserved and that due credit is given |
| 22 | * to the University of Michigan at Ann Arbor. The name of the University |
| 23 | * may not be used to endorse or promote products derived from this |
| 24 | * software without specific prior written permission. This software |
| 25 | * is provided ``as is'' without express or implied warranty. |
| 26 | */ |
| 27 | |
| 28 | #ifndef _LBER_H |
| 29 | #define _LBER_H |
| 30 | |
| 31 | #include <lber_types.h> |
| 32 | #include <string.h> |
| 33 | |
| 34 | LDAP_BEGIN_DECL |
| 35 | |
| 36 | /* |
| 37 | * ber_tag_t represents the identifier octets at the beginning of BER |
| 38 | * elements. OpenLDAP treats them as mere big-endian unsigned integers. |
| 39 | * |
| 40 | * Actually the BER identifier octets look like this: |
| 41 | * |
| 42 | * Bits of 1st octet: |
| 43 | * ______ |
| 44 | * 8 7 | CLASS |
| 45 | * 0 0 = UNIVERSAL |
| 46 | * 0 1 = APPLICATION |
| 47 | * 1 0 = CONTEXT-SPECIFIC |
| 48 | * 1 1 = PRIVATE |
| 49 | * _____ |
| 50 | * | 6 | DATA-TYPE |
| 51 | * 0 = PRIMITIVE |
| 52 | * 1 = CONSTRUCTED |
| 53 | * ___________ |
| 54 | * | 5 ... 1 | TAG-NUMBER |
| 55 | * |
| 56 | * For ASN.1 tag numbers >= 0x1F, TAG-NUMBER above is 0x1F and the next |
| 57 | * BER octets contain the actual ASN.1 tag number: Big-endian, base |
| 58 | * 128, 8.bit = 1 in all but the last octet, minimum number of octets. |
| 59 | */ |
| 60 | |
| 61 | /* BER classes and mask (in 1st identifier octet) */ |
| 62 | #define LBER_CLASS_UNIVERSAL ((ber_tag_t) 0x00U) |
| 63 | #define LBER_CLASS_APPLICATION ((ber_tag_t) 0x40U) |
| 64 | #define LBER_CLASS_CONTEXT ((ber_tag_t) 0x80U) |
| 65 | #define LBER_CLASS_PRIVATE ((ber_tag_t) 0xc0U) |
| 66 | #define LBER_CLASS_MASK ((ber_tag_t) 0xc0U) |
| 67 | |
| 68 | /* BER encoding type and mask (in 1st identifier octet) */ |
| 69 | #define LBER_PRIMITIVE ((ber_tag_t) 0x00U) |
| 70 | #define LBER_CONSTRUCTED ((ber_tag_t) 0x20U) |
| 71 | #define LBER_ENCODING_MASK ((ber_tag_t) 0x20U) |
| 72 | |
| 73 | #define LBER_BIG_TAG_MASK ((ber_tag_t) 0x1fU) |
| 74 | #define LBER_MORE_TAG_MASK ((ber_tag_t) 0x80U) |
| 75 | |
| 76 | /* |
| 77 | * LBER_ERROR and LBER_DEFAULT are values that can never appear |
| 78 | * as valid BER tags, so it is safe to use them to report errors. |
| 79 | * Valid tags have (tag & (ber_tag_t) 0xFF) != 0xFF. |
| 80 | */ |
| 81 | #define LBER_ERROR ((ber_tag_t) -1) |
| 82 | #define LBER_DEFAULT ((ber_tag_t) -1) |
| 83 | |
| 84 | /* general BER types we know about */ |
| 85 | #define LBER_BOOLEAN ((ber_tag_t) 0x01UL) |
| 86 | #define LBER_INTEGER ((ber_tag_t) 0x02UL) |
| 87 | #define LBER_BITSTRING ((ber_tag_t) 0x03UL) |
| 88 | #define LBER_OCTETSTRING ((ber_tag_t) 0x04UL) |
| 89 | #define LBER_NULL ((ber_tag_t) 0x05UL) |
| 90 | #define LBER_ENUMERATED ((ber_tag_t) 0x0aUL) |
| 91 | #define LBER_SEQUENCE ((ber_tag_t) 0x30UL) /* constructed */ |
| 92 | #define LBER_SET ((ber_tag_t) 0x31UL) /* constructed */ |
| 93 | |
| 94 | /* LBER BerElement options */ |
| 95 | #define LBER_USE_DER 0x01 |
| 96 | |
| 97 | /* get/set options for BerElement */ |
| 98 | #define LBER_OPT_BER_OPTIONS 0x01 |
| 99 | #define LBER_OPT_BER_DEBUG 0x02 |
| 100 | #define LBER_OPT_BER_REMAINING_BYTES 0x03 |
| 101 | #define LBER_OPT_BER_TOTAL_BYTES 0x04 |
| 102 | #define LBER_OPT_BER_BYTES_TO_WRITE 0x05 |
| 103 | #define LBER_OPT_BER_MEMCTX 0x06 |
| 104 | |
| 105 | #define LBER_OPT_DEBUG_LEVEL LBER_OPT_BER_DEBUG |
| 106 | #define LBER_OPT_REMAINING_BYTES LBER_OPT_BER_REMAINING_BYTES |
| 107 | #define LBER_OPT_TOTAL_BYTES LBER_OPT_BER_TOTAL_BYTES |
| 108 | #define LBER_OPT_BYTES_TO_WRITE LBER_OPT_BER_BYTES_TO_WRITE |
| 109 | |
| 110 | #define LBER_OPT_LOG_PRINT_FN 0x8001 |
| 111 | #define LBER_OPT_MEMORY_FNS 0x8002 |
| 112 | #define LBER_OPT_ERROR_FN 0x8003 |
| 113 | #define LBER_OPT_LOG_PRINT_FILE 0x8004 |
| 114 | |
| 115 | /* get/set Memory Debug options */ |
| 116 | #define LBER_OPT_MEMORY_INUSE 0x8005 /* for memory debugging */ |
| 117 | #define LBER_OPT_LOG_PROC 0x8006 /* for external logging function */ |
| 118 | |
| 119 | typedef int* (*BER_ERRNO_FN) LDAP_P(( void )); |
| 120 | |
| 121 | typedef void (*BER_LOG_PRINT_FN) LDAP_P(( LDAP_CONST char *buf )); |
| 122 | |
| 123 | typedef void* (BER_MEMALLOC_FN) LDAP_P(( ber_len_t size, void *ctx )); |
| 124 | typedef void* (BER_MEMCALLOC_FN) LDAP_P(( ber_len_t n, ber_len_t size, void *ctx )); |
| 125 | typedef void* (BER_MEMREALLOC_FN) LDAP_P(( void *p, ber_len_t size, void *ctx )); |
| 126 | typedef void (BER_MEMFREE_FN) LDAP_P(( void *p, void *ctx )); |
| 127 | |
| 128 | typedef struct lber_memory_fns { |
| 129 | BER_MEMALLOC_FN *bmf_malloc; |
| 130 | BER_MEMCALLOC_FN *bmf_calloc; |
| 131 | BER_MEMREALLOC_FN *bmf_realloc; |
| 132 | BER_MEMFREE_FN *bmf_free; |
| 133 | } BerMemoryFunctions; |
| 134 | |
| 135 | /* LBER Sockbuf_IO options */ |
| 136 | #define LBER_SB_OPT_GET_FD 1 |
| 137 | #define LBER_SB_OPT_SET_FD 2 |
| 138 | #define LBER_SB_OPT_HAS_IO 3 |
| 139 | #define LBER_SB_OPT_SET_NONBLOCK 4 |
| 140 | #define LBER_SB_OPT_GET_SSL 7 |
| 141 | #define LBER_SB_OPT_DATA_READY 8 |
| 142 | #define LBER_SB_OPT_SET_READAHEAD 9 |
| 143 | #define LBER_SB_OPT_DRAIN 10 |
| 144 | #define LBER_SB_OPT_NEEDS_READ 11 |
| 145 | #define LBER_SB_OPT_NEEDS_WRITE 12 |
| 146 | #define LBER_SB_OPT_GET_MAX_INCOMING 13 |
| 147 | #define LBER_SB_OPT_SET_MAX_INCOMING 14 |
| 148 | |
| 149 | /* Only meaningful ifdef LDAP_PF_LOCAL_SENDMSG */ |
| 150 | #define LBER_SB_OPT_UNGET_BUF 15 |
| 151 | |
| 152 | /* Largest option used by the library */ |
| 153 | #define LBER_SB_OPT_OPT_MAX 15 |
| 154 | |
| 155 | /* LBER IO operations stacking levels */ |
| 156 | #define LBER_SBIOD_LEVEL_PROVIDER 10 |
| 157 | #define LBER_SBIOD_LEVEL_TRANSPORT 20 |
| 158 | #define LBER_SBIOD_LEVEL_APPLICATION 30 |
| 159 | |
| 160 | /* get/set options for Sockbuf */ |
| 161 | #define LBER_OPT_SOCKBUF_DESC 0x1000 |
| 162 | #define LBER_OPT_SOCKBUF_OPTIONS 0x1001 |
| 163 | #define LBER_OPT_SOCKBUF_DEBUG 0x1002 |
| 164 | |
| 165 | /* on/off values */ |
| 166 | LBER_V( char ) ber_pvt_opt_on; |
| 167 | #define LBER_OPT_ON ((void *) &ber_pvt_opt_on) |
| 168 | #define LBER_OPT_OFF ((void *) 0) |
| 169 | |
| 170 | #define LBER_OPT_SUCCESS (0) |
| 171 | #define LBER_OPT_ERROR (-1) |
| 172 | |
| 173 | typedef struct berelement BerElement; |
| 174 | typedef struct sockbuf Sockbuf; |
| 175 | |
| 176 | typedef struct sockbuf_io Sockbuf_IO; |
| 177 | |
| 178 | /* Structure for LBER IO operation descriptor */ |
| 179 | typedef struct sockbuf_io_desc { |
| 180 | int sbiod_level; |
| 181 | Sockbuf *sbiod_sb; |
| 182 | Sockbuf_IO *sbiod_io; |
| 183 | void *sbiod_pvt; |
| 184 | struct sockbuf_io_desc *sbiod_next; |
| 185 | } Sockbuf_IO_Desc; |
| 186 | |
| 187 | /* Structure for LBER IO operation functions */ |
| 188 | struct sockbuf_io { |
| 189 | int (*sbi_setup)( Sockbuf_IO_Desc *sbiod, void *arg ); |
| 190 | int (*sbi_remove)( Sockbuf_IO_Desc *sbiod ); |
| 191 | int (*sbi_ctrl)( Sockbuf_IO_Desc *sbiod, int opt, void *arg); |
| 192 | |
| 193 | ber_slen_t (*sbi_read)( Sockbuf_IO_Desc *sbiod, void *buf, |
| 194 | ber_len_t len ); |
| 195 | ber_slen_t (*sbi_write)( Sockbuf_IO_Desc *sbiod, void *buf, |
| 196 | ber_len_t len ); |
| 197 | |
| 198 | int (*sbi_close)( Sockbuf_IO_Desc *sbiod ); |
| 199 | }; |
| 200 | |
| 201 | /* Helper macros for LBER IO functions */ |
| 202 | #define LBER_SBIOD_READ_NEXT( sbiod, buf, len ) \ |
| 203 | ( (sbiod)->sbiod_next->sbiod_io->sbi_read( (sbiod)->sbiod_next, \ |
| 204 | buf, len ) ) |
| 205 | #define LBER_SBIOD_WRITE_NEXT( sbiod, buf, len ) \ |
| 206 | ( (sbiod)->sbiod_next->sbiod_io->sbi_write( (sbiod)->sbiod_next, \ |
| 207 | buf, len ) ) |
| 208 | #define LBER_SBIOD_CTRL_NEXT( sbiod, opt, arg ) \ |
| 209 | ( (sbiod)->sbiod_next ? \ |
| 210 | ( (sbiod)->sbiod_next->sbiod_io->sbi_ctrl( \ |
| 211 | (sbiod)->sbiod_next, opt, arg ) ) : 0 ) |
| 212 | |
| 213 | /* structure for returning a sequence of octet strings + length */ |
| 214 | typedef struct berval { |
| 215 | ber_len_t bv_len; |
| 216 | char *bv_val; |
| 217 | } BerValue; |
| 218 | |
| 219 | typedef BerValue *BerVarray; /* To distinguish from a single bv */ |
| 220 | |
| 221 | /* this should be moved to lber-int.h */ |
| 222 | |
| 223 | /* |
| 224 | * in bprint.c: |
| 225 | */ |
| 226 | LBER_F( void ) |
| 227 | ber_error_print LDAP_P(( |
| 228 | LDAP_CONST char *data )); |
| 229 | |
| 230 | LBER_F( void ) |
| 231 | ber_bprint LDAP_P(( |
| 232 | LDAP_CONST char *data, ber_len_t len )); |
| 233 | |
| 234 | LBER_F( void ) |
| 235 | ber_dump LDAP_P(( |
| 236 | BerElement *ber, int inout )); |
| 237 | |
| 238 | /* |
| 239 | * in decode.c: |
| 240 | */ |
| 241 | typedef int (*BERDecodeCallback) LDAP_P(( |
| 242 | BerElement *ber, |
| 243 | void *data, |
| 244 | int mode )); |
| 245 | |
| 246 | LBER_F( ber_tag_t ) |
| 247 | ber_get_tag LDAP_P(( |
| 248 | BerElement *ber )); |
| 249 | |
| 250 | LBER_F( ber_tag_t ) |
| 251 | ber_skip_tag LDAP_P(( |
| 252 | BerElement *ber, |
| 253 | ber_len_t *len )); |
| 254 | |
| 255 | LBER_F( ber_tag_t ) |
| 256 | ber_peek_tag LDAP_P(( |
| 257 | BerElement *ber, |
| 258 | ber_len_t *len )); |
| 259 | |
| 260 | LBER_F( ber_tag_t ) |
| 261 | ber_skip_element LDAP_P(( |
| 262 | BerElement *ber, |
| 263 | struct berval *bv )); |
| 264 | |
| 265 | LBER_F( ber_tag_t ) |
| 266 | ber_peek_element LDAP_P(( |
| 267 | LDAP_CONST BerElement *ber, |
| 268 | struct berval *bv )); |
| 269 | |
| 270 | LBER_F( ber_tag_t ) |
| 271 | ber_get_int LDAP_P(( |
| 272 | BerElement *ber, |
| 273 | ber_int_t *num )); |
| 274 | |
| 275 | LBER_F( ber_tag_t ) |
| 276 | ber_get_enum LDAP_P(( |
| 277 | BerElement *ber, |
| 278 | ber_int_t *num )); |
| 279 | |
| 280 | LBER_F( ber_tag_t ) |
| 281 | ber_get_stringb LDAP_P(( |
| 282 | BerElement *ber, |
| 283 | char *buf, |
| 284 | ber_len_t *len )); |
| 285 | |
| 286 | #define LBER_BV_ALLOC 0x01 /* allocate/copy result, otherwise in-place */ |
| 287 | #define LBER_BV_NOTERM 0x02 /* omit NUL-terminator if parsing in-place */ |
| 288 | #define LBER_BV_STRING 0x04 /* fail if berval contains embedded \0 */ |
| 289 | /* LBER_BV_STRING currently accepts a terminating \0 in the berval, because |
| 290 | * Active Directory sends that in at least the diagonsticMessage field. |
| 291 | */ |
| 292 | |
| 293 | LBER_F( ber_tag_t ) |
| 294 | ber_get_stringbv LDAP_P(( |
| 295 | BerElement *ber, |
| 296 | struct berval *bv, |
| 297 | int options )); |
| 298 | |
| 299 | LBER_F( ber_tag_t ) |
| 300 | ber_get_stringa LDAP_P(( |
| 301 | BerElement *ber, |
| 302 | char **buf )); |
| 303 | |
| 304 | LBER_F( ber_tag_t ) |
| 305 | ber_get_stringal LDAP_P(( |
| 306 | BerElement *ber, |
| 307 | struct berval **bv )); |
| 308 | |
| 309 | LBER_F( ber_tag_t ) |
| 310 | ber_get_bitstringa LDAP_P(( |
| 311 | BerElement *ber, |
| 312 | char **buf, |
| 313 | ber_len_t *len )); |
| 314 | |
| 315 | LBER_F( ber_tag_t ) |
| 316 | ber_get_null LDAP_P(( |
| 317 | BerElement *ber )); |
| 318 | |
| 319 | LBER_F( ber_tag_t ) |
| 320 | ber_get_boolean LDAP_P(( |
| 321 | BerElement *ber, |
| 322 | ber_int_t *boolval )); |
| 323 | |
| 324 | LBER_F( ber_tag_t ) |
| 325 | ber_first_element LDAP_P(( |
| 326 | BerElement *ber, |
| 327 | ber_len_t *len, |
| 328 | char **last )); |
| 329 | |
| 330 | LBER_F( ber_tag_t ) |
| 331 | ber_next_element LDAP_P(( |
| 332 | BerElement *ber, |
| 333 | ber_len_t *len, |
| 334 | LDAP_CONST char *last )); |
| 335 | |
| 336 | LBER_F( ber_tag_t ) |
| 337 | ber_scanf LDAP_P(( |
| 338 | BerElement *ber, |
| 339 | LDAP_CONST char *fmt, |
| 340 | ... )); |
| 341 | |
| 342 | LBER_F( int ) |
| 343 | ber_decode_oid LDAP_P(( |
| 344 | struct berval *in, |
| 345 | struct berval *out )); |
| 346 | |
| 347 | /* |
| 348 | * in encode.c |
| 349 | */ |
| 350 | LBER_F( int ) |
| 351 | ber_encode_oid LDAP_P(( |
| 352 | struct berval *in, |
| 353 | struct berval *out )); |
| 354 | |
| 355 | typedef int (*BEREncodeCallback) LDAP_P(( |
| 356 | BerElement *ber, |
| 357 | void *data )); |
| 358 | |
| 359 | LBER_F( int ) |
| 360 | ber_put_enum LDAP_P(( |
| 361 | BerElement *ber, |
| 362 | ber_int_t num, |
| 363 | ber_tag_t tag )); |
| 364 | |
| 365 | LBER_F( int ) |
| 366 | ber_put_int LDAP_P(( |
| 367 | BerElement *ber, |
| 368 | ber_int_t num, |
| 369 | ber_tag_t tag )); |
| 370 | |
| 371 | LBER_F( int ) |
| 372 | ber_put_ostring LDAP_P(( |
| 373 | BerElement *ber, |
| 374 | LDAP_CONST char *str, |
| 375 | ber_len_t len, |
| 376 | ber_tag_t tag )); |
| 377 | |
| 378 | LBER_F( int ) |
| 379 | ber_put_berval LDAP_P(( |
| 380 | BerElement *ber, |
| 381 | struct berval *bv, |
| 382 | ber_tag_t tag )); |
| 383 | |
| 384 | LBER_F( int ) |
| 385 | ber_put_string LDAP_P(( |
| 386 | BerElement *ber, |
| 387 | LDAP_CONST char *str, |
| 388 | ber_tag_t tag )); |
| 389 | |
| 390 | LBER_F( int ) |
| 391 | ber_put_bitstring LDAP_P(( |
| 392 | BerElement *ber, |
| 393 | LDAP_CONST char *str, |
| 394 | ber_len_t bitlen, |
| 395 | ber_tag_t tag )); |
| 396 | |
| 397 | LBER_F( int ) |
| 398 | ber_put_null LDAP_P(( |
| 399 | BerElement *ber, |
| 400 | ber_tag_t tag )); |
| 401 | |
| 402 | LBER_F( int ) |
| 403 | ber_put_boolean LDAP_P(( |
| 404 | BerElement *ber, |
| 405 | ber_int_t boolval, |
| 406 | ber_tag_t tag )); |
| 407 | |
| 408 | LBER_F( int ) |
| 409 | ber_start_seq LDAP_P(( |
| 410 | BerElement *ber, |
| 411 | ber_tag_t tag )); |
| 412 | |
| 413 | LBER_F( int ) |
| 414 | ber_start_set LDAP_P(( |
| 415 | BerElement *ber, |
| 416 | ber_tag_t tag )); |
| 417 | |
| 418 | LBER_F( int ) |
| 419 | ber_put_seq LDAP_P(( |
| 420 | BerElement *ber )); |
| 421 | |
| 422 | LBER_F( int ) |
| 423 | ber_put_set LDAP_P(( |
| 424 | BerElement *ber )); |
| 425 | |
| 426 | LBER_F( int ) |
| 427 | ber_printf LDAP_P(( |
| 428 | BerElement *ber, |
| 429 | LDAP_CONST char *fmt, |
| 430 | ... )); |
| 431 | |
| 432 | |
| 433 | /* |
| 434 | * in io.c: |
| 435 | */ |
| 436 | |
| 437 | LBER_F( ber_slen_t ) |
| 438 | ber_skip_data LDAP_P(( |
| 439 | BerElement *ber, |
| 440 | ber_len_t len )); |
| 441 | |
| 442 | LBER_F( ber_slen_t ) |
| 443 | ber_read LDAP_P(( |
| 444 | BerElement *ber, |
| 445 | char *buf, |
| 446 | ber_len_t len )); |
| 447 | |
| 448 | LBER_F( ber_slen_t ) |
| 449 | ber_write LDAP_P(( |
| 450 | BerElement *ber, |
| 451 | LDAP_CONST char *buf, |
| 452 | ber_len_t len, |
| 453 | int zero )); /* nonzero is unsupported from OpenLDAP 2.4.18 */ |
| 454 | |
| 455 | LBER_F( void ) |
| 456 | ber_free LDAP_P(( |
| 457 | BerElement *ber, |
| 458 | int freebuf )); |
| 459 | |
| 460 | LBER_F( void ) |
| 461 | ber_free_buf LDAP_P(( BerElement *ber )); |
| 462 | |
| 463 | LBER_F( int ) |
| 464 | ber_flush2 LDAP_P(( |
| 465 | Sockbuf *sb, |
| 466 | BerElement *ber, |
| 467 | int freeit )); |
| 468 | #define LBER_FLUSH_FREE_NEVER (0x0) /* traditional behavior */ |
| 469 | #define LBER_FLUSH_FREE_ON_SUCCESS (0x1) /* traditional behavior */ |
| 470 | #define LBER_FLUSH_FREE_ON_ERROR (0x2) |
| 471 | #define LBER_FLUSH_FREE_ALWAYS (LBER_FLUSH_FREE_ON_SUCCESS|LBER_FLUSH_FREE_ON_ERROR) |
| 472 | |
| 473 | LBER_F( int ) |
| 474 | ber_flush LDAP_P(( |
| 475 | Sockbuf *sb, |
| 476 | BerElement *ber, |
| 477 | int freeit )); /* DEPRECATED */ |
| 478 | |
| 479 | LBER_F( BerElement * ) |
| 480 | ber_alloc LDAP_P(( void )); /* DEPRECATED */ |
| 481 | |
| 482 | LBER_F( BerElement * ) |
| 483 | der_alloc LDAP_P(( void )); /* DEPRECATED */ |
| 484 | |
| 485 | LBER_F( BerElement * ) |
| 486 | ber_alloc_t LDAP_P(( |
| 487 | int beroptions )); |
| 488 | |
| 489 | LBER_F( BerElement * ) |
| 490 | ber_dup LDAP_P(( |
| 491 | BerElement *ber )); |
| 492 | |
| 493 | LBER_F( ber_tag_t ) |
| 494 | ber_get_next LDAP_P(( |
| 495 | Sockbuf *sb, |
| 496 | ber_len_t *len, |
| 497 | BerElement *ber )); |
| 498 | |
| 499 | LBER_F( void ) |
| 500 | ber_init2 LDAP_P(( |
| 501 | BerElement *ber, |
| 502 | struct berval *bv, |
| 503 | int options )); |
| 504 | |
| 505 | LBER_F( void ) |
| 506 | ber_init_w_nullc LDAP_P(( /* DEPRECATED */ |
| 507 | BerElement *ber, |
| 508 | int options )); |
| 509 | |
| 510 | LBER_F( void ) |
| 511 | ber_reset LDAP_P(( |
| 512 | BerElement *ber, |
| 513 | int was_writing )); |
| 514 | |
| 515 | LBER_F( BerElement * ) |
| 516 | ber_init LDAP_P(( |
| 517 | struct berval *bv )); |
| 518 | |
| 519 | LBER_F( int ) |
| 520 | ber_flatten LDAP_P(( |
| 521 | BerElement *ber, |
| 522 | struct berval **bvPtr )); |
| 523 | |
| 524 | LBER_F( int ) |
| 525 | ber_flatten2 LDAP_P(( |
| 526 | BerElement *ber, |
| 527 | struct berval *bv, |
| 528 | int alloc )); |
| 529 | |
| 530 | LBER_F( int ) |
| 531 | ber_remaining LDAP_P(( |
| 532 | BerElement *ber )); |
| 533 | |
| 534 | /* |
| 535 | * LBER ber accessor functions |
| 536 | */ |
| 537 | |
| 538 | LBER_F( int ) |
| 539 | ber_get_option LDAP_P(( |
| 540 | void *item, |
| 541 | int option, |
| 542 | void *outvalue)); |
| 543 | |
| 544 | LBER_F( int ) |
| 545 | ber_set_option LDAP_P(( |
| 546 | void *item, |
| 547 | int option, |
| 548 | LDAP_CONST void *invalue)); |
| 549 | |
| 550 | /* |
| 551 | * LBER sockbuf.c |
| 552 | */ |
| 553 | |
| 554 | LBER_F( Sockbuf * ) |
| 555 | ber_sockbuf_alloc LDAP_P(( |
| 556 | void )); |
| 557 | |
| 558 | LBER_F( void ) |
| 559 | ber_sockbuf_free LDAP_P(( |
| 560 | Sockbuf *sb )); |
| 561 | |
| 562 | LBER_F( int ) |
| 563 | ber_sockbuf_add_io LDAP_P(( |
| 564 | Sockbuf *sb, |
| 565 | Sockbuf_IO *sbio, |
| 566 | int layer, |
| 567 | void *arg )); |
| 568 | |
| 569 | LBER_F( int ) |
| 570 | ber_sockbuf_remove_io LDAP_P(( |
| 571 | Sockbuf *sb, |
| 572 | Sockbuf_IO *sbio, |
| 573 | int layer )); |
| 574 | |
| 575 | LBER_F( int ) |
| 576 | ber_sockbuf_ctrl LDAP_P(( |
| 577 | Sockbuf *sb, |
| 578 | int opt, |
| 579 | void *arg )); |
| 580 | |
| 581 | LBER_V( Sockbuf_IO ) ber_sockbuf_io_tcp; |
| 582 | LBER_V( Sockbuf_IO ) ber_sockbuf_io_readahead; |
| 583 | LBER_V( Sockbuf_IO ) ber_sockbuf_io_fd; |
| 584 | LBER_V( Sockbuf_IO ) ber_sockbuf_io_debug; |
| 585 | LBER_V( Sockbuf_IO ) ber_sockbuf_io_udp; |
| 586 | |
| 587 | /* |
| 588 | * LBER memory.c |
| 589 | */ |
| 590 | LBER_F( void * ) |
| 591 | ber_memalloc LDAP_P(( |
| 592 | ber_len_t s )); |
| 593 | |
| 594 | LBER_F( void * ) |
| 595 | ber_memrealloc LDAP_P(( |
| 596 | void* p, |
| 597 | ber_len_t s )); |
| 598 | |
| 599 | LBER_F( void * ) |
| 600 | ber_memcalloc LDAP_P(( |
| 601 | ber_len_t n, |
| 602 | ber_len_t s )); |
| 603 | |
| 604 | LBER_F( void ) |
| 605 | ber_memfree LDAP_P(( |
| 606 | void* p )); |
| 607 | |
| 608 | LBER_F( void ) |
| 609 | ber_memvfree LDAP_P(( |
| 610 | void** vector )); |
| 611 | |
| 612 | LBER_F( void ) |
| 613 | ber_bvfree LDAP_P(( |
| 614 | struct berval *bv )); |
| 615 | |
| 616 | LBER_F( void ) |
| 617 | ber_bvecfree LDAP_P(( |
| 618 | struct berval **bv )); |
| 619 | |
| 620 | LBER_F( int ) |
| 621 | ber_bvecadd LDAP_P(( |
| 622 | struct berval ***bvec, |
| 623 | struct berval *bv )); |
| 624 | |
| 625 | LBER_F( struct berval * ) |
| 626 | ber_dupbv LDAP_P(( |
| 627 | struct berval *dst, struct berval *src )); |
| 628 | |
| 629 | LBER_F( struct berval * ) |
| 630 | ber_bvdup LDAP_P(( |
| 631 | struct berval *src )); |
| 632 | |
| 633 | LBER_F( struct berval * ) |
| 634 | ber_mem2bv LDAP_P(( |
| 635 | LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv)); |
| 636 | |
| 637 | LBER_F( struct berval * ) |
| 638 | ber_str2bv LDAP_P(( |
| 639 | LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv)); |
| 640 | |
| 641 | #define ber_bvstr(a) ((ber_str2bv)((a), 0, 0, NULL)) |
| 642 | #define ber_bvstrdup(a) ((ber_str2bv)((a), 0, 1, NULL)) |
| 643 | |
| 644 | LBER_F( char * ) |
| 645 | ber_strdup LDAP_P(( |
| 646 | LDAP_CONST char * )); |
| 647 | |
| 648 | LBER_F( ber_len_t ) |
| 649 | ber_strnlen LDAP_P(( |
| 650 | LDAP_CONST char *s, ber_len_t len )); |
| 651 | |
| 652 | LBER_F( char * ) |
| 653 | ber_strndup LDAP_P(( |
| 654 | LDAP_CONST char *s, ber_len_t l )); |
| 655 | |
| 656 | LBER_F( struct berval * ) |
| 657 | ber_bvreplace LDAP_P(( |
| 658 | struct berval *dst, LDAP_CONST struct berval *src )); |
| 659 | |
| 660 | LBER_F( void ) |
| 661 | ber_bvarray_free LDAP_P(( BerVarray p )); |
| 662 | |
| 663 | LBER_F( int ) |
| 664 | ber_bvarray_add LDAP_P(( BerVarray *p, BerValue *bv )); |
| 665 | |
| 666 | #define ber_bvcmp(v1,v2) \ |
| 667 | ((v1)->bv_len < (v2)->bv_len \ |
| 668 | ? -1 : ((v1)->bv_len > (v2)->bv_len \ |
| 669 | ? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) )) |
| 670 | |
| 671 | /* |
| 672 | * error.c |
| 673 | */ |
| 674 | LBER_F( int * ) ber_errno_addr LDAP_P((void)); |
| 675 | #define ber_errno (*(ber_errno_addr)()) |
| 676 | |
| 677 | #define LBER_ERROR_NONE 0 |
| 678 | #define LBER_ERROR_PARAM 0x1 |
| 679 | #define LBER_ERROR_MEMORY 0x2 |
| 680 | |
| 681 | LDAP_END_DECL |
| 682 | |
| 683 | #endif /* _LBER_H */ |
| 684 | |