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