]> git.sur5r.net Git - openldap/blob - doc/man/man3/lber-types.3
8662d2b5e4735f0a5f9ad382f4dd6ac06aaa3e73
[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, ber_free
10 \- LBER types and allocation functions
11 .SH LIBRARY
12 OpenLDAP LBER (liblber, -llber)
13 .SH SYNOPSIS
14 .B #include <lber.h>
15 .LP
16 .nf
17 .ft B
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 .ft
31 .fi
32 .LP
33 .BI "void ber_bvfree(struct berval *" bv ");"
34 .LP
35 .BI "void ber_bvecfree(struct berval **" bvec ");"
36 .LP
37 .BI "void ber_bvecadd(struct berval ***" bvec ", struct berval *" bv ");"
38 .LP
39 .BI "void ber_bvarray_free(struct berval *" bvarray ");"
40 .LP
41 .BI "void ber_bvarray_add(BerVarray *" bvarray ", BerValue *" bv ");"
42 .LP
43 .BI "struct berval *ber_bvdup(const struct berval *" bv ");"
44 .LP
45 .BI "struct berval *ber_dupbv(const struct berval *" dst ", struct berval *" src ");"
46 .LP
47 .BI "struct berval *ber_bvstr(const char *" str ");"
48 .LP
49 .BI "struct berval *ber_bvstrdup(const char *" str ");"
50 .LP
51 .BI "struct berval *ber_str2bv(const char *" str ", ber_len_t " len ", int " dup ", struct berval *" bv ");"
52 .LP
53 .BI "void ber_free(BerElement *" ber ", int " freebuf ");"
54 .SH DESCRIPTION
55 .LP
56 The following are the basic types and structures defined for use
57 with the Lightweight BER library.  
58 .LP
59 .B ber_int_t
60 is a signed integer of at least 32 bits.  It is commonly equivalent to
61 .BR int .
62 .B ber_uint_t
63 is the unsigned variant of
64 .BR ber_int_t .
65 .LP
66 .B ber_len_t
67 is an unsigned integer of at least 32 bits used to represent a length.  
68 It is commonly equivalent to a
69 .BR size_t .
70 .B ber_slen_t
71 is the signed variant to
72 .BR ber_len_t .
73 .LP
74 .B ber_tag_t
75 is an unsigned integer of at least 32 bits used to represent a
76 BER tag.  It is commonly equivalent to a
77 .BR unsigned\ long .
78 .LP
79 The actual definitions of the integral impl_TYPE_t types are platform
80 specific.
81 .LP
82 .BR BerValue ,
83 commonly used as
84 .BR struct\ berval ,
85 is used to hold an arbitrary sequence of octets.
86 .B bv_val
87 points to
88 .B bv_len
89 octets.
90 .B bv_val
91 is not necessarily terminated by a NUL (zero) octet.
92 .BR ber_bvfree ()
93 frees a BerValue, pointed to by \fIbv\fP, returned from this API.  If \fIbv\fP
94 is NULL, the routine does nothing.
95 .LP
96 .BR ber_bvecfree ()
97 frees an array of BerValues (and the array), pointed to by \fIbvec\fP,
98 returned from this API.  If \fIbvec\fP is NULL, the routine does nothing.
99 .BR ber_bvecadd ()
100 appends the \fIbv\fP pointer to the \fIbvec\fP array.  Space for the array
101 is allocated as needed.  The end of the array is marked by a NULL pointer.
102 .LP
103 .BR ber_bvarray_free ()
104 frees an array of BerValues (and the array), pointed to by \fIbvarray\fP,
105 returned from this API.  If \fIbvarray\fP is NULL, the routine does nothing.
106 .BR ber_bvarray_add ()
107 appends the contents of the BerValue pointed to by \fIbv\fP to the
108 \fIbvarray\fP array.  Space for the new element is allocated as needed.
109 The end of the array is marked by a BerValue with a NULL bv_val field.
110 .LP
111 .BR ber_bvdup ()
112 returns a copy of a BerValue.  The routine returns NULL upon error
113 (e.g. out of memory).  The caller should use
114 .BR ber_bvfree ()
115 to deallocate the resulting BerValue.
116 .BR ber_dupbv ()
117 copies a BerValue from \fIsrc\fP to \fIdst\fP.  If \fIdst\fP is NULL a
118 new BerValue will be allocated to hold the copy.  The routine returns NULL
119 upon error, otherwise it returns a pointer to the copy.  If \fIdst\fP is
120 NULL the caller should use
121 .BR ber_bvfree ()
122 to deallocate the resulting BerValue, otherwise
123 .BR ber_memfree ()
124 should be used to deallocate the \fIdst->bv_val\fP.  (The
125 .BR ber_bvdup ()
126 function is internally implemented as ber_dupbv(NULL, bv).
127 .BR ber_bvdup ()
128 is provided only for compatibility with an expired draft of the LDAP C API;
129 .BR ber_dupbv ()
130 is the preferred interface.)
131 .LP
132 .BR ber_bvstr ()
133 returns a BerValue containing the string pointed to by \fIstr\fP.
134 .BR ber_bvstrdup ()
135 returns a BerValue containing a copy of the string pointed to by \fIstr\fP.
136 .BR ber_str2bv ()
137 returns a BerValue containing the string pointed to by \fIstr\fP, whose
138 length may be optionally specified in \fIlen\fP.  If \fIdup\fP is non-zero,
139 the BerValue will contain a copy of \fIstr\fP.  If \fIlen\fP is zero, the
140 number of bytes to copy will be determined by
141 .BR strlen (3),
142 otherwise \fIlen\fP bytes will be copied.  If \fIbv\fP is non-NULL, the result
143 will be stored in the given BerValue, otherwise a new BerValue will be
144 allocated to store the result.  NOTE: Both
145 .BR ber_bvstr ()
146 and
147 .BR ber_bvstrdup ()
148 are implemented as macros using
149 .BR ber_str2bv ()
150 in this version of the library.
151 .LP
152 .B BerElement
153 is an opaque structure used to maintain state information used in
154 encoding and decoding.  BerElement structures are created using
155 .BR ber_alloc_t (3)
156 and
157 .BR ber_init (3).
158 .BR ber_free ()
159 frees a BerElement pointed to by \fIber\fP.  If \fIber\fP is NULL, the routine
160 does nothing.  If \fIfreebuf\fP is zero, the internal buffer is not freed.
161 .SH SEE ALSO
162 .BR lber-encode (3),
163 .BR lber-decode (3),
164 .BR lber-memory (3)
165 .LP
166 .SH ACKNOWLEDGEMENTS
167 .B OpenLDAP
168 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
169 .B OpenLDAP
170 is derived from University of Michigan LDAP 3.3 Release.