]> git.sur5r.net Git - openldap/blob - doc/man/man3/lber-types.3
Happy New Year
[openldap] / doc / man / man3 / lber-types.3
1 .TH LBER_TYPES 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2018 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 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
7 .SH LIBRARY
8 OpenLDAP LBER (liblber, \-llber)
9 .SH SYNOPSIS
10 .B #include <lber.h>
11 .LP
12 .nf
13 .ft B
14 typedef impl_tag_t ber_tag_t;
15 typedef impl_int_t ber_int_t;
16 typedef impl_uint_t ber_uint_t;
17 typedef impl_len_t ber_len_t;
18 typedef impl_slen_t ber_slen_t;
19
20 typedef struct berval {
21     ber_len_t bv_len;
22     char *bv_val;
23 } BerValue, *BerVarray;
24
25 typedef struct berelement BerElement;
26 .ft
27 .fi
28 .LP
29 .BI "void ber_bvfree(struct berval *" bv ");"
30 .LP
31 .BI "void ber_bvecfree(struct berval **" bvec ");"
32 .LP
33 .BI "void ber_bvecadd(struct berval ***" bvec ", struct berval *" bv ");"
34 .LP
35 .BI "void ber_bvarray_free(struct berval *" bvarray ");"
36 .LP
37 .BI "void ber_bvarray_add(BerVarray *" bvarray ", BerValue *" bv ");"
38 .LP
39 .BI "struct berval *ber_bvdup(const struct berval *" bv ");"
40 .LP
41 .BI "struct berval *ber_dupbv(const struct berval *" dst ", struct berval *" src ");"
42 .LP
43 .BI "struct berval *ber_bvstr(const char *" str ");"
44 .LP
45 .BI "struct berval *ber_bvstrdup(const char *" str ");"
46 .LP
47 .BI "struct berval *ber_str2bv(const char *" str ", ber_len_t " len ", int " dup ", struct berval *" bv ");"
48 .LP
49 .BI "BerElement *ber_alloc_t(int " options ");"
50 .LP
51 .BI "BerElement *ber_init(struct berval *" bv ");"
52 .LP
53 .BI "void ber_init2(BerElement *" ber ", struct berval *" bv ", int " options ");"
54 .LP
55 .BI "void ber_free(BerElement *" ber ", int " freebuf ");"
56 .SH DESCRIPTION
57 .LP
58 The following are the basic types and structures defined for use
59 with the Lightweight BER library.  
60 .LP
61 .B ber_int_t
62 is a signed integer of at least 32 bits.  It is commonly equivalent to
63 .BR int .
64 .B ber_uint_t
65 is the unsigned variant of
66 .BR ber_int_t .
67 .LP
68 .B ber_len_t
69 is an unsigned integer of at least 32 bits used to represent a length.  
70 It is commonly equivalent to a
71 .BR size_t .
72 .B ber_slen_t
73 is the signed variant to
74 .BR ber_len_t .
75 .LP
76 .B ber_tag_t
77 is an unsigned integer of at least 32 bits used to represent a
78 BER tag.  It is commonly equivalent to a
79 .BR unsigned\ long .
80 .LP
81 The actual definitions of the integral impl_TYPE_t types are platform
82 specific.
83 .LP
84 .BR BerValue ,
85 commonly used as
86 .BR struct\ berval ,
87 is used to hold an arbitrary sequence of octets.
88 .B bv_val
89 points to
90 .B bv_len
91 octets.
92 .B bv_val
93 is not necessarily terminated by a NULL (zero) octet.
94 .BR ber_bvfree ()
95 frees a BerValue, pointed to by \fIbv\fP, returned from this API.  If \fIbv\fP
96 is NULL, the routine does nothing.
97 .LP
98 .BR ber_bvecfree ()
99 frees an array of BerValues (and the array), pointed to by \fIbvec\fP,
100 returned from this API.  If \fIbvec\fP is NULL, the routine does nothing.
101 .BR ber_bvecadd ()
102 appends the \fIbv\fP pointer to the \fIbvec\fP array.  Space for the array
103 is allocated as needed.  The end of the array is marked by a NULL pointer.
104 .LP
105 .BR ber_bvarray_free ()
106 frees an array of BerValues (and the array), pointed to by \fIbvarray\fP,
107 returned from this API.  If \fIbvarray\fP is NULL, the routine does nothing.
108 .BR ber_bvarray_add ()
109 appends the contents of the BerValue pointed to by \fIbv\fP to the
110 \fIbvarray\fP array.  Space for the new element is allocated as needed.
111 The end of the array is marked by a BerValue with a NULL bv_val field.
112 .LP
113 .BR ber_bvdup ()
114 returns a copy of a BerValue.  The routine returns NULL upon error
115 (e.g. out of memory).  The caller should use
116 .BR ber_bvfree ()
117 to deallocate the resulting BerValue.
118 .BR ber_dupbv ()
119 copies a BerValue from \fIsrc\fP to \fIdst\fP.  If \fIdst\fP is NULL a
120 new BerValue will be allocated to hold the copy.  The routine returns NULL
121 upon error, otherwise it returns a pointer to the copy.  If \fIdst\fP is
122 NULL the caller should use
123 .BR ber_bvfree ()
124 to deallocate the resulting BerValue, otherwise
125 .BR ber_memfree ()
126 should be used to deallocate the \fIdst->bv_val\fP.  (The
127 .BR ber_bvdup ()
128 function is internally implemented as ber_dupbv(NULL, bv).
129 .BR ber_bvdup ()
130 is provided only for compatibility with an expired draft of the LDAP C API;
131 .BR ber_dupbv ()
132 is the preferred interface.)
133 .LP
134 .BR ber_bvstr ()
135 returns a BerValue containing the string pointed to by \fIstr\fP.
136 .BR ber_bvstrdup ()
137 returns a BerValue containing a copy of the string pointed to by \fIstr\fP.
138 .BR ber_str2bv ()
139 returns a BerValue containing the string pointed to by \fIstr\fP, whose
140 length may be optionally specified in \fIlen\fP.  If \fIdup\fP is non-zero,
141 the BerValue will contain a copy of \fIstr\fP.  If \fIlen\fP is zero, the
142 number of bytes to copy will be determined by
143 .BR strlen (3),
144 otherwise \fIlen\fP bytes will be copied.  If \fIbv\fP is non-NULL, the result
145 will be stored in the given BerValue, otherwise a new BerValue will be
146 allocated to store the result.  NOTE: Both
147 .BR ber_bvstr ()
148 and
149 .BR ber_bvstrdup ()
150 are implemented as macros using
151 .BR ber_str2bv ()
152 in this version of the library.
153 .LP
154 .B BerElement
155 is an opaque structure used to maintain state information used in
156 encoding and decoding.
157 .BR ber_alloc_t ()
158 is used to create an empty BerElement structure. If
159 .B LBER_USE_DER
160 is specified for the
161 .I options
162 parameter then data lengths for data written to the BerElement will be
163 encoded in the minimal number of octets required, otherwise they will
164 always be written as four byte values. 
165 .BR ber_init ()
166 creates a BerElement structure that is initialized with a copy of the
167 data in its
168 .I bv
169 parameter.
170 .BR ber_init2 ()
171 initializes an existing BerElement
172 .I ber
173 using the data in the
174 .I bv
175 parameter. The data is referenced directly, not copied. The
176 .I options
177 parameter is the same as for
178 .BR ber_alloc_t ().
179 .BR ber_free ()
180 frees a BerElement pointed to by \fIber\fP.  If \fIber\fP is NULL, the routine
181 does nothing.  If \fIfreebuf\fP is zero, the internal buffer is not freed.
182 .SH SEE ALSO
183 .BR lber-encode (3),
184 .BR lber-decode (3),
185 .BR lber-memory (3)
186 .LP
187 .SH ACKNOWLEDGEMENTS
188 .so ../Project