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

📄 library.c

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 C
📖 第 1 页 / 共 4 页
字号:
#if defined(OCI_BIG_UINT_ENABLED)

        if ((OCILib.ver_runtime >= 10) && (OCILobCopy2 != NULL))
        {
            OCILib.use_lob_ub8 = TRUE;
        }

#endif

#if defined(OCI_STMT_SCROLLABLE_READONLY)

        if ((OCILib.ver_runtime >= 9) && (OCIStmtFetch2 != NULL))
        {
            OCILib.use_scrollable_cursors = TRUE;
        }

#endif

    }

#endif

#if defined(OCI_CHARSET_UNICODE)

    /* Oracle 8i does not support full Unicode mode */

    if ((res == TRUE) && (OCILib.ver_runtime == OCI_8))
    {
        OCI_ExceptionNotAvailable(NULL, OCI_FEATURE_UNICODE_USERDATA);

        res = FALSE;
    }

#endif

    /* Initialize OCI environment */

    if (res == TRUE)
    {
        /* check modes */

        if (mode & OCI_ENV_THREADED)
            oci_mode |= OCI_THREADED;

        /* create environment on success */

        res = res && (OCI_SUCCESS == OCIEnvCreate(&OCILib.env, oci_mode,
                                                  (dvoid *) NULL, NULL, NULL, NULL,
                                                  (size_t) 0, (dvoid **) NULL));

        /*  allocate error handle */

        res = res && (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) OCILib.env,
                                                     (dvoid **) (void *) &OCILib.err,
                                                     (ub4) OCI_HTYPE_ERROR,
                                                     (size_t) 0, (dvoid **) NULL));
    }

    /* on success, we need to initialize OCIThread object support */

    if (res == TRUE)
    {
        if (OCI_LIB_THREADED)
        {
            OCIThreadProcessInit();

            res = (OCI_SUCCESS == OCIThreadInit(OCILib.env, OCILib.err));
        }

        /* create thread for thread errors */

        OCILib.key_errs = OCI_ThreadKeyCreateInternal((POCI_THREADKEYDEST) OCI_ErrorFree);

        /* allocate connections internal list */

        if (res == TRUE)
        {
            OCILib.cons  = OCI_ListCreate(OCI_IPC_CONNECTION);

            res = (OCILib.cons != NULL);
        }

        /* allocate connection pools internal list */

        if (res == TRUE)
        {

            OCILib.pools = OCI_ListCreate(OCI_IPC_CONNPOOL);

            res = (OCILib.pools != NULL);
        }

    }

    if (res == TRUE)
        OCILib.loaded = TRUE;

    return res;
}

/* ------------------------------------------------------------------------ *
 * OCI_Cleanup
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_Cleanup(void)
{
    boolean res = TRUE;

    /* free all connections */

    OCI_ListForEach(OCILib.cons, (boolean (*)(void *)) OCI_ConnectionClose);
    OCI_ListClear(OCILib.cons);

    /* free all pools */

    OCI_ListForEach(OCILib.pools, (boolean (*)(void *)) OCI_ConnPoolClose);
    OCI_ListClear(OCILib.pools);

    /* free objects */

    OCI_KeyMapFree();

    OCI_ListFree(OCILib.cons);
    OCI_ListFree(OCILib.pools);

    OCILib.cons    = NULL;
    OCILib.pools   = NULL;
    OCILib.key_map = NULL;

    /* finalize OCIThread object support */

    if (OCI_LIB_THREADED)
    {
        OCI_CALL0
        (
            res, OCILib.err,

            OCIThreadTerm(OCILib.env, OCILib.err)
        )
    }

    /* free error thread key */

    if (OCILib.key_errs != NULL)
    {
        OCI_ThreadKey *key = OCILib.key_errs;
        OCI_Error *err     = OCI_ErrorGet(FALSE);

        OCILib.key_errs = NULL;

        OCI_ErrorFree(err);
        OCI_ThreadKeySet(key, NULL);
        OCI_ThreadKeyFree(key);
    }

    /* set unloaded flag */

    OCILib.loaded = FALSE;

    /* close error handle */

    if (OCILib.err != NULL)
       OCI_HandleFree(OCILib.err, OCI_HTYPE_ERROR);

    /* close environment handle
       => direct OCIHandleFree() because this handle was not allocated
       with OCI_HandleAlloc()
    */

    if (OCILib.env != NULL)
        OCIHandleFree(OCILib.env, OCI_HTYPE_ENV);

#ifdef OCI_IMPORT_RUNTIME

    if (OCILib.lib_handle != NULL)
        LIB_CLOSE(OCILib.lib_handle);

#endif

    /* checks for not freed handles */

    if (OCILib.nb_hndlp > 0)
    {
        OCI_ExceptionUnfreedData(OCI_HDLE_HANDLE, OCILib.nb_hndlp);
        res = FALSE;
    }

   /* checks for not freed descriptors */

    if (OCILib.nb_descp > 0)
    {
        OCI_ExceptionUnfreedData(OCI_HDLE_DESCRIPTOR, OCILib.nb_descp);
        res = FALSE;
    }

    /* checks for not freed objects */

    if (OCILib.nb_objinst > 0)
    {
        OCI_ExceptionUnfreedData(OCI_HDLE_OBJECT, OCILib.nb_objinst);
        res = FALSE;
    }

    memset(&OCILib, 0, sizeof(OCILib));

    return res;
}

/* ------------------------------------------------------------------------ *
 * OCI_GetOCICompileVersion
 * ------------------------------------------------------------------------ */

unsigned int OCI_API OCI_GetOCICompileVersion(void)
{
    return (unsigned int) OCILib.ver_compile;
}

/* ------------------------------------------------------------------------ *
 * OCI_GetOCIRuntimeVersion
 * ------------------------------------------------------------------------ */

unsigned int OCI_API OCI_GetOCIRuntimeVersion(void)
{
    return (unsigned int) OCILib.ver_runtime;
}

/* ------------------------------------------------------------------------ *
 * OCI_GetImportMode
 * ------------------------------------------------------------------------ */

unsigned int OCI_API OCI_GetImportMode(void)
{
    return (unsigned int) OCI_IMPORT_MODE;
}

/* ------------------------------------------------------------------------ *
 * OCI_GetCharsetMetaData
 * ------------------------------------------------------------------------ */

unsigned int OCI_API OCI_GetCharsetMetaData(void)
{
    return (unsigned int) OCI_CHAR_MTEXT;
}

/* ------------------------------------------------------------------------ *
 * OCI_GetCharsetUserData
 * ------------------------------------------------------------------------ */

unsigned int OCI_API OCI_GetCharsetUserData(void)
{
    return (unsigned int) OCI_CHAR_DTEXT;
}

/* ------------------------------------------------------------------------ *
 * OCI_GetLastError
 * ------------------------------------------------------------------------ */

OCI_Error * OCI_API OCI_GetLastError(void)
{
    OCI_Error *err = NULL;

    if ((OCILib.loaded == FALSE) || (OCI_LIB_CONTEXT))
    {
        err = OCI_ErrorGet(TRUE);

        if (err != NULL)
        {
            if (err->raise == FALSE)
                err = NULL;
        }
    }

    return err;
}

⌨️ 快捷键说明

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