C:/Users/vincent/Data/Perso/dev/ocilib/ocilib/src/ocilib_defs.h

00001 /*
00002    +----------------------------------------------------------------------+   
00003    |                                                                      |
00004    |                     OCILIB - C Driver for Oracle                     |
00005    |                                                                      |
00006    |                      (C Wrapper for Oracle OCI)                      |
00007    |                                                                      |
00008    +----------------------------------------------------------------------+
00009    |                      Website : http://www.ocilib.net                 |
00010    +----------------------------------------------------------------------+
00011    |               Copyright (c) 2007-2009 Vincent ROGIER                 |
00012    +----------------------------------------------------------------------+
00013    | This library is free software; you can redistribute it and/or        |
00014    | modify it under the terms of the GNU Lesser General Public           |
00015    | License as published by the Free Software Foundation; either         |
00016    | version 2 of the License, or (at your option) any later version.     |
00017    |                                                                      |
00018    | This library is distributed in the hope that it will be useful,      |
00019    | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
00020    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
00021    | Lesser General Public License for more details.                      |
00022    |                                                                      |
00023    | You should have received a copy of the GNU Lesser General Public     |
00024    | License along with this library; if not, write to the Free           |
00025    | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   |
00026    +----------------------------------------------------------------------+
00027    |          Author: Vincent ROGIER <vince.rogier@gmail.com>             |
00028    +----------------------------------------------------------------------+ 
00029 */
00030 
00031 /* ------------------------------------------------------------------------ *
00032  * $Id: ocilib_defs.h, v 3.4.0 2009-07-30 17:40 Vince $
00033  * ------------------------------------------------------------------------ */
00034 
00035 #ifndef OCILIB_OCILIB_DEFS_H_INCLUDED
00036 #define OCILIB_OCILIB_DEFS_H_INCLUDED
00037 
00038 #include "ocilib.h"
00039 #include "oci_import.h"
00040 
00041 /* ************************************************************************ *
00042                            ORACLE VERSION DETECTION
00043  * ************************************************************************ */
00044 
00045 #ifdef OCI_IMPORT_RUNTIME
00046 
00047   /* for runtime loading, set compile time version to the highest minimum
00048      version needed by OCILIB encapsulation of OCI */
00049   #define OCI_VERSION_COMPILE OCI_11_1
00050   /* set runtime version to unknown, it will be guessed from symbols loading */
00051   #define OCI_VERSION_RUNTIME OCI_UNKNOWN
00052 
00053 #else
00054 
00055   #if   defined(OCI_LOB_OPT_COMPRESS)       /* = OCI_11_1 */
00056 
00057     #define OCI_VERSION_COMPILE OCI_11_1
00058     #define OCI_VERSION_RUNTIME OCI_11_1
00059 
00060   #elif defined(OCI_DBSHUTDOWN_ABORT)       /* = OCI_10_2 */
00061 
00062     #define OCI_VERSION_COMPILE OCI_10_2
00063     #define OCI_VERSION_RUNTIME OCI_10_2
00064 
00065   #elif defined(OCI_ATTR_DB_CHARSET_ID)     /* = OCI_10_1 */
00066 
00067     #define OCI_VERSION_COMPILE OCI_10_1
00068     #define OCI_VERSION_RUNTIME OCI_10_1
00069 
00070   #elif defined(OCI_ATTR_STMTCACHESIZE)     /* = OCI_9_2 */
00071 
00072     #define OCI_VERSION_COMPILE OCI_9_2
00073     #define OCI_VERSION_RUNTIME OCI_9_2
00074 
00075   #elif defined(SQLT_PNTY)                  /* = OCI_9_0 */
00076 
00077     #define OCI_VERSION_COMPILE OCI_9_0
00078     #define OCI_VERSION_RUNTIME OCI_9_0
00079 
00080   #elif defined(OCIThreadHandle)             /* = OCI_8_1 */
00081 
00082     #define OCI_VERSION_COMPILE OCI_8_1
00083     #define OCI_VERSION_RUNTIME OCI_8_1
00084 
00085   #elif defined(OCIEnv)                      /* = OCI_8_0 */
00086 
00087     #define OCI_VERSION_COMPILE OCI_8_0
00088     #define OCI_VERSION_RUNTIME OCI_8_0
00089 
00090   #else                                      /* OCI_UNKNOWN */
00091 
00092     #define OCI_VERSION_COMPILE OCI_UNKNOWN
00093     #define OCI_VERSION_RUNTIME OCI_UNKNOWN
00094 
00095   #endif
00096 
00097 #endif
00098 
00099 /* tries to enable Oracle 10g support for lobs > 4Go with OCILobxxx2() calls */
00100 
00101 #if defined(OCI_BIG_UINT_ENABLED) && defined(ORAXB8_DEFINED)
00102   #define OCI_LOB2_API_ENABLED
00103 #endif
00104 
00105 /* ************************************************************************ *
00106                      CHARSET AND STRING TYPES DETECTION
00107  * ************************************************************************ */
00108 
00109 /* mtext and dtext are public character types for meta and user string types
00110    We need to handle as well internal string types because :
00111    
00112    - wchar_t is not the same type on all platforms (that is such a pain !),
00113    - OCI, in Unicode mode, uses Fixed length UTF16 encoding (2 bytes)
00114    
00115    So, omtext and odtext were added to represent internal meta and user string
00116    types.
00117 
00118    The following checks find out the real types and sizes of omtext and odtext
00119 */
00120    
00121 #ifdef OCI_CHARSET_ANSI
00122 
00123   /* easy ! */
00124   #define omtext mtext
00125   #define odtext dtext
00126 
00127 #else
00128 
00129   #define WCHAR_2_BYTES 0xFFFF
00130   #define WCHAR_4_BYTES 0x7FFFFFFF
00131 
00132   /* 
00133      Actually, the only need to use string conversion is when using wchar_t
00134      on unixes systems. This test will probably change in future releases to
00135      handle internally UTF8, by example
00136   */
00137 
00138   #if WCHAR_MAX == WCHAR_4_BYTES
00139     /* so, input/output conversion will be needed */
00140     #define OCI_CHECK_STRINGS
00141   #endif
00142 
00143   #ifdef OCI_METADATA_UNICODE
00144 
00145     #ifdef OCI_CHECK_STRINGS
00146       /* conversion for meta string needed */
00147       #define OCI_CHECK_METASTRINGS
00148     #endif
00149 
00150     /* internal meta string type is UTF16 (2 bytes) */
00151     #define omtext unsigned short
00152 
00153   #else
00154 
00155     /* internal meta string type is char */
00156     #define omtext char
00157 
00158   #endif
00159 
00160   #ifdef OCI_USERDATA_UNICODE
00161 
00162     #ifdef OCI_CHECK_STRINGS
00163       /* conversion for data string needed */
00164       #define OCI_CHECK_DATASTRINGS
00165     #endif
00166 
00167     /* internal data string type is UTF16 (2 bytes) */
00168     #define odtext unsigned short
00169 
00170   #else
00171 
00172     /* internal data string type is char */
00173     #define odtext char
00174 
00175   #endif
00176 
00177 #endif
00178 
00179 
00180 /* ************************************************************************ *
00181                             INTERNAL  CONSTANTS
00182  * ************************************************************************ */
00183 
00184 /* ------------------------------------------------------------------------ *
00185  * DEfault environnement mode
00186  * ------------------------------------------------------------------------ */
00187 
00188 #ifdef OCI_METADATA_UNICODE
00189     #define OCI_ENV_MODE    OCI_UTF16 
00190 #else
00191     #define OCI_ENV_MODE    OCI_DEFAULT
00192 #endif
00193 
00194 /* ------------------------------------------------------------------------ *
00195  * Internal Pointer Codes
00196  * ------------------------------------------------------------------------ */
00197 
00198  /* -- external C pointers ---- */
00199 
00200 #define OCI_IPC_VOID             1
00201 #define OCI_IPC_SHORT            2
00202 #define OCI_IPC_INT              3
00203 #define OCI_IPC_BIGINT           4
00204 #define OCI_IPC_DOUBLE           5
00205 #define OCI_IPC_STRING           6
00206 #define OCI_IPC_PROC             7
00207 
00208 /* -- external OCILIB handles - */
00209 
00210 #define OCI_IPC_ERROR            8
00211 #define OCI_IPC_TYPE_INFO        9
00212 #define OCI_IPC_CONNECTION       10
00213 #define OCI_IPC_CONNPOOL         11
00214 #define OCI_IPC_TRANSACTION      12
00215 #define OCI_IPC_STATEMENT        13 
00216 #define OCI_IPC_RESULTSET        14
00217 #define OCI_IPC_COLUMN           15
00218 #define OCI_IPC_DATE             16
00219 #define OCI_IPC_TIMESTAMP        17
00220 #define OCI_IPC_INTERVAL         18
00221 #define OCI_IPC_LOB              19
00222 #define OCI_IPC_FILE             20
00223 #define OCI_IPC_LONG             21
00224 #define OCI_IPC_OBJECT           22
00225 #define OCI_IPC_COLLECTION       23
00226 #define OCI_IPC_ITERATOR         24
00227 #define OCI_IPC_ELEMENT          25
00228 #define OCI_IPC_HASHTABLE        26
00229 #define OCI_IPC_THREAD           27
00230 #define OCI_IPC_MUTEX            28
00231 #define OCI_IPC_BIND             29
00232 #define OCI_IPC_REF              30
00233 #define OCI_IPC_DIRPATH          31
00234 
00235 /* ---- Internal pointers ----- */
00236  
00237 #define OCI_IPC_LIST             32
00238 #define OCI_IPC_LIST_ITEM        33
00239 #define OCI_IPC_BIND_ARRAY       34
00240 #define OCI_IPC_DEFINE           35
00241 #define OCI_IPC_DEFINE_ARRAY     36
00242 #define OCI_IPC_HASHENTRY        37
00243 #define OCI_IPC_HASHENTRY_ARRAY  38
00244 #define OCI_IPC_HASHVALUE        39
00245 #define OCI_IPC_THREADKEY        40
00246 #define OCI_IPC_OCIDATE          41
00247 #define OCI_IPC_TM               42
00248 #define OCI_IPC_RESULTSET_ARRAY  43
00249 #define OCI_IPC_PLS_SIZE_ARRAY   44
00250 #define OCI_IPC_PLS_RCODE_ARRAY  45
00251 #define OCI_IPC_SERVER_OUPUT     46
00252 #define OCI_IPC_INDICATOR_ARRAY  47
00253 #define OCI_IPC_LEN_ARRAY        48
00254 #define OCI_IPC_BUFF_ARRAY       49
00255 #define OCI_IPC_LONG_BUFFER      50
00256 #define OCI_IPC_TRACE_INFO       51
00257 #define OCI_IPC_DP_COL_ARRAY     52
00258 #define OCI_IPC_BATCH_ERRORS     53
00259 
00260 /* ------------------------------------------------------------------------ *
00261  * Oracle conditionnal features 
00262  * ------------------------------------------------------------------------ */
00263 
00264 #define OCI_FEATURE_UNICODE_USERDATA    1
00265 #define OCI_FEATURE_TIMESTAMP           2
00266 #define OCI_FEATURE_DIRPATH_DATE_CACHE  3
00267 #define OCI_FEATURE_SCROLLABLE_CURSOR   4
00268 #define OCI_FEATURE_REMOTE_DBS_CONTROL  5
00269 
00270 /* ------------------------------------------------------------------------ *
00271  * Oracle conditionnal features 
00272  * ------------------------------------------------------------------------ */
00273 
00274 #define OCI_HDLE_HANDLE                 1
00275 #define OCI_HDLE_DESCRIPTOR             2
00276 #define OCI_HDLE_OBJECT                 3
00277 
00278 /* ------------------------------------------------------------------------ *
00279  * statement status
00280  * ------------------------------------------------------------------------ */
00281 
00282 #define OCI_STMT_CLOSED                 1
00283 #define OCI_STMT_PREPARED               2
00284 #define OCI_STMT_EXECUTED               3
00285 
00286 /* ------------------------------------------------------------------------ *
00287  * connection states
00288  * ------------------------------------------------------------------------ */
00289 
00290 #define OCI_CONN_ALLOCATED              1
00291 #define OCI_CONN_ATTACHED               2
00292 #define OCI_CONN_LOGGED                 3
00293 
00294 /* ------------------------------------------------------------------------ *
00295  * objects status
00296  * ------------------------------------------------------------------------ */
00297 
00298 #define OCI_OBJECT_ALLOCATED            1
00299 #define OCI_OBJECT_FETCHED_CLEAN        2
00300 #define OCI_OBJECT_FETCHED_DIRTY        3
00301 
00302 /* ------------------------------------------------------------------------ *
00303  * bind type
00304  * ------------------------------------------------------------------------ */
00305 
00306 #define OCI_BIND_INPUT                  1
00307 #define OCI_BIND_OUTPUT                 2
00308 
00309 /* ------------------------------------------------------------------------ *
00310  * Type of schema describing
00311  * ------------------------------------------------------------------------ */
00312 
00313 #define OCI_DESC_RESULTSET              1
00314 #define OCI_DESC_COLUMN                 2
00315 #define OCI_DESC_TABLE                  3
00316 #define OCI_DESC_TYPE                   4
00317 #define OCI_DESC_COLLECTION             5
00318 
00319 /* ------------------------------------------------------------------------ *
00320  * Direct path object status
00321  * ------------------------------------------------------------------------ */
00322 
00323 #define OCI_DPS_NOT_PREPARED            1
00324 #define OCI_DPS_PREPARED                2
00325 #define OCI_DPS_CONVERTED               3
00326 #define OCI_DPS_TERMINATED              4
00327 
00328 /* ------------------------------------------------------------------------ *
00329  * internal statement fetch direction
00330  * ------------------------------------------------------------------------ */
00331 
00332 #define OCI_SFD_NEXT                    0x02
00333 #define OCI_SFD_FIRST                   0x04
00334 #define OCI_SFD_LAST                    0x08
00335 #define OCI_SFD_PREV                    0x10
00336 
00337 /* ------------------------------------------------------------------------ *
00338  * internal direct path column types
00339  * ------------------------------------------------------------------------ */
00340 
00341 #define OCI_DDT_TEXT                    1
00342 #define OCI_DDT_BINARY                  2
00343 #define OCI_DDT_NUMBER                  3
00344 #define OCI_DDT_OTHERS                  4
00345 
00346 /* ------------------------------------------------------------------------ *
00347  * internal integer types
00348  * ------------------------------------------------------------------------ */
00349 
00350 #define OCI_NUM_UNSIGNED               2
00351 #define OCI_NUM_SHORT                  4
00352 #define OCI_NUM_INT                    8
00353 #define OCI_NUM_BIGINT                 16
00354 #define OCI_NUM_NUMBER                 32
00355 #define OCI_NUM_DOUBLE                 64
00356 
00357 #define OCI_NUM_USHORT                 (OCI_NUM_SHORT  | OCI_NUM_UNSIGNED)
00358 #define OCI_NUM_UINT                   (OCI_NUM_INT    | OCI_NUM_UNSIGNED)
00359 #define OCI_NUM_BIGUINT                (OCI_NUM_BIGINT | OCI_NUM_UNSIGNED)
00360 
00361 /* ------------------------------------------------------------------------ *
00362  *  output buffer server line size
00363  * ------------------------------------------------------------------------ */
00364 
00365 #define OCI_OUPUT_LSIZE                 255
00366 #define OCI_OUPUT_LSIZE_10G             32767
00367 
00368 /* ------------------------------------------------------------------------ *
00369  *  string functions mapping
00370  * ------------------------------------------------------------------------ */
00371 
00372 #ifdef OCI_METADATA_UNICODE
00373   #define mttoupper           towupper
00374   #define mtisdigit           iswdigit
00375   #define mtsscanf            swscanf
00376 #else
00377   #define mttoupper           toupper
00378   #define mtisdigit           isdigit
00379   #define mtsscanf            sscanf
00380 #endif
00381 
00382 /* ------------------------------------------------------------------------ *
00383  *  Unicode constants
00384  * ------------------------------------------------------------------------ */
00385 
00386 /* OCI unicode flag */
00387 
00388 #ifndef OCI_UTF16ID
00389   #define OCI_UTF16ID                   OCI_UCS2ID
00390 #endif
00391 
00392 /* unicode constants */
00393 
00394 #define UNI_SHIFT             ((int) 10 )
00395 #define UNI_BASE              ((unsigned int) 0x0010000UL)
00396 #define UNI_MASK              ((unsigned int) 0x3FFUL)
00397 #define UNI_REPLACEMENT_CHAR  ((unsigned int) 0x0000FFFD)
00398 #define UNI_MAX_BMP           ((unsigned int) 0x0000FFFF)
00399 #define UNI_MAX_UTF16         ((unsigned int) 0x0010FFFF)
00400 #define UNI_MAX_UTF32         ((unsigned int) 0x7FFFFFFF)
00401 #define UNI_MAX_LEGAL_UTF32   ((unsigned int) 0x0010FFFF)
00402 #define UNI_SUR_HIGH_START    ((unsigned int) 0xD800)
00403 #define UNI_SUR_HIGH_END      ((unsigned int) 0xDBFF)
00404 #define UNI_SUR_LOW_START     ((unsigned int) 0xDC00)
00405 #define UNI_SUR_LOW_END       ((unsigned int) 0xDFFF)
00406 
00407 /* ------------------------------------------------------------------------ *
00408  * Local helper macros
00409  * ------------------------------------------------------------------------ */
00410 
00411 /* check OCI status */
00412 
00413 #define OCI_NO_ERROR(res)   (((res) == OCI_SUCCESS) ||  \
00414                              ((res) == OCI_SUCCESS_WITH_INFO))
00415 
00416 
00417 /* memory management helpers */
00418 
00419 #define OCI_FREE(ptr)                   OCI_MemFree(ptr), ptr = NULL;
00420 
00421 /* indicator and nullity handlers */
00422 
00423 #define OCI_IND(exp)                    (sb2) ((exp) ? 0 : -1)
00424 
00425 #define OCI_NOT_NULL(def)                                   \
00426     ((def != NULL) &&                                       \
00427      (rs->row_cur > 0) &&                                   \
00428      ((sb2) ((sb2*)def->buf.inds)[rs->row_cur-1] != -1))
00429 
00430 
00431 #define OCI_NOT_USED(p)                 (p) = (p);
00432 
00433 /* miscellaneaous */
00434 
00435 #define OCI_NB_ARG_VERSION              3
00436 
00437 #define OCI_LIB_THREADED                (OCILib.env_mode & OCI_ENV_THREADED)
00438 
00439 #define OCI_LIB_CONTEXT                 (OCILib.env_mode & OCI_ENV_CONTEXT)
00440 
00441 
00442 #define OCI_RESULT(res)                                                        \
00443                                                                                \
00444         if (OCI_LIB_CONTEXT)                                                   \
00445             OCI_SetStatus(res);                                                \
00446 
00447 #ifdef _WINDOWS
00448   #define OCI_CVT_CHAR                  1
00449 #else
00450   #define OCI_CVT_CHAR                  0
00451 #endif
00452 
00453 #define OCI_SQLCMD_COUNT                126
00454 
00455 #define OCI_ERR_MSG_SIZE                512
00456 
00457 #endif    /* OCILIB_OCILIB_DEFS_H_INCLUDED */
00458 

Generated on Thu Jul 30 17:41:53 2009 for OCILIB (C Driver for Oracle) by  doxygen 1.5.4