cvs: /php4/ext/dba dba.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c php3_dba.h
| From: | Sascha Schumann | Date: | Fri, 17 Sep 1999 09:56:30 +0000 |
| Subject: | cvs: /php4/ext/dba dba.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c php3_dba.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-4568@lists.php.net to get a copy of this message | ||
sas Fri Sep 17 05:56:30 1999 EDT
Modified files:
/php4/ext/dba dba.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c
php3_dba.h
Log:
Convert to Ex API. Does anyone have a better name for it?
Index: php4/ext/dba/dba.c
diff -u php4/ext/dba/dba.c:1.4 php4/ext/dba/dba.c:1.5
--- php4/ext/dba/dba.c:1.4 Mon Aug 2 15:16:40 1999
+++ php4/ext/dba/dba.c Fri Sep 17 05:56:29 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.4 1999/08/02 19:16:40 zeev Exp $ */
+/* $Id: dba.c,v 1.5 1999/09/17 09:56:29 sas Exp $ */
#include "php.h"
@@ -86,31 +86,35 @@
/* {{{ macromania */
-#define DBA_ID_PARS pval *id; dba_info *info = NULL; int type, ac = ARG_COUNT(ht)
+#define DBA_ID_PARS \
+ pval **id; \
+ dba_info *info = NULL; \
+ int type, ac = ARG_COUNT(ht)
/* these are used to get the standard arguments */
-#define DBA_GET1 \
- if(ac != 1 || getParameters(ht, ac, &id) != SUCCESS) { \
- WRONG_PARAM_COUNT; \
+#define DBA_GET1 \
+ if(ac != 1 || getParametersEx(ac, &id) != SUCCESS) { \
+ WRONG_PARAM_COUNT; \
}
-#define DBA_GET2 \
- pval *key; \
- if(ac != 2 || getParameters(ht, ac, &key, &id) != SUCCESS) { \
- WRONG_PARAM_COUNT; \
- } \
- convert_to_string(key)
+#define DBA_GET2 \
+ pval **key; \
+ if(ac != 2 || getParametersEx(ac, &key, &id) != SUCCESS) { \
+ WRONG_PARAM_COUNT; \
+ } \
+ convert_to_string_ex(key)
-#define DBA_IF_NOT_CORRECT_TYPE(link_id) \
- info = php3_list_find(link_id, &type); \
+#define DBA_IF_NOT_CORRECT_TYPE(link_id) \
+ info = php3_list_find(link_id, &type); \
if(!info || (type != GLOBAL(le_db) && type != GLOBAL(le_pdb)))
-#define DBA_ID_GET \
- convert_to_long(id); \
- DBA_IF_NOT_CORRECT_TYPE(id->value.lval) { \
- php_error(E_WARNING, "Unable to find DBA identifier %d", id->value.lval); \
- RETURN_FALSE; \
+#define DBA_ID_GET \
+ convert_to_long_ex(id); \
+ DBA_IF_NOT_CORRECT_TYPE((*id)->value.lval) { \
+ php_error(E_WARNING, "Unable to find DBA identifier %d", \
+ (*id)->value.lval); \
+ RETURN_FALSE; \
}
#define DBA_ID_GET1 DBA_ID_PARS; DBA_GET1; DBA_ID_GET
@@ -196,7 +200,7 @@
{
dba_handler *hptr;
- PUTS("V1 ($Id: dba.c,v 1.4 1999/08/02 19:16:40 zeev Exp $)");
+ PUTS("V1 ($Id: dba.c,v 1.5 1999/09/17 09:56:29 sas Exp $)");
for(hptr = handler; hptr->name; hptr++) {
PUTS(" ");
PUTS(hptr->name);
@@ -208,13 +212,13 @@
static void _php3_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
DBA_ID_PARS;
- pval *val, *key;
+ pval **val, **key;
- if(ac != 3 || getParameters(ht, ac, &key, &val, &id) != SUCCESS) {
+ if(ac != 3 || getParametersEx(ac, &key, &val, &id) != SUCCESS) {
WRONG_PARAM_COUNT;
}
- convert_to_string(key);
- convert_to_string(val);
+ convert_to_string_ex(key);
+ convert_to_string_ex(val);
DBA_ID_GET;
DBA_WRITE_CHECK;
@@ -230,7 +234,7 @@
static void _php3_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
- pval **args = (pval **) NULL;
+ pval ***args = (pval ***) NULL;
int ac = ARG_COUNT(ht);
dba_mode_t modenr;
dba_info *info;
@@ -246,15 +250,15 @@
/* we pass additional args to the respective handler */
args = emalloc(ac * sizeof(pval *));
- if(getParametersArray(ht, ac, args) != SUCCESS) {
+ if(getParametersArrayEx(ac, args) != SUCCESS) {
FREENOW;
WRONG_PARAM_COUNT;
}
/* we only take string arguments */
for(i = 0; i < ac; i++) {
- convert_to_string(args[i]);
- keylen += args[i]->value.str.len;
+ convert_to_string_ex(args[i]);
+ keylen += (*args[i])->value.str.len;
}
if(persistent) {
@@ -263,8 +267,8 @@
keylen = 0;
for(i = 0; i < ac; i++) {
- memcpy(key+keylen,args[i]->value.str.val,args[i]->value.str.len);
- keylen += args[i]->value.str.len;
+ memcpy(key+keylen,(*args[i])->value.str.val,(*args[i])->value.str.len);
+ keylen += (*args[i])->value.str.len;
}
if(zend_hash_find(&ht_keys, key, keylen, (void **) &info) == SUCCESS) {
@@ -273,17 +277,16 @@
}
}
- /* this is O(n) and could be improved */
for(hptr = handler; hptr->name &&
- strcasecmp(hptr->name, args[2]->value.str.val); hptr++);
+ strcasecmp(hptr->name, (*args[2])->value.str.val); hptr++);
if(!hptr->name) {
- php_error(E_WARNING, "no such handler: %s", args[2]->value.str.val);
+ php_error(E_WARNING, "no such handler: %s", (*args[2])->value.str.val);
FREENOW;
RETURN_FALSE;
}
- switch(args[1]->value.str.val[0]) {
+ switch((*args[1])->value.str.val[0]) {
case 'c':
modenr = DBA_CREAT;
break;
@@ -297,14 +300,14 @@
modenr = DBA_TRUNC;
break;
default:
- php_error(E_WARNING,"illegal DBA mode: %s",args[1]->value.str.val);
+ php_error(E_WARNING,"illegal DBA mode: %s",(*args[1])->value.str.val);
FREENOW;
RETURN_FALSE;
}
info = malloc(sizeof(*info));
memset(info, 0, sizeof(info));
- info->path = strdup(args[0]->value.str.val);
+ info->path = strdup((*args[0])->value.str.val);
info->mode = modenr;
info->argc = ac - 3;
info->argv = args + 3;
@@ -354,7 +357,7 @@
{
DBA_ID_GET1;
- php3_list_delete(id->value.lval);
+ php3_list_delete((*id)->value.lval);
}
/* }}} */
Index: php4/ext/dba/dba_db2.c
diff -u php4/ext/dba/dba_db2.c:1.2 php4/ext/dba/dba_db2.c:1.3
--- php4/ext/dba/dba_db2.c:1.2 Tue Aug 17 10:18:27 1999
+++ php4/ext/dba/dba_db2.c Fri Sep 17 05:56:30 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_db2.c,v 1.2 1999/08/17 14:18:27 sas Exp $ */
+/* $Id: dba_db2.c,v 1.3 1999/09/17 09:56:30 sas Exp $ */
#include "php.h"
@@ -78,8 +78,8 @@
return FAILURE;
if(info->argc > 0) {
- convert_to_long(info->argv[0]);
- filemode = info->argv[0]->value.lval;
+ convert_to_long_ex(info->argv[0]);
+ filemode = (*info->argv[0])->value.lval;
}
if(!db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) {
Index: php4/ext/dba/dba_dbm.c
diff -u php4/ext/dba/dba_dbm.c:1.1 php4/ext/dba/dba_dbm.c:1.2
--- php4/ext/dba/dba_dbm.c:1.1 Wed Jul 21 11:12:31 1999
+++ php4/ext/dba/dba_dbm.c Fri Sep 17 05:56:30 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_dbm.c,v 1.1 1999/07/21 15:12:31 sas Exp $ */
+/* $Id: dba_dbm.c,v 1.2 1999/09/17 09:56:30 sas Exp $ */
#include "php.h"
@@ -66,8 +66,8 @@
int filemode = 0644;
if(info->argc > 0) {
- convert_to_long(info->argv[0]);
- filemode = info->argv[0]->value.lval;
+ convert_to_long_ex(info->argv[0]);
+ filemode = (*info->argv[0])->value.lval;
}
if(info->mode == DBA_TRUNC) {
Index: php4/ext/dba/dba_gdbm.c
diff -u php4/ext/dba/dba_gdbm.c:1.1 php4/ext/dba/dba_gdbm.c:1.2
--- php4/ext/dba/dba_gdbm.c:1.1 Wed Jul 21 11:12:31 1999
+++ php4/ext/dba/dba_gdbm.c Fri Sep 17 05:56:30 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_gdbm.c,v 1.1 1999/07/21 15:12:31 sas Exp $ */
+/* $Id: dba_gdbm.c,v 1.2 1999/09/17 09:56:30 sas Exp $ */
#include "php.h"
@@ -59,8 +59,8 @@
return FAILURE;
if(info->argc > 0) {
- convert_to_long(info->argv[0]);
- filemode = info->argv[0]->value.lval;
+ convert_to_long_ex(info->argv[0]);
+ filemode = (*info->argv[0])->value.lval;
}
dbf = gdbm_open(info->path, 0, gmode, filemode, NULL);
Index: php4/ext/dba/dba_ndbm.c
diff -u php4/ext/dba/dba_ndbm.c:1.1 php4/ext/dba/dba_ndbm.c:1.2
--- php4/ext/dba/dba_ndbm.c:1.1 Wed Jul 21 11:12:31 1999
+++ php4/ext/dba/dba_ndbm.c Fri Sep 17 05:56:30 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_ndbm.c,v 1.1 1999/07/21 15:12:31 sas Exp $ */
+/* $Id: dba_ndbm.c,v 1.2 1999/09/17 09:56:30 sas Exp $ */
#include "php.h"
@@ -69,8 +69,8 @@
}
if(info->argc > 0) {
- convert_to_long(info->argv[0]);
- filemode = info->argv[0]->value.lval;
+ convert_to_long_ex(info->argv[0]);
+ filemode = (*info->argv[0])->value.lval;
}
dbf = dbm_open(info->path, gmode, filemode);
Index: php4/ext/dba/php3_dba.h
diff -u php4/ext/dba/php3_dba.h:1.1 php4/ext/dba/php3_dba.h:1.2
--- php4/ext/dba/php3_dba.h:1.1 Wed Jul 21 11:12:32 1999
+++ php4/ext/dba/php3_dba.h Fri Sep 17 05:56:30 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php3_dba.h,v 1.1 1999/07/21 15:12:32 sas Exp $ */
+/* $Id: php3_dba.h,v 1.2 1999/09/17 09:56:30 sas Exp $ */
#ifndef _DBA_H
#define _DBA_H
@@ -48,7 +48,7 @@
dba_mode_t mode;
/* arg[cv] are only available when the dba_open handler is called! */
int argc;
- pval **argv;
+ pval ***argv;
/* private */
struct dba_handler *hnd;
} dba_info;
@@ -91,7 +91,7 @@
DBA_OPTIMIZE_FUNC(x); \
DBA_SYNC_FUNC(x)
-#define VALLEN(p) (p)->value.str.val, (p)->value.str.len
+#define VALLEN(p) (*p)->value.str.val, (*p)->value.str.len
PHP_FUNCTION(dba_open);
PHP_FUNCTION(dba_popen);