• Main Page
  • Modules
  • Data Structures
  • Files
  • File List

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

Generated on Mon Dec 13 2010 22:32:02 for OCILIB (C Driver for Oracle) by  doxygen 1.7.2