Header file

All of the sample programs reference the sample header file, example.h, the contents of which are as follows:

/*
 ** example.h
 **
 ** This is the header file that goes with the 
 ** Sybase Client-Library sample programs. 
 **
 **
 */
 
 /*
 ** Define symbolic names, constants, and macros
 */
 #define EX_MAXSTRINGLEN     255
 #define EX_BUFSIZE          1024
 #define EX_CTLIB_VERSION    CS_CURRENT_VERSION
 #define EX_BLK_VERSION      BLK_VERSION_155
 #define EX_ERROR_OUT        stderr
 
 /*
 ** exit status values
 */
 #define  EX_EXIT_SUCCEED 0
 #define  EX_EXIT_FAIL 1
 
 /*
 ** Define global variables used in all sample
 ** programs
 */
 #define EX_SERVER           NULL/* use DSQUERY
                                   env var */
 #define EX_USERNAME         "sa"
 #define EX_PASSWORD         ""

The sample programs make use of the define statements in example.h as illustrated in the following fragments:

 CS_CHAR *Ex_username = EX_USERNAME;
 CS_CHAR *Ex_password = EX_PASSWORD;
 
 /* 
 ** If a user name is defined, set the 
 ** CS_USERNAME property.
 */
 if (retcode == CS_SUCCEED && Ex_username != NULL)
 {
     if ((retcode = ct_con_props(*connection,
         CS_SET, CS_USERNAME, Ex_username,
         CS_NULLTERM, NULL)) != CS_SUCCEED)
     {
         ex_error("ct_con_props(username) failed");
     }
 }
 
 /*  
 ** If a password is defined, set the 
 ** CS_PASSWORD property.
 */
 if (retcode == CS_SUCCEED && Ex_password != NULL)
 {
     if ((retcode = ct_con_props(*connection,
         CS_SET, CS_PASSWORD, Ex_password,
         CS_NULLTERM, NULL)) != CS_SUCCEED)
     {
         ex_error("ct_con_props(password) failed");
     }
 }

EX_USERNAME is defined in example.h as “sa.” Before running the sample programs, edit example.h to change “sa” to your server login name.

EX_PASSWORD is defined in example.h as a null (“ ”) string. Before running the sample programs, you may want to edit example.h and change the null (“ ”) string to your server password.

There are three options regarding EX_PASSWORD. Choose the one that best meets your needs: