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