.\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
-ber_get_next, ber_skiptag, ber_peek_tag, ber_scanf, ber_get_int, ber_get_stringb, ber_get_stringa, ber_get_null, ber_get_boolean, ber_get_bitstring, ber_first_element, ber_next_element \- LBER simplified Basic Encoding Rules library routines for decoding
+ber_get_next, ber_skip_tag, ber_peek_tag, ber_scanf, ber_get_int, ber_get_enum, ber_get_stringb, ber_get_stringa, ber_get_null, ber_get_boolean, ber_get_bitstring, ber_first_element, ber_next_element \- LBER simplified Basic Encoding Rules library routines for decoding
.SH SYNOPSIS
.nf
.ft B
.LP
.nf
.ft B
-ber_tag_t ber_get_int(ber, num)
+ber_tag_t ber_get_int(
+ BerElement \(**ber,
+ ber_int_t \(**num);
+.ft
+.fi
+.LP
+.nf
+.ft B
+ber_tag_t ber_get_enum(
BerElement \(**ber,
ber_int_t \(**num);
.ft
Octet string. A char ** should be supplied. Memory is allocated,
filled with the contents of the octet string, null-terminated, and
returned in the parameter.
-The caller should free the returned ber_val using ber_memfree();
+The caller should free the returned ber_val using ber_memfree().
.TP
.SM s
Octet string. A char * buffer should be supplied, followed by a pointer
Octet string. A struct ber_val ** should be supplied, which upon return
points to a dynamically allocated struct berval containing the octet string
and its length.
-The caller should free the returned structure using ber_bvfree();
+The caller should free the returned structure using ber_bvfree().
+.TP
+.SM o
+Octet string. A struct ber_val * should be supplied, which upon return
+points containing the dynamically allocated octet string and its length.
+The caller should free the returned octet string using ber_memfree().
.TP
.SM b
Boolean. A pointer to a ber_int_t should be supplied.
.TP
+.SM e
+Enumeration. A pointer to a ber_int_t should be supplied.
+.TP
.SM i
Integer. A pointer to a ber_int_t should be supplied.
.TP
Sequence of octet strings. A char *** should be supplied, which upon
return points to a dynamically allocated null-terminated array of char *'s
containing the octet strings. NULL is returned if the sequence is empty.
+The caller should free the returned array and octet strings using
+ber_memvfree().
.TP
.SM V
Sequence of octet strings with lengths.
struct berval *'s
containing the octet strings and their lengths.
NULL is returned if the sequence is empty.
-The caller should free the returned structures using ber_bvecfree();
+The caller should free the returned structures using ber_bvecfree().
+.TP
+.SM l
+Length of the next element. A pointer to a ber_len_t should be supplied.
+.TP
+.SM t
+Tag of the next element. A pointer to a ber_tag_t should be supplied.
+.TP
+.SM T
+Skip element and return its tag. A pointer to a ber_tag_t should be supplied.
.TP
.SM x
Skip element. The next element is skipped.
.LP
The ber_get_stringa() routine is used to dynamically allocate space into
which an octet string is read.
-The caller should free the returned string using ber_memfree();
+The caller should free the returned string using ber_memfree().
.LP
The ber_get_stringal() routine is used to dynamically allocate space
into which an octet string and its length are read. It takes a
struct berval **, and returns the result in this parameter.
-The caller should free the returned structure using ber_bvfree();
+The caller should free the returned structure using ber_bvfree().
.LP
The ber_get_null() routine is used to read a NULL element. It returns
the tag of the element it skips over.
.LP
-The ber_get_boolean() routine is used to read a boolean value. It is called
-the same way that ber_get_int() is called.
+The ber_get_boolean() routine is used to read a boolean value.
+It is called the same way that ber_get_int() is called.
+.LP
+The ber_get_enum() routine is used to read a enumeration value.
+It is called the same way that ber_get_int() is called.
.LP
The ber_get_bitstringa() routine is used to read a bitstring value. It
takes a char ** which will hold the dynamically allocated bits, followed by an
-unsigned long *, which will point to the length (in bits) of the
-bitstring returned.
-The caller should free the returned string using ber_memfree();
+ber_len_t *, which will point to the length (in bits) of the bitstring returned.
+The caller should free the returned string using ber_memfree().
.LP
The ber_first_element() routine is used to return the tag and length
of the first element in a set or sequence. It also returns in \fIcookie\fP
The element can be decoded using ber_scanf() as follows.
.LP
.nf
- ber_int_t scope, ali, size, time, attrsonly;
+ ber_int_t scope, deref, size, time, attrsonly;
char *dn, **attrs;
ber_tag_t tag;
- tag = ber_scanf( ber, "{aiiiib{v}}",
- &dn, &scope, &ali,
+ tag = ber_scanf( ber, "{aeeiib{v}}",
+ &dn, &scope, &deref,
&size, &time, &attrsonly, &attrs );
if( tag == LBER_ERROR ) {
} else {
/* success */
}
+
+ ber_memfree( dn );
+ ber_memvfree( attrs );
.fi
.SH ERRORS
If an error occurs during decoding, generally these routines return
.BR ldap-sync (3)
.BR ldap-async (3)
.LP
-Yeong, W., Howes, T., and Hardcastle-Kille, S., "Lightweight Directory Access
-Protocol", OSI-DS-26, April 1992.
+Yeong, W., Howes, T., and Hardcastle-Kille, S.,
+"Lightweight Directory Access Protocol", OSI-DS-26, April 1992.
.LP
Information Processing - Open Systems Interconnection - Model and Notation -
Service Definition - Specification of Basic Encoding Rules for Abstract
.\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
-ber_alloc, ber_flush, ber_printf, ber_put_int, ber_put_ostring, ber_put_string, ber_put_null, ber_put_boolean, ber_put_bitstring, ber_start_seq, ber_start_set, ber_put_seq, ber_put_set \- LBER simplified Basic Encoding Rules library routines for encoding
+ber_alloc_t, ber_flush, ber_printf, ber_put_int, ber_put_enum, ber_put_ostring, ber_put_string, ber_put_null, ber_put_boolean, ber_put_bitstring, ber_start_seq, ber_start_set, ber_put_seq, ber_put_set \- LBER simplified Basic Encoding Rules library routines for encoding
.SH SYNOPSIS
.nf
.ft B
.LP
.nf
.ft B
+int ber_put_enum(
+ BerElement *ber,
+ ber_int_t num,
+ ber_tag_t tag);
+.ft
+.fi
+.LP
+.nf
+.ft B
int ber_put_ostring(
BerElement *ber,
const char \(**str,
general, these routines return the length of the element encoded, or
-1 if an error occurred.
.LP
-The ber_alloc_t() routine is used to allocate a new BER element. The
+The ber_alloc_t() routine is used to allocate a new BER element. It
+should be called with an argument of LBER_USE_DER. The
ber_flush() routine is used to actually write the element to a socket
(or file) descriptor, once it has been fully encoded (using ber_printf()
and friends). The \fIsb\fP structure contains the descriptor and a
Boolean. An ber_int_t parameter should be supplied. A boolean element
is output.
.TP
+.SM e
+Enumeration. An ber_int_t parameter should be supplied. An
+enumeration element is output.
+.TP
.SM i
Integer. An ber_int_t parameter should be supplied. An integer element
is output.
Octet string. A char * is supplied, followed by the length of the
string pointed to. An octet string element is output.
.TP
+.SM O
+Octet string. A struct berval * is supplied.
+An octet string element is output.
+.TP
.SM s
Octet string. A null-terminated string is supplied. An octet string
element is output, not including the trailing NULL octet.
supplied. Note that a construct like '{v}' is required to get
an actual SEQUENCE OF octet strings.
.TP
+.SM V
+Several octet strings. A null-terminated array of struct berval *'s
+is supplied. Note that a construct like '{V}' is required to get
+an actual SEQUENCE OF octet strings.
+.TP
.SM {
Begin sequence. No parameter is required.
.TP
The ber_put_int() routine writes the integer element \fInum\fP to
the BER element \fIber\fP.
.LP
+The ber_put_enum() routine writes the enumberation element
+\fInum\fP to the BER element \fIber\fP.
+.LP
The ber_put_boolean() routine writes the boolean value given by
\fIbool\fP to the BER element.
.LP
int rc;
ber_int_t scope, ali, size, time, attrsonly;
char *dn, **attrs;
+ BerElement *ber;
/* ... fill in values ... */
+
ber = ber_alloc_t( LBER_USE_DER );
if ( ber == NULL ) {
/* error */
- }
+ }
rc = ber_printf( ber, "{siiiib{v}}", dn, scope, ali,
size, time, attrsonly, attrs );
.BR ldap-sync (3)
.BR ldap-parse (3)
.LP
-Yeong, W., Howes, T., and Hardcastle-Kille, S., "Lightweight Directory Access
-Protocol", OSI-DS-26, April 1992.
+Yeong, W., Howes, T., and Hardcastle-Kille, S.,
+"Lightweight Directory Access Protocol", OSI-DS-26, April 1992.
.LP
Information Processing - Open Systems Interconnection - Model and Notation -
Service Definition - Specification of Basic Encoding Rules for Abstract