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:
Change your server password to a null (“ ”) string while you are running the samples. This creates the possibility of a security breach, because while your password is set to this published value, an unauthorized person might take the opportunity to log in to the server as you. If this is a problem, choose one of the other methods of handling passwords for the sample programs.
In example.h, change the null (“ ”) string to your own server password. Use the operating system’s protection mechanisms to prevent others from accessing the header file while you are using it. When you are finished with the samples, edit the line so that it again says “server_password.”
In the sample programs, modify the ct_con_props code that sets the server password—substitute your own code to prompt users of the samples for their server passwords. Because this code is platform-specific, Sybase does not supply it.