Skip to content

Commit f110b97

Browse files
author
Danny Heijl
committed
New ini-stuff incorporated. Porting to PHP4 and ZTS hopefully complete.
1 parent c927593 commit f110b97

File tree

2 files changed

+34
-148
lines changed

2 files changed

+34
-148
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 Working (including blobs, php_ini stuff still needs rewriting)
17+
informix Working

ext/informix/ifx.ec

Lines changed: 33 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
| license@php.net so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
1515
| Authors: Danny Heijl <Danny.Heijl@cevi.be> : initial cut (ODS 7.2x) |
16+
| PHP4 port |
1617
| Christian Cartus <chc@idgruppe.de> : blobs, and IUS 9 |
1718
| Jouni Ahto <jah@mork.net> : configuration stuff |
1819
| Based on the MySQL code by: Zeev Suraski <zeev@php.net> |
@@ -25,92 +26,13 @@
2526
* you a very short one
2627
* -------------------------------------------------------------------
2728
*/
28-
/*
29-
* I started with the mysql-driver, removed all stuff I did not need,
30-
* and changed all mysql-specific stuff to Informix-ESQL/C.
31-
* I used the X-open way of using ESQL/C (using an SQL descriptor and
32-
* not the Informix-specific way). It is perhaps a little bit slower,
33-
* but more verbose and less prone to coding errors.
34-
* This is the first time in my life I coded ESQL/C, so do not look too
35-
* closely and do not hesitate to point out errors/omissions etc...
36-
* Aug. 8, 1998
37-
* Danny Heijl, Danny.Heijl@cevi.be
38-
*/
3929

4030
/* TODO:
4131
*
4232
* ? Safe mode implementation
43-
*
44-
* Jouni Ahto promised help and already did the configuration stuff
45-
* (Jouni Ahto <jah@mork.net>).
46-
*
4733
*/
4834

4935

50-
/*
51-
Changes: 23.8.1998 (chc@idgruppe.de)
52-
- full blobsupport (TEXT and BYTE)
53-
- new functions: ifx_create_blob, ifx_copy_blob, ifx_free_blob,
54-
ifx_update_blob, ifx_get_blob, ifx_blobinfile_mode
55-
- file and memory-support of blobs
56-
- load TEXT and BYTE in memory by default
57-
(controllable by "ifx.blobinfile" in php3.ini-file)
58-
- update all functions to support blobs (ifx_query, ifx_prepare,
59-
ifx_do, ifx_htmltbl_result, ifx_fetch_row)
60-
- minor bug-fixes
61-
- Test-Page (informix_blob.php3) which tests the blob-support
62-
63-
64-
Changes: 11.9.1998 (chc@idgruppe.de)
65-
- ifx_query and ifx_prepare: blob-paramters now as array
66-
- new funtions: ifx_textasvarchar, ifx_byteasvarchar, ifx_nullformat
67-
- new php.ini-variables: ifx.textasvarchar, ifx.byteasvarchar, ifx.nullformat
68-
- update all functions to support blobarray and new functions
69-
(ifx_query, ifx_prepare, ifx_do, ifx_htmltbl_result, ifx_fetch_row)
70-
- minor bug-fixes
71-
- Test-Page (informix_blob.php3) updated
72-
- begin with coding of slob-support
73-
(still deactivated, not yet complete: #undef HAVE_IFX_IUS in php3_ifx.h)
74-
- ifx_fetch_row returns always a blob-id (contains "NULL"-flag or content from db)
75-
(except ifx_textasvarchar, ifx_byteasvarchar set to 1)
76-
77-
Changes 14.9.1998 (chc@idgruppe.de)
78-
- supports now IUS- serial8,int8,boolean, nchar, nvchar, lvarchar
79-
- still incomplete slob-support
80-
81-
Changes 25.9.1998 (danny.heijl@cevi.be)
82-
- cursory and non-cursory stored procedures
83-
84-
Changes 24.10.1998 (chc@idgruppe.de)
85-
- changes the internal structure of IFX_BLOB and IFX_SLOB into one structure.
86-
it is now prepared for general-id-usage.
87-
- fixed a lvarchar-bug (i hate esql/c)
88-
89-
Changes 12.11.1998 (danny.heijl@cevi.be)
90-
- added proto comments
91-
92-
Changes 04/03/1999 (danny.heijl@cevi.be)
93-
- added "SET CONNECTION" statement to ifx_fetch_row() so that you can now
94-
fetch rows from different databases simultaneously
95-
(ifx_query() & ifx_prepare() were already OK).
96-
97-
Changes 05/03/1999 (danny.heijl@cevi.be)
98-
- made all sqlerrd[] fields of sqlca structure available
99-
with ifx_getsqlca($query_id) in a pseudo-row after a
100-
prepare (select statements) or insert/update (non-select statements).
101-
gives access to affected rows and serial insert values
102-
- made all internal functions static
103-
104-
105-
Changes 09/03/1999 (danny.heijl@cevi.be)
106-
- suppressed ESQL/C BLOB memory leak fix for ESQL/C 7.24 and higher
107-
this is the same fix as in Perl DBD::Informix
108-
- really free an Ifx_Result now, do not wait for script termination
109-
- code cleanup
110-
111-
*/
112-
113-
11436
#if defined(COMPILE_DL)
11537
#include "dl/phpdl.h"
11638
#endif
@@ -250,7 +172,7 @@ php3_module_entry ifx_module_entry = {
250172
STANDARD_MODULE_PROPERTIES
251173
};
252174

253-
#if COMPILE_DL
175+
#ifdef COMPILE_DL
254176
DLEXPORT php3_module_entry *get_module(void) { return &ifx_module_entry; }
255177
#if 0
256178
BOOL WINAPI DllMain(HANDLE hModule,
@@ -393,74 +315,47 @@ char *a_result_id;
393315
return;
394316
}
395317

318+
319+
PHP_INI_BEGIN()
320+
STD_PHP_INI_ENTRY("ifx.allow_persistent", "1", PHP_INI_SYSTEM,
321+
OnUpdateInt, allow_persistent, php_ifx_globals, ifx_globals)
322+
STD_PHP_INI_ENTRY("ifx.max_persistent", "0", PHP_INI_SYSTEM,
323+
OnUpdateInt, max_persistent, php_ifx_globals, ifx_globals)
324+
STD_PHP_INI_ENTRY("ifx.max_links", "0", PHP_INI_SYSTEM,
325+
OnUpdateInt, max_links, php_ifx_globals, ifx_globals)
326+
STD_PHP_INI_ENTRY("ifx.default_host", NULL, PHP_INI_SYSTEM,
327+
OnUpdateString, default_host, php_ifx_globals, ifx_globals)
328+
STD_PHP_INI_ENTRY("ifx.default_user", NULL, PHP_INI_SYSTEM,
329+
OnUpdateString, default_user, php_ifx_globals, ifx_globals)
330+
STD_PHP_INI_ENTRY("ifx.default_password", NULL, PHP_INI_SYSTEM,
331+
OnUpdateString, default_password, php_ifx_globals, ifx_globals)
332+
STD_PHP_INI_ENTRY("ifx.blobinfile", "1", PHP_INI_ALL,
333+
OnUpdateInt, blobinfile, php_ifx_globals, ifx_globals)
334+
STD_PHP_INI_ENTRY("ifx.textasvarchar", "0", PHP_INI_ALL,
335+
OnUpdateInt, textasvarchar, php_ifx_globals, ifx_globals)
336+
STD_PHP_INI_ENTRY("ifx.byteasvarchar", "0", PHP_INI_ALL,
337+
OnUpdateInt, byteasvarchar, php_ifx_globals, ifx_globals)
338+
STD_PHP_INI_ENTRY("ifx.charasvarchar", "0", PHP_INI_ALL,
339+
OnUpdateInt, charasvarchar, php_ifx_globals, ifx_globals)
340+
STD_PHP_INI_ENTRY("ifx.nullformat", "0", PHP_INI_ALL,
341+
OnUpdateInt, nullformat, php_ifx_globals, ifx_globals)
342+
PHP_INI_END()
343+
396344
int php3_minit_ifx(INIT_FUNC_ARGS)
397345
{
398346
#ifdef ZTS
399-
ifx_globals_id = ts_allocate_id(sizeof(php_ifx_globals), php_ifx_init_globals, NULL);
347+
ifx_globals_id = ts_allocate_id(sizeof(php_ifx_globals), php_ifx_init_globals, NULL);
400348
#else
401-
IFXG(num_persistent)=0;
349+
IFXG(num_persistent)=0;
402350
#endif
403351

404-
405-
if (cfg_get_long("ifx.blobinfile",
406-
&IFXG(blobinfile))==FAILURE) {
407-
IFXG(blobinfile)=BLOBINFILE;
408-
}
409-
410-
if (cfg_get_long("ifx.textasvarchar",
411-
&IFXG(textasvarchar))==FAILURE) {
412-
IFXG(textasvarchar)=0;
413-
}
414-
415-
416-
if (cfg_get_long("ifx.byteasvarchar",
417-
&IFXG(byteasvarchar))==FAILURE) {
418-
IFXG(byteasvarchar)=0;
419-
}
420-
421-
if (cfg_get_long("ifx.charasvarchar",
422-
&IFXG(charasvarchar))==FAILURE) {
423-
IFXG(charasvarchar)=0;
424-
}
425-
426-
if (cfg_get_long("ifx.nullformat",
427-
&IFXG(nullformat))==FAILURE) {
428-
IFXG(nullformat)=0;
429-
}
352+
REGISTER_INI_ENTRIES();
430353

431354
IFXG(nullvalue) = malloc(1);
432355
IFXG(nullvalue)[0] = 0;
433356
IFXG(nullstring) = malloc(5);
434357
strcpy(IFXG(nullstring), "NULL");
435358

436-
if (cfg_get_long("ifx.allow_persistent",
437-
&IFXG(allow_persistent))==FAILURE) {
438-
IFXG(allow_persistent)=1;
439-
}
440-
if (cfg_get_long("ifx.max_persistent",
441-
&IFXG(max_persistent))==FAILURE) {
442-
IFXG(max_persistent)=-1;
443-
}
444-
if (cfg_get_long("ifx.max_links",
445-
&IFXG(max_links))==FAILURE) {
446-
IFXG(max_links)=-1;
447-
}
448-
if (cfg_get_string("ifx.default_host",
449-
&IFXG(default_host))==FAILURE
450-
|| IFXG(default_host)[0]==0) {
451-
IFXG(default_host)=NULL;
452-
}
453-
if (cfg_get_string("ifx.default_user",
454-
&IFXG(default_user))==FAILURE
455-
|| IFXG(default_user)[0]==0) {
456-
IFXG(default_user)=NULL;
457-
}
458-
if (cfg_get_string("ifx.default_password",
459-
&IFXG(default_password))==FAILURE
460-
|| IFXG(default_password)[0]==0) {
461-
IFXG(default_password)=NULL;
462-
}
463-
464359
IFXG(num_persistent)=0;
465360
IFXG(sv_sqlcode)=0;
466361

@@ -475,6 +370,7 @@ int php3_minit_ifx(INIT_FUNC_ARGS)
475370
IFXG(le_link),
476371
IFXG(le_plink));
477372
#endif
373+
478374
ifx_module_entry.type = type;
479375

480376
REGISTER_LONG_CONSTANT("IFX_SCROLL", IFX_SCROLL, CONST_CS | CONST_PERSISTENT);
@@ -494,6 +390,7 @@ $endif;
494390

495391
int php3_mshutdown_ifx(SHUTDOWN_FUNC_ARGS){
496392

393+
UNREGISTER_INI_ENTRIES();
497394
return SUCCESS;
498395

499396
}
@@ -531,22 +428,11 @@ void php3_info_ifx(ZEND_MODULE_INFO_FUNC_ARGS)
531428
"<tr><td>Persistent links:</td><td>%d/%s</td></tr>\n"
532429
"<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
533430
"<tr><td>Client API version:</td><td>%02.2f</td></tr>\n"
534-
#if !(WIN32|WINNT)
535-
"<tr><td valign=\"top\">Compilation definitions:</td><td>"
536-
"<tt>IFX_INCLUDE=%s<br>\n"
537-
"IFX_LFLAGS=%s<br>\n"
538-
"IFX_LIBS=%s<br></tt></td></tr>"
539-
#endif
540431
"</table>\n",
541432
(IFXG(allow_persistent)?"Yes":"No"),
542433
IFXG(num_persistent),maxp,
543434
IFXG(num_links),maxl,
544435
(double)(CLIENT_SQLI_VER/100.0)
545-
#if !(WIN32|WINNT)
546-
,PHP_IFX_INCLUDE,
547-
PHP_IFX_LFLAGS,
548-
PHP_IFX_LIBS
549-
#endif
550436
);
551437
}
552438

0 commit comments

Comments
 (0)