The LDAP API defines various data structures which are used to
pass information to and from a client application. Some of these
structures are opaque; that is, their internal layout is not
visible to a client application. In such cases, the API may
return a pointer to such a structure, but the only use of such
a pointer to a client application is as a parameter to subsequent
library calls.
Some structures are public. Their contents are defined by the
API, and client applications may allocate and manipulate such
structures or use them as parameters to LDAP functions.
All data structures used by the API are defined with "natural"
alignment; that is, each member of a data structure will be
aligned on an address boundary appropriate to its type.
Opaque Data Structures
The following data structures are opaque. Applications should
not make any assumptions about the contents or size of such data
structures.
typedef struct ldap
LDAP;
typedef struct ldapmsg
LDAPMessage;
typedef struct berelement
BerElement;
Public Data Structures
The following data structures are described in the IETF documents
relating to the LDAP API, and definitions are provided for
them in LDAP.H. Applications may allocate and manipulate such
structures, as well as use them in calls to the LDAP API.
typedef struct berval { .. }
BerValue;
typedef struct ldapapiinfo { .. }
LDAPAPIInfo;
typedef struct ldap_apifeature_info { .. }
LDAPAPIFeatureInfo;
typedef struct ldapcontrol { .. }
LDAPControl;
typedef struct ldapmod { .. }
LDAPMod;
Note that the pointer size in effect at compilation time
determines the layout of data structures, which themselves
contain pointer fields. Since all of the public data structures
listed here contain one or more pointers, their size and layout
will differ depending on the pointer size.
For example, in the case of the structure berval, the API
provides the following definition:
struct berval {
ber_len_t bv_len;
char *bv_val;
} BerValue;
(where ber_len_t is equivalent on OpenVMS to an unsigned 32-bit
integer).
The following code would therefore work correctly regardless of
pointer size:
#include <ldap.h>
.
.
.
char *buff;
BerValue val;
.
.
.
buff = (char *)malloc(255);
.
.
.
val.bv_len = 255;
val.bv_val = buff;
.
.
.