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_t len, int dup, struct berval *bv);

BerElement *ber_alloc_t(int options);

BerElement *ber_init(struct berval *bv);

void ber_init2(BerElement *ber, struct berval *bv, int options);

void ber_free(BerElement *ber, int freebuf);


The following are the basic types and structures defined for use with the Lightweight BER library.

ber_int_t is a signed integer of at least 32 bits. It is commonly equivalent to int. ber_uint_t is the unsigned variant of ber_int_t.

ber_len_t is an unsigned integer of at least 32 bits used to represent a length. It is commonly equivalent to a size_t. ber_slen_t is the signed variant to ber_len_t.

ber_tag_t is an unsigned integer of at least 32 bits used to represent a BER tag. It is commonly equivalent to a unsigned long.

The actual definitions of the integral impl_TYPE_t types are platform specific.

BerValue, commonly used as struct berval, is used to hold an arbitrary sequence of octets. bv_val points to bv_len octets. bv_val is not necessarily terminated by a NULL (zero) octet. ber_bvfree() frees a BerValue, pointed to by bv, returned from this API. If bv is NULL, the routine does nothing.

ber_bvecfree() frees an array of BerValues (and the array), pointed to by bvec, returned from this API. If bvec is NULL, the routine does nothing. ber_bvecadd() appends the bv pointer to the bvec 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 by bvarray, returned from this API. If bvarray is NULL, the routine does nothing. ber_bvarray_add() appends the contents of the BerValue pointed to by bv to the bvarray 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 use ber_bvfree() to deallocate the resulting BerValue. ber_dupbv() copies a BerValue from src to dst. If dst 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. If dst is NULL the caller should use ber_bvfree() to deallocate the resulting BerValue, otherwise ber_memfree() should be used to deallocate the dst->bv_val. (The ber_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 by str. ber_bvstrdup() returns a BerValue containing a copy of the string pointed to by str. ber_str2bv() returns a BerValue containing the string pointed to by str, whose length may be optionally specified in len. If dup is non-zero, the BerValue will contain a copy of str. If len is zero, the number of bytes to copy will be determined by strlen(3), otherwise len bytes will be copied. If bv is non-NULL, the result will be stored in the given BerValue, otherwise a new BerValue will be allocated to store the result. NOTE: Both ber_bvstr() and ber_bvstrdup() are implemented as macros using ber_str2bv() in this version of the library.

BerElement is an opaque structure used to maintain state information used in encoding and decoding. ber_alloc_t() is used to create an empty BerElement structure. If LBER_USE_DER is specified for the options 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 its bv parameter. ber_init2() initializes an existing BerElement ber using the data in the bv parameter. The data is referenced directly, not copied. The options parameter is the same as for ber_alloc_t(). ber_free() frees a BerElement pointed to by ber. If ber is NULL, the routine does nothing. If freebuf is zero, the internal buffer is not freed.


lber-encode(3), lber-decode(3), lber-memory(3)


OpenLDAP Software is developed and maintained by The OpenLDAP Project <>. OpenLDAP Software is derived from University of Michigan LDAP 3.3 Release.

More Linux Commands

initrd(4) - boot loader initialized RAM disk (Man Page).....
The special file /dev/initrd is a read-only block device. This device is a RAM disk that is initialized (e.g., loaded) by the boot loader before the kernel is s

slk_touch_sp(3ncurses) - curses screen-pointer extension....
This implementation can be configured to provide a set of functions which improve the ability to manage multiple screens. This feature can be added to any of th

stdarg(3) - variable argument lists - Linux manual page.....
A function may be called with a varying number of arguments of varying types. The include file &lt;stdarg.h&gt; declares a type va_list and defines three macros for s

gnutls_dh_params_export_raw(3) - API function (Man Page)....
This function will export the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters will be allocated using gnutls_malloc()

XtCreateWindow(3) - window creation convenience function....
The XtCreateWindow function calls the Xlib XCreateWindow function with values from the widget structure and the passed parameters. Then, it assigns the created

Tcl_DStringInit(3) - manipulate dynamic strings (Man Page)
Dynamic strings provide a mechanism for building up arbitrarily long strings by gradually appending information. If the dynamic string is short then there will

glColor4f(3gl) - set the current color - Linux manual page
The GL stores both a current single-valued color index and a current four-valued RGBA color. glColor sets a new four-valued RGBA color. glColor has two major va

resolv.conf(5) - resolver configuration file (Man Page).....
The resolver is a set of routines in the C library that provide access to the Internet Domain Name System (DNS). The resolver configuration file contains inform

unzip(1) - list, test and extract compressed files in a ZIP
unzip will list, test, or extract files from a ZIP archive, commonly found on MS-DOS systems. The default behavior (with no options) is to extract into the curr

install(1) - copy files and set attributes - Linux man page
This install program copies files (often just compiled) into destination locations you choose. If you want to download and install a ready-to-use package on a G

glGetTexGeniv(3gl) - return texture coordinate generation pa
glGetTexGen returns in params selected parameters of a texture coordinate generation function that was specified using glTexGen. coord names one of the (s, t, r

vgcreate(8) - create a volume group - Linux manual page.....
vgcreate creates a new volume group called VolumeGroupName using the block special device PhysicalDevicePath. If PhysicalDevicePath was not previously configure

We can't live, work or learn in freedom unless the software we use is free.