CVS update: php3/functions
| From: | jah | Date: | Sat, 19 Dec 1998 19:00:04 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-2878@lists.php.net to get a copy of this message | ||
Date: Saturday December 19, 1998 @ 14:00
Author: jah
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv8168/functions
Modified Files:
interbase.c php3_interbase.h
Log Message:
Made InterBase support at least marginally usable before 3.0.6. Still
*very* unfinished.
Index: php3/functions/interbase.c
diff -c php3/functions/interbase.c:1.4 php3/functions/interbase.c:1.5
*** php3/functions/interbase.c:1.4 Tue Nov 3 10:52:39 1998
--- php3/functions/interbase.c Sat Dec 19 14:00:03 1998
***************
*** 28,34 ****
+----------------------------------------------------------------------+
*/
! /* $Id: interbase.c,v 1.4 1998/11/03 15:52:39 rasmus Exp $ */
/* TODO: A lot... */
--- 28,34 ----
+----------------------------------------------------------------------+
*/
! /* $Id: interbase.c,v 1.5 1998/12/19 19:00:03 jah Exp $ */
/* TODO: A lot... */
***************
*** 43,50 ****
#include "php3_list.h"
#include "php3_string.h"
! #define SWAP(a) a
!
function_entry ibase_functions[] = {
{"ibase_connect", php3_ibase_connect, NULL},
{"ibase_pconnect", php3_ibase_pconnect, NULL},
--- 43,49 ----
#include "php3_list.h"
#include "php3_string.h"
! /* {{{ extension definition structures */
function_entry ibase_functions[] = {
{"ibase_connect", php3_ibase_connect, NULL},
{"ibase_pconnect", php3_ibase_pconnect, NULL},
***************
*** 65,77 ****
"InterBase",
ibase_functions,
php3_minit_ibase,
! php3_mfinish_ibase,
php3_rinit_ibase,
NULL,
php3_info_ibase,
STANDARD_MODULE_PROPERTIES
};
#if defined(THREAD_SAFE)
typedef ibase_global_struct{
ibase_module php3_ibase_module;
--- 64,78 ----
"InterBase",
ibase_functions,
php3_minit_ibase,
! NULL,
php3_rinit_ibase,
NULL,
php3_info_ibase,
STANDARD_MODULE_PROPERTIES
};
+ /* }}} */
+ /* {{{ thread safety stuff */
#if defined(THREAD_SAFE)
typedef ibase_global_struct{
ibase_module php3_ibase_module;
***************
*** 88,95 ****
#define IBASE_TLS_VARS
ibase_module php3_ibase_module;
#endif
!
static void _php3_ibase_close_link(isc_db_handle db)
{
ISC_STATUS status[20];
--- 89,97 ----
#define IBASE_TLS_VARS
ibase_module php3_ibase_module;
#endif
! /* }}} */
+ /* {{{ _php3_ibase_close_link() */
static void _php3_ibase_close_link(isc_db_handle db)
{
ISC_STATUS status[20];
***************
*** 98,104 ****
--- 100,108 ----
isc_detach_database(status, &db);
IBASE_GLOBAL(php3_ibase_module).num_links--;
}
+ /* }}} */
+ /* {{{ _php3_ibase_close_plink() */
static void _php3_ibase_close_plink(isc_db_handle db)
{
ISC_STATUS status[20];
***************
*** 108,114 ****
--- 112,120 ----
php3_ibase_module.num_persistent--;
php3_ibase_module.num_links--;
}
+ /* }}} */
+ /* {{{ _php3_ibase_free_result() */
static void _php3_ibase_free_result(ibase_result_handle *result)
{
int i;
***************
*** 128,134 ****
--- 134,142 ----
isc_dsql_free_statement(status, &result->result, DSQL_drop);
efree(result);
}
+ /* }}} */
+ /* {{{ _php3_ibase_free_query() */
static void _php3_ibase_free_query(ibase_query_handle *query)
{
int i;
***************
*** 146,152 ****
--- 154,162 ----
isc_dsql_free_statement(status, &query->query, DSQL_drop);
efree(query);
}
+ /* }}} */
+ /* {{{ startup, shutdown and info functions */
int php3_minit_ibase(INIT_FUNC_ARGS)
{
IBASE_TLS_VARS;
***************
*** 166,171 ****
--- 176,189 ----
}
*/
IBASE_GLOBAL(php3_ibase_module).manualtransactions = 0;
+ if (cfg_get_string("ibase.default_user",
&IBASE_GLOBAL(php3_ibase_module).default_user) == FAILURE
+ || IBASE_GLOBAL(php3_ibase_module).default_user[0] == 0) {
+ IBASE_GLOBAL(php3_ibase_module).default_user = "";
+ }
+ if (cfg_get_string("ibase.default_password",
&IBASE_GLOBAL(php3_ibase_module).default_password) == FAILURE
+ || IBASE_GLOBAL(php3_ibase_module).default_password[0] == 0) {
+ IBASE_GLOBAL(php3_ibase_module).default_password = "";
+ }
if (cfg_get_string("ibase.timeformat", &IBASE_GLOBAL(php3_ibase_module).timeformat)
== FAILURE) {
IBASE_GLOBAL(php3_ibase_module).timeformat = "%Y-%m-%d %H:%M:%S";
}
***************
*** 186,206 ****
return SUCCESS;
}
- int php3_mfinish_ibase(void)
- {
- IBASE_TLS_VARS;
-
- efree(IBASE_GLOBAL(php3_ibase_module).timeformat);
- return SUCCESS;
- }
-
/* TODO IF NEEDED
! int php3_mfinish_ibase(INIT_FUNC_ARGS)
{
}
! int php3_rfinish_ibase(INIT_FUNC_ARGS)
{
}
*/
--- 204,216 ----
return SUCCESS;
}
/* TODO IF NEEDED
! int php3_mfinish_ibase(void)
{
}
! int php3_rfinish_ibase(void)
{
}
*/
***************
*** 209,215 ****
--- 219,227 ----
{
/* TODO */
}
+ /* }}} */
+ /* {{{ _php_ibase_attach_db() */
static int _php_ibase_attach_db(char *server, char *uname, int uname_len, char *passwd, int
passwd_len, isc_db_handle *db)
{
ISC_STATUS status[20];
***************
*** 247,253 ****
--- 259,267 ----
}
return 0;
}
+ /* }}} */
+ /* {{{ _php3_ibase_connect() */
static void _php3_ibase_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
pval *server, *uname, *passwd;
***************
*** 259,268 ****
--- 273,312 ----
int hashed_details_length;
IBASE_TLS_VARS;
+ ib_uname = IBASE_GLOBAL(php3_ibase_module).default_user;
+ ib_passwd = IBASE_GLOBAL(php3_ibase_module).default_password;
+ ib_uname_len = ib_uname ? strlen(ib_uname) : 0;
+ ib_passwd_len = ib_passwd ? strlen(ib_passwd) : 0;
+
switch(ARG_COUNT(ht)) {
case 1:
+ {
+ if (getParameters(ht, 1, &server) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string(server);
+ ib_server = server->value.str.val;
+ ib_server_len = server->value.str.len;
+ hashed_details_length = server->value.str.len+ib_uname_len+ib_passwd_len+5+3;
+ hashed_details = (char *) emalloc(hashed_details_length+1);
+ sprintf(hashed_details, "ibase_%s_%s_%s", ib_server, ib_uname, ib_passwd);
+ }
break;
case 2:
+ {
+ if (getParameters(ht, 2, &server, &uname) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string(server);
+ convert_to_string(uname);
+ ib_server = server->value.str.val;
+ ib_uname = uname->value.str.val;
+ ib_server_len = server->value.str.len;
+ ib_uname_len = uname->value.str.len;
+ hashed_details_length = server->value.str.len+uname->value.str.len+ib_passwd_len+5+3;
+ hashed_details = (char *) emalloc(hashed_details_length+1);
+ sprintf(hashed_details, "ibase_%s_%s_%s", ib_server, ib_uname, ib_passwd);
+ }
break;
case 3:
{
***************
*** 385,401 ****
--- 429,454 ----
efree(hashed_details);
IBASE_GLOBAL(php3_ibase_module).default_link=return_value->value.lval;
}
+ /* }}} */
+ /* {{{ proto int ibase_connect(string database [, string username] [, string password])
+ Open a connection to an InterBase database */
void php3_ibase_connect(INTERNAL_FUNCTION_PARAMETERS)
{
_php3_ibase_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
+ /* }}} */
+ /* {{{ proto int ibase_pconnect(string database [, string username] [, string password])
+ Open a persistent connection to an InterBase database */
void php3_ibase_pconnect(INTERNAL_FUNCTION_PARAMETERS)
{
_php3_ibase_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
+ /* }}} */
+ /* {{{ proto int ibase_close([int link_identifier])
+ Close an InterBase connection */
void php3_ibase_close(INTERNAL_FUNCTION_PARAMETERS)
{
pval *ibase_link;
***************
*** 428,434 ****
--- 481,489 ----
php3_list_delete(ibase_link->value.lval);
RETURN_TRUE;
}
+ /* }}} */
+ /* {{{ _php3_ibase_prepare() */
static XSQLDA *_php3_ibase_prepare(isc_db_handle db, isc_tr_handle tr, isc_stmt_handle
*query_handle, char *query)
{
ISC_STATUS status[20];
***************
*** 473,479 ****
--- 528,536 ----
return NULL;
}
}
+ /* }}} */
+ /* {{{ _php3_ibase_execute() */
static XSQLDA *_php3_ibase_execute(isc_tr_handle tr_handle, isc_stmt_handle query_handle, XSQLDA
*isqlda, ISC_STATUS *status)
{
int i, coltype;
***************
*** 582,588 ****
--- 639,648 ----
return NULL;
}
+ /* }}} */
+ /* {{{ proto int ibase_query([int link_identifier, ]string query)
+ Execute a query (without parameter placeholders). */
void php3_ibase_query(INTERNAL_FUNCTION_PARAMETERS)
{
pval *query, *ibase_link;
***************
*** 662,668 ****
--- 722,731 ----
}
}
}
+ /* }}} */
+ /* {{{ proto int ibase_fetch_row(int result)
+ Fetch a row from the results of a query. */
void php3_ibase_fetch_row(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
***************
*** 672,677 ****
--- 735,741 ----
char string_data[255];
char *fieldname;
char *char_data;
+ struct tm t;
ibase_result_handle *ibase_result;
ISC_STATUS status[20];
XSQLVAR *var;
***************
*** 705,712 ****
for (i = 0; i < ibase_result->sqlda->sqld; i++) {
var[i].sqlname[var[i].sqlname_length] = '\0';
fieldname = var[i].sqlname;
! if (ibase_result->sqlda->sqlvar[i].sqlind) { /* Column is NULL */
! /* continue; */
}
coltype = var[i].sqltype & ~1;
switch(coltype) {
--- 769,776 ----
for (i = 0; i < ibase_result->sqlda->sqld; i++) {
var[i].sqlname[var[i].sqlname_length] = '\0';
fieldname = var[i].sqlname;
! if (ibase_result->sqlda->sqlvar[i].sqlind) {
! /* Column is NULL. Something to be done here? */
}
coltype = var[i].sqltype & ~1;
switch(coltype) {
***************
*** 777,793 ****
add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
_php3_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1,
pval_ptr);
break;
! case SQL_DATE: {
! struct tm t;
isc_decode_date((ISC_QUAD *) var[i].sqldata, &t);
#if HAVE_STRFTIME
! collen = (int) strftime(string_data, 255, php3_ibase_module.timeformat, &t);
#else
! collen = sprintf(string_data, "%4d-%2d-%2d %2d:%2d:%2d", t.tm_year+1900,
t.tm_mon+1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
#endif
add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
_php3_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1,
pval_ptr);
- }
break;
case SQL_BLOB:
case SQL_ARRAY:
--- 841,855 ----
add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
_php3_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1,
pval_ptr);
break;
! case SQL_DATE:
isc_decode_date((ISC_QUAD *) var[i].sqldata, &t);
#if HAVE_STRFTIME
! collen = (int) strftime(string_data, 255, IBASE_GLOBAL(php3_ibase_module).timeformat,
&t);
#else
! collen = sprintf(string_data, "%4d-%02d-%02d %02d:%02d:%02d", t.tm_year+1900,
t.tm_mon+1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
#endif
add_get_index_stringl(return_value, i, string_data, collen, (void **) &pval_ptr, 1);
_php3_hash_pointer_update(return_value->value.ht, fieldname, var[i].sqlname_length+1,
pval_ptr);
break;
case SQL_BLOB:
case SQL_ARRAY:
***************
*** 808,814 ****
--- 870,879 ----
RETURN_FALSE;
}
}
+ /* }}} */
+ /* {{{ proto int ibase_free_result(int result)
+ Free the memory used by a result. */
void php3_ibase_free_result(INTERNAL_FUNCTION_PARAMETERS)
{
pval *result;
***************
*** 834,840 ****
--- 899,908 ----
php3_list_delete(result->value.lval);
RETURN_TRUE;
}
+ /* }}} */
+ /* {{{ proto int ibase_prepare([int link_identifier, ]string query)
+ Prepare a query for later binding of parameter placeholders and execution. */
void php3_ibase_prepare(INTERNAL_FUNCTION_PARAMETERS)
{
pval *query, *ibase_link;
***************
*** 890,896 ****
--- 958,967 ----
return_value->value.lval = php3_list_insert(ibase_query, php3_ibase_module.le_query);
return_value->type = IS_LONG;
}
+ /* }}} */
+ /* {{{ proto int ibase_bind (int query)
+ Bind parameter placeholders in a previously prepared query. Still nonfunctional. */
void php3_ibase_bind(INTERNAL_FUNCTION_PARAMETERS)
{
pval *query;
***************
*** 947,953 ****
--- 1018,1027 ----
}
*/
}
+ /* }}} */
+ /* {{{ proto int ibase_execute(int query)
+ Execute a previously prepared (and possibly binded) query. */
void php3_ibase_execute(INTERNAL_FUNCTION_PARAMETERS)
{
pval *query;
***************
*** 981,987 ****
--- 1055,1064 ----
return_value->value.lval = php3_list_insert(ibase_result,
IBASE_GLOBAL(php3_ibase_module).le_result);
return_value->type = IS_LONG;
}
+ /* }}} */
+ /* {{{ proto int ibase_free_query(int query)
+ Free memory used by a query */
void php3_ibase_free_query(INTERNAL_FUNCTION_PARAMETERS)
{
pval *query;
***************
*** 1007,1013 ****
--- 1084,1093 ----
php3_list_delete(query->value.lval);
RETURN_TRUE;
}
+ /* }}} */
+ /* {{{ proto int ibase_timefmt(string format)
+ Sets the format of datetime columns returned from queries. Still nonfunctional. */
void php3_ibase_timefmt(INTERNAL_FUNCTION_PARAMETERS)
{
pval *pmode;
***************
*** 1025,1030 ****
--- 1105,1111 ----
RETURN_FALSE;
#endif
}
+ /* }}} */
#endif
Index: php3/functions/php3_interbase.h
diff -c php3/functions/php3_interbase.h:1.1 php3/functions/php3_interbase.h:1.2
*** php3/functions/php3_interbase.h:1.1 Tue Oct 6 09:51:47 1998
--- php3/functions/php3_interbase.h Sat Dec 19 14:00:04 1998
***************
*** 28,34 ****
+----------------------------------------------------------------------+
*/
! /* $Id: php3_interbase.h,v 1.1 1998/10/06 13:51:47 jah Exp $ */
#ifndef _PHP3_IBASE_H
#define _PHP3_IBASE_H
--- 28,34 ----
+----------------------------------------------------------------------+
*/
! /* $Id: php3_interbase.h,v 1.2 1998/12/19 19:00:04 jah Exp $ */
#ifndef _PHP3_IBASE_H
#define _PHP3_IBASE_H
***************
*** 66,72 ****
long max_links, max_persistent;
long allow_persistent;
int le_link, le_plink, le_result, le_query;
! char *default_server, *default_user, *default_password;
long manualtransactions;
char *timeformat;
} ibase_module;
--- 66,72 ----
long max_links, max_persistent;
long allow_persistent;
int le_link, le_plink, le_result, le_query;
! char *default_user, *default_password;
long manualtransactions;
char *timeformat;
} ibase_module;
--
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