21 printf(
"%d: row type %s bind len %d\n", line, vartype_name,
bind_len);
24 fprintf(stderr,
"error: dbcmd\n");
30 fprintf(stderr,
"error: expected a result set, none returned.\n");
34 memset(
str,
'$',
sizeof(
str));
37 fprintf(stderr,
"Had problem with bind\n");
41 fprintf(stderr,
"Failed. Expected a row\n");
48 char *p = strchr(
str,
'$');
52 char *p = strchr(
str, 0);
55 for (;
i <
sizeof(
str)-1; ++
i) {
60 printf(
"str '%s'\n",
str);
62 fprintf(stderr,
"Expected '%s' string\n",
expected);
67 fprintf(stderr,
"Was expecting no more rows\n");
73 #define row(bind, expected) test_row(bind, #bind, expected, __LINE__)
76 main(
int argc,
char **argv)
84 printf(
"Starting %s\n", argv[0]);
91 printf(
"About to logon as \"%s\"\n",
USER);
98 printf(
"About to open \"%s\"\n",
SERVER);
102 fprintf(stderr,
"Unable to connect to %s\n",
SERVER);
CS_RETCODE read_login_info(void)
int syb_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
int syb_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line)
void set_malloc_options(void)
static const char * expected[]
static const char * str(char *buf, int n)
#define DBSETLPWD(x, y)
Set the password in the login packet.
#define DBSETLAPP(x, y)
Set the (client) application name in the login packet.
#define DBSETLUSER(x, y)
Set the username in the login packet.
LOGINREC * dblogin(void)
Allocate a LOGINREC structure.
RETCODE dbresults(DBPROCESS *dbproc)
Set up query results.
RETCODE dbinit(void)
Initialize db-lib.
RETCODE dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
Tie a host variable to a resultset column.
RETCODE dbcmd(DBPROCESS *dbproc, const char cmdstring[])
Append SQL to the command buffer.
RETCODE dbsqlexec(DBPROCESS *dbproc)
send the SQL command to the server and wait for an answer.
EHANDLEFUNC dberrhandle(EHANDLEFUNC handler)
Set an error handler, for messages from db-lib.
void dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr)
Associate client-allocated (and defined) data with a DBPROCESS.
void dbloginfree(LOGINREC *login)
free the LOGINREC
void dbexit()
Close server connections and free all related structures.
MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler)
Set a message handler, for messages from the server.
void dbclose(DBPROCESS *dbproc)
Close a connection to the server and free associated resources.
int strcmp(const char *str1, const char *str2)
static DBPROCESS * dbproc
#define row(bind, expected)
int main(int argc, char **argv)
static int expected_error
static void test_row(int vartype, const char *vartype_name, const char *expected, int line)
static const char * select_cmd