mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-03 20:40:05 -05:00
More updates. Need to add lber-sockbuf.3 ...
This commit is contained in:
parent
713e6beb8d
commit
5d927e7bb2
4 changed files with 231 additions and 228 deletions
|
|
@ -1,4 +1,4 @@
|
|||
.TH LBER_DECODE 3 "19 January 2002" "OpenLDAP LDVERSION"
|
||||
.TH LBER_DECODE 3 "25 January 2002" "OpenLDAP LDVERSION"
|
||||
.\" $OpenLDAP$
|
||||
.\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
|
|
@ -76,7 +76,9 @@ routine is used to read the next BER element from the given Sockbuf,
|
|||
returns the length of the entire element in \fIlen\fP, and sets up
|
||||
\fIber\fP for subsequent calls to
|
||||
.BR ber_scanf ()
|
||||
et al to decode the element.
|
||||
et al to decode the element. See
|
||||
.BR lber-sockbuf (3)
|
||||
for details of the Sockbuf implementation of the \fIsb\fP parameter.
|
||||
.LP
|
||||
The
|
||||
.BR ber_scanf ()
|
||||
|
|
@ -343,6 +345,7 @@ which must be freed by the caller using supplied deallocation routines.
|
|||
.SH SEE ALSO
|
||||
.BR lber-encode (3)
|
||||
.BR lber-memory (3)
|
||||
.BR lber-sockbuf (3)
|
||||
.BR lber-types (3)
|
||||
.SH ACKNOWLEDGEMENTS
|
||||
.B OpenLDAP
|
||||
|
|
|
|||
|
|
@ -1,130 +1,39 @@
|
|||
.TH LBER_ENCODE 3 "12 May 2000" "OpenLDAP LDVERSION"
|
||||
.TH LBER_ENCODE 3 "25 January 2002" "OpenLDAP LDVERSION"
|
||||
.\" $OpenLDAP$
|
||||
.\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
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
|
||||
#include <lber.h>
|
||||
.ft
|
||||
.fi
|
||||
.B #include <lber.h>
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
BerElement *ber_alloc_t( int options );
|
||||
.ft
|
||||
.fi
|
||||
.BI "BerElement *ber_alloc_t(int " options ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_flush(
|
||||
Sockbuf *sb,
|
||||
BerElement *ber,
|
||||
int freeit);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_flush(Sockbuf *" sb ", BerElement *" ber ", int " freeit ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_printf(
|
||||
BerElement *ber,
|
||||
const char \(**fmt, ...);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_printf(BerElement *" ber ", const char *" fmt ", ...);"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_int(
|
||||
BerElement *ber,
|
||||
ber_int_t num,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_int(BerElement *" ber ", ber_int_t " num ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_enum(
|
||||
BerElement *ber,
|
||||
ber_int_t num,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_enum(BerElement *" ber ", ber_int_t " num ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_ostring(
|
||||
BerElement *ber,
|
||||
const char \(**str,
|
||||
ber_len_t long len,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_ostring(BerElement *" ber ", const char *" str ", ber_len_t " len ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_string(
|
||||
BerElement *ber,
|
||||
const char \(**str,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_string(BerElement *" ber ", const char *" str ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_null(
|
||||
BerElement *ber;
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_null(BerElement *" ber ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_boolean(
|
||||
BerElement *ber;
|
||||
ber_int_t bool;
|
||||
ber_tag_t tag;
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_boolean(BerElement *" ber ", ber_int_t " bool ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_bitstring(
|
||||
BerElement *ber,
|
||||
const char *str,
|
||||
ber_len_t blen,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_bitstring(BerElement *" ber ", const char *" str ", ber_len_t " blen ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_start_seq(
|
||||
BerElement *ber,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_start_seq(BerElement *" ber ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_start_set(
|
||||
BerElement *ber,
|
||||
ber_tag_t tag);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_start_set(BerElement *" ber ", ber_tag_t " tag ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_seq(
|
||||
BerElement *ber);
|
||||
.ft
|
||||
.fi
|
||||
.BI "int ber_put_seq(BerElement *" ber ");"
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
int ber_put_set(
|
||||
BerElement *ber);
|
||||
.BI "int ber_put_set(BerElement *" ber ");"
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These routines provide a subroutine interface to a simplified
|
||||
|
|
@ -132,131 +41,168 @@ implementation of the Basic Encoding Rules of ASN.1. The version
|
|||
of BER these routines support is the one defined for the LDAP
|
||||
protocol. The encoding rules are the same as BER, except that
|
||||
only definite form lengths are used, and bitstrings and octet strings
|
||||
are always encoded in primitive form. In addition, these lightweight
|
||||
BER routines restrict tags and class to fit in a single octet (this
|
||||
means the actual tag must be less than 31). When a "tag" is specified
|
||||
in the descriptions below, it refers to the tag, class, and primitive
|
||||
or constructed bit in the first octet of the encoding. This
|
||||
are always encoded in primitive form. This
|
||||
man page describes the encoding routines in the lber library. See
|
||||
lber-decode(3) for details on the corresponding decoding routines.
|
||||
Consult lber-types(3) for information about types, allocators, and deallocators.
|
||||
.BR lber-decode (3)
|
||||
for details on the corresponding decoding routines. Consult
|
||||
.BR lber-types (3)
|
||||
for information about types, allocators, and deallocators.
|
||||
.LP
|
||||
Normally, the only routines that need be called by an application
|
||||
are ber_alloc_t() to allocate a BER element for encoding, ber_printf()
|
||||
to do the actual encoding, and ber_flush() to actually write the
|
||||
element. The other routines are provided for those
|
||||
applications that need more control than ber_printf() provides. In
|
||||
Normally, the only routines that need to be called by an application
|
||||
are
|
||||
.BR ber_alloc_t ()
|
||||
to allocate a BER element for encoding,
|
||||
.BR ber_printf ()
|
||||
to do the actual encoding, and
|
||||
.BR ber_flush ()
|
||||
to actually write the element. The other routines are provided for those
|
||||
applications that need more control than
|
||||
.BR ber_printf ()
|
||||
provides. In
|
||||
general, these routines return the length of the element encoded, or
|
||||
-1 if an error occurred.
|
||||
LBER_ERROR if an error occurred.
|
||||
.LP
|
||||
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
|
||||
BerElement used for input buffering. Only the \fIsb_sd\fP field is relevant
|
||||
to the ber_flush() routine.
|
||||
The
|
||||
.BR ber_alloc_t ()
|
||||
routine is used to allocate a new BER element. It
|
||||
should be called with an argument of LBER_USE_DER.
|
||||
.LP
|
||||
The ber_printf() routine is used to encode a BER element in much the
|
||||
same way that sprintf(3) works. One important difference, though, is
|
||||
The
|
||||
.BR ber_flush ()
|
||||
routine is used to actually write the element to a socket
|
||||
(or file) descriptor, once it has been fully encoded (using
|
||||
.BR ber_printf ()
|
||||
and friends). See
|
||||
.BR lber-sockbuf(3)
|
||||
for more details on the Sockbuf implementation of the \fIsb\fP parameter.
|
||||
If the \fIfreeit\fP parameter is non-zero, the supplied \fIber\fP will
|
||||
be freed after its contents have been flushed.
|
||||
.LP
|
||||
The
|
||||
.BR ber_printf ()
|
||||
routine is used to encode a BER element in much the same way that
|
||||
.BR sprintf (3)
|
||||
works. One important difference, though, is
|
||||
that some state information is kept with the \fIber\fP parameter so
|
||||
that multiple calls can be made to ber_printf() to append things to
|
||||
the end of the BER element. Ber_printf() writes to \fIber\fP, a pointer to a
|
||||
BerElement such as returned by ber_alloc(). It interprets and
|
||||
that multiple calls can be made to
|
||||
.BR ber_printf ()
|
||||
to append things to the end of the BER element.
|
||||
.BR Ber_printf ()
|
||||
writes to \fIber\fP, a pointer to a BerElement such as returned by
|
||||
.BR ber_alloc_t ().
|
||||
It interprets and
|
||||
formats its arguments according to the format string \fIfmt\fP.
|
||||
The format string can contain the following characters:
|
||||
.RS
|
||||
.LP
|
||||
.TP 3
|
||||
.SM b
|
||||
.B b
|
||||
Boolean. An ber_int_t parameter should be supplied. A boolean element
|
||||
is output.
|
||||
.TP
|
||||
.SM e
|
||||
.B e
|
||||
Enumeration. An ber_int_t parameter should be supplied. An
|
||||
enumeration element is output.
|
||||
.TP
|
||||
.SM i
|
||||
.B i
|
||||
Integer. An ber_int_t parameter should be supplied. An integer element
|
||||
is output.
|
||||
.TP
|
||||
.SM B
|
||||
.B B
|
||||
Bitstring. A char * pointer to the start of the bitstring is supplied,
|
||||
followed by the number of bits in the bitstring. A bitstring element
|
||||
is output.
|
||||
.TP
|
||||
.SM n
|
||||
.B n
|
||||
Null. No parameter is required. A null element is output.
|
||||
.TP
|
||||
.SM o
|
||||
.B o
|
||||
Octet string. A char * is supplied, followed by the length of the
|
||||
string pointed to. An octet string element is output.
|
||||
.TP
|
||||
.SM O
|
||||
.B O
|
||||
Octet string. A struct berval * is supplied.
|
||||
An octet string element is output.
|
||||
.TP
|
||||
.SM s
|
||||
.B s
|
||||
Octet string. A null-terminated string is supplied. An octet string
|
||||
element is output, not including the trailing NULL octet.
|
||||
.TP
|
||||
.SM t
|
||||
.B t
|
||||
Tag. A ber_tag_t specifying the tag to give the next element
|
||||
is provided. This works across calls.
|
||||
.TP
|
||||
.SM v
|
||||
.B v
|
||||
Several octet strings. A null-terminated array of char *'s is
|
||||
supplied. Note that a construct like '{v}' is required to get
|
||||
an actual SEQUENCE OF octet strings.
|
||||
.TP
|
||||
.SM V
|
||||
.B 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 {
|
||||
.B W
|
||||
Several octet strings. An array of struct berval's is supplied. The
|
||||
array is terminated by a struct berval with a NULL bv_val.
|
||||
Note that a construct like '{W}' is required to get
|
||||
an actual SEQUENCE OF octet strings.
|
||||
.TP
|
||||
.B {
|
||||
Begin sequence. No parameter is required.
|
||||
.TP
|
||||
.SM }
|
||||
.B }
|
||||
End sequence. No parameter is required.
|
||||
.TP
|
||||
.SM [
|
||||
.B [
|
||||
Begin set. No parameter is required.
|
||||
.TP
|
||||
.SM ]
|
||||
.B ]
|
||||
End set. No parameter is required.
|
||||
.RE
|
||||
.LP
|
||||
The ber_put_int() routine writes the integer element \fInum\fP to
|
||||
the BER element \fIber\fP.
|
||||
The
|
||||
.BR 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.
|
||||
The
|
||||
.BR ber_put_enum ()
|
||||
routine writes the enumeration 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.
|
||||
The
|
||||
.BR ber_put_boolean ()
|
||||
routine writes the boolean value given by \fIbool\fP to the BER element.
|
||||
.LP
|
||||
The ber_put_bitstring() routine writes \fIblen\fP bits starting
|
||||
The
|
||||
.BR ber_put_bitstring ()
|
||||
routine writes \fIblen\fP bits starting
|
||||
at \fIstr\fP as a bitstring value to the given BER element. Note
|
||||
that \fIblen\fP is the length \fIin bits\fP of the bitstring.
|
||||
.LP
|
||||
The ber_put_ostring() routine writes \fIlen\fP bytes starting at
|
||||
The
|
||||
.BR ber_put_ostring ()
|
||||
routine writes \fIlen\fP bytes starting at
|
||||
\fIstr\fP to the BER element as an octet string.
|
||||
.LP
|
||||
The ber_put_string() routine writes the null-terminated string (minus
|
||||
The
|
||||
.BR ber_put_string ()
|
||||
routine writes the null-terminated string (minus
|
||||
the terminating '\0') to the BER element as an octet string.
|
||||
.LP
|
||||
The ber_put_null() routine writes a NULL element to the BER element.
|
||||
The
|
||||
.BR ber_put_null ()
|
||||
routine writes a NULL element to the BER element.
|
||||
.LP
|
||||
The ber_start_seq() routine is used to start a sequence in the BER
|
||||
element. The ber_start_set() routine works similarly.
|
||||
The end of the sequence or set is marked by the nearest matching
|
||||
call to ber_put_seq() or ber_put_set(), respectively.
|
||||
.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
|
||||
a magic cookie parameter that should be passed to subsequent calls to
|
||||
ber_next_element(), which returns similar information.
|
||||
The
|
||||
.BR ber_start_seq ()
|
||||
routine is used to start a sequence in the BER element. The
|
||||
.BR ber_start_set ()
|
||||
routine works similarly.
|
||||
The end of the sequence or set is marked by the nearest matching call to
|
||||
.BR ber_put_seq ()
|
||||
or
|
||||
.BR ber_put_set (),
|
||||
respectively.
|
||||
.SH EXAMPLES
|
||||
Assuming the following variable declarations, and that the variables
|
||||
have been assigned appropriately, an lber encoding of
|
||||
|
|
@ -302,14 +248,14 @@ can be achieved like so:
|
|||
rc = ber_printf( ber, "{siiiib{v}}", dn, scope, ali,
|
||||
size, time, attrsonly, attrs );
|
||||
|
||||
if( rc == -1 ) {
|
||||
if( rc == LBER_ERROR ) {
|
||||
/* error */
|
||||
} else {
|
||||
/* success */
|
||||
}
|
||||
.fi
|
||||
.SH ERRORS
|
||||
If an error occurs during encoding, generally these routines return -1.
|
||||
If an error occurs during encoding, generally these routines return LBER_ERROR.
|
||||
.LP
|
||||
.SH NOTES
|
||||
.LP
|
||||
|
|
@ -318,10 +264,8 @@ The return values for all of these functions are declared in the
|
|||
.SH SEE ALSO
|
||||
.BR lber-decode (3)
|
||||
.BR lber-memory (3)
|
||||
.BR lber-sockbuf (3)
|
||||
.BR lber-types (3)
|
||||
.BR ldap-async (3)
|
||||
.BR ldap-sync (3)
|
||||
.BR ldap-parse (3)
|
||||
.SH ACKNOWLEDGEMENTS
|
||||
.B OpenLDAP
|
||||
is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
|
||||
|
|
|
|||
|
|
@ -1,29 +1,21 @@
|
|||
.TH LBER_MEMORY 3 "29 August 2001" "OpenLDAP LDVERSION"
|
||||
.TH LBER_MEMORY 3 "25 January 2002" "OpenLDAP LDVERSION"
|
||||
.\" $OpenLDAP$
|
||||
.\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
ber_memalloc, ber_memcalloc, ber_memrealloc, ber_memfree \- LBER memory allocators
|
||||
ber_memalloc, ber_memcalloc, ber_memrealloc, ber_memfree, ber_memvfree \- LBER memory allocators
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
#include <lber.h>
|
||||
.ft
|
||||
.fi
|
||||
.B #include <lber.h>
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
void * ber_memalloc( ber_len_t bytes )
|
||||
|
||||
void * ber_memcalloc( ber_len_t nelems, ber_len_t bytes )
|
||||
|
||||
void * ber_memrealloc( void *ptr, ber_len_t bytes);
|
||||
|
||||
void ber_memfree( void *ptr );
|
||||
|
||||
void ber_memvfree( void **vec );
|
||||
.ft
|
||||
.fi
|
||||
.BI "void *ber_memalloc(ber_len_t " bytes ");"
|
||||
.LP
|
||||
.BI "void *ber_memcalloc(ber_len_t " nelems ", ber_len_t " bytes ");"
|
||||
.LP
|
||||
.BI "void *ber_memrealloc(void *" ptr ", ber_len_t " bytes ");"
|
||||
.LP
|
||||
.BI "void ber_memfree(void *" ptr ");"
|
||||
.LP
|
||||
.BI "void ber_memvfree(void **" vec ");"
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These routines are used to allocate/deallocate memory used/returned
|
||||
|
|
@ -31,6 +23,21 @@ by the Lightweight BER library as required by
|
|||
.BR lber-encode (3)
|
||||
and
|
||||
.BR lber-decode (3).
|
||||
.BR ber_memalloc (),
|
||||
.BR ber_memcalloc (),
|
||||
.BR ber_memrealloc (),
|
||||
and
|
||||
.BR ber_memfree ()
|
||||
are used exactly like the standard
|
||||
.BR malloc (3),
|
||||
.BR calloc (3),
|
||||
.BR realloc (3),
|
||||
and
|
||||
.BR free(3)
|
||||
routines, respectively. The
|
||||
.BR ber_memvfree ()
|
||||
routine is used to free a dynamically allocated array of pointers to
|
||||
arbitrary dynamically allocated objects.
|
||||
.SH SEE ALSO
|
||||
.BR lber-decode (3)
|
||||
.BR lber-encode (3)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
.TH LBER_TYPES 3 "29 August 2001" "OpenLDAP LDVERSION"
|
||||
.TH LBER_TYPES 3 "25 January 2002" "OpenLDAP LDVERSION"
|
||||
.\" $OpenLDAP$
|
||||
.\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
ber_int_t, ber_uint_t, ber_len_t, ber_slen_t, ber_tag_t \- LBER types
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
#include <lber.h>
|
||||
.ft
|
||||
.fi
|
||||
.B #include <lber.h>
|
||||
.LP
|
||||
.nf
|
||||
.ft B
|
||||
|
|
@ -19,29 +15,36 @@ typedef impl_uint_t ber_uint_t;
|
|||
typedef impl_len_t ber_len_t;
|
||||
typedef impl_slen_t ber_slen_t;
|
||||
|
||||
|
||||
typedef struct berval {
|
||||
ber_len_t bv_len;
|
||||
char *bv_val;
|
||||
} BerValue;
|
||||
|
||||
void ber_bvfree( struct berval *bv );
|
||||
|
||||
void ber_bvecfree( struct berval **bvec );
|
||||
|
||||
struct berval *ber_bvdup( const struct berval *bv );
|
||||
|
||||
struct berval *ber_bvstr( const char *str );
|
||||
|
||||
struct berval *ber_bvstrdup( const char *str );
|
||||
|
||||
} BerValue, *BerVarray;
|
||||
|
||||
typedef struct berelement BerElement;
|
||||
|
||||
void ber_free( BerElement *ber, int freebuf );
|
||||
|
||||
.ft
|
||||
.fi
|
||||
.LP
|
||||
.BI "void ber_bvfree(struct berval *" bv ");"
|
||||
.LP
|
||||
.BI "void ber_bvecfree(struct berval **" bvec ");"
|
||||
.LP
|
||||
.BI "void ber_bvecadd(struct berval ***" bvec ", struct berval *" bv ");"
|
||||
.LP
|
||||
.BI "void ber_bvarray_free(struct berval *" bvarray ");"
|
||||
.LP
|
||||
.BI "void ber_bvarray_add(BerVarray *" bvarray ", BerValue *" bv ");"
|
||||
.LP
|
||||
.BI "struct berval *ber_bvdup(const struct berval *" bv ");"
|
||||
.LP
|
||||
.BI "struct berval *ber_dupbv(const struct berval *" dst ", struct berval *" src ");"
|
||||
.LP
|
||||
.BI "struct berval *ber_bvstr(const char *" str ");"
|
||||
.LP
|
||||
.BI "struct berval *ber_bvstrdup(const char *" str ");"
|
||||
.LP
|
||||
.BI "struct berval *ber_str2bv(const char *" str ", ber_len_t " len ", int " dup ", struct berval *" bv ");"
|
||||
.LP
|
||||
.BI "void ber_free(BerElement *" ber ", int " freebuf ");"
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
The following are the basic types and structures defined for use
|
||||
|
|
@ -55,7 +58,7 @@ is the unsigned variant of
|
|||
.BR ber_int_t .
|
||||
.LP
|
||||
.B ber_len_t
|
||||
is a unsigned integer of at least 32 bits used to represent a length.
|
||||
is an unsigned integer of at least 32 bits used to represent a length.
|
||||
It is commonly equivalent to a
|
||||
.BR size_t .
|
||||
.B ber_slen_t
|
||||
|
|
@ -63,36 +66,82 @@ is the signed variant to
|
|||
.BR ber_len_t .
|
||||
.LP
|
||||
.B ber_tag_t
|
||||
is a unsigned integer of at least 32 bits used to represent a
|
||||
is an unsigned integer of at least 32 bits used to represent a
|
||||
BER tag. It is commonly equivalent to a
|
||||
.BR unsigned\ long .
|
||||
.LP
|
||||
The actual definitions of the integal impl_TYPE_t types are platform
|
||||
The actual definitions of the integral impl_TYPE_t types are platform
|
||||
specific.
|
||||
.LP
|
||||
.BR BerValue ,
|
||||
commonly used as
|
||||
.BR struct\ berval ,
|
||||
is used to holds an arbitrary sequence of octets.
|
||||
is used to hold an arbitrary sequence of octets.
|
||||
.B bv_val
|
||||
points to
|
||||
.B bv_len
|
||||
octets.
|
||||
.B bv_val
|
||||
is not necessarly terminated by a NULL (zero) octet.
|
||||
is not necessarly terminated by a NUL (zero) octet.
|
||||
.BR ber_bvfree ()
|
||||
frees a BerValue, pointed to by bv, returned from this API. If bv
|
||||
frees a BerValue, pointed to by \fIbv\fP, returned from this API. If \fIbv\fP
|
||||
is NULL, the routine does nothing.
|
||||
.LP
|
||||
.BR ber_bvecfree ()
|
||||
frees an array of BerValues (and the array), pointed to by bvec,
|
||||
returned from this API. If bvec is NULL, the routine does nothing.
|
||||
frees an array of BerValues (and the array), pointed to by \fIbvec\fP,
|
||||
returned from this API. If \fIbvec\fP is NULL, the routine does nothing.
|
||||
.BR ber_bvecadd ()
|
||||
appends the \fIbv\fP pointer to the \fIbvec\fP array. Space for the array
|
||||
is allocated as needed. The end of the array is marked by a NULL pointer.
|
||||
.LP
|
||||
.BR ber_bvarray_free ()
|
||||
frees an array of BerValues (and the array), pointed to by \fIbvarray\fP,
|
||||
returned from this API. If \fIbvarray\fP is NULL, the routine does nothing.
|
||||
.BR ber_bvarray_add ()
|
||||
appends the contents of the BerValue pointed to by \fIbv\fP to the
|
||||
\fIbvarray\fP array. Space for the new element is allocated as needed.
|
||||
The end of the array is marked by a BerValue with a NULL bv_val field.
|
||||
.LP
|
||||
.BR ber_bvdup ()
|
||||
returns a copy of a BerValue. The routine returns NULL upon error
|
||||
(e.g. out of memory).
|
||||
(e.g. out of memory). The caller should use
|
||||
.BR ber_bvfree ()
|
||||
to deallocate the resulting BerValue.
|
||||
.BR ber_dupbv ()
|
||||
copies a BerValue from \fIsrc\fP to \fIdst\fP. If \fIdst\fP is NULL a
|
||||
new BerValue will be allocated to hold the copy. The routine returns NULL
|
||||
upon error, otherwise it returns a pointer to the copy. If \fIdst\fP is
|
||||
NULL the caller should use
|
||||
.BR ber_bvfree ()
|
||||
to deallocate the resulting BerValue, otherwise
|
||||
.BR ber_memfree ()
|
||||
should be used to deallocate the \fIdst->bv_val\fP. (The
|
||||
.BR ber_bvdup ()
|
||||
function is internally implemented as ber_dupbv(NULL, bv).
|
||||
.BR ber_bvdup ()
|
||||
is provided only for compatibility with an expired draft of the LDAP C API;
|
||||
.BR ber_dupbv ()
|
||||
is the preferred interface.)
|
||||
.LP
|
||||
.BR ber_bvstr ()
|
||||
returns a BerValue containing the string pointed to by str.
|
||||
returns a BerValue containing the string pointed to by \fIstr\fP.
|
||||
.BR ber_bvstrdup ()
|
||||
returns a BerValue containing a copy of the string pointed to by str.
|
||||
returns a BerValue containing a copy of the string pointed to by \fIstr\fP.
|
||||
.BR ber_str2bv ()
|
||||
returns a BerValue containing the string pointed to by \fIstr\fP, whose
|
||||
length may be optionally specified in \fIlen\fP. If \fIdup\fP is non-zero,
|
||||
the BerValue will contain a copy of \fIstr\fP. If \fIlen\fP is zero, the
|
||||
number of bytes to copy will be determined by
|
||||
.BR strlen (3),
|
||||
otherwise \fIlen\fP bytes will be copied. If \fIbv\fP is non-NULL, the result
|
||||
will be stored in the given BerValue, otherwise a new BerValue will be
|
||||
allocated to store the result. NOTE: Both
|
||||
.BR ber_bvstr ()
|
||||
and
|
||||
.BR ber_bvstrdup ()
|
||||
are implemented as macros using
|
||||
.BR ber_str2bv ()
|
||||
in this version of the library.
|
||||
.LP
|
||||
.B BerElement
|
||||
is an opaque structure used to maintain state information used in
|
||||
|
|
@ -101,8 +150,8 @@ encoding and decoding. BerElement structures are created using
|
|||
and
|
||||
.BR ber_init (3).
|
||||
.BR ber_free ()
|
||||
frees a BerElement pointed to by ber. If ber is NULL, the routine
|
||||
does nothing. If freebuf is zero, the internal buffer is not freed.
|
||||
frees a BerElement pointed to by \fIber\fP. If \fIber\fP is NULL, the routine
|
||||
does nothing. If \fIfreebuf\fP is zero, the internal buffer is not freed.
|
||||
.SH SEE ALSO
|
||||
.BR lber-encode (3)
|
||||
.BR lber-decode (3)
|
||||
|
|
|
|||
Loading…
Reference in a new issue