CVS update: php3/functions
| From: | sas | Date: | Sun, 09 May 1999 12:46:51 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5434@lists.php.net to get a copy of this message | ||
Date: Sunday May 9, 1999 @ 8:46
Author: sas
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv29590
Modified Files:
dba.c
Log Message:
revert last patch to dba.c
Index: php3/functions/dba.c
diff -u php3/functions/dba.c:1.8 php3/functions/dba.c:1.9
--- php3/functions/dba.c:1.8 Sun Apr 25 18:24:11 1999
+++ php3/functions/dba.c Sun May 9 08:46:50 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.8 1999/04/25 22:24:11 sas Exp $ */
+/* $Id: dba.c,v 1.9 1999/05/09 12:46:50 sas Exp $ */
#include "php.h"
@@ -84,59 +84,35 @@
/* {{{ macromania */
-#define DBA_ID_PARS int idset = 0; 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_GETLAST \
- info = php_persistent_list_find(DBAG(modkey), \
- php_persistent_lastid(DBAG(modkey))); \
-
#define DBA_GET1 \
- if(ac == 0) { \
- DBA_GETLAST; \
- } else if(ac != 1 || getParameters(ht, ac, &id) != SUCCESS ||
- /* assignment is correct! */
- !(idset = 1)) { \
+ if(ac != 1 || getParameters(ht, ac, &id) != SUCCESS) { \
WRONG_PARAM_COUNT; \
}
#define DBA_GET2 \
pval *key; \
- if(ac == 1) { \
- DBA_GETLAST; \
- } \
- if(ac < 1 || ac > 2 || getParameters(ht, ac, &key, &id) != SUCCESS ||
- !(idset = 1)) { \
+ if(ac != 2 || getParameters(ht, ac, &id, &key) != SUCCESS) { \
WRONG_PARAM_COUNT; \
} \
convert_to_string(key)
-
-#define DBA_GET3 \
- pval *key, *val; \
- if(ac == 2) { \
- DBA_GETLAST; \
- } \
- if(ac < 2 || ac > 3 || getParameters(ht, ac, &key, &val, &id) != SUCCESS ||
- !(idset = 1)) { \
- WRONG_PARAM_COUNT; \
- } \
- convert_to_string(key); \
- convert_to_string(val)
+#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 \
- if(idset) {\
- convert_to_long(id); \
- info = php_persistent_list_find(DBAG(modkey), id->value.lval); \
- } \
- if(!info) { \
- php3_error(E_WARNING, "Unable to find dba identifier"); \
+ convert_to_long(id); \
+ DBA_IF_NOT_CORRECT_TYPE(id->value.lval) { \
+ php3_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
#define DBA_ID_GET2 DBA_ID_PARS; DBA_GET2; DBA_ID_GET
-#define DBA_ID_GET3 DBA_ID_PARS; DBA_GET3; DBA_ID_GET
/* a dba handler must have specific routines */
@@ -148,7 +124,6 @@
},
#define GLOBAL(a) a
-#define DBAG(a) a
/* }}} */
@@ -170,7 +145,9 @@
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
-static int modkey;
+static int le_db;
+static int le_pdb;
+static HashTable ht_keys;
/* }}} */
/* {{{ helper routines */
@@ -187,7 +164,9 @@
static int php3_minit_dba(INIT_FUNC_ARGS)
{
- DBAG(modkey) = php_persistent_new("DBA", dba_close);
+ _php3_hash_init(&ht_keys, 0, NULL, NULL, 1);
+ GLOBAL(le_db) = register_list_destructors(dba_close, NULL);
+ GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close);
return SUCCESS;
}
/* }}} */
@@ -195,7 +174,7 @@
static int php3_mshutdown_dba(void)
{
- php_persistent_destroy(DBAG(modkey));
+ _php3_hash_destroy(&ht_keys);
return SUCCESS;
}
/* }}} */
@@ -205,7 +184,7 @@
{
dba_handler *hptr;
- PUTS("V1 ($Id: dba.c,v 1.8 1999/04/25 22:24:11 sas Exp $)");
+ PUTS("V1 ($Id: dba.c,v 1.9 1999/05/09 12:46:50 sas Exp $)");
for(hptr = handler; hptr->name; hptr++) {
PUTS(" ");
PUTS(hptr->name);
@@ -216,7 +195,14 @@
static void _php3_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
- DBA_ID_GET3;
+ DBA_ID_PARS;
+ pval *val, *key;
+
+ if(ac != 3 || getParameters(ht, ac, &id, &key, &val) != SUCCESS) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string(val);
+ DBA_ID_GET;
if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode))
RETURN_TRUE;
@@ -263,11 +249,11 @@
memcpy(key+keylen,args[i]->value.str.val,args[i]->value.str.len);
keylen += args[i]->value.str.len;
}
-
- if((listid = php_persistent_fetch(DBAG(modkey), key, keylen)) != -1) {
+
+ if(_php3_hash_find(&ht_keys, key, keylen, (void **) &info) == SUCCESS) {
efree(args);
efree(key);
- RETURN_LONG(listid);
+ RETURN_LONG(php3_list_insert(info, GLOBAL(le_pdb)));
}
}
--
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