ber_printf (Compact 2013)
3/26/2014
This function is used to encode a basic encoding rules (BER) element in much the same way that sprintf works. One important difference, though, is that state information is kept in the pBerElement argument so that multiple calls can be made to ber_printf to append to the end of the BER element. The pBerElement argument passed to this function must be a pointer to a BerElement structure returned by a call to the ber_alloc_t function.
Syntax
INT ber_printf(
BerElement* pBerElement,
UNICODE PTCHAR fmt,
...
);
Parameters
- pBerElement
[in, out] Pointer to the BerElement structure being encoded.
- fmt
[in] Encoding format string (see the Remarks section below).
- ...
[in] Values to be encoded as specified by the fmt argument.
Return Value
This function returns a non-negative number on success and -1 on failure.
Remarks
The following table shows the format characters that the format string can contain.
Value |
Description |
---|---|
t |
Tag. The next argument is a ber_tag_t specifying the tag to override the next element to be written to the BerElement. This works across calls. |
b |
Boolean. The next argument is a ber_int_t, containing either 0 for FALSE or 0xff for TRUE. A Boolean element is output. If this format character is not preceded by the t format modifier, the tag 0x01U is used for the element. |
e |
Enumerated. The next argument is a ber_int_t, containing the enumerated value. An enumerated element is output. If this format character is not preceded by the t format modifier, the tag 0x0AU is used for the element. |
i |
Integer. The next argument is a ber_int_t, containing the integer value. An integer element is output. If this format character is not preceded by the t format modifier, the tag 0x02U is used for the element. |
B |
Bitstring. The next two arguments are a char* pointer to the start of the bitstring, followed by a ber_len_t containing the number of bits in the bitstring. A bitstring element is output. If this format character is not preceded by the t format modifier, the tag 0x03U is used for the element. |
n |
Null. No argument is needed. An ASN.1 NULL element is output. If this format character is not preceded by the t format modifier, the tag 0x05U is used for the element. |
o |
Octet string. The next two arguments are a char* pointer, followed by a ber_len_t with the length of the string. The string may contain null bytes and do not have to be zero-terminated. An octet string element is output. If this format character is not preceded by the t format modifier, the tag 0x04U is used for the element. |
s |
Octet string. The next argument is a char* pointing to a zero-terminated string. An octet string element is output, which does not include the trailing '\0' (null) byte. If this format character is not preceded by the t format modifier, the tag 0x04U is used for the element. |
v |
Several octet strings. The next argument is a char **, which is an array of char* pointers to zero-terminated strings. The last element in the array must be a NULL pointer. The octet strings do not include the trailing '\0' (null) byte.
Note:
A construct like {v} is used to get an actual SEQUENCE OF octet strings. The t format modifier cannot be used with this format character.
|
V |
Several octet strings. A NULL-terminated array of berval*structures is supplied.
Note:
A construct like {V} is used to get an actual SEQUENCE OF octet strings. The t format modifier cannot be used with this format character.
|
{ |
Begin sequence. No argument is needed. If this format character is not preceded by the t format modifier, the tag 0x30U is used. |
} |
End sequence. No argument is needed. The t format modifier cannot be used with this format character. |
[ |
Begin set. No argument is needed. If this format character is not preceded by the t format modifier, the tag 0x31U is used. |
] |
End set. No argument is needed. The t format modifier cannot be used with this format character. |
Each use of a '{' format character must be matched by a '}' character, either later in the format string, or in the format string of a subsequent call to ber_printf for that specific BerElement. The same applies to the [and] format characters.
Requirements
Header |
winber.h |
Library |
wldap32.lib |
See Also
Reference
Other LDAP Functions
ber_alloc_t
ber_scanf
BerElement
berval