1 2 #ifndef COMMON_h 3 #define COMMON_h 4 5 #undef NDEBUG 6 7 #include <config.h> 8 9 #include <stdarg.h> 10 #include <stdio.h> 11 12 #if HAVE_UNISTD_H 13 #include <unistd.h> 14 #endif /* HAVE_UNISTD_H */ 15 16 #if HAVE_STDLIB_H 17 #include <stdlib.h> 18 #endif /* HAVE_STDLIB_H */ 19 20 #if HAVE_STRING_H 21 #include <string.h> 22 #endif /* HAVE_STRING_H */ 23 24 #ifdef DBNTWIN32 25 #include <windows.h> 26 /* fix MingW missing declare */ 27 #ifndef _WINDOWS_ 28 #define _WINDOWS_ 1 29 #endif 30 #endif 31 32 #include <sqlfront.h> 33 #include <sqldb.h> 34 35 #include <freetds/sysdep_private.h> 36 37 #if !defined(EXIT_FAILURE) 38 #define EXIT_FAILURE 1 39 #define EXIT_SUCCESS 0 40 #endif 41 42 #ifndef FREETDS_SRCDIR 43 #define FREETDS_SRCDIR FREETDS_TOPDIR "/src/dblib/unittests" 44 #endif 45 46 #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF) 47 #define snprintf _snprintf 48 #endif 49 50 #ifdef DBNTWIN32 51 /* 52 * Define Sybase's symbols in terms of Microsoft's. 53 * This allows these tests to be run using Microsoft's include 54 * files and library (libsybdb.lib). 55 */ 56 #define MSDBLIB 1 57 #define MICROSOFT_DBLIB 1 58 #define dbloginfree(l) dbfreelogin(l) 59 60 #define SYBESMSG SQLESMSG 61 #define SYBECOFL SQLECOFL 62 63 #define SYBAOPSUM SQLAOPSUM 64 #define SYBAOPMAX SQLAOPMAX 65 66 #define SYBINT4 SQLINT4 67 #define SYBDATETIME SQLDATETIME 68 #define SYBCHAR SQLCHAR 69 #define SYBVARCHAR SQLVARCHAR 70 #define SYBTEXT SQLTEXT 71 #define SYBBINARY SQLBINARY 72 #define SYBIMAGE SQLIMAGE 73 #define SYBDECIMAL SQLDECIMAL 74 75 #define dberrhandle(h) dberrhandle((DBERRHANDLE_PROC) h) 76 #define dbmsghandle(h) dbmsghandle((DBMSGHANDLE_PROC) h) 77 #endif 78 79 /* cf getopt(3) */ 80 extern char *optarg; 81 extern int optind; 82 extern int optopt; 83 extern int opterr; 84 extern int optreset; 85 86 extern char PASSWORD[512]; 87 extern char USER[512]; 88 extern char SERVER[512]; 89 extern char DATABASE[512]; 90 91 void set_malloc_options(void); 92 int read_login_info(int argc, char **argv); 93 int syb_msg_handler(DBPROCESS * dbproc, 94 DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); 95 int syb_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); 96 97 RETCODE sql_cmd(DBPROCESS *dbproc); 98 RETCODE sql_rewind(void); 99 RETCODE sql_reopen(const char *fn); 100 101 #define int2ptr(i) ((void*)(((char*)0)+(i))) 102 #define ptr2int(p) ((int)(((char*)(p))-((char*)0))) 103 104 #endif 105