1LBER_DECODE(3) Library Functions Manual LBER_DECODE(3)
2
3
4
6 ber_get_next, ber_skip_tag, ber_peek_tag, ber_scanf, ber_get_int,
7 ber_get_enum, ber_get_stringb, ber_get_stringa, ber_get_stringal,
8 ber_get_stringbv, ber_get_null, ber_get_boolean, ber_get_bitstring,
9 ber_first_element, ber_next_element - OpenLDAP LBER simplified Basic
10 Encoding Rules library routines for decoding
11
13 OpenLDAP LBER (liblber, -llber)
14
16 #include <lber.h>
17
18 ber_tag_t ber_get_next(Sockbuf *sb, ber_len_t *len, BerElement *ber);
19
20 ber_tag_t ber_skip_tag(BerElement *ber, ber_len_t *len);
21
22 ber_tag_t ber_peek_tag(BerElement *ber, ber_len_t *len);
23
24 ber_tag_t ber_scanf(BerElement *ber, const char *fmt, ...);
25
26 ber_tag_t ber_get_int(BerElement *ber, ber_int_t *num);
27
28 ber_tag_t ber_get_enum(BerElement *ber, ber_int_t *num);
29
30 ber_tag_t ber_get_stringb(BerElement *ber, char *buf, ber_len_t *len);
31
32 ber_tag_t ber_get_stringa(BerElement *ber, char **buf);
33
34 ber_tag_t ber_get_stringal(BerElement *ber, struct berval **bv);
35
36 ber_tag_t ber_get_stringbv(BerElement *ber, struct berval *bv, int
37 alloc);
38
39 ber_tag_t ber_get_null(BerElement *ber);
40
41 ber_tag_t ber_get_boolean(BerElement *ber, ber_int_t *bool);
42
43 ber_tag_t ber_get_bitstringa(BerElement *ber, char **buf, ber_len_t
44 *blen);
45
46 ber_tag_t ber_first_element(BerElement *ber, ber_len_t *len, char
47 **cookie);
48
49 ber_tag_t ber_next_element(BerElement *ber, ber_len_t *len, const char
50 *cookie);
51
53 These routines provide a subroutine interface to a simplified implemen‐
54 tation of the Basic Encoding Rules of ASN.1. The version of BER these
55 routines support is the one defined for the LDAP protocol. The encod‐
56 ing rules are the same as BER, except that only definite form lengths
57 are used, and bitstrings and octet strings are always encoded in primi‐
58 tive form. This man page describes the decoding routines in the lber
59 library. See lber-encode(3) for details on the corresponding encoding
60 routines. Consult lber-types(3) for information about types, alloca‐
61 tors, and deallocators.
62
63 Normally, the only routines that need to be called by an application
64 are ber_get_next() to get the next BER element and ber_scanf() to do
65 the actual decoding. In some cases, ber_peek_tag() may also need to be
66 called in normal usage. The other routines are provided for those
67 applications that need more control than ber_scanf() provides. In gen‐
68 eral, these routines return the tag of the element decoded, or
69 LBER_ERROR if an error occurred.
70
71 The ber_get_next() routine is used to read the next BER element from
72 the given Sockbuf, sb. It strips off and returns the leading tag,
73 strips off and returns the length of the entire element in len, and
74 sets up ber for subsequent calls to ber_scanf() et al to decode the
75 element. See lber-sockbuf(3) for details of the Sockbuf implementation
76 of the sb parameter.
77
78 The ber_scanf() routine is used to decode a BER element in much the
79 same way that scanf(3) works. It reads from ber, a pointer to a
8