1LBER_ENCODE(3)             Library Functions Manual             LBER_ENCODE(3)
2
3
4

NAME

6       ber_alloc_t,    ber_flush,    ber_flush2,    ber_printf,   ber_put_int,
7       ber_put_enum,    ber_put_ostring,     ber_put_string,     ber_put_null,
8       ber_put_boolean,   ber_put_bitstring,   ber_start_seq,   ber_start_set,
9       ber_put_seq, ber_put_set -  OpenLDAP  LBER  simplified  Basic  Encoding
10       Rules library routines for encoding
11

LIBRARY

13       OpenLDAP LBER (liblber, -llber)
14

SYNOPSIS

16       #include <lber.h>
17
18       BerElement *ber_alloc_t(int options);
19
20       int ber_flush(Sockbuf *sb, BerElement *ber, int freeit);
21
22       int ber_flush2(Sockbuf *sb, BerElement *ber, int freeit);
23
24       int ber_printf(BerElement *ber, const char *fmt, ...);
25
26       int ber_put_int(BerElement *ber, ber_int_t num, ber_tag_t tag);
27
28       int ber_put_enum(BerElement *ber, ber_int_t num, ber_tag_t tag);
29
30       int  ber_put_ostring(BerElement  *ber,  const char *str, ber_len_t len,
31       ber_tag_t tag);
32
33       int ber_put_string(BerElement *ber, const char *str, ber_tag_t tag);
34
35       int ber_put_null(BerElement *ber, ber_tag_t tag);
36
37       int ber_put_boolean(BerElement *ber, ber_int_t bool, ber_tag_t tag);
38
39       int ber_put_bitstring(BerElement *ber, const char *str, ber_len_t blen,
40       ber_tag_t tag);
41
42       int ber_start_seq(BerElement *ber, ber_tag_t tag);
43
44       int ber_start_set(BerElement *ber, ber_tag_t tag);
45
46       int ber_put_seq(BerElement *ber);
47
48       int ber_put_set(BerElement *ber);
49

DESCRIPTION

51       These routines provide a subroutine interface to a simplified implemen‐
52       tation of the Basic Encoding Rules of ASN.1.  The version of BER  these
53       routines  support is the one defined for the LDAP protocol.  The encod‐
54       ing rules are the same as BER, except that only definite  form  lengths
55       are used, and bitstrings and octet strings are always encoded in primi‐
56       tive form.  This man page describes the encoding routines in  the  lber
57       library.   See lber-decode(3) for details on the corresponding decoding
58       routines.  Consult lber-types(3) for information about  types,  alloca‐
59       tors, and deallocators.
60
61       Normally,  the  only  routines that need to be called by an application
62       are ber_alloc_t() to allocate a BER element for encoding,  ber_printf()
63       to  do the actual encoding, and ber_flush2() to actually write the ele‐
64       ment.  The other routines are provided for those applications that need
65       more  control  than  ber_printf() provides.  In general, these routines
66       return the length of the element encoded, or -1 if an error occurred.
67
68       The ber_alloc_t() routine is used to allocate a new  BER  element.   It
69       should be called with an argument of LBER_USE_DER.
70
71       The  ber_flush2()  routine  is  used to actually write the element to a
72       socket (or file) descriptor, once it  has  been  fully  encoded  (using
73       ber_printf() and friends).  See lber-sockbuf(3) for more details on the
74       Sockbuf implementation of the sb parameter.  If the freeit parameter is
75       non-zero,  the  supplied ber will be freed.  If LBER_FLUSH_FREE_ON_SUC‐
76       CESS is used, the ber is only freed when successfully  flushed,  other‐
77       wise it is left intact; if LBER_FLUSH_FREE_ON_ERROR is used, the ber is
78       only freed when an error  occurs,  otherwise  it  is  left  intact;  if
79