1LBER_ENCODE(3) Library Functions Manual LBER_ENCODE(3)
2
3
4
6 ber_alloc_t, ber_flush, ber_printf, ber_put_int, ber_put_enum,
7 ber_put_ostring, ber_put_string, ber_put_null, ber_put_boolean,
8 ber_put_bitstring, ber_start_seq, ber_start_set, ber_put_seq,
9 ber_put_set - LBER simplified Basic Encoding Rules library routines for
10 encoding
11
13 OpenLDAP LBER (liblber, -llber)
14
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_printf(BerElement *ber, const char *fmt, ...);
23
24 int ber_put_int(BerElement *ber, ber_int_t num, ber_tag_t tag);
25
26 int ber_put_enum(BerElement *ber, ber_int_t num, ber_tag_t tag);
27
28 int ber_put_ostring(BerElement *ber, const char *str, ber_len_t len,
29 ber_tag_t tag);
30
31 int ber_put_string(BerElement *ber, const char *str, ber_tag_t tag);
32
33 int ber_put_null(BerElement *ber, ber_tag_t tag);
34
35 int ber_put_boolean(BerElement *ber, ber_int_t bool, ber_tag_t tag);
36
37 int ber_put_bitstring(BerElement *ber, const char *str, ber_len_t blen,
38 ber_tag_t tag);
39
40 int ber_start_seq(BerElement *ber, ber_tag_t tag);
41
42 int ber_start_set(BerElement *ber, ber_tag_t tag);
43
44 int ber_put_seq(BerElement *ber);
45
46 int ber_put_set(BerElement *ber);
47
49 These routines provide a subroutine interface to a simplified implemen‐
50 tation of the Basic Encoding Rules of ASN.1. The version of BER these
51 routines support is the one defined for the LDAP protocol. The encod‐
52 ing rules are the same as BER, except that only definite form lengths
53 are used, and bitstrings and octet strings are always encoded in primi‐
54 tive form. This man page describes the encoding routines in the lber
55 library. See lber-decode(3) for details on the corresponding decoding
56 routines. Consult lber-types(3) for information about types, alloca‐
57 tors, and deallocators.
58
59 Normally, the only routines that need to be called by an application
60 are ber_alloc_t() to allocate a BER element for encoding, ber_printf()
61 to do the actual encoding, and ber_flush() to actually write the ele‐
62 ment. The other routines are provided for those applications that need
63 more control than ber_printf() provides. In general, these routines
64 return the length of the element encoded, or -1 if an error occurred.
65
66 The ber_alloc_t() routine is used to allocate a new BER element. It
67 should be called with an argument of LBER_USE_DER.
68
69 The ber_flush() routine is used to actually write the element to a
70 socket (or file) descriptor, once it has been fully encoded (using
71 ber_printf() and friends). See lber-sockbuf(3) for more details on the
72 Sockbuf implementation of the sb parameter. If the freeit parameter is
73 non-zero, the supplied ber will be freed after its contents have been
74 flushed.
75
76 The ber_printf() routine is used to encode a BER element in much the
77 same way that sprintf(3) works. One important difference, though, is
78 that some state information is kept with the ber parameter so that mul‐
79 tiple calls can be mad