⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ocilib_types.h

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
   +----------------------------------------------------------------------+
   |                                                                      |
   |                     OCILIB - C Driver for Oracle                     |
   |                                                                      |
   |                      (C Wrapper for Oracle OCI)                      |
   |                                                                      |
   +----------------------------------------------------------------------+
   |                      Website : http://ocilib.net                     |
   +----------------------------------------------------------------------+
   |               Copyright (c) 2007-2009 Vincent ROGIER                 |
   +----------------------------------------------------------------------+
   | This library is free software; you can redistribute it and/or        |
   | modify it under the terms of the GNU Library General Public          |
   | License as published by the Free Software Foundation; either         |
   | version 2 of the License, or (at your option) any later version.     |
   |                                                                      |
   | This library is distributed in the hope that it will be useful,      |
   | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
   | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
   | Library General Public License for more details.                     |
   |                                                                      |
   | You should have received a copy of the GNU Library General Public    |
   | License along with this library; if not, write to the Free           |
   | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   |
   +----------------------------------------------------------------------+
   |          Author: Vincent ROGIER <vince.rogier@gmail.com>             |
   +----------------------------------------------------------------------+
*/

/* ------------------------------------------------------------------------ *
 * $Id: ocilib_types.h, v 3.2.0 2009/04/20 00:00 Vince $
 * ------------------------------------------------------------------------ */


#ifndef OCILIB_OCILIB_TYPES_H_INCLUDED
#define OCILIB_OCILIB_TYPES_H_INCLUDED

#include "ocilib_defs.h"

/* ************************************************************************ *
 *                             PRIVATE TYPES
 * ************************************************************************ */

/*
 * OCI_Item : Internal list entry.
 *
 * The library needs to manage internal list of objects in order to be able to
 * free them if the application doest not.
 *
 * @note
 * Internal lists are using mutexes for resource locking in multithreaded
 * environments
 *
 */

struct OCI_Item
{
   void             *data; /* pointer to external data */
   struct OCI_Item  *next; /* next element in list */
};

typedef struct OCI_Item OCI_Item;

/*
 * OCI_List : Internal list object.
 *
 * The OCI_List object is used to maintain a collection of handles allocated
 * by user programs.
 *
 * Those handles are freed when the collection owner is destroyed.
 * So, we make sure that if OCI_Cleanup() is called, all allocated handles will
 * be destroyed even if the program does not free them.
 *
 */

struct OCI_List
{
    OCI_Item    *head;   /* pointer to first item */
    OCI_Mutex   *mutex;  /* mutex handle */
    ub4          count;  /* number of elements in list */
    int          type;   /* type of list item */
};

typedef struct OCI_List OCI_List;

/*
 * Server output object used to retrieve server dbms.output buffers
 *
 */

struct OCI_ServerOutput
{
    ub1                *arrbuf;    /* array buffer */
    unsigned int        arrsize;   /* array size */
    unsigned int        cursize;   /* number of filled items in the array */
    unsigned int        curpos;    /* current position in the array */
    unsigned int        lnsize;    /* line size */
    OCI_Statement      *stmt;      /* pointer to statement object (dbms_output calls) */
};

typedef struct OCI_ServerOutput OCI_ServerOutput;

/*
 * Connection trace information
 *
 */

struct OCI_TraceInfo
{
    mtext identifier[OCI_SIZE_TRACE_ID+1];
    mtext module[OCI_SIZE_TRACE_MODULE+1];
    mtext action[OCI_SIZE_TRACE_ACTION+1];
    mtext info[OCI_SIZE_TRACE_INF0+1];
};

typedef struct OCI_TraceInfo OCI_TraceInfo;

/* ************************************************************************ *
 *                             PUBLIC TYPES
 * ************************************************************************ */

/*
 * Error object
 *
 */

struct OCI_Error
{
    boolean          raise;                  /* Error flag */
    boolean          active;                 /* to avoid recursive exceptions */
    OCI_Connection  *con;                    /* pointer to connection object */
    OCI_Statement   *stmt;                   /* pointer to statement object */
    sb4              ocode;                  /* Oracle OCI error code */
    int              icode;                  /* OCILIB internal error code */
    mtext            str[OCI_SIZE_BUFFER+1]; /* error message */
    unsigned int     type;                   /* OCILIB error type */
};

/*
 * Mutex object
 *
 * Mutexes have their own error handle to avoid conflict using OCIErrorGet()
 * from different threads
 *
 */

struct OCI_Mutex
{
    OCIThreadMutex  *handle;  /* OCI Mutex handle */
    OCIError        *err;     /* OCI Error handle */
};

/*
 * Thread object
 *
 * Threads have their own error handle to avoid conflict using OCIErrorGet()
 *
 */

struct OCI_Thread
{
    OCIThreadHandle *handle;    /* OCI Thread handle */
    OCIThreadId     *id;        /* OCI Thread ID */
    OCIError        *err;       /* OCI Error handle */
    void            *arg;       /* thread routine argument */
    POCI_THREAD      proc;      /* thread routine */
};

/*
 * Thread key object
 *
 * Thread keys have their own error handle to avoid conflict using OCIErrorGet()
 * from differents threads
 *
 */

struct OCI_ThreadKey
{
    OCIThreadKey    *handle;  /* OCI Thread key handle */
    OCIError        *err;     /* OCI Error handle */
};

typedef struct OCI_ThreadKey OCI_ThreadKey;

/*
 * OCI_Library : Internal OCILIB library encapsulation.
 *
 * It's a static, local and unique object that collects all the global variables
 * needed by the library
 *
 */

struct OCI_Library
{
    OCI_List       *cons;                   /* list of connection objects */
    OCI_List       *pools;                  /* list of pools objects */
    OCIEnv         *env;                    /* OCI environment handle */
    OCIError       *err;                    /* OCI error handle */
    POCI_ERROR      error_handler;          /* user defined error handler */
    ub1             ver_compile;            /* OCI version used at compile time */
    ub1             ver_runtime;            /* OCI version used at runtime */
    ub1             use_lob_ub8;            /* use 64 bits integers for lobs ? */
    ub1             use_scrollable_cursors; /* use Oracle 9i fetch API */
    ub4             env_mode;               /* default environment mode */
    boolean         loaded;                 /* OCILIB correctly loaded ? */
    OCI_Error       lib_err;                /* Error used when OCILIB is not loaded */
    OCI_HashTable  *key_map;                /* hash table for mapping name/key */
    OCI_ThreadKey  *key_errs;               /* Thread key to store thread errors */
    unsigned int    nb_hndlp;               /* number of OCI handles allocated */
    unsigned int    nb_descp;               /* number of OCI descriptors allocated */
    unsigned int    nb_objinst;             /* number of OCI objects allocated */
#ifdef OCI_IMPORT_RUNTIME
    LIB_HANDLE      lib_handle;             /* handle of runtime shared library */
#endif
};

typedef struct OCI_Library OCI_Library;

/*
 * Connection Pool object
 *
 */

struct OCI_ConnPool
{
    OCI_List        *cons;      /* list of connection objects */
#if OCI_VERSION_COMPILE >= OCI_9
    OCICPool        *handle;    /* OCI pool handle */
#else
    void            *handle;    /* fake handle for alignment */
#endif
    OCIError        *err;       /* OCI context handle */
    mtext           *name;      /* pool name */
    mtext           *db;        /* database */
    mtext           *user;      /* user */
    mtext           *pwd;       /* password */
    OCI_Mutex       *mutex;     /* mutex handle */
    ub4              mode;      /* session mode */
    ub4              min;       /* minimum of connections */
    ub4              max;       /* maximum of connections */
    ub4              incr;      /* increment step of connections */
    unsigned int     nb_busy;   /* number of busy connections */
    unsigned int     nb_opened; /* number of opened connections */
    unsigned int     timeout;   /* connection idle timeout */
    boolean          nowait;    /* wait for new connection */
};

/*
 * Connection object
 *
 */

struct OCI_Connection
{
    mtext              *db;        /* database */
    mtext              *user;      /* user */
    mtext              *pwd;       /* password */
    mtext              *version;   /* server version */
    OCI_List           *stmts;     /* list of statements */
    OCI_List           *trsns;     /* list of transactions */
    OCI_List           *tinfs;     /* list of type info objects */
    OCI_Transaction    *trs;       /* pointer to current transaction object */
    OCI_ConnPool       *pool;      /* pointer to connection pool parent */
    OCI_ServerOutput   *svopt;     /* Pointer to server output object */
    OCIServer          *svr;       /* OCI server handle */
    OCIError           *err;       /* OCI context handle */
    OCISession         *ses;       /* OCI session handle */
    OCISvcCtx          *cxt;       /* OCI context handle */
    boolean             autocom;   /* auto commit mode */
    unsigned int        nb_files;  /* number of OCI_File opened by the connection */
    unsigned int        mode;      /* session mode */
    int                 cstate;    /* connection state */
    void               *usrdata;   /* user data */
    mtext              *fmt_date;  /* date string format for conversion */
    mtext              *fmt_num;   /* numeric string format for conversion */
    unsigned int        ver_maj;   /* server version major number */
    unsigned int        ver_min;   /* server version minor number */
    unsigned int        ver_rev;   /* server version revision number */
    OCI_TraceInfo      *trace;     /* trace information */
};

/*
 * Transaction object
 *
 */

struct OCI_Transaction
{
    OCI_Connection  *con;       /* pointer to connection object */
    OCITrans        *htr;       /* OCI transaction handle */
    unsigned int     timeout;   /* timeout */
    unsigned int     mode;      /* transaction mode */
    boolean          local;     /* is local transaction ? */
    OCI_XID          xid;       /* global transaction identifier */
};

/*
 * Column object
 *
 */

struct OCI_Column
{
    /* 0racle infos */
    ub2              ocode;     /* Oracle SQL code */
    ub2              tcode;     /* Oracle type code */
    ub2              icode;     /* Internal translated Oracle SQL code */
    ub2              size;      /* SQL Size */
    sb2              prec;      /* SQL precision 1 (number prec, leading prec) */
    sb2              prec2;     /* SQL precision 2 (fractional prec) */
    sb1              scale;     /* SQL scale */
    ub1              type;      /* internal datatype */
    ub1              null;      /* is nullable */
    ub1              charused;  /* is column size expressed in characters */
    mtext           *name;      /* column name */
    ub2              charsize;  /* SQL Size in character */
    ub1              csfrm;     /* charset form */
    ub1              dtype;     /* oracle handle type */

    /* OCILIB infos */
    ub4              bufsize;   /* element size */
    OCI_TypeInfo    *typinf;    /* user type descriptor */
    ub4              subtype;   /* object type */
};

/*
 * OCI_Buffer : Internal input/output buffer
 *
 */

struct OCI_Buffer
{
    void            *handle;   /* OCI handle (bind or define) */
    void           **data;     /* data / array of data */
    void            *inds;     /* array of indicators */
    void            *lens;     /* array of lengths */
    dtext           *temp;     /* temporary buffer for string conversion */
    ub4              count;    /* number of elements in the buffer */
    int              sizelen;  /* size of an element in the lens array */
};

typedef struct OCI_Buffer OCI_Buffer;

/*
 * OCI_Bind object
 *
 */

struct OCI_Bind
{
    OCI_Statement   *stmt;      /* pointer to statement object */
    void           **input;     /* input values */
    mtext           *name;      /* name of the bind */
    sb4              size;      /* data size */
    OCI_Buffer       buf;       /* place holder */
    ub2              dynpos;    /* index of the bind for dynamic binds */
    ub2             *plrcds;    /* PL/SQL tables return codes */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -