Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 17 Data Types and Structures

ldap_thread_fns

The ldap_thread_fns structure contains a set of pointers to functions that you want to use when write a multithreaded client.

The ldap_thread_fns structure is defined as follows:

struct ldap_thread_fns {
   LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc;
   LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free;
   LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock;
   LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock;
   LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno;
   LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno;
   LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno;
   LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno;
   void *ltf_lderrno_arg;
};
The fields in this structure are described below:

ltf_mutex_alloc

Function pointer for allocating a mutex. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_ALLOC_CALLBACK.

ltf_mutex_free

Function pointer for freeing a mutex. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_FREE_CALLBACK.

ltf_mutex_lock

Function pointer for locking critical sections of code. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_LOCK_CALLBACK.

ltf_mutex_unlock

Function pointer for unlocking critical sections of code. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_UNLOCK_CALLBACK.

ltf_get_errno

Function pointer for getting the value of the errno variable. This function is called by the client when needed if the function pointer is not NULL.

In a threaded environment, errno is typically redefined so that it has a value for each thread, rather than a global value for the entire process. This redefinition is done at compile time. Because the libldap library does not know what method your code and threading environment will use to get the value of errno for each thread, it calls this function to obtain the value of errno.

The function must have the prototype specified by LDAP_TF_GET_ERRNO_CALLBACK.

ltf_set_errno

Function pointer for setting the value of the errno variable. This function is called by the client when needed if the function pointer is not NULL.

In a threaded environment, errno is typically redefined so that it has a value for each thread, rather than a global value for the entire process. This redefinition is done at compile time. Because the libldap library does not know what method your code and threading environment will use to get the value of errno for each thread, it calls this function to set the value of errno.

The function must have the prototype specified by LDAP_TF_SET_ERRNO_CALLBACK.

ltf_get_lderrno

Function pointer for getting error values from calls to functions in the libldap library. This function is called by the client as needed if the function pointer isn't NULL.

If this function pointer is not set, the libldap library records these errors in fields in the LDAP structure.

The function must have the prototype specified by LDAP_TF_GET_LDERRNO_CALLBACK.

ltf_set_lderrno

Function pointer for setting error values from calls to functions in the libldap library. This function is called by the client as needed if the function pointer isn't NULL.

If this function pointer is not set, the libldap library records these errors in fields in the LDAP structure.

The function must have the prototype specified by LDAP_TF_SET_LDERRNO_CALLBACK.

ltf_lderrno_arg

Additional parameter passed to the functions for getting and setting error values from calls to functions in the libldap library. (*ltf_get_lderrno) and (*ltf_set_lderrno) identify these functions.

For an example of setting up the ldap_thread_fns structure, see Chapter 16, "Writing Multithreaded Clients."


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:05:28