Export (0) Print
Expand All
Expand Minimize

ber_scanf function

The ber_scanf function decodes a BER element in a similar manner as sscanf_s. One important difference is that some state status data is kept with the BerElement argument so that multiple calls can be made to ber_scanf to sequentially read from the BER element. The BerElement argument should be a pointer to a BerElement returned by ber_init.

Syntax


INT ber_scanf(
  _Inout_  BerElement *pBerElement,
  _In_     PCHAR fmt,
  _In_      ...
);

Parameters

pBerElement [in, out]

Pointer to the decoded BerElement structure.

fmt [in]

Encoding format string. For more information, see Remarks section.

... [in]

Pointers to variables used to hold the values decoded as specified by the fmt argument.

Return value

On error, the function returns LBER_ERROR.

Remarks

The function interprets the bytes according to the format string fmt, and stores the results in its additional arguments. The format string contains conversion specifications used to direct the interpretation of the BER element. The format string can contain characters listed in the following table.

CharacterDescription
aOctet string. A char** argument must be supplied. Memory is allocated, filled with the contents of the octet string, zero-terminated, and the pointer to the string is stored in the argument. The returned value should be freed using ldap_memfree. The tag of the element must indicate the primitive form (constructed strings are not supported), but is otherwise ignored and discarded during the decoding. This format cannot be used with octet strings which could contain null bytes.
OOctet string. A berval** argument must be supplied, which upon return points to an allocated berval that contains the octet string and its length. ber_bvfree should be called to free the allocated memory. The tag of the element must indicate the primitive form (constructed strings are not supported), but is otherwise ignored during the decoding.
bBoolean. A pointer to a ber_int_t must be supplied. The ber_int_t value stored will be 0 for FALSE or nonzero for TRUE. The tag of the element must indicate the primitive form, but is otherwise ignored during the decoding.
eEnumerated. A pointer to a ber_int_t must be supplied. The tag of the element must indicate the primitive form but is otherwise ignored during the decoding. ber_scanf will return an error if the value of the enumerated value cannot be stored in a ber_int_t.
iInteger. A pointer to a ber_int_t must be supplied. The tag of the element must indicate the primitive form, but is otherwise ignored during decoding. ber_scanf will return an error if the integer cannot be stored in a ber_int_t.
BBitstring. A char** argument must be supplied which will point to the allocated bits, followed by a ber_len_t * argument, which will point to the length (in bits) of the bitstring returned. ldap_memfree should be called to free the bitstring. The tag of the element must indicate the primitive form (constructed bitstrings are not supported), but is otherwise ignored during the decoding.
nNull. No argument is required. The element is verified to have a zero-length value and is skipped. The tag is ignored.
tTag. A pointer to a ber_tag_t must be supplied. The ber_tag_t value stored will be the tag of the next element in the pBerElement, represented so it can be written using the t format of ber_printf. The decoding position within the pBerElement argument is unchanged by this.
vSeveral octet strings. A char*** argument must be supplied, which upon return points to an allocated null-terminated array of char *'s that contain the octet strings. NULL is stored if the sequence is empty. ldap_memfree should be called to free each element of the array and the array itself. The tag of the sequence and of the octet strings are ignored.
VSeveral octet strings (which could contain null bytes). A berval*** must be supplied, which upon return points to an allocated NULL-terminated array of berval*'s containing the octet strings and their lengths. NULL is stored if the sequence is empty. ber_bvecfree can be called to free the allocated memory. The tag of the sequence and of the octet strings are ignored.
xSkip element. The next element is skipped. No argument is required.
{Begin sequence. No argument is required. The initial sequence tag and length are skipped.
}End sequence. No argument is required.
[Begin set. No argument is required. The initial set tag and length are skipped.
]End set. No argument is required.

 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Winber.h

Library

Wldap32.lib

DLL

Wldap32.dll

See also

Functions
berval
BerElement
ber_printf

 

 

Show:
© 2014 Microsoft