CVS update: php3/functions
| From: | sas | Date: | Sun, 09 May 1999 16:54:35 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5441@lists.php.net to get a copy of this message | ||
Date: Sunday May 9, 1999 @ 12:54
Author: sas
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv19674/functions
Modified Files:
dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c php3_dba.h
Added Files:
dba_db2.c php3_db2.h
Log Message:
- add dba_sync()
- move id parameter to the last place where possible
- add DB2 support
Index: php3/functions/dba.c
diff -u php3/functions/dba.c:1.9 php3/functions/dba.c:1.10
--- php3/functions/dba.c:1.9 Sun May 9 08:46:50 1999
+++ php3/functions/dba.c Sun May 9 12:54:34 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.9 1999/05/09 12:46:50 sas Exp $ */
+/* $Id: dba.c,v 1.10 1999/05/09 16:54:34 sas Exp $ */
#include "php.h"
@@ -40,6 +40,7 @@
#include "php3_ndbm.h"
#include "php3_dbm.h"
#include "php3_cdb.h"
+#include "php3_db2.h"
function_entry dba_functions[] = {
PHP_FE(dba_open, NULL)
@@ -53,6 +54,7 @@
PHP_FE(dba_firstkey, NULL)
PHP_FE(dba_nextkey, NULL)
PHP_FE(dba_optimize, NULL)
+ PHP_FE(dba_sync, NULL)
{NULL,NULL,NULL}
};
@@ -80,6 +82,7 @@
char* (*firstkey)(dba_info *, int *);
char* (*nextkey)(dba_info *, int *);
void (*optimize)(dba_info *);
+ int (*sync)(dba_info *);
} dba_handler;
/* {{{ macromania */
@@ -95,7 +98,7 @@
#define DBA_GET2 \
pval *key; \
- if(ac != 2 || getParameters(ht, ac, &id, &key) != SUCCESS) { \
+ if(ac != 2 || getParameters(ht, ac, &key, &id) != SUCCESS) { \
WRONG_PARAM_COUNT; \
} \
convert_to_string(key)
@@ -142,6 +145,9 @@
#if DBA_CDB
DBA_HND(cdb)
#endif
+#if DBA_DB2
+ DBA_HND(db2)
+#endif
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
@@ -184,7 +190,7 @@
{
dba_handler *hptr;
- PUTS("V1 ($Id: dba.c,v 1.9 1999/05/09 12:46:50 sas Exp $)");
+ PUTS("V1 ($Id: dba.c,v 1.10 1999/05/09 16:54:34 sas Exp $)");
for(hptr = handler; hptr->name; hptr++) {
PUTS(" ");
PUTS(hptr->name);
@@ -198,7 +204,7 @@
DBA_ID_PARS;
pval *val, *key;
- if(ac != 3 || getParameters(ht, ac, &id, &key, &val) != SUCCESS) {
+ if(ac != 3 || getParameters(ht, ac, &key, &val, &id) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_string(val);
@@ -338,7 +344,7 @@
}
/* }}} */
-/* {{{ proto bool dba_exists(int handle, string key)
+/* {{{ proto bool dba_exists(string key, int handle)
checks, if the specified key exists */
PHP_FUNCTION(dba_exists)
{
@@ -351,7 +357,7 @@
}
/* }}} */
-/* {{{ proto string dba_fetch(int handle, string key)
+/* {{{ proto string dba_fetch(string key, int handle)
fetches the data associated with key */
PHP_FUNCTION(dba_fetch)
{
@@ -397,7 +403,7 @@
}
/* }}} */
-/* {{{ proto bool dba_delete(int handle, string key)
+/* {{{ proto bool dba_delete(string key, int handle)
deletes the entry associated with key */
PHP_FUNCTION(dba_delete)
{
@@ -409,7 +415,7 @@
}
/* }}} */
-/* {{{ proto bool dba_insert(int handle, string key, string value)
+/* {{{ proto bool dba_insert(string key, string value, int handle)
inserts value as key, returns false, if key exists already */
PHP_FUNCTION(dba_insert)
{
@@ -417,7 +423,7 @@
}
/* }}} */
-/* {{{ proto bool dba_replace(int handle, string key, string value)
+/* {{{ proto bool dba_replace(string key, string value, int handle)
inserts value as key, replaces key, if key exists already */
PHP_FUNCTION(dba_replace)
{
@@ -432,6 +438,19 @@
DBA_ID_GET1;
info->hnd->optimize(info);
+}
+/* }}} */
+
+/* {{{ proto bool dba_sync(int handle)
+ sync database */
+PHP_FUNCTION(dba_sync)
+{
+ DBA_ID_GET1;
+
+ if(info->hnd->sync(info)) {
+ RETURN_TRUE;
+ }
+ RETURN_FALSE;
}
/* }}} */
Index: php3/functions/dba_cdb.c
diff -u php3/functions/dba_cdb.c:1.7 php3/functions/dba_cdb.c:1.8
--- php3/functions/dba_cdb.c:1.7 Wed Apr 21 05:50:13 1999
+++ php3/functions/dba_cdb.c Sun May 9 12:54:34 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_cdb.c,v 1.7 1999/04/21 09:50:13 sas Exp $ */
+/* $Id: dba_cdb.c,v 1.8 1999/05/09 16:54:34 sas Exp $ */
#include "php.h"
@@ -161,9 +161,6 @@
DBA_NEXTKEY_FUNC(cdb)
{
-
-/* this is much faster */
-#if 1
CDB_INFO;
uint32 len;
char buf[8];
@@ -184,8 +181,9 @@
cdb->pos += 8 + len + cdb_unpack(buf + 4);
return nkey;
-#else
-/* seek to passed key, jump over the key and the value and read the next key */
+#if 0
+ /* this code cdb_seeks and is thus slower than directly seeking
+ in the file */
CDB_INFO;
char *nkey = NULL;
uint32 len;
@@ -211,4 +209,11 @@
DBA_OPTIMIZE_FUNC(cdb)
{
}
+
+DBA_SYNC_FUNC(cdb)
+{
+ /* this is read-only */
+ return 1;
+}
+
#endif
Index: php3/functions/dba_dbm.c
diff -u php3/functions/dba_dbm.c:1.7 php3/functions/dba_dbm.c:1.8
--- php3/functions/dba_dbm.c:1.7 Sun May 9 09:41:25 1999
+++ php3/functions/dba_dbm.c Sun May 9 12:54:35 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_dbm.c,v 1.7 1999/05/09 13:41:25 jah Exp $ */
+/* $Id: dba_dbm.c,v 1.8 1999/05/09 16:54:35 sas Exp $ */
#include "php.h"
@@ -131,4 +131,10 @@
{
/* dummy */
}
+
+DBA_SYNC_FUNC(dbm)
+{
+ return 1;
+}
+
#endif
Index: php3/functions/dba_gdbm.c
diff -u php3/functions/dba_gdbm.c:1.6 php3/functions/dba_gdbm.c:1.7
--- php3/functions/dba_gdbm.c:1.6 Sun May 9 10:33:03 1999
+++ php3/functions/dba_gdbm.c Sun May 9 12:54:35 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_gdbm.c,v 1.6 1999/05/09 14:33:03 sas Exp $ */
+/* $Id: dba_gdbm.c,v 1.7 1999/05/09 16:54:35 sas Exp $ */
#include "php.h"
@@ -173,5 +173,13 @@
{
GDBM_DATA;
gdbm_reorganize(dba->dbf);
+}
+
+DBA_SYNC_FUNC(gdbm)
+{
+ GDBM_DATA;
+
+ gdbm_sync(dba->dbf);
+ return 1;
}
#endif
Index: php3/functions/dba_ndbm.c
diff -u php3/functions/dba_ndbm.c:1.5 php3/functions/dba_ndbm.c:1.6
--- php3/functions/dba_ndbm.c:1.5 Sun May 9 09:41:25 1999
+++ php3/functions/dba_ndbm.c Sun May 9 12:54:35 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_ndbm.c,v 1.5 1999/05/09 13:41:25 jah Exp $ */
+/* $Id: dba_ndbm.c,v 1.6 1999/05/09 16:54:35 sas Exp $ */
#include "php.h"
@@ -153,5 +153,10 @@
DBA_OPTIMIZE_FUNC(ndbm)
{
+}
+
+DBA_SYNC_FUNC(ndbm)
+{
+ return 1;
}
#endif
Index: php3/functions/php3_dba.h
diff -u php3/functions/php3_dba.h:1.7 php3/functions/php3_dba.h:1.8
--- php3/functions/php3_dba.h:1.7 Sun Apr 25 18:24:11 1999
+++ php3/functions/php3_dba.h Sun May 9 12:54:35 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php3_dba.h,v 1.7 1999/04/25 22:24:11 sas Exp $ */
+/* $Id: php3_dba.h,v 1.8 1999/05/09 16:54:35 sas Exp $ */
#ifndef _DBA_H
#define _DBA_H
@@ -76,6 +76,8 @@
char *dba_nextkey_##x(dba_info *info, int *newlen)
#define DBA_OPTIMIZE_FUNC(x) \
void dba_optimize_##x(dba_info *info)
+#define DBA_SYNC_FUNC(x) \
+ int dba_sync_##x(dba_info *info)
#define DBA_FUNCS(x) \
DBA_OPEN_FUNC(x); \
@@ -86,7 +88,8 @@
DBA_EXISTS_FUNC(x); \
DBA_FIRSTKEY_FUNC(x); \
DBA_NEXTKEY_FUNC(x); \
- DBA_OPTIMIZE_FUNC(x)
+ DBA_OPTIMIZE_FUNC(x); \
+ DBA_SYNC_FUNC(x)
#define VALLEN(p) (p)->value.str.val, (p)->value.str.len
@@ -101,6 +104,7 @@
PHP_FUNCTION(dba_exists);
PHP_FUNCTION(dba_fetch);
PHP_FUNCTION(dba_optimize);
+PHP_FUNCTION(dba_sync);
#else
#define dba_module_ptr NULL
--
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