lber.h 15 KB

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