cvs: /php4/ext/pgsql pgsql.c php3_pgsql.h pqsql.dsp
| From: | Andi Gutmans | Date: | Sat, 20 Nov 1999 01:05:16 +0000 |
| Subject: | cvs: /php4/ext/pgsql pgsql.c php3_pgsql.h pqsql.dsp | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-6550@lists.php.net to get a copy of this message | ||
andi Fri Nov 19 20:05:16 1999 EDT
Modified files:
/php4/ext/pgsql pgsql.c php3_pgsql.h pqsql.dsp
Log:
- Should pretty much work now
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.25 php4/ext/pgsql/pgsql.c:1.26
--- php4/ext/pgsql/pgsql.c:1.25 Fri Nov 19 19:45:44 1999
+++ php4/ext/pgsql/pgsql.c Fri Nov 19 20:04:45 1999
@@ -17,11 +17,10 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql.c,v 1.25 1999/11/20 00:45:44 andi Exp $ */
+/* $Id: pgsql.c,v 1.26 1999/11/20 01:04:45 andi Exp $ */
#include <stdlib.h>
-
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
@@ -83,6 +82,8 @@
php3_module_entry *get_module() { return &pgsql_module_entry; }
#endif
+static int le_link,le_plink,le_result,le_lofp,le_string;
+
#ifdef ZTS
int pgsql_globals_id;
#else
@@ -120,12 +121,9 @@
efree(pg_result);
}
-
-int php3_minit_pgsql(INIT_FUNC_ARGS)
+static void php_pgsql_init_globals(PGLS_D)
{
- PGLS_FETCH();
- ELS_FETCH();
-
+ PGG(num_persistent) = 0;
if (cfg_get_long("pgsql.allow_persistent",&PGG(allow_persistent))==FAILURE) {
PGG(allow_persistent)=1;
}
@@ -135,13 +133,24 @@
if (cfg_get_long("pgsql.max_links",&PGG(max_links))==FAILURE) {
PGG(max_links)=-1;
}
- PGG(num_persistent)=0;
- PGG(le_link) = register_list_destructors(_close_pgsql_link,NULL);
- PGG(le_plink) = register_list_destructors(NULL,_close_pgsql_plink);
+}
+
+PHP_MINIT_FUNCTION(pgsql)
+{
+ ELS_FETCH();
+
+#ifdef ZTS
+ pgsql_globals_id = ts_allocate_id(sizeof(php_pgsql_globals), php_pgsql_init_globals, NULL);
+#else
+ php_pgsql_init_globals(PGLS_C);
+#endif
+
+ le_link = register_list_destructors(_close_pgsql_link,NULL);
+ le_plink = register_list_destructors(NULL,_close_pgsql_plink);
/* PGG(le_result = register_list_destructors(PQclear,NULL); */
- PGG(le_result) = register_list_destructors(_free_result,NULL);
- PGG(le_lofp) = register_list_destructors(_free_ptr,NULL);
- PGG(le_string) = register_list_destructors(_free_ptr,NULL);
+ le_result = register_list_destructors(_free_result,NULL);
+ le_lofp = register_list_destructors(_free_ptr,NULL);
+ le_string = register_list_destructors(_free_ptr,NULL);
REGISTER_LONG_CONSTANT("PGSQL_ASSOC", PGSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_NUM", PGSQL_NUM, CONST_CS | CONST_PERSISTENT);
@@ -277,7 +286,7 @@
}
/* hash it up */
- new_le.type = PGG(le_plink);
+ new_le.type = le_plink;
new_le.ptr = pgsql;
if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le,
sizeof(list_entry), NULL)==FAILURE) {
efree(hashed_details);
@@ -286,7 +295,7 @@
PGG(num_links)++;
PGG(num_persistent)++;
} else { /* we do */
- if (le->type != PGG(le_plink)) {
+ if (le->type != le_plink) {
RETURN_FALSE;
}
/* ensure that the link did not die */
@@ -305,7 +314,7 @@
}
pgsql = (PGconn *) le->ptr;
}
- return_value->value.lval = php3_list_insert(pgsql,PGG(le_plink));
+ return_value->value.lval = php3_list_insert(pgsql,le_plink);
return_value->type = IS_LONG;
} else {
list_entry *index_ptr,new_index_ptr;
@@ -324,7 +333,7 @@
}
link = (int) index_ptr->ptr;
ptr = php3_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==PGG(le_link) || type==PGG(le_plink))) {
+ if (ptr && (type==le_link || type==le_plink)) {
return_value->value.lval = PGG(default_link) = link;
return_value->type = IS_LONG;
efree(hashed_details);
@@ -350,7 +359,7 @@
}
/* add it to the list */
- return_value->value.lval = php3_list_insert(pgsql,PGG(le_link));
+ return_value->value.lval = php3_list_insert(pgsql,le_link);
return_value->type = IS_LONG;
/* add it to the hash */
@@ -421,7 +430,7 @@
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
@@ -463,7 +472,7 @@
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
@@ -575,7 +584,7 @@
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
@@ -604,7 +613,7 @@
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
- return_value->value.lval = php3_list_insert(pg_result,PGG(le_result));
+ return_value->value.lval = php3_list_insert(pg_result,le_result);
return_value->type = IS_LONG;
} else {
RETURN_FALSE;
@@ -633,7 +642,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -721,7 +730,7 @@
if ((tmp_name=PQgetvalue(result,i,name_offset))==NULL) {
continue;
}
- new_oid_entry.type = PGG(le_string);
+ new_oid_entry.type = le_string;
new_oid_entry.ptr = estrdup(tmp_name);
zend_hash_update(list,hashed_oid_key,strlen(hashed_oid_key)+1,(void *) &new_oid_entry,
sizeof(list_entry), NULL);
if (!ret && atoi(tmp_oid)==oid) {
@@ -752,7 +761,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -827,7 +836,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -856,7 +865,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -925,7 +934,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -1017,7 +1026,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -1088,7 +1097,7 @@
}
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -1114,7 +1123,7 @@
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
@@ -1157,7 +1166,7 @@
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
@@ -1214,7 +1223,7 @@
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
@@ -1268,7 +1277,7 @@
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
@@ -1314,7 +1323,7 @@
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
- return_value->value.lval = php3_list_insert(pgsql_lofp, PGG(le_lofp));
+ return_value->value.lval = php3_list_insert(pgsql_lofp, le_lofp);
return_value->type = IS_LONG;
}
}
@@ -1326,7 +1335,7 @@
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
- return_value->value.lval = php3_list_insert(pgsql_lofp, PGG(le_lofp));
+ return_value->value.lval = php3_list_insert(pgsql_lofp, le_lofp);
return_value->type = IS_LONG;
}
}
@@ -1355,7 +1364,7 @@
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
@@ -1397,7 +1406,7 @@
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
@@ -1440,7 +1449,7 @@
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
@@ -1480,7 +1489,7 @@
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
Index: php4/ext/pgsql/php3_pgsql.h
diff -u php4/ext/pgsql/php3_pgsql.h:1.5 php4/ext/pgsql/php3_pgsql.h:1.6
--- php4/ext/pgsql/php3_pgsql.h:1.5 Fri Nov 19 19:30:08 1999
+++ php4/ext/pgsql/php3_pgsql.h Fri Nov 19 20:04:45 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php3_pgsql.h,v 1.5 1999/11/20 00:30:08 andi Exp $ */
+/* $Id: php3_pgsql.h,v 1.6 1999/11/20 01:04:45 andi Exp $ */
#ifndef _PHP3_PGSQL_H
#define _PHP3_PGSQL_H
@@ -58,7 +58,7 @@
#define PHP_PGSQL_API
#endif
-extern int php3_minit_pgsql(INIT_FUNC_ARGS);
+extern PHP_MINIT_FUNCTION(pgsql);;
extern int php3_rinit_pgsql(INIT_FUNC_ARGS);
PHP_FUNCTION(pgsql_connect);
PHP_FUNCTION(pgsql_pconnect);
@@ -117,7 +117,7 @@
long num_links,num_persistent;
long max_links,max_persistent;
long allow_persistent;
- int le_link,le_plink,le_result,le_lofp,le_string;
+ int le_lofp,le_string;
} php_pgsql_globals;
/* extern pgsql_module php3_pgsql_module; */
Index: php4/ext/pgsql/pqsql.dsp
diff -u php4/ext/pgsql/pqsql.dsp:1.1 php4/ext/pgsql/pqsql.dsp:1.2
--- php4/ext/pgsql/pqsql.dsp:1.1 Fri Nov 19 19:45:44 1999
+++ php4/ext/pgsql/pqsql.dsp Fri Nov 19 20:04:45 1999
@@ -43,7 +43,8 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PQSQL_EXPORTS" /YX
/FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\libzend" /I
"..\..\..\PostgreSQL\include" /I "..\..\..\bindlib_w32" /D "WIN32" /D
"NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"PQSQL_EXPORTS" /D HAVE_PGSQL=1 /D "COMPILE_DL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\libzend" /I
"..\..\..\PostgreSQL\include" /I "..\..\..\bindlib_w32" /D "WIN32" /D
"NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"PQSQL_EXPORTS" /D HAVE_PGSQL=1 /D "COMPILE_DL" /D "ZTS" /FD /c
+# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -53,7 +54,7 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libpq.lib php4ts.lib ws2_32.lib /nologo /dll
/machine:I386 /libpath:"..\..\..\PostgreSQL\lib" /libpath:"..\..\Release_TS"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libpqdll.lib php4ts.lib /nologo
/dll /machine:I386 /libpath:"..\..\..\PostgreSQL\lib"
/libpath:"..\..\Release_TS"
!ELSEIF "$(CFG)" == "pqsql - Win32 Debug"
@@ -68,8 +69,8 @@
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PQSQL_EXPORTS" /YX
/FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\libzend" /I
"..\..\..\PostgreSQL\include" /I "..\..\..\bindlib_w32" /D "WIN32" /D
"_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"PQSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_PGSQL=1 /D "ZTS" /FR /YX /FD
/GZ /c
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PQSQL_EXPORTS" /YX
/FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\libzend" /I
"..\..\..\PostgreSQL\include" /I "..\..\..\bindlib_w32" /D "WIN32" /D
"_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"PQSQL_EXPORTS" /D "COMPILE_DL" /D HAVE_PGSQL=1 /D "ZTS" /FR /YX /FD
/GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"