1 /* 2 * 3 * iodbc.h 4 * 5 * $Id$ 6 * 7 * Configuration 8 * 9 * The iODBC driver manager. 10 * 11 * Copyright (C) 1995 Ke Jin <kejin@empress.com> 12 * Copyright (C) 1996-2021 OpenLink Software <iodbc@openlinksw.com> 13 * All Rights Reserved. 14 * 15 * This software is released under the terms of either of the following 16 * licenses: 17 * 18 * - GNU Library General Public License (see LICENSE.LGPL) 19 * - The BSD License (see LICENSE.BSD). 20 * 21 * Note that the only valid version of the LGPL license as far as this 22 * project is concerned is the original GNU Library General Public License 23 * Version 2, dated June 1991. 24 * 25 * While not mandated by the BSD license, any patches you make to the 26 * iODBC source code may be contributed back into the iODBC project 27 * at your discretion. Contributions will benefit the Open Source and 28 * Data Access community as a whole. Submissions may be made at: 29 * 30 * http://www.iodbc.org 31 * 32 * 33 * GNU Library Generic Public License Version 2 34 * ============================================ 35 * This library is free software; you can redistribute it and/or 36 * modify it under the terms of the GNU Library General Public 37 * License as published by the Free Software Foundation; only 38 * Version 2 of the License dated June 1991. 39 * 40 * This library is distributed in the hope that it will be useful, 41 * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 43 * Library General Public License for more details. 44 * 45 * You should have received a copy of the GNU Library General Public 46 * License along with this library; if not, write to the Free 47 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 48 * 49 * 50 * The BSD License 51 * =============== 52 * Redistribution and use in source and binary forms, with or without 53 * modification, are permitted provided that the following conditions 54 * are met: 55 * 56 * 1. Redistributions of source code must retain the above copyright 57 * notice, this list of conditions and the following disclaimer. 58 * 2. Redistributions in binary form must reproduce the above copyright 59 * notice, this list of conditions and the following disclaimer in 60 * the documentation and/or other materials provided with the 61 * distribution. 62 * 3. Neither the name of OpenLink Software Inc. nor the names of its 63 * contributors may be used to endorse or promote products derived 64 * from this software without specific prior written permission. 65 * 66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 67 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 68 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 69 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENLINK OR 70 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 71 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 72 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 73 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 74 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 75 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 76 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 77 */ 78 79 #ifndef _IODBC_H 80 #define _IODBC_H 81 82 #ifdef HAVE_CONFIG_H 83 #include <config.h> 84 #elif defined (__APPLE__) 85 #include "macos_config.h" 86 #endif 87 88 #ifndef VERSION 89 #define VERSION "3.52.15" 90 #define MAJ_VERSION "3" 91 #define MIN_VERSION "52" 92 #endif 93 94 #ifndef IODBC_BUILD 95 #define IODBC_BUILD 15210607 /* 0001.0928 */ 96 #endif 97 98 #if !defined(WINDOWS) && !defined(WIN32_SYSTEM) 99 #define _UNIX_ 100 101 #include <stdlib.h> 102 #include <stdio.h> 103 #include <string.h> 104 #include <sys/types.h> 105 106 #define MEM_ALLOC(size) (malloc((size_t)(size))) 107 #define MEM_FREE(ptr) {if(ptr) free(ptr);} 108 109 #define STRCPY(t, s) (strcpy((char*)(t), (char*)(s))) 110 #define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n))) 111 #define STRCAT(t, s) (strcat((char*)(t), (char*)(s))) 112 #define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n))) 113 #define STREQ(a, b) (strcmp((char*)(a), (char*)(b)) == 0) 114 #define STRNEQ(a, b, n) (strncmp((char*)(a), (char*)(b), (size_t)(n)) == 0) 115 #define STRLEN(str) ((str)? strlen((char*)(str)):0) 116 #define STRDUP(t) (strdup((char*)(t))) 117 #define STRCASEEQ(a, b) (strcasecmp((char*)(a), (char*)(b)) == 0) 118 #define STRNCASEEQ(a, b, n) (strncasecmp((char*)(a), (char*)(b), (size_t)(n)) == 0) 119 120 #define WCSCPY(t, s) (wcscpy((wchar_t*)(t), (wchar_t*)(s))) 121 #define WCSNCPY(t,s,n) (wcsncpy((wchar_t*)(t), (wchar_t*)(s), (size_t)(n))) 122 #define WCSCAT(t, s) (wcscat((wchar_t*)(t), (wchar_t*)(s))) 123 #define WCSNCAT(t,s,n) (wcsncat((wchar_t*)(t), (wchar_t*)(s), (size_t)(n))) 124 #define WCSEQ(a, b) (wcscmp((wchar_t*)(a), (wchar_t*)(b)) == 0) 125 #define WCSNEQ(a, b, n) (wcsncmp((wchar_t*)(a), (wchar_t*)(b), (size_t)(n)) == 0) 126 #define WCSLEN(str) ((str)? wcslen((wchar_t*)(str)):0) 127 #define WCSDUP(t) (wcsdup((wchar_t*)(t))) 128 #define WCSCASEEQ(a, b) (wcscasecmp((wchar_t*)(a), (wchar_t*)(b)) == 0) 129 #define WCSNCASEEQ(a, b, n) (wcsncasecmp((wchar_t*)(a), (wchar_t*)(b), (size_t)(n)) == 0) 130 131 132 #define EXPORT 133 #define CALLBACK 134 #define FAR 135 136 #ifndef WIN32 137 #define UNALIGNED 138 #endif 139 140 /* 141 * If not defined, use this as the system default odbc.ini file 142 */ 143 #if !defined(SYS_ODBC_INI) || (defined(__APPLE__) && !defined(ODBC_INI_APP)) 144 # if defined(__BEOS__) 145 # define SYS_ODBC_INI "/boot/beos/etc/odbc.ini" 146 # elif defined(_MAC) 147 # ifdef __POWERPC__ 148 # define SYS_ODBC_INI "Boot:System Folder:Preferences:ODBC Preferences PPC" 149 # else 150 # define SYS_ODBC_INI "Boot:System Folder:Preferences:ODBC Preferences" 151 # endif 152 # elif defined(__APPLE__) 153 # define SYS_ODBC_INI "/etc/odbc.ini" 154 # define ODBC_INI_APP "/Library/ODBC/odbc.ini" 155 # else 156 # define SYS_ODBC_INI "/etc/odbc.ini" 157 # endif 158 #endif 159 160 #if !defined(SYS_ODBCINST_INI) || (defined(__APPLE__) && !defined(ODBCINST_INI_APP)) 161 # if defined(__BEOS__) 162 # define SYS_ODBCINST_INI "/boot/beos/etc/odbcinst.ini" 163 # elif defined(macintosh) 164 # elif defined(__APPLE__) 165 # define SYS_ODBCINST_INI "/etc/odbcinst.ini" 166 # define ODBCINST_INI_APP "/Library/ODBC/odbcinst.ini" 167 # else 168 # define SYS_ODBCINST_INI "/etc/odbcinst.ini" 169 # endif 170 #endif 171 172 #endif /* _UNIX_ */ 173 174 #if defined(WINDOWS) || defined(WIN32_SYSTEM) 175 #include <windows.h> 176 #include <windowsx.h> 177 178 #ifdef _MSVC_ 179 #define MEM_ALLOC(size) (fmalloc((size_t)(size))) 180 #define MEM_FREE(ptr) ((ptr)? ffree((PTR)(ptr)):0) 181 #define STRCPY(t, s) (fstrcpy((char FAR*)(t), (char FAR*)(s))) 182 #define STRNCPY(t,s,n) (fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n))) 183 #define STRLEN(str) ((str)? fstrlen((char FAR*)(str)):0) 184 #define STREQ(a, b) (fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)) 185 #define STRCAT(t, s) (strcat((char*)(t), (char*)(s))) 186 #define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n))) 187 #define STRNCMP(t,s,n) (strncmp((char*)(t), (char*)(s), (size_t)(n))) 188 #endif 189 190 #ifdef _BORLAND_ 191 #define MEM_ALLOC(size) (farmalloc((unsigned long)(size))) 192 #define MEM_FREE(ptr) ((ptr)? farfree((void far*)(ptr)):0) 193 #define STRCPY(t, s) (_fstrcpy((char FAR*)(t), (char FAR*)(s))) 194 #define STRNCPY(t,s,n) (_fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n))) 195 #define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0) 196 #define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0)) 197 #define STRCAT(t, s) (strcat((char*)(t), (char*)(s))) 198 #define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n))) 199 #define STRNCMP(t,s,n) (strncmp((char*)(t), (char*)(s), (size_t)(n))) 200 #endif 201 202 #endif /* WINDOWS */ 203 204 #ifdef VMS 205 /* 206 * VMS also defines _UNIX_ above. This is OK for iODBC since all used UNIX 207 * interfaces are supported. 208 * The DEC C RTL actually supports dlopen(), etc, but I have made my own 209 * implementation that supports: 210 * - Proper error messages from dlopen() 211 * - The ability to place the driver in other directories than SYS$SHARE: 212 * - Neither implementation can do dlopen(NULL,), but my implementation 213 * will not crash in this case. 214 * To use old DEC C dlopen() implementation, remove the following define. 215 */ 216 #define DLDAPI_VMS_IODBC /* Use enhanced dlopen() */ 217 #endif 218 219 #define SYSERR (-1) 220 221 #ifndef NULL 222 #define NULL ((void *)0UL) 223 #endif 224 225 /* 226 * Map generic pointer to internal pointer 227 */ 228 #define STMT(stmt, var) \ 229 STMT_t *stmt = (STMT_t *)var 230 231 #define CONN(con, var) \ 232 DBC_t *con = (DBC_t *)var 233 234 #define GENV(genv, var) \ 235 GENV_t *genv = (GENV_t *)var 236 237 #define ENVR(env, var) \ 238 ENV_t *env = (ENV_t *)var 239 240 #define DESC(desc, var) \ 241 DESC_t *desc = (DESC_t *)var 242 243 #define NEW_VAR(type, var) \ 244 type *var = (type *)MEM_ALLOC(sizeof(type)) 245 246 247 /* these are deprecated defines from the odbc headers */ 248 #define SQL_CONNECT_OPT_DRVR_START 1000 249 250 #endif /* _IODBC_H */ 251