OCI_List * OCI_ListCreate ( int type ) { OCI_List *list = NULL; /* allocate list */ list = (OCI_List *) OCI_MemAlloc(OCI_IPC_LIST, sizeof(*list), (size_t) 1, TRUE); /* create a mutex on multithreaded environments */ if (list != NULL) { list->type = type; if (OCI_LIB_THREADED) { list->mutex = OCI_MutexCreateInternal(); if (list->mutex == NULL) { OCI_FREE(list); } } } return list; }
OCI_Mutex * OCI_API OCI_MutexCreate ( void ) { OCI_CALL_ENTER(OCI_Mutex*, NULL) OCI_CALL_CHECK_INITIALIZED() OCI_RETVAL = OCI_MutexCreateInternal(); OCI_STATUS = (NULL != OCI_RETVAL); OCI_CALL_EXIT() }
OCI_Mutex * OCI_API OCI_MutexCreate ( void ) { OCI_LIB_CALL_ENTER(OCI_Mutex*, NULL) OCI_CHECK_INITIALIZED() call_retval = OCI_MutexCreateInternal(); call_status = (NULL != call_retval); OCI_LIB_CALL_EXIT() }
OCI_Pool * OCI_API OCI_PoolCreate ( const mtext *db, const mtext *user, const mtext *pwd, unsigned int type, unsigned int mode, unsigned int min_con, unsigned int max_con, unsigned int incr_con ) { OCI_Pool *pool = NULL; OCI_Item *item = NULL; boolean res = TRUE; OCI_CHECK_MIN(NULL, NULL, max_con, 1, NULL); /* let's be sure OCI_Initialize() has been called */ OCI_CHECK_INITIALIZED(NULL); /* make sure that we do not have a XA session flag */ mode &= ~OCI_SESSION_XA; /* create pool object */ item = OCI_ListAppend(OCILib.pools, sizeof(*pool)); if (item != NULL) { pool = (OCI_Pool *) item->data; /* create internal lists */ pool->cons = OCI_ListCreate(OCI_IPC_CONNECTION); if (OCI_LIB_THREADED) { /* create mutex for OCI_PoolGetConnection() */ pool->mutex = OCI_MutexCreateInternal(); res = (pool->mutex != NULL); } } else { res = FALSE; } /* set attributes */ if (res == TRUE) { pool->mode = mode; pool->min = min_con; pool->max = max_con; pool->incr = incr_con; pool->db = mtsdup(db != NULL ? db : MT("")); pool->user = mtsdup(user != NULL ? user : MT("")); pool->pwd = mtsdup(pwd != NULL ? pwd : MT("")); } #if OCI_VERSION_COMPILE < OCI_9_2 type = OCI_POOL_CONNECTION; #endif #if OCI_VERSION_COMPILE >= OCI_9_0 if (res == TRUE) { if (type == OCI_POOL_CONNECTION) { pool->htype = OCI_HTYPE_CPOOL; } #if OCI_VERSION_COMPILE >= OCI_9_2 else { pool->htype = OCI_HTYPE_SPOOL; } #endif } if (OCILib.version_runtime >= OCI_9_0) { int osize_name = -1; int osize_db = -1; void *ostr_name = NULL; void *ostr_db = NULL; /* allocate error handle */ if (res == TRUE) { res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) OCILib.env, (dvoid **) (void *) &pool->err, (ub4) OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) NULL)); } /* allocate pool handle */ if (res == TRUE) { res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) OCILib.env, (dvoid **) (void *) &pool->handle, (ub4) pool->htype, (size_t) 0, (dvoid **) NULL)); } /* allocate authentification handle only if needed */ #if OCI_VERSION_COMPILE >= OCI_11_1 if (res == TRUE) { if ((pool->htype == OCI_HTYPE_SPOOL) && (OCILib.version_runtime >= OCI_11_1)) { int osize = -1; void *ostr = OCI_GetInputMetaString(OCILIB_DRIVER_NAME, &osize); /* allocate authentification handle */ res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) OCILib.env, (dvoid **) (void *) &pool->authp, (ub4) OCI_HTYPE_AUTHINFO, (size_t) 0, (dvoid **) NULL)); /* set OCILIB's driver layer name attribute only for session pools here For standalone connections and connection pool this attribute is set in OCI_ConnectionLogon() */ OCI_CALL3 ( res, pool->err, OCIAttrSet((dvoid *) pool->authp, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_DRIVER_NAME, pool->err) ) OCI_ReleaseMetaString(ostr); /* set auth handle on the session pool */ OCI_CALL3 ( res, pool->err, OCIAttrSet((dvoid *) pool->handle, (ub4) OCI_HTYPE_SPOOL, (dvoid *) pool->authp, (ub4) sizeof(pool->authp), (ub4) OCI_ATTR_SPOOL_AUTH, pool->err) ) } }