Date: 04/25/99
- Next message: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Previous message: sas: "[PHP-DEV] CVS update: php3"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Reply: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sunday April 25, 1999 @ 18:24
Author: sas
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv19110/functions
Modified Files:
dba.c php3_dba.h
Added Files:
mcrypt.c php_mcrypt.h
Log Message:
- "Backport" of mcrypt module
- some changes to make integration of PHP4 modules easier
Index: php3/functions/dba.c
diff -u php3/functions/dba.c:1.7 php3/functions/dba.c:1.8
--- php3/functions/dba.c:1.7 Wed Apr 21 11:57:09 1999
+++ php3/functions/dba.c Sun Apr 25 18:24:11 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.7 1999/04/21 15:57:09 sas Exp $ */
+/* $Id: dba.c,v 1.8 1999/04/25 22:24:11 sas Exp $ */
#include "php.h"
@@ -84,35 +84,59 @@
/* {{{ macromania */
-#define DBA_ID_PARS pval *id; dba_info *info = NULL; int type, ac = ARG_COUNT(ht)
+#define DBA_ID_PARS int idset = 0; 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 != 1 || getParameters(ht, ac, &id) != SUCCESS) { \
+ if(ac == 0) { \
+ DBA_GETLAST; \
+ } else if(ac != 1 || getParameters(ht, ac, &id) != SUCCESS ||
+ /* assignment is correct! */
+ !(idset = 1)) { \
WRONG_PARAM_COUNT; \
}
#define DBA_GET2 \
pval *key; \
- if(ac != 2 || getParameters(ht, ac, &id, &key) != SUCCESS) { \
+ if(ac == 1) { \
+ DBA_GETLAST; \
+ } \
+ if(ac < 1 || ac > 2 || getParameters(ht, ac, &key, &id) != SUCCESS ||
+ !(idset = 1)) { \
WRONG_PARAM_COUNT; \
} \
convert_to_string(key)
-#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_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_ID_GET \
- 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); \
+ 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"); \
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 */
@@ -124,6 +148,7 @@
},
#define GLOBAL(a) a
+#define DBAG(a) a
/* }}} */
@@ -145,9 +170,7 @@
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
-static int le_db;
-static int le_pdb;
-static HashTable ht_keys;
+static int modkey;
/* }}} */
/* {{{ helper routines */
@@ -164,9 +187,7 @@
static int php3_minit_dba(INIT_FUNC_ARGS)
{
- _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);
+ DBAG(modkey) = php_persistent_new("DBA", dba_close);
return SUCCESS;
}
/* }}} */
@@ -174,7 +195,7 @@
static int php3_mshutdown_dba(void)
{
- _php3_hash_destroy(&ht_keys);
+ php_persistent_destroy(DBAG(modkey));
return SUCCESS;
}
/* }}} */
@@ -184,7 +205,7 @@
{
dba_handler *hptr;
- PUTS("V1 ($Id: dba.c,v 1.7 1999/04/21 15:57:09 sas Exp $)");
+ PUTS("V1 ($Id: dba.c,v 1.8 1999/04/25 22:24:11 sas Exp $)");
for(hptr = handler; hptr->name; hptr++) {
PUTS(" ");
PUTS(hptr->name);
@@ -195,14 +216,7 @@
static void _php3_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
- 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;
+ DBA_ID_GET3;
if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode))
RETURN_TRUE;
@@ -249,11 +263,11 @@
memcpy(key+keylen,args[i]->value.str.val,args[i]->value.str.len);
keylen += args[i]->value.str.len;
}
-
- if(_php3_hash_find(&ht_keys, key, keylen, (void **) &info) == SUCCESS) {
+
+ if((listid = php_persistent_fetch(DBAG(modkey), key, keylen)) != -1) {
efree(args);
efree(key);
- RETURN_LONG(php3_list_insert(info, GLOBAL(le_pdb)));
+ RETURN_LONG(listid);
}
}
Index: php3/functions/php3_dba.h
diff -u php3/functions/php3_dba.h:1.6 php3/functions/php3_dba.h:1.7
--- php3/functions/php3_dba.h:1.6 Wed Apr 21 05:50:13 1999
+++ php3/functions/php3_dba.h Sun Apr 25 18:24:11 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php3_dba.h,v 1.6 1999/04/21 09:50:13 sas Exp $ */
+/* $Id: php3_dba.h,v 1.7 1999/04/25 22:24:11 sas Exp $ */
#ifndef _DBA_H
#define _DBA_H
@@ -46,7 +46,7 @@
void *dbf; /* ptr to private data or whatever */
char *path;
dba_mode_t mode;
- /* arg[cv] are only available when the open handler is called! */
+ /* arg[cv] are only available when the dba_open handler is called! */
int argc;
pval **argv;
/* private */
@@ -56,26 +56,26 @@
extern php3_module_entry dba_module_entry;
#define dba_module_ptr &dba_module_entry
-/* common declarations+prototypes which must be used by modules */
+/* common prototypes which must be supplied by modules */
#define DBA_OPEN_FUNC(x) \
- extern int dba_open_##x(dba_info *info)
+ int dba_open_##x(dba_info *info)
#define DBA_CLOSE_FUNC(x) \
- extern void dba_close_##x(dba_info *info)
+ void dba_close_##x(dba_info *info)
#define DBA_FETCH_FUNC(x) \
- extern char *dba_fetch_##x(dba_info *info, char *key, int keylen, int *newlen)
+ char *dba_fetch_##x(dba_info *info, char *key, int keylen, int *newlen)
#define DBA_UPDATE_FUNC(x) \
- extern int dba_update_##x(dba_info *info, char *key, int keylen, char *val, int vallen, int mode)
+ int dba_update_##x(dba_info *info, char *key, int keylen, char *val, int vallen, int mode)
#define DBA_EXISTS_FUNC(x) \
- extern int dba_exists_##x(dba_info *info, char *key, int keylen)
+ int dba_exists_##x(dba_info *info, char *key, int keylen)
#define DBA_DELETE_FUNC(x) \
- extern int dba_delete_##x(dba_info *info, char *key, int keylen)
+ int dba_delete_##x(dba_info *info, char *key, int keylen)
#define DBA_FIRSTKEY_FUNC(x) \
- extern char *dba_firstkey_##x(dba_info *info, int *newlen)
+ char *dba_firstkey_##x(dba_info *info, int *newlen)
#define DBA_NEXTKEY_FUNC(x) \
- extern char *dba_nextkey_##x(dba_info *info, int *newlen)
+ char *dba_nextkey_##x(dba_info *info, int *newlen)
#define DBA_OPTIMIZE_FUNC(x) \
- extern void dba_optimize_##x(dba_info *info)
+ void dba_optimize_##x(dba_info *info)
#define DBA_FUNCS(x) \
DBA_OPEN_FUNC(x); \
@@ -90,17 +90,17 @@
#define VALLEN(p) (p)->value.str.val, (p)->value.str.len
-extern PHP_FUNCTION(dba_open);
-extern PHP_FUNCTION(dba_popen);
-extern PHP_FUNCTION(dba_close);
-extern PHP_FUNCTION(dba_firstkey);
-extern PHP_FUNCTION(dba_nextkey);
-extern PHP_FUNCTION(dba_replace);
-extern PHP_FUNCTION(dba_insert);
-extern PHP_FUNCTION(dba_delete);
-extern PHP_FUNCTION(dba_exists);
-extern PHP_FUNCTION(dba_fetch);
-extern PHP_FUNCTION(dba_optimize);
+PHP_FUNCTION(dba_open);
+PHP_FUNCTION(dba_popen);
+PHP_FUNCTION(dba_close);
+PHP_FUNCTION(dba_firstkey);
+PHP_FUNCTION(dba_nextkey);
+PHP_FUNCTION(dba_replace);
+PHP_FUNCTION(dba_insert);
+PHP_FUNCTION(dba_delete);
+PHP_FUNCTION(dba_exists);
+PHP_FUNCTION(dba_fetch);
+PHP_FUNCTION(dba_optimize);
#else
#define dba_module_ptr NULL
-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Previous message: sas: "[PHP-DEV] CVS update: php3"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Reply: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

