ct_exit

Description

Exit Client-Library.

Syntax

CS_RETCODE ct_exit(context, option)
 
CS_CONTEXT    *context;
CS_INT                option;

Parameters

context

A pointer to a CS_CONTEXT structure.

context identifies the Client-Library context being exited.

option

ct_exit can behave in different ways, depending on the value specified for option. The following symbolic values are legal for option:

Value of option

Result

CS_UNUSED

ct_exit closes all open connections for which no results are pending and terminates Client-Library for this context. If results are pending on one or more connections, ct_exit returns CS_FAIL and does not terminate Client-Library.

CS_FORCE_EXIT

ct_exit closes all open connections for this context, whether or not any results are pending, and terminates Client-Library for this context.

To properly exit Client-Library, wait until all asynchronous operations are complete, then call ct_exit.

If an asynchronous operation is in progress when ct_exit is called, the routine returns CS_FAIL and does not exit Client-Library properly, even when CS_FORCE_EXIT is used.

Returns

ct_exit returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

        /*
         ** ex_ctx_cleanup()
         **
         ** Parameters:
         **  context  Pointer to context structure.
         **  status   Status of last interaction with Client-
         **           Library.
         **           If not ok, this routine will perform a
         **           force exit.
         **
         ** Returns:
         ** Result of function calls from Client-Library.
         */
        CS_RETCODE CS_PUBLIC
         ex_ctx_cleanup(context, status)
         CS_CONTEXT*    context;
         CS_RETCODE  status;
         {
             CS_RETCODE  retcode;
             CS_INT      exit_option;
           exit_option = (status != CS_SUCCEED) ? CS_FORCE_EXIT :
                 CS_UNUSED;
             retcode = ct_exit(context, exit_option);
             if (retcode != CS_SUCCEED)
             {
                 ex_error("ex_ctx_cleanup: ct_exit() failed");
                 return retcode;
             }
             retcode = cs_ctx_drop(context);
             if (retcode != CS_SUCCEED)
             {
                 ex_error("ex_ctx_cleanup: cs_ctx_drop() failed");
                 return retcode;
             }
             return retcode;
         }

This code excerpt is from the exutils.c sample program.

Usage

See also

ct_close, ct_init