NAME |LIBRARY |SYNOPSIS |DESCRIPTION |SEE ALSO |ACKNOWLEDGEMENTS |COLOPHON | |
LBER_TYPES(3) Library Functions ManualLBER_TYPES(3)ber_int_t, ber_uint_t, ber_len_t, ber_slen_t, ber_tag_t, struct berval, BerValue, BerVarray, BerElement, ber_bvfree, ber_bvecfree, ber_bvecadd, ber_bvarray_free, ber_bvarray_add, ber_bvdup, ber_dupbv, ber_bvstr, ber_bvstrdup, ber_str2bv, ber_alloc_t, ber_init, ber_init2, ber_free - OpenLDAP LBER types and allocation functions
OpenLDAP LBER (liblber, -llber)
#include <lber.h>typedef impl_tag_t ber_tag_t;typedef impl_int_t ber_int_t;typedef impl_uint_t ber_uint_t;typedef impl_len_t ber_len_t;typedef impl_slen_t ber_slen_t;typedef struct berval {ber_len_t bv_len;char *bv_val;} BerValue, *BerVarray;typedef struct berelement BerElement;void ber_bvfree(struct berval *bv);void ber_bvecfree(struct berval **bvec);void ber_bvecadd(struct berval ***bvec, struct berval *bv);void ber_bvarray_free(struct berval *bvarray);void ber_bvarray_add(BerVarray *bvarray, BerValue *bv);struct berval *ber_bvdup(const struct berval *bv);struct berval *ber_dupbv(const struct berval *dst, struct berval*src);struct berval *ber_bvstr(const char *str);struct berval *ber_bvstrdup(const char *str);struct berval *ber_str2bv(const char *str, ber_len_tlen, intdup,struct berval *bv);BerElement *ber_alloc_t(intoptions);BerElement *ber_init(struct berval *bv);void ber_init2(BerElement *ber, struct berval *bv, intoptions);void ber_free(BerElement *ber, intfreebuf);The following are the basic types and structures defined for use with the Lightweight BER library.ber_int_tis a signed integer of at least 32 bits. It is commonly equivalent toint.ber_uint_tis the unsigned variant ofber_int_t.ber_len_tis an unsigned integer of at least 32 bits used to represent a length. It is commonly equivalent to asize_t.ber_slen_tis the signed variant tober_len_t.ber_tag_tis an unsigned integer of at least 32 bits used to represent a BER tag. It is commonly equivalent to aunsigned long. The actual definitions of the integral impl_TYPE_t types are platform specific.BerValue, commonly used asstruct berval, is used to hold an arbitrary sequence of octets.bv_valpoints tobv_lenoctets.bv_valis not necessarily terminated by a NULL (zero) octet.ber_bvfree() frees a BerValue, pointed to bybv, returned from this API. Ifbv is NULL, the routine does nothing.ber_bvecfree() frees an array of BerValues (and the array), pointed to bybvec, returned from this API. Ifbvec is NULL, the routine does nothing.ber_bvecadd() appends thebv pointer to thebvec array. Space for the array is allocated as needed. The end of the array is marked by a NULL pointer.ber_bvarray_free() frees an array of BerValues (and the array), pointed to bybvarray, returned from this API. Ifbvarray is NULL, the routine does nothing.ber_bvarray_add() appends the contents of the BerValue pointed to bybv to thebvarray array. Space for the new element is allocated as needed. The end of the array is marked by a BerValue with a NULL bv_val field.ber_bvdup() returns a copy of a BerValue. The routine returns NULL upon error (e.g. out of memory). The caller should useber_bvfree() to deallocate the resulting BerValue.ber_dupbv() copies a BerValue fromsrc todst. Ifdst is NULL a new BerValue will be allocated to hold the copy. The routine returns NULL upon error, otherwise it returns a pointer to the copy. Ifdst is NULL the caller should useber_bvfree() to deallocate the resulting BerValue, otherwiseber_memfree() should be used to deallocate thedst->bv_val. (Theber_bvdup() function is internally implemented as ber_dupbv(NULL, bv).ber_bvdup() is provided only for compatibility with an expired draft of the LDAP C API;ber_dupbv() is the preferred interface.)ber_bvstr() returns a BerValue containing the string pointed to bystr.ber_bvstrdup() returns a BerValue containing a copy of the string pointed to bystr.ber_str2bv() returns a BerValue containing the string pointed to bystr, whose length may be optionally specified inlen. Ifdup is non-zero, the BerValue will contain a copy ofstr. Iflen is zero, the number of bytes to copy will be determined bystrlen(3), otherwiselen bytes will be copied. Ifbv is non-NULL, the result will be stored in the given BerValue, otherwise a new BerValue will be allocated to store the result. NOTE: Bothber_bvstr() andber_bvstrdup() are implemented as macros usingber_str2bv() in this version of the library.BerElementis an opaque structure used to maintain state information used in encoding and decoding.ber_alloc_t() is used to create an empty BerElement structure. IfLBER_USE_DERis specified for theoptions parameter then data lengths for data written to the BerElement will be encoded in the minimal number of octets required, otherwise they will always be written as four byte values.ber_init() creates a BerElement structure that is initialized with a copy of the data in itsbv parameter.ber_init2() initializes an existing BerElementber using the data in thebv parameter. The data is referenced directly, not copied. Theoptions parameter is the same as forber_alloc_t().ber_free() frees a BerElement pointed to byber. Ifber is NULL, the routine does nothing. Iffreebuf is zero, the internal buffer is not freed.
lber-encode(3),lber-decode(3),lber-memory(3)
OpenLDAP Softwareis developed and maintained by The OpenLDAP Project <http://www.openldap.org/>.OpenLDAP Softwareis derived from the University of Michigan LDAP 3.3 Release.
This page is part of theOpenLDAP (an open source implementation of the Lightweight Directory Access Protocol) project. Information about the project can be found at ⟨http://www.openldap.org/⟩. If you have a bug report for this manual page, see ⟨http://www.openldap.org/its/⟩. This page was obtained from the project's upstream Git repository ⟨https://git.openldap.org/openldap/openldap.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-05.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgOpenLDAP LDVERSION RELEASEDATELBER_TYPES(3)Pages that refer to this page:lber-decode(3), lber-encode(3), lber-memory(3), lber-sockbuf(3), ldap(3), ldap_extended_operation(3), ldap_first_attribute(3), ldap_parse_result(3), ldap_search(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |