1 /* Copyright (C) 2000-2015 Lavtech.com corp. All rights reserved.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16 */
17 
18 #ifndef _UDM_CONFIG_H
19 #define _UDM_CONFIG_H
20 
21 #include "udm_autoconf.h"
22 
23 /* ODBC Library */
24 #if (HAVE_IODBC|| HAVE_UNIXODBC||HAVE_SOLID||HAVE_VIRT||HAVE_EASYSOFT||HAVE_SAPDB||HAVE_DB2)
25 #define HAVE_ODBC 1
26 #endif
27 
28 /* Backend */
29 #if defined (HAVE_SQLITE3_AMALGAMATION)
30 #define HAVE_SQLITE3 1
31 #endif
32 
33 #ifndef HAVE_SQL
34 #if (HAVE_ODBC||HAVE_MYSQL||HAVE_PGSQL||HAVE_IBASE||HAVE_ORACLE8||HAVE_CTLIB||HAVE_SQLITE||HAVE_SQLITE3)
35 #define HAVE_SQL 1
36 #endif
37 #endif
38 
39 /* Unix/Windows specific stuff */
40 
41 #ifdef WIN32
42 
43 #include <windows.h>
44 #define HAVE_WINDOWS_H
45 #define HAVE_IO_H
46 #define HAVE_DIRECT_H
47 #define HAVE_PROCESS_H
48 #define HAVE_WINSOCK_H
49 #define __INDLIB__		__declspec(dllexport) /* export functions for DLL  */
50 #define UDMSLASH		'\\'
51 #define UDMSLASHSTR		"\\"
52 #define UDM_TMP_DIR		"."
53 #define UDMSLEEP(x)		_sleep(x*1000)
54 #define getpid()		_getpid()
55 #define UDM_IWRITE		S_IWRITE
56 #define UDM_BINARY		O_BINARY
57 
58 #define snprintf	_snprintf
59 #define vsnprintf	_vsnprintf
60 #define lseek		_lseek
61 #define open		_open
62 #define popen		_popen
63 #define pclose	    	_pclose
64 #define read		_read
65 #define write		_write
66 #define strdup		_strdup
67 
68 typedef __int32 udmhash32_t;
69 typedef unsigned __int64 udmhash64_t;
70 typedef unsigned __int64 udm_uint8;
71 typedef unsigned __int32 uint4;
72 typedef __int32 int4;
73 typedef __int64 udm_timer_t;
74 
75 #define SDPALIGN __int64
76 
77 #ifdef __cplusplus
78   #define __C_LINK "C"
79 #else
80   #define __C_LINK
81 #endif
82 
83 #define __UDMCALL __cdecl
84 
85 #else /* WIN32 */
86 
87 #define __C_LINK
88 #define __UDMCALL
89 
90 #define UDMSLASH		'/'
91 #define UDMSLASHSTR		"/"
92 #define UDM_TMP_DIR		"/tmp"
93 #define UDMSLEEP(x)		sleep(x)
94 #define closesocket(x)		close(x)
95 #define UDM_IWRITE		0644
96 #define UDM_BINARY		0
97 
98 #if SIZEOF_SHORT == 4
99 typedef short udmhash32_t;
100 typedef unsigned short uint4;
101 typedef short int4;
102 #elif SIZEOF_INT == 4
103 typedef int udmhash32_t;
104 typedef unsigned int uint4;
105 typedef int int4;
106 #else
107 typedef long udmhash32_t;
108 typedef unsigned long uint4;
109 typedef long int4;
110 #endif
111 
112 #if SIZEOF_INT == 8
113 typedef unsigned int udmhash64_t;
114 typedef unsigned int udm_uint8;
115 #elif SIZEOF_LONG == 8
116 typedef unsigned long udmhash64_t;
117 typedef unsigned long udm_uint8;
118 #else
119 typedef unsigned long long udmhash64_t;
120 typedef unsigned long long udm_uint8;
121 #endif
122 
123 #if (SIZEOF_CHARP == SIZEOF_INT)
124 #define SDPALIGN int
125 #elif (SIZEOF_CHARP == SIZEOF_LONG)
126 #define SDPALIGN long
127 #elif (SIZEOF_CHARP == SIZEOF_SHORT)
128 #define SDPALIGN short
129 #else
130 #define SDPALIGN long long
131 #endif
132 
133 typedef unsigned long long udm_timer_t;
134 
135 
136 #endif /* WIN32 */
137 
138 #define UDM_API(x)   __C_LINK x __UDMCALL
139 
140 typedef int4 urlid_t;
141 typedef uint4 udmcrc32_t;
142 
143 #define UDM_MAX_URLID_T 0x7FFFFFFF
144 
145 #ifndef _GNU_SOURCE
146 #define _GNU_SOURCE
147 #endif
148 #ifndef __USE_GNU
149 #define __USE_GNU
150 #endif
151 
152 /* For strtok_r() */
153 #ifndef _REENTRANT
154 #define _REENTRANT
155 #endif
156 
157 #ifndef EFENCE
158 
159 #define UdmFree free
160 #define UdmRealloc realloc
161 #define UdmMalloc malloc
162 #define UdmCalloc calloc
163 #define UdmValloc valloc
164 #define UdmStrdup strdup
165 #ifdef HAVE_STRNDUP
166 #define udm_strndup strndup
167 #endif
168 
169 #else
170 #include "udm_efence.h"
171 #endif
172 
173 #ifdef USE_PARANOIA
174 extern void *UdmViolationEnter(void);
175 extern void UdmViolationExit(void *);
176 #define UdmDebugEnter()            void *paran= UdmViolationEnter();
177 #define UdmDebugReturn(rc)         {UdmViolationExit(paran);return rc;}
178 #define UdmDebugReturnVoid()       {UdmViolationExit(paran);return;}
179 #else
180 #define UdmViolationExit(x)
181 #define UdmDebugEnter()           /* UdmDebugEnter() */
182 #define UdmDebugReturn(rc)        {return rc;}
183 #define UdmDebugReturnVoid()      {return;}
184 #endif
185 
186 #ifndef PATH_MAX
187 #define PATH_MAX 512
188 #endif
189 
190 #ifdef HAVE_DEBUG
191   #define UDM_ASSERT(x)  assert(x)
192   #ifdef HAVE_PTHREAD
193     #ifdef WIN32
194     #define UDM_ASSERT_MUTEX_OWNER(x) UDM_ASSERT((x)->count >0 && (UdmThreadSelf() == (x)->thread))
195     #else
196     #define UDM_ASSERT_MUTEX_OWNER(x) UDM_ASSERT((x)->count > 0 && pthread_equal(pthread_self(),(x)->thread))
197     #endif
198   #else
199     #define UDM_ASSERT_MUTEX_OWNER(x)
200   #endif
201 #else
202   #define UDM_ASSERT(x)
203   #define UDM_ASSERT_MUTEX_OWNER(x)
204 #endif
205 
206 #ifndef __GNUC__
207 #define __attribute__(A)
208 #endif
209 
210 #ifdef __GNUC__
211 #define GCC_VERSION (__GNUC__ * 10000  + __GNUC_MINOR__ * 100  + __GNUC_PATCHLEVEL__)
212 #else
213 #define GCC_VERSION 0
214 #endif
215 
216 #if GCC_VERSION > 40600
217 #define HAVE_GCC_PRAGMA_PUSH
218 #endif
219 
220 #endif /* _UDM_CONFIG_H */
221