CVS update: php31/ext/oracle

From: Date: Sat, 17 Oct 1998 20:45:39 +0000
Subject: CVS update: php31/ext/oracle
Groups: php.dev 
Request: Send a blank email to php-dev+get-1878@lists.php.net to get a copy of this message
Date: Saturday October 17, 1998 @ 16:45 Author: shane Update of /repository/php31/ext/oracle In directory asf:/u2/tmp/cvs-serv29817/ext/oracle Modified Files: oracle.c Log Message: fixes to get 3.1 compiling again under windows. mysql ported from 3.0 then backported to 3.0 Some project file updates porting other extensions from 3.0 in process. fixes to registry functions to support binary Index: php31/ext/oracle/oracle.c diff -c php31/ext/oracle/oracle.c:2.3 php31/ext/oracle/oracle.c:2.4 *** php31/ext/oracle/oracle.c:2.3 Thu Sep 10 20:22:40 1998 --- php31/ext/oracle/oracle.c Sat Oct 17 16:45:38 1998 *************** *** 29,42 **** | Andreas Karajannis <Andreas.Karajannis@gmd.de> | +----------------------------------------------------------------------+ */ #include "php.h" #include "internal_functions.h" #include "oracle.h" #if HAVE_ORACLE - #include "php3_list.h" #include "build-defs.h" #include "snprintf.h" #ifndef min --- 29,46 ---- | Andreas Karajannis <Andreas.Karajannis@gmd.de> | +----------------------------------------------------------------------+ */ + #if defined(COMPILE_DL) + #include "dl/phpdl.h" + #endif #include "php.h" #include "internal_functions.h" #include "oracle.h" #if HAVE_ORACLE #include "php3_list.h" + #if !(WIN32|WINNT) #include "build-defs.h" + #endif #include "snprintf.h" #ifndef min *************** *** 111,118 **** }; php3_module_entry oracle_module_entry = { ! "Oracle", oracle_functions, php3_minit_oracle, php3_mshutdown_oracle, ! php3_rinit_oracle, NULL, php3_info_oracle, 0, 0, 0, NULL }; static const text *ora_func_tab[] = --- 115,128 ---- }; php3_module_entry oracle_module_entry = { ! "Oracle", ! oracle_functions, ! php3_minit_oracle, ! php3_mshutdown_oracle, ! php3_rinit_oracle, ! NULL, ! php3_info_oracle, ! STANDARD_MODULE_PROPERTIES }; static const text *ora_func_tab[] = *************** *** 151,160 **** }; #if COMPILE_DL ! php3_module_entry *get_module() { return &oracle_module_entry; }; #if (WIN32|WINNT) && defined(THREAD_SAFE) ! /* NOTE: You should have an odbc.def file where you export DllMain */ BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { --- 161,170 ---- }; #if COMPILE_DL ! DLEXPORT php3_module_entry *get_module() { return &oracle_module_entry; }; #if (WIN32|WINNT) && defined(THREAD_SAFE) ! /* NOTE: You should have an oracle.def file where you export DllMain */ BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { *************** *** 179,191 **** #endif #endif - static void pvalue_ora_param_destructor(oraParam *param) - { - if(param && param->progv){ - efree(param->progv); - } - } - static int _cursors_cleanup(list_entry *le) { ORACLE_TLS_VARS; --- 189,194 ---- *************** *** 239,244 **** --- 242,249 ---- } if (cur->params){ _php3_hash_destroy(cur->params); + efree(cur->params); + cur->params = NULL; } if (cur->columns){ for(i = 0; i < cur->ncols; i++){ *************** *** 779,785 **** cursor->params = (HashTable *)emalloc(sizeof(HashTable)); if (!cursor->params || _php3_hash_init(cursor->params, 19, NULL, ! (void (*)(void *))pvalue_ora_param_destructor, 0) == FAILURE){ php3_error(E_ERROR, "Unable to initialize parameter list"); RETURN_FALSE; --- 784,791 ---- cursor->params = (HashTable *)emalloc(sizeof(HashTable)); if (!cursor->params || _php3_hash_init(cursor->params, 19, NULL, ! NULL, 0) == ! /* (void (*)(void *))pval_ora_param_destructor, 0) == */ FAILURE){ php3_error(E_ERROR, "Unable to initialize parameter list"); RETURN_FALSE; *************** *** 810,816 **** paramptr->progvl = argv[3]->value.lval + 1; if(argc > 4){ convert_to_long(argv[4]); ! paramptr->type = argv[4]->value.lval; }else{ paramptr->type = 0; } --- 816,822 ---- paramptr->progvl = argv[3]->value.lval + 1; if(argc > 4){ convert_to_long(argv[4]); ! paramptr->type = (short)argv[4]->value.lval; }else{ paramptr->type = 0; } *************** *** 834,845 **** RETURN_TRUE; } ! /* */ void php3_Ora_Exec(INTERNAL_FUNCTION_PARAMETERS) { /* cursor_index */ pval *arg; oraCursor *cursor = NULL; if (getParameters(ht, 1, &arg) == FAILURE) WRONG_PARAM_COUNT; --- 840,853 ---- RETURN_TRUE; } ! /* ! XXX Make return values compatible with old module ? */ void php3_Ora_Exec(INTERNAL_FUNCTION_PARAMETERS) { /* cursor_index */ pval *arg; oraCursor *cursor = NULL; + if (getParameters(ht, 1, &arg) == FAILURE) WRONG_PARAM_COUNT; *************** *** 1383,1392 **** --- 1391,1402 ---- void php3_info_oracle() { + #if !(WIN32|WINNT) php3_printf("Oracle version: %s<br>\n" "Compile-time ORACLE_HOME: %s<br>\n" "Libraries used: %s", PHP_ORACLE_VERSION, PHP_ORACLE_HOME, PHP_ORACLE_LIBS); + #endif } *************** *** 1405,1427 **** plist = ORACLE_GLOBAL(php3_oracle_module).resource_plist; conn = (oraConnection *)php3_list_find(ind, &type); ! if (conn && type != ORACLE_GLOBAL(php3_oracle_module).le_conn) return conn; conn = (oraConnection *)php3_plist_find(ind, &type); ! if (conn && type != ORACLE_GLOBAL(php3_oracle_module).le_pconn) return conn; php3_error(E_WARNING,"Bad Oracle connection number (%d)", ind); return NULL; } ! /* ! static void ! ora_del_conn(HashTable *list, int ind) ! { ! php3_list_delete(ind); ! } ! */ int ora_add_cursor(HashTable *list, oraCursor *cursor) { ORACLE_TLS_VARS; --- 1415,1431 ---- plist = ORACLE_GLOBAL(php3_oracle_module).resource_plist; conn = (oraConnection *)php3_list_find(ind, &type); ! if (conn && type == ORACLE_GLOBAL(php3_oracle_module).le_conn) return conn; conn = (oraConnection *)php3_plist_find(ind, &type); ! if (conn && type == ORACLE_GLOBAL(php3_oracle_module).le_pconn) return conn; php3_error(E_WARNING,"Bad Oracle connection number (%d)", ind); return NULL; } ! int ora_add_cursor(HashTable *list, oraCursor *cursor) { ORACLE_TLS_VARS; *************** *** 1570,1581 **** --- 1574,1592 ---- return 1; } + /* see oracle_hack.c */ + extern PHPAPI HashTable *php3i_get_symbol_table(void); + int ora_set_param_values(oraCursor *cursor, int isout) { char *paramname; oraParam *param; pval *pdata; int i, len; + #if (WIN32|WINNT) + /* see oracle_hack.c */ + HashTable *symbol_table=php3i_get_symbol_table(); + #endif _php3_hash_internal_pointer_reset(cursor->params); if(_php3_hash_num_elements(cursor->params) != cursor->nparams){ *************** *** 1589,1612 **** return 0; } if(_php3_hash_get_current_data(cursor->params, (void **)&param) == FAILURE){ ! php3_error(E_WARNING, "Can't get parameter data"); ! return 0; ! } if(isout){ /* XXX param->alen + 1 ?? */ if(param->type != 1 && param->alen > 0){ SET_VAR_STRINGL(paramname, param->progv, param->alen); } continue; }else if(param->type == 2){ continue; } ! if(_php3_hash_find(&GLOBAL(symbol_table), paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){ php3_error(E_WARNING, "Can't find variable for parameter"); return 0; } convert_to_string(pdata); if(param->progvl <= pdata->value.str.len){ php3_error(E_NOTICE, "Input value will be truncated"); --- 1600,1649 ---- return 0; } if(_php3_hash_get_current_data(cursor->params, (void **)&param) == FAILURE){ ! php3_error(E_WARNING, "Can't get parameter data"); ! efree(paramname); ! return 0; ! } if(isout){ /* XXX param->alen + 1 ?? */ if(param->type != 1 && param->alen > 0){ + #if (WIN32|WINNT) + /* see oracle_hack.c */ + { + pval var; + char *name=(paramname); + var.value.str.val = (param->progv); + var.value.str.len = (param->alen); + var.type = IS_STRING; + _php3_hash_update(symbol_table, name, strlen(name)+1, &var, sizeof(pval),NULL); + } + #else SET_VAR_STRINGL(paramname, param->progv, param->alen); + #endif } + efree(paramname); continue; }else if(param->type == 2){ + efree(paramname); continue; } ! ! /* FIXME Globals don't work in extensions on windows, have to do something ! else here. See oracle_hack.c */ ! #if (WIN32|WINNT) ! if(_php3_hash_find(symbol_table, paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){ ! php3_error(E_WARNING, "Can't find variable for parameter"); ! efree(paramname); ! return 0; ! } ! #else if(_php3_hash_find(&GLOBAL(symbol_table), paramname, strlen(paramname) + 1, (void **)&pdata) == FAILURE){ php3_error(E_WARNING, "Can't find variable for parameter"); + efree(paramname); return 0; } + #endif convert_to_string(pdata); if(param->progvl <= pdata->value.str.len){ php3_error(E_NOTICE, "Input value will be truncated"); *************** *** 1616,1670 **** strncpy(param->progv, pdata->value.str.val, len); param->progv[len] = '\0'; } return 1; } - /* Scan statement for parameters and setup hash if any found. Currently only named - parameters are supported (e.g. :foo). Returns number of distinct parameters. - */ - #if 0 - int ora_numparams(char *sql, oraCursor *curs) - { - while(*sql) { - if (*sql == '\'') - in_literal = ~in_literal; - if ((*sql != ':' && *sql != '?') || in_literal) { - sql++; - continue; - } - start = sql; /* save name inc colon */ - sql++; - if (*start == '?') { /* X/Open standard */ - return -1; - } else if (isDIGIT(*sql)){ /* ':1' */ - return -1; - } else if (isALNUM(*src)) { /* ':foo' */ - while(isALNUM(*src)) /* includes '_' */ - sql++; - } else { /* perhaps ':=' PL/SQL construct */ - continue; - } - namelen = sql - start; - if (curs->params == NULL){ - if (!(curs->params = (HashTable *)emalloc(sizeof(HashTable)))){ - php3_error(E_WARNING, "Out of memory"); - return -1; - } - if (_php3_hash_init(cursor->params, 19, NULL, - (void (*)(void *))pvalue_ora_param_destructor, 0) == - FAILURE){ - php3_error(E_WARNING, "Unable to initialize parameter list"); - efree(curs->params); - curs->params = NULL; - return -1; - } - } - _php3_hash_add(curs->params, start, namelen, ptr, size, (void **)&pDest) - - } - #endif #endif /* HAVE_ORACLE */ /* --- 1653,1664 ---- strncpy(param->progv, pdata->value.str.val, len); param->progv[len] = '\0'; + efree(paramname); } return 1; } #endif /* HAVE_ORACLE */ /* -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1878) next »