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