iodbc.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. *
  3. * iodbc.h
  4. *
  5. * $Id$
  6. *
  7. * Configuration
  8. *
  9. * The iODBC driver manager.
  10. *
  11. * Copyright (C) 1995 Ke Jin <[email protected]>
  12. * Copyright (C) 1996-2021 OpenLink Software <[email protected]>
  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. #ifndef _IODBC_H
  79. #define _IODBC_H
  80. #ifdef HAVE_CONFIG_H
  81. #include <config.h>
  82. #elif defined (__APPLE__)
  83. #include "macos_config.h"
  84. #endif
  85. #ifndef VERSION
  86. #define VERSION "3.52.15"
  87. #define MAJ_VERSION "3"
  88. #define MIN_VERSION "52"
  89. #endif
  90. #ifndef IODBC_BUILD
  91. #define IODBC_BUILD 15210705 /* 0001.0928 */
  92. #endif
  93. #if !defined(WINDOWS) && !defined(WIN32_SYSTEM)
  94. #define _UNIX_
  95. #include <stdlib.h>
  96. #include <stdio.h>
  97. #include <string.h>
  98. #include <sys/types.h>
  99. #define MEM_ALLOC(size) (malloc((size_t)(size)))
  100. #define MEM_FREE(ptr) {if(ptr) free(ptr);}
  101. #define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
  102. #define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))
  103. #define STRCAT(t, s) (strcat((char*)(t), (char*)(s)))
  104. #define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n)))
  105. #define STREQ(a, b) (strcmp((char*)(a), (char*)(b)) == 0)
  106. #define STRNEQ(a, b, n) (strncmp((char*)(a), (char*)(b), (size_t)(n)) == 0)
  107. #define STRLEN(str) ((str)? strlen((char*)(str)):0)
  108. #define STRDUP(t) (strdup((char*)(t)))
  109. #define STRCASEEQ(a, b) (strcasecmp((char*)(a), (char*)(b)) == 0)
  110. #define STRNCASEEQ(a, b, n) (strncasecmp((char*)(a), (char*)(b), (size_t)(n)) == 0)
  111. #define WCSCPY(t, s) (wcscpy((wchar_t*)(t), (wchar_t*)(s)))
  112. #define WCSNCPY(t,s,n) (wcsncpy((wchar_t*)(t), (wchar_t*)(s), (size_t)(n)))
  113. #define WCSCAT(t, s) (wcscat((wchar_t*)(t), (wchar_t*)(s)))
  114. #define WCSNCAT(t,s,n) (wcsncat((wchar_t*)(t), (wchar_t*)(s), (size_t)(n)))
  115. #define WCSEQ(a, b) (wcscmp((wchar_t*)(a), (wchar_t*)(b)) == 0)
  116. #define WCSNEQ(a, b, n) (wcsncmp((wchar_t*)(a), (wchar_t*)(b), (size_t)(n)) == 0)
  117. #define WCSLEN(str) ((str)? wcslen((wchar_t*)(str)):0)
  118. #define WCSDUP(t) (wcsdup((wchar_t*)(t)))
  119. #define WCSCASEEQ(a, b) (wcscasecmp((wchar_t*)(a), (wchar_t*)(b)) == 0)
  120. #define WCSNCASEEQ(a, b, n) (wcsncasecmp((wchar_t*)(a), (wchar_t*)(b), (size_t)(n)) == 0)
  121. #define EXPORT
  122. #define CALLBACK
  123. #define FAR
  124. #ifndef WIN32
  125. #define UNALIGNED
  126. #endif
  127. /*
  128. * If not defined, use this as the system default odbc.ini file
  129. */
  130. #if !defined(SYS_ODBC_INI) || (defined(__APPLE__) && !defined(ODBC_INI_APP))
  131. # if defined(__BEOS__)
  132. # define SYS_ODBC_INI "/boot/beos/etc/odbc.ini"
  133. # elif defined(_MAC)
  134. # ifdef __POWERPC__
  135. # define SYS_ODBC_INI "Boot:System Folder:Preferences:ODBC Preferences PPC"
  136. # else
  137. # define SYS_ODBC_INI "Boot:System Folder:Preferences:ODBC Preferences"
  138. # endif
  139. # elif defined(__APPLE__)
  140. # define SYS_ODBC_INI "/etc/odbc.ini"
  141. # define ODBC_INI_APP "/Library/ODBC/odbc.ini"
  142. # else
  143. # define SYS_ODBC_INI "/etc/odbc.ini"
  144. # endif
  145. #endif
  146. #if !defined(SYS_ODBCINST_INI) || (defined(__APPLE__) && !defined(ODBCINST_INI_APP))
  147. # if defined(__BEOS__)
  148. # define SYS_ODBCINST_INI "/boot/beos/etc/odbcinst.ini"
  149. # elif defined(macintosh)
  150. # elif defined(__APPLE__)
  151. # define SYS_ODBCINST_INI "/etc/odbcinst.ini"
  152. # define ODBCINST_INI_APP "/Library/ODBC/odbcinst.ini"
  153. # else
  154. # define SYS_ODBCINST_INI "/etc/odbcinst.ini"
  155. # endif
  156. #endif
  157. #endif /* _UNIX_ */
  158. #if defined(WINDOWS) || defined(WIN32_SYSTEM)
  159. #include <windows.h>
  160. #include <windowsx.h>
  161. #ifdef _MSVC_
  162. #define MEM_ALLOC(size) (fmalloc((size_t)(size)))
  163. #define MEM_FREE(ptr) ((ptr)? ffree((PTR)(ptr)):0)
  164. #define STRCPY(t, s) (fstrcpy((char FAR*)(t), (char FAR*)(s)))
  165. #define STRNCPY(t,s,n) (fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
  166. #define STRLEN(str) ((str)? fstrlen((char FAR*)(str)):0)
  167. #define STREQ(a, b) (fstrcmp((char FAR*)(a), (char FAR*)(b) == 0))
  168. #define STRCAT(t, s) (strcat((char*)(t), (char*)(s)))
  169. #define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n)))
  170. #define STRNCMP(t,s,n) (strncmp((char*)(t), (char*)(s), (size_t)(n)))
  171. #endif
  172. #ifdef _BORLAND_
  173. #define MEM_ALLOC(size) (farmalloc((unsigned long)(size)))
  174. #define MEM_FREE(ptr) ((ptr)? farfree((void far*)(ptr)):0)
  175. #define STRCPY(t, s) (_fstrcpy((char FAR*)(t), (char FAR*)(s)))
  176. #define STRNCPY(t,s,n) (_fstrncpy((char FAR*)(t), (char FAR*)(s), (size_t)(n)))
  177. #define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0)
  178. #define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0))
  179. #define STRCAT(t, s) (strcat((char*)(t), (char*)(s)))
  180. #define STRNCAT(t,s,n) (strncat((char*)(t), (char*)(s), (size_t)(n)))
  181. #define STRNCMP(t,s,n) (strncmp((char*)(t), (char*)(s), (size_t)(n)))
  182. #endif
  183. #endif /* WINDOWS */
  184. #ifdef VMS
  185. /*
  186. * VMS also defines _UNIX_ above. This is OK for iODBC since all used UNIX
  187. * interfaces are supported.
  188. * The DEC C RTL actually supports dlopen(), etc, but I have made my own
  189. * implementation that supports:
  190. * - Proper error messages from dlopen()
  191. * - The ability to place the driver in other directories than SYS$SHARE:
  192. * - Neither implementation can do dlopen(NULL,), but my implementation
  193. * will not crash in this case.
  194. * To use old DEC C dlopen() implementation, remove the following define.
  195. */
  196. #define DLDAPI_VMS_IODBC /* Use enhanced dlopen() */
  197. #endif
  198. #define SYSERR (-1)
  199. #ifndef NULL
  200. #define NULL ((void *)0UL)
  201. #endif
  202. /*
  203. * Map generic pointer to internal pointer
  204. */
  205. #define STMT(stmt, var) \
  206. STMT_t *stmt = (STMT_t *)var
  207. #define CONN(con, var) \
  208. DBC_t *con = (DBC_t *)var
  209. #define GENV(genv, var) \
  210. GENV_t *genv = (GENV_t *)var
  211. #define ENVR(env, var) \
  212. ENV_t *env = (ENV_t *)var
  213. #define DESC(desc, var) \
  214. DESC_t *desc = (DESC_t *)var
  215. #define NEW_VAR(type, var) \
  216. type *var = (type *)MEM_ALLOC(sizeof(type))
  217. /* these are deprecated defines from the odbc headers */
  218. #define SQL_CONNECT_OPT_DRVR_START 1000
  219. #endif /* _IODBC_H */