#include "ext/standard/php3_standard.h"
#include "php_informix.h"
#include "php_globals.h"
-
+#include "php_ini.h"
#if WIN32|WINNT
#include <winsock.h>
#include <netinet/in.h>
#endif
-#include "php_ini.h"
#if HAVE_IFX
STANDARD_MODULE_PROPERTIES
};
+static php_ifx_listids ifx_listids; /* these are globals, no thread safety needed says zeeev */
+
+
#ifdef COMPILE_DL
DLEXPORT php3_module_entry *get_module(void) { return &ifx_module_entry; }
#if 0
#endif
-#define CHECK_LINK(link) { \
- if (link==0) { \
- php_error(E_WARNING, \
- "Informix: A link to the server could not be established"); \
- RETURN_FALSE; \
- } \
- }
+#define CHECK_LINK(link) { if (link==0) { php_error(E_WARNING, "Informix: A link to the server could not be established"); RETURN_FALSE; }}
#define DUP 1
OnUpdateInt, nullformat, php_ifx_globals, ifx_globals)
PHP_INI_END()
+#ifdef ZTS
+static void php_ifx_init_globals(php_ifx_globals *ifx_globals)
+{
+ IFXG(num_persistent) = 0;
+ IFXG(nullvalue) = malloc(1);
+ IFXG(nullvalue)[0] = 0;
+ IFXG(nullstring) = malloc(5);
+ strcpy(IFXG(nullstring), "NULL");
+
+ IFXG(num_persistent)=0;
+ IFXG(sv_sqlcode)=0;
+
+}
+#endif
+
PHP_MINIT_FUNCTION(ifx)
{
ELS_FETCH();
#ifdef ZTS
ifx_globals_id = ts_allocate_id(sizeof(php_ifx_globals), php_ifx_init_globals, NULL);
+
#else
IFXG(num_persistent)=0;
-#endif
-
- REGISTER_INI_ENTRIES();
-
IFXG(nullvalue) = malloc(1);
IFXG(nullvalue)[0] = 0;
IFXG(nullstring) = malloc(5);
IFXG(num_persistent)=0;
IFXG(sv_sqlcode)=0;
- IFXG(le_result) = register_list_destructors(ifx_free_result,NULL);
- IFXG(le_idresult) = register_list_destructors(ifx_free_result,NULL);
- IFXG(le_link) = register_list_destructors(_close_ifx_link,NULL);
- IFXG(le_plink) = register_list_destructors(NULL,_close_ifx_plink);
+#endif
+ REGISTER_INI_ENTRIES();
+
+ IFXL(le_result) = register_list_destructors(ifx_free_result,NULL);
+ IFXL(le_idresult) = register_list_destructors(ifx_free_result,NULL);
+ IFXL(le_link) = register_list_destructors(_close_ifx_link,NULL);
+ IFXL(le_plink) = register_list_destructors(NULL,_close_ifx_plink);
+
+ ifx_module_entry.type = type;
+
#if 0
printf("Registered: %d,%d,%d\n",
- IFXG(le_result),
- IFXG(le_link),
- IFXG(le_plink));
+ IFXL(le_result),
+ IFXL(le_link),
+ IFXL(le_plink));
#endif
- ifx_module_entry.type = type;
-
REGISTER_LONG_CONSTANT("IFX_SCROLL", IFX_SCROLL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IFX_HOLD", IFX_HOLD, CONST_CS | CONST_PERSISTENT);
$ifdef HAVE_IFX_IUS;
}
/* hash it up */
- new_le.type = IFXG(le_plink);
+ new_le.type = IFXL(le_plink);
new_le.ptr = ifx;
if (zend_hash_update(plist, hashed_details,
hashed_details_length+1,
IFXG(num_persistent)++;
IFXG(num_links)++;
} else { /* we do */
- if (le->type != IFXG(le_plink)) {
+ if (le->type != IFXL(le_plink)) {
RETURN_FALSE;
}
/* ensure that the link did not die */
}
ifx = le->ptr;
}
- ZEND_REGISTER_RESOURCE(return_value, ifx, IFXG(le_plink));
+ ZEND_REGISTER_RESOURCE(return_value, ifx, IFXL(le_plink));
} else { /* non persistent */
list_entry *index_ptr,new_index_ptr;
}
link = (int) index_ptr->ptr;
ptr = zend_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==IFXG(le_link) || type==IFXG(le_plink))) {
+ if (ptr && (type==IFXL(le_link) || type==IFXL(le_plink))) {
zend_list_addref(link);
return_value->value.lval = link;
php3_ifx_set_default_link(link);
}
/* add it to the list */
- ZEND_REGISTER_RESOURCE(return_value, ifx, IFXG(le_link));
+ ZEND_REGISTER_RESOURCE(return_value, ifx, IFXL(le_link));
/* add it to the hash */
new_index_ptr.ptr = (void *) return_value->value.lval;
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE2(ifx, char *, ifx_link, id, "IFX link", IFXG(le_link), IFXG(le_plink));
+ ZEND_FETCH_RESOURCE2(ifx, char *, ifx_link, id, "IFX link", IFXL(le_link), IFXL(le_plink));
EXEC SQL SET CONNECTION :ifx;
EXEC SQL close database;
}
id = -1;
- ZEND_FETCH_RESOURCE2(ifx, char *, ifx_link, id, "IFX link", IFXG(le_link), IFXG(le_plink));
+ ZEND_FETCH_RESOURCE2(ifx, char *, ifx_link, id, "IFX link", IFXL(le_link), IFXL(le_plink));
affected_rows = -1; /* invalid */
}
- ZEND_REGISTER_RESOURCE(return_value, Ifx_Result, IFXG(le_result));
+ ZEND_REGISTER_RESOURCE(return_value, Ifx_Result, IFXL(le_result));
}
/* }}} */
}
id = -1;
- ZEND_FETCH_RESOURCE2(ifx, char *, ifx_link, id, "IFX link", IFXG(le_link), IFXG(le_plink));
+ ZEND_FETCH_RESOURCE2(ifx, char *, ifx_link, id, "IFX link", IFXL(le_link), IFXL(le_plink));
affected_rows = -1; /* invalid */
} /* if select */
- ZEND_REGISTER_RESOURCE(return_value, Ifx_Result, IFXG(le_result));
+ ZEND_REGISTER_RESOURCE(return_value, Ifx_Result, IFXL(le_result));
}
/* }}} */
break;
}
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
IFXG(sv_sqlcode) = 0;
IFXG(sv_sqlcode )= 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
return_value->value.lval = Ifx_Result->affected_rows;
return_value->type = IS_LONG;
break;
}
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
nullstr=php3_intifx_null();
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
if (strcmp(Ifx_Result->cursorid,"") == 0) {
php_error(E_WARNING,"Not a select cursor !");
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
if (strcmp(Ifx_Result->cursorid,"") == 0) {
php_error(E_WARNING,"Not a select cursor !");
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
if (strcmp(Ifx_Result->cursorid,"") == 0) {
php_error(E_WARNING,"Not a select cursor !");
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
return_value->value.lval = Ifx_Result->rowid;
return_value->type = IS_LONG;
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
/* create pseudo-row array to return */
if (array_init(return_value)==FAILURE) {
IFXG(sv_sqlcode) = 0;
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
return_value->value.lval = Ifx_Result->numcols;
return_value->type = IS_LONG;
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXG(le_result));
+ ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", IFXL(le_result));
IFXG(sv_sqlcode = 0);
IFX_IDRES *Ifx_res;
int type;
+ IFXLS_FETCH();
+
Ifx_res = (IFX_IDRES *) php3_list_find(id,&type);
- if (type!=IFXG(le_idresult)) {
+ if (type!=IFXL(le_idresult)) {
php_error(E_WARNING,"%d is not a Informix id-result index",
id);
return -1;
static long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list) {
IFX_IDRES *Ifx_blob;
+ IFXLS_FETCH();
Ifx_blob=emalloc(sizeof(IFX_IDRES));
if(Ifx_blob==NULL) {
Ifx_blob->BLOB.blob_data.loc_oflags=LOC_WONLY;
Ifx_blob->BLOB.blob_data.loc_size=-1;
}
- return php3_list_insert(Ifx_blob,IFXG(le_idresult));
+ return php3_list_insert(Ifx_blob,IFXL(le_idresult));
}
IFX_IDRES *Ifx_blob, *Ifx_blob_orig;
loc_t *locator, *locator_orig;
int type;
+
+ IFXLS_FETCH();
Ifx_blob_orig = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || !(Ifx_blob_orig->type==TYPE_BLBYTE || Ifx_blob_orig->type==TYPE_BLTEXT)) {
+ if (type!=IFXL(le_idresult) || !(Ifx_blob_orig->type==TYPE_BLBYTE || Ifx_blob_orig->type==TYPE_BLTEXT)) {
php_error(E_WARNING,"%d is not a Informix blob-result index",
bid);
return -1;
locator->loc_oflags=locator_orig->loc_oflags;
}
- return php3_list_insert(Ifx_blob,IFXG(le_idresult));
+ return php3_list_insert(Ifx_blob,IFXL(le_idresult));
}
IFX_IDRES *Ifx_blob;
int type;
+ IFXLS_FETCH();
+
Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
php_error(E_WARNING,"%d is not a Informix blob-result index",
bid);
return -1;
IFX_IDRES *Ifx_blob;
int type;
+ IFXLS_FETCH();
+
Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
php_error(E_WARNING,"%d is not a Informix blob-result index",
bid);
return -1;
IFX_IDRES *Ifx_blob;
int type;
+ IFXLS_FETCH();
+
Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
php_error(E_WARNING,"%d is not a Informix blob-result index",
bid);
return -1;
IFX_IDRES *Ifx_blob;
int type;
+ IFXLS_FETCH();
+
Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
php_error(E_WARNING,"%d is not a Informix blob-result index",
bid);
return NULL;
IFX_IDRES *Ifx_blob;
int type;
+ IFXLS_FETCH();
+
Ifx_blob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
php_error(E_WARNING,"%d is not a Informix blob-result index",
bid);
return -1;
PHP_FUNCTION(ifx_blobinfile_mode) {
pval *pmode;
-
+
+ IFXLS_FETCH();
+
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
WRONG_PARAM_COUNT;
}
sets the default text-mode for all select-queries */
PHP_FUNCTION(ifx_textasvarchar) {
pval *pmode;
+
+ IFXLS_FETCH();
-
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
WRONG_PARAM_COUNT;
}
PHP_FUNCTION(ifx_byteasvarchar) {
pval *pmode;
+
+ IFXLS_FETCH();
+
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
WRONG_PARAM_COUNT;
}
PHP_FUNCTION(ifx_nullformat) {
pval *pmode;
+
+ IFXLS_FETCH();
+
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
WRONG_PARAM_COUNT;
static char* php3_intifx_null() {
char* tmp;
+
+ IFXLS_FETCH();
+
if(IFXG(nullformat)==0) {
tmp=IFXG(nullvalue);
} else {
static long php3_intifx_create_char(char* param, long len, HashTable *list) {
IFX_IDRES *Ifx_char;
+
+ IFXLS_FETCH();
Ifx_char=emalloc(sizeof(IFX_IDRES));
if(Ifx_char==NULL) {
Ifx_char->CHAR.char_data[len]=0;
Ifx_char->CHAR.len=len;
}
- return php3_list_insert(Ifx_char,IFXG(le_idresult));
+ return php3_list_insert(Ifx_char,IFXL(le_idresult));
}
/* ----------------------------------------------------------------------
static long php3_intifx_get_char(long bid, HashTable *list, char** content) {
IFX_IDRES *Ifx_char;
int type;
-
+
+ IFXLS_FETCH();
+
Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
php_error(E_WARNING,"%d is not a Informix char-result index",
bid);
return -1;
IFX_IDRES *Ifx_char;
int type;
+
+ IFXLS_FETCH();
+
Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
php_error(E_WARNING,"%d is not a Informix char-result index",
bid);
return -1;
IFX_IDRES *Ifx_char;
int type;
+ IFXLS_FETCH();
+
Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
+ if (type!=IFXL(le_idresult) && !(Ifx_char->type==TYPE_CHAR)) {
php_error(E_WARNING,"%d is not a Informix char-result index",
bid);
return -1;
return -1;
}
- return php3_list_insert(Ifx_slob,IFXG(le_idresult));
+ return php3_list_insert(Ifx_slob,IFXL(le_idresult));
}
IFX_IDRES *Ifx_slob;
int type;
+ IFXLS_FETCH();
+
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
return -1;
IFX_IDRES *Ifx_slob;
int type;
+ IFXLS_FETCH();
+
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
return -1;
int errcode;
int type;
+ IFXLS_FETCH();
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
return -1;
static long php3_intifxus_new_slob(HashTable *list) {
IFX_IDRES *Ifx_slob;
+ IFXLS_FETCH();
Ifx_slob=emalloc(sizeof(IFX_IDRES));
if(Ifx_slob==NULL) {
Ifx_slob->type=TYPE_SLOB;
Ifx_slob->SLOB.lofd=-1;
Ifx_slob->SLOB.createspec=NULL;
- return php3_list_insert(Ifx_slob,IFXG(le_idresult));
+ return php3_list_insert(Ifx_slob,IFXL(le_idresult));
}
IFX_IDRES *Ifx_slob;
int type;
+ IFXLS_FETCH();
+
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
return NULL;
int type;
long lakt_seek_pos;
+ IFXLS_FETCH();
+
+
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(pbid);
bid=pbid->value.lval;
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
RETURN_FALSE;
ifx_int8_t akt_seek_pos,offset;
int type,mode;
+
+ IFXLS_FETCH();
+
if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &pbid, &pmode, &poffset)==FAILURE) {
WRONG_PARAM_COUNT;
}
bid=pbid->value.lval;
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
RETURN_FALSE;
int errcode,type;
char *buffer;
+
+ IFXLS_FETCH();
+
if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid, &pnbytes)==FAILURE) {
WRONG_PARAM_COUNT;
bid=pbid->value.lval;
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
RETURN_FALSE;
int errcode,type;
char *buffer;
+
+ IFXLS_FETCH();
+
if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid, &pcontent)==FAILURE) {
WRONG_PARAM_COUNT;
bid=pbid->value.lval;
Ifx_slob = (IFX_IDRES *) php3_list_find(bid,&type);
- if (type!=IFXG(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
+ if (type!=IFXL(le_idresult) || Ifx_slob->type!=TYPE_SLOB) {
php_error(E_WARNING,"%d is not a Informix slob-result index",
bid);
RETURN_FALSE;