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