Exits Client-Library.
CS_RETCODE ct_exit (context, option); CS_CONTEXT *context CS_INT option;
(I) A context structure. The context structure is defined in the program call cs_ctx_alloc. This value identifies the Client-Library context being exited.
If this value is invalid or nonexistent, ct_exit fails.
(O) Indicator specifying whether or not ct_exit closes connections for which results are pending.
ct_exit can behave in different ways, depending on the value specified for option. The following table lists the symbolic values that are legal for option:
OPTION value |
ct_exit action |
---|---|
CS_UNUSED (-99999) |
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 (300) |
Closes all open connections for this context, whether or not any results are pending, and terminates Client-Library for this context. |
ct_exit returns one of the following values:
Value |
Meaning |
---|---|
CS_SUCCEED (-1) |
The routine completed successfully. |
CS_FAIL (-2) |
The routine failed. |
TDS_INVALID_PARAMETER (-4) |
A parameter contains an illegal value. |
TDS_RESULTS_STILL_ACTIVE (-50) |
Some results are still pending. |
TDS_CONNECTION_TERMINATED (4997) |
The connection is not active. |
TDS_WRONG_STATE (-6) |
Program is in the wrong communication state to issue this call. |
The following code fragment demonstrates the use of ct_exit. It is taken from the sample program SYCTSAA6 in Appendix A, “Sample Language Application.”
/********************************************************************/ /* */ /* Subroutine to perform exit client library and deallocate context */ /* structure. */ /* */ /********************************************************************/ void quit_client_library () { CS_INT rc; /*------------------------------------------------------------------*/ /* Exit the Client Library */ /*------------------------------------------------------------------*/ rc = ct_exit (context, (long) CS_UNUSED); if (rc == CS_FAIL) { strncpy (msgstr, "CT_EXIT failed", msg_size); error_out(rc) ; } /*------------------------------------------------------------------*/ /* De-allocate the context structure */ /*------------------------------------------------------------------*/ rc = cs_ctx_drop (context); if (rc == CS_FAIL) { strncpy (msgstr, "CT_CTX_DROP failed", msg_size); error_out(rc) ; } EXEC CICS RETURN ; } /* end quit_client_library */
ct_exit terminates a Client-Library context. It closes all open connections, deallocates internal data space and cleans up any platform-specific initialization.
ct_exit must be the last Client-Library routine called within a Client-Library context.
If an application needs to call Client-Library routines after it calls ct_exit, it can re-initialize Client-Library by calling ct_init again.
If results are pending on any of the context connections and option is not passed as CS_FORCE_EXIT, ct_exit returns CS_FAIL. This means that Client-Library is not correctly terminated. The application must handle the pending results before calling ct_exit, or it can call ct_exit again, specifying CS_FORCE_EXIT.
To close a single connection, an application calls ct_close.
If ct_init is called for a context, the application must call ct_exit before it calls cs_ctx_drop to deallocate the context.
Related functions