Skip to content

Commit f857a77

Browse files
author
Danny Heijl
committed
Informix extension now works but php_ini stuff still needs rewriting.
1 parent 9a910ed commit f857a77

File tree

2 files changed

+47
-46
lines changed

2 files changed

+47
-46
lines changed

MODULES_STATUS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ ldap Working
1414
oci8 Working (but no blob-support yet)
1515
oracle Working
1616
iptc Working
17-
informix being ported (compiles but does not work yet)
17+
informix Working (php_ini stuff needs rewriting)

ext/informix/ifx.ec

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -395,23 +395,13 @@ char *a_result_id;
395395

396396
int php3_minit_ifx(INIT_FUNC_ARGS)
397397
{
398-
#if defined(THREAD_SAFE)
399-
ifx_global_struct *ifx_globals;
400-
CREATE_MUTEX(ifx_mutex,"Informix_TLS");
401-
SET_MUTEX(ifx_mutex);
402-
numthreads++;
403-
if (numthreads==1){
404-
if ((InformixTls=TlsAlloc())==0xFFFFFFFF){
405-
FREE_MUTEX(ifx_mutex);
406-
return 0;
407-
}
408-
}
409-
FREE_MUTEX(ifx_mutex);
410-
ifx_globals = (ifx_global_struct *)
411-
LocalAlloc(LPTR, sizeof(ifx_global_struct));
412-
TlsSetValue(InformixTls, (void *) ifx_globals);
398+
#ifdef ZTS
399+
ifx_globals_id = ts_allocate_id(sizeof(php_ifx_globals), php_ifx_init_globals, NULL);
400+
#else
401+
IFXG(num_persistent)=0;
413402
#endif
414403

404+
415405
if (cfg_get_long("ifx.blobinfile",
416406
&IFXG(blobinfile))==FAILURE) {
417407
IFXG(blobinfile)=BLOBINFILE;
@@ -470,16 +460,14 @@ int php3_minit_ifx(INIT_FUNC_ARGS)
470460
|| IFXG(default_password)[0]==0) {
471461
IFXG(default_password)=NULL;
472462
}
463+
473464
IFXG(num_persistent)=0;
474465
IFXG(sv_sqlcode)=0;
475-
IFXG(le_result) =
476-
register_list_destructors(ifx_free_result,NULL);
477-
IFXG(le_idresult) =
478-
register_list_destructors(ifx_free_result,NULL);
479-
IFXG(le_link) =
480-
register_list_destructors(_close_ifx_link,NULL);
481-
IFXG(le_plink) =
482-
register_list_destructors(NULL,_close_ifx_plink);
466+
467+
IFXG(le_result) = register_list_destructors(ifx_free_result,NULL);
468+
IFXG(le_idresult) = register_list_destructors(ifx_free_result,NULL);
469+
IFXG(le_link) = register_list_destructors(_close_ifx_link,NULL);
470+
IFXG(le_plink) = register_list_destructors(NULL,_close_ifx_plink);
483471

484472
#if 0
485473
printf("Registered: %d,%d,%d\n",
@@ -505,21 +493,9 @@ $endif;
505493

506494

507495
int php3_mshutdown_ifx(SHUTDOWN_FUNC_ARGS){
508-
#if defined(THREAD_SAFE)
509-
IFXLS_FETCH();
510-
if (ifx_globals != 0)
511-
LocalFree((HLOCAL) ifx_globals);
512-
SET_MUTEX(ifx_mutex);
513-
numthreads--;
514-
if (!numthreads){
515-
if (!TlsFree(InformixTls)){
516-
FREE_MUTEX(ifx_mutex);
517-
return 0;
518-
}
519-
}
520-
FREE_MUTEX(ifx_mutex);
521-
#endif
496+
522497
return SUCCESS;
498+
523499
}
524500

525501
int php3_rinit_ifx(INIT_FUNC_ARGS)
@@ -756,8 +732,7 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
756732
}
757733
ifx = le->ptr;
758734
}
759-
return_value->value.lval = php3_list_insert(ifx,
760-
IFXG(le_plink));
735+
return_value->value.lval = php3_list_insert(ifx, IFXG(le_plink));
761736
return_value->type = IS_LONG;
762737
} else { /* non persistent */
763738
list_entry *index_ptr,new_index_ptr;
@@ -996,10 +971,23 @@ EXEC SQL END DECLARE SECTION;
996971

997972
IFXG(sv_sqlcode) = 0;
998973

999-
/* get the first 2 parameters */
1000-
if (getParameters(ht, 2, &query, &ifx_link)==FAILURE) {
1001-
RETURN_FALSE;
974+
/* get the first 2 parameters,
975+
php4 insists on the correct number of arguments */
976+
switch(ARG_COUNT(ht)) {
977+
case 2:
978+
if (getParameters(ht, 2, &query, &ifx_link)==FAILURE)
979+
RETURN_FALSE;
980+
break;
981+
case 3:
982+
if (getParameters(ht, 3, &query, &ifx_link, &dummy)==FAILURE)
983+
RETURN_FALSE;
984+
break;
985+
case 4:
986+
if (getParameters(ht, 4, &query, &ifx_link, &dummy, &dummy)==FAILURE)
987+
RETURN_FALSE;
988+
break;
1002989
}
990+
1003991
convert_to_long(ifx_link);
1004992
id = ifx_link->value.lval;
1005993

@@ -1378,10 +1366,23 @@ EXEC SQL END DECLARE SECTION;
13781366

13791367
IFXG(sv_sqlcode) = 0;
13801368

1381-
/* get the first 2 parameters */
1382-
if (getParameters(ht, 2, &query, &ifx_link)==FAILURE) {
1383-
RETURN_FALSE;
1369+
/* get the first 2 parameters,
1370+
php4 insists on the correct number of arguments */
1371+
switch(ARG_COUNT(ht)) {
1372+
case 2:
1373+
if (getParameters(ht, 2, &query, &ifx_link)==FAILURE)
1374+
RETURN_FALSE;
1375+
break;
1376+
case 3:
1377+
if (getParameters(ht, 3, &query, &ifx_link, &dummy)==FAILURE)
1378+
RETURN_FALSE;
1379+
break;
1380+
case 4:
1381+
if (getParameters(ht, 4, &query, &ifx_link, &dummy, &dummy)==FAILURE)
1382+
RETURN_FALSE;
1383+
break;
13841384
}
1385+
13851386
convert_to_long(ifx_link);
13861387
id = ifx_link->value.lval;
13871388

0 commit comments

Comments
 (0)