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_free - LBER types  and  allocation  func‐
10       tions
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       void ber_free(BerElement *ber, int freebuf);
53

DESCRIPTION

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

SEE ALSO

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

ACKNOWLEDGEMENTS

124       OpenLDAP   is   developed   and  maintained  by  The  OpenLDAP  Project
125       (http://www.openldap.org/).  OpenLDAP is  derived  from  University  of
126       Michigan LDAP 3.3 Release.
127
128
129
130OpenLDAP 2.3.34                    2007/2/16                     LBER_TYPES(3)
Impressum