ct_callback

Description

Install or retrieve a Client-Library callback routine.

Syntax

CS_RETCODE ct_callback(context, connection,
 action, type, func)
 
 CS_CONTEXT          *context;
 CS_CONNECTION   *connection;
 CS_INT                     action;
 CS_INT                      type;
 CS_VOID                   *func;

Parameters

context

A pointer to a CS_CONTEXT structure. A CS_CONTEXT structure defines a Client-Library application context.

Either context or connection must be NULL:

connection

A pointer to a CS_CONNECTION structure. A CS_CONNECTION structure contains information about a particular client/server connection.

Either context or connection must be NULL:

action

One of the following symbolic values:

Value of action

Meaning

CS_SET

Installs a callback

CS_GET

Retrieves the currently installed callback of this type

type

The type of callback routine of interest. The following table lists the symbolic values for type:

Table 3-2: Values for ct_callback type parameter

Value of type

Meaning

CS_CLIENTMSG_CB

A client message callback, as described in “Client message callbacks”.

CS_COMPLETION_CB

A completion callback, as described in “Completion callbacks”.

CS_DS_LOOKUP_CB

A directory callback, as described in “Directory callbacks”.

CS_ENCRYPT_CB

An encryption callback, as described in “Encryption callbacks”.

CS_CHALLENGE_CB

A negotiation callback, as described in “Negotiation callbacks”.

CS_NOTIF_CB

A registered procedure notification callback, as described in “Notification callbacks”.

CS_SECSESSION_CB

A security session callback, as described in “Security session callbacks”.

CS_SERVERMSG_CB

A server message callback, as described in “Server message callbacks”.

CS_SIGNAL_CB + signal_number

A signal callback, as described in “Signal callbacks”.

Signal callbacks are identified by adding the signal number of interest to the manifest constant CS_SIGNAL_CB. For example, to install a signal callback for a SIGALRM signal, pass type as CS_SIGNAL_CB + SIGALRM.

func

A pointer variable.

If a callback routine is being installed, func is the address of the callback routine to install.

If a callback routine is being retrieved, ct_callback sets *func to the address of the currently installed callback routine.

Returns

ct_callback returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_BUSY

An asynchronous operation is already pending for this connection. For more information, see “Asynchronous programming”.

Examples

Example 1

          /*
           ** Install message and completion handlers.
           */
           retstat = ct_callback(Ex_context, NULL, CS_SET,
                CS_CLIENTMSG_CB,(CS_VOID *)ex_clientmsg_cb);
           if (retstat != CS_SUCCEED)
           {
                ex_panic("ct_callback failed");
           }
           retstat = ct_callback(Ex_context, NULL, CS_SET,
                CS_SERVERMSG_CB,(CS_VOID *)ex_servermsg_cb);
           if (retstat != CS_SUCCEED)
           {
                ex_panic("ct_callback failed");
           }
          retstat = ct_callback(Ex_context, NULL, CS_SET,
                CS_COMPLETION_CB,(CS_VOID *)CompletionCB);
           if (retstat != CS_SUCCEED)
           {
                ex_panic("ct_callback failed");
           }

This code excerpt is from the ex_amain.c example program. For additional examples of using ct_callback, see the ex_alib.c and exutils.c example programs.

Usage

See also

“Callbacks”, ct_capability, ct_config, ct_con_props, ct_connect