1LBER_TYPES(3)              Library Functions Manual              LBER_TYPES(3)
2
3
4

NAME

6       ber_int_t, ber_uint_t, ber_len_t, ber_slen_t, ber_tag_t, struct berval,
7       BerValue, BerVarray, BerElement, ber_bvfree, ber_bvecfree, ber_bvecadd,
8       ber_bvarray_free,  ber_bvarray_add,  ber_bvdup,  ber_dupbv,  ber_bvstr,
9       ber_bvstrdup, ber_str2bv, ber_alloc_t, ber_init, ber_init2, ber_free  -
10       OpenLDAP LBER types and allocation functions
11

LIBRARY

13       OpenLDAP LBER (liblber, -llber)
14

SYNOPSIS

16       #include <lber.h>
17
18       typedef impl_tag_t ber_tag_t;
19       typedef impl_int_t ber_int_t;
20       typedef impl_uint_t ber_uint_t;
21       typedef impl_len_t ber_len_t;
22       typedef impl_slen_t ber_slen_t;
23
24       typedef struct berval {
25           ber_len_t bv_len;
26           char *bv_val;
27       } BerValue, *BerVarray;
28
29       typedef struct berelement BerElement;
30
31       void ber_bvfree(struct berval *bv);
32
33       void ber_bvecfree(struct berval **bvec);
34
35       void ber_bvecadd(struct berval ***bvec, struct berval *bv);
36
37       void ber_bvarray_free(struct berval *bvarray);
38
39       void ber_bvarray_add(BerVarray *bvarray, BerValue *bv);
40
41       struct berval *ber_bvdup(const struct berval *bv);
42
43       struct berval *ber_dupbv(const struct berval *dst, struct berval *src);
44
45       struct berval *ber_bvstr(const char *str);
46
47       struct berval *ber_bvstrdup(const char *str);
48
49       struct  berval  *ber_str2bv(const  char  *str,  ber_len_t len, int dup,
50       struct berval *bv);
51
52       BerElement *ber_alloc_t(int options);
53
54       BerElement *ber_init(struct berval *bv);
55
56       void ber_init2(BerElement *ber, struct berval *bv, int options);
57
58       void ber_free(BerElement *ber, int freebuf);
59

DESCRIPTION

61       The following are the basic types and structures defined for  use  with
62       the Lightweight BER library.
63
64       ber_int_t  is  a  signed  integer  of at least 32 bits.  It is commonly
65       equivalent to int.  ber_uint_t is the unsigned variant of ber_int_t.
66
67       ber_len_t is an unsigned integer of at least 32 bits used to  represent
68       a  length.   It  is commonly equivalent to a size_t.  ber_slen_t is the
69       signed variant to ber_len_t.
70
71       ber_tag_t is an unsigned integer of at least 32 bits used to  represent
72       a BER tag.  It is commonly equivalent to a unsigned long.
73
74       The  actual  definitions of the integral impl_TYPE_t types are platform
75       specific.
76
77       BerValue, commonly used as struct berval, is used to hold an  arbitrary
78       sequence  of  octets.   bv_val  points to bv_len octets.  bv_val is not
79       necessarily terminated by a NULL (zero) octet.   ber_bvfree()  frees  a
80       BerValue, pointed to by bv, returned from this API.  If bv is NULL, the
81       routine does nothing.
82
83       ber_bvecfree() frees an array of BerValues (and the array), pointed  to
84       by  bvec,  returned  from  this API.  If bvec is NULL, the routine does
85       nothing.  ber_bvecadd() appends the  bv  pointer  to  the  bvec  array.
86       Space  for  the  array is allocated as needed.  The end of the array is
87       marked by a NULL pointer.
88
89       ber_bvarray_free() frees an array of BerValues (and the array), pointed
90       to by bvarray, returned from this API.  If bvarray is NULL, the routine
91       does nothing.  ber_bvarray_add() appends the contents of  the  BerValue
92       pointed  to  by  bv to the bvarray array.  Space for the new element is
93       allocated as needed.  The end of the array is marked by a BerValue with
94       a NULL bv_val field.
95
96       ber_bvdup()  returns  a  copy  of a BerValue.  The routine returns NULL
97       upon error (e.g. out of memory).  The caller should use ber_bvfree() to
98       deallocate  the resulting BerValue.  ber_dupbv() copies a BerValue from
99       src to dst.  If dst is NULL a new BerValue will be  allocated  to  hold
100       the  copy.  The routine returns NULL upon error, otherwise it returns a
101       pointer to the copy.  If dst is NULL the caller should use ber_bvfree()
102       to deallocate the resulting BerValue, otherwise ber_memfree() should be
103       used to deallocate  the  dst->bv_val.   (The  ber_bvdup()  function  is
104       internally implemented as ber_dupbv(NULL, bv).  ber_bvdup() is provided
105       only for compatibility with  an  expired  draft  of  the  LDAP  C  API;
106       ber_dupbv() is the preferred interface.)
107
108       ber_bvstr() returns a BerValue containing the string pointed to by str.
109       ber_bvstrdup() returns a BerValue  containing  a  copy  of  the  string
110       pointed  to  by  str.   ber_str2bv()  returns a BerValue containing the
111       string pointed to by str, whose length may be optionally  specified  in
112       len.   If dup is non-zero, the BerValue will contain a copy of str.  If
113       len is zero, the  number  of  bytes  to  copy  will  be  determined  by
114       strlen(3),  otherwise len bytes will be copied.  If bv is non-NULL, the
115       result will be stored in the given BerValue, otherwise a  new  BerValue
116       will  be  allocated  to  store  the result.  NOTE: Both ber_bvstr() and
117       ber_bvstrdup() are implemented as macros  using  ber_str2bv()  in  this
118       version of the library.
119
120       BerElement  is  an  opaque structure used to maintain state information
121       used in encoding and decoding.  ber_alloc_t()  is  used  to  create  an
122       empty  BerElement  structure.  If  LBER_USE_DER  is  specified  for the
123       options parameter then data lengths for data written to the  BerElement
124       will  be  encoded  in  the minimal number of octets required, otherwise
125       they will always be written as four byte values.  ber_init() creates  a
126       BerElement structure that is initialized with a copy of the data in its
127       bv parameter.  ber_init2() initializes an existing BerElement ber using
128       the  data  in  the  bv  parameter. The data is referenced directly, not
129       copied. The  options  parameter  is  the  same  as  for  ber_alloc_t().
130       ber_free()  frees  a BerElement pointed to by ber.  If ber is NULL, the
131       routine does nothing.  If freebuf is zero, the internal buffer  is  not
132       freed.
133

SEE ALSO

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

ACKNOWLEDGEMENTS

138       OpenLDAP  Software  is developed and maintained by The OpenLDAP Project
139       <http://www.openldap.org/>.  OpenLDAP Software is derived from the Uni‐
140       versity of Michigan LDAP 3.3 Release.
141
142
143
144OpenLDAP 2.4.50                   2020/04/28                     LBER_TYPES(3)
Impressum