summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-01-31 20:10:11 +0000
committerMarcus Boerger <helly@php.net>2003-01-31 20:10:11 +0000
commit13e162eb04aa00ed5e28f481821e1a5dcce670af (patch)
tree1eef3fcc9194e6f5467d0bba860b7e50805d5424
parent05e397b3302bf6f845c9368eb31d2d3f5c489c11 (diff)
downloadphp-git-13e162eb04aa00ed5e28f481821e1a5dcce670af.tar.gz
MFH: Version info
-rw-r--r--ext/dba/dba.c27
-rw-r--r--ext/dba/dba_cdb.c13
-rw-r--r--ext/dba/dba_db2.c5
-rw-r--r--ext/dba/dba_db3.c5
-rw-r--r--ext/dba/dba_db4.c5
-rw-r--r--ext/dba/dba_dbm.c5
-rw-r--r--ext/dba/dba_flatfile.c5
-rw-r--r--ext/dba/dba_gdbm.c6
-rw-r--r--ext/dba/dba_ndbm.c6
-rw-r--r--ext/dba/libcdb/cdb.c7
-rw-r--r--ext/dba/libcdb/cdb.h2
-rw-r--r--ext/dba/libcdb/cdb_make.c6
-rw-r--r--ext/dba/libcdb/cdb_make.h1
-rw-r--r--ext/dba/libflatfile/flatfile.c7
-rw-r--r--ext/dba/libflatfile/flatfile.h1
-rw-r--r--ext/dba/php_dba.h7
16 files changed, 94 insertions, 14 deletions
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index 8295629401..e0c3cb7fa1 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -147,7 +147,7 @@ ZEND_GET_MODULE(dba)
{\
#alias, flags, dba_open_##name, dba_close_##name, dba_fetch_##name, dba_update_##name, \
dba_exists_##name, dba_delete_##name, dba_firstkey_##name, dba_nextkey_##name, \
- dba_optimize_##name, dba_sync_##name \
+ dba_optimize_##name, dba_sync_##name, dba_info_##name \
},
#define DBA_HND(name, flags) DBA_NAMED_HND(name, name, flags)
@@ -191,7 +191,7 @@ static dba_handler handler[] = {
#if DBA_FLATFILE
DBA_HND(flatfile, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */
#endif
- { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
+ { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
static int le_db;
@@ -750,23 +750,26 @@ PHP_FUNCTION(dba_sync)
}
/* }}} */
-/* {{{ proto array dba_handlers()
+/* {{{ proto array dba_handlers([bool full_info])
List configured databases */
PHP_FUNCTION(dba_handlers)
{
dba_handler *hptr;
+ zend_bool full_info = 0;
- if (ZEND_NUM_ARGS()!=0) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &full_info) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
RETURN_FALSE;
}
- if (array_init(return_value) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
- RETURN_FALSE;
- }
+ array_init(return_value);
+
for(hptr = handler; hptr->name; hptr++) {
- add_next_index_string(return_value, hptr->name, 1);
+ if (full_info) {
+ add_assoc_string(return_value, hptr->name, hptr->info(hptr, NULL TSRMLS_CC), 0);
+ } else {
+ add_next_index_string(return_value, hptr->name, 1);
+ }
}
}
/* }}} */
@@ -784,10 +787,8 @@ PHP_FUNCTION(dba_list)
RETURN_FALSE;
}
- if (array_init(return_value) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
- RETURN_FALSE;
- }
+ array_init(return_value);
+
numitems = zend_hash_next_free_element(&EG(regular_list));
for (i=1; i<numitems; i++) {
if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
diff --git a/ext/dba/dba_cdb.c b/ext/dba/dba_cdb.c
index 3f98eb6d5f..fb1a3f3ba2 100644
--- a/ext/dba/dba_cdb.c
+++ b/ext/dba/dba_cdb.c
@@ -324,6 +324,19 @@ DBA_SYNC_FUNC(cdb)
return SUCCESS;
}
+DBA_INFO_FUNC(cdb)
+{
+#if DBA_CDB_BUILTIN
+ if (!strcmp(hnd->name, "cdb")) {
+ return estrdup(cdb_version());
+ } else {
+ return estrdup(cdb_make_version());
+ }
+#else
+ return estrdup("External");
+#endif
+}
+
#endif
/*
diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c
index 0227cc5e34..9ef28a7a66 100644
--- a/ext/dba/dba_db2.c
+++ b/ext/dba/dba_db2.c
@@ -188,6 +188,11 @@ DBA_SYNC_FUNC(db2)
return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS;
}
+DBA_INFO_FUNC(db2)
+{
+ return estrdup(DB_VERSION_STRING);
+}
+
#endif
/*
diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c
index 0bce28a72d..3d0e892219 100644
--- a/ext/dba/dba_db3.c
+++ b/ext/dba/dba_db3.c
@@ -217,6 +217,11 @@ DBA_SYNC_FUNC(db3)
return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS;
}
+DBA_INFO_FUNC(db3)
+{
+ return estrdup(DB_VERSION_STRING);
+}
+
#endif
/*
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c
index bc5a1365b8..0195d61400 100644
--- a/ext/dba/dba_db4.c
+++ b/ext/dba/dba_db4.c
@@ -222,6 +222,11 @@ DBA_SYNC_FUNC(db4)
return dba->dbp->sync(dba->dbp, 0) ? FAILURE : SUCCESS;
}
+DBA_INFO_FUNC(db4)
+{
+ return estrdup(DB_VERSION_STRING);
+}
+
#endif
/*
diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c
index 5025e023a9..f50d58a03f 100644
--- a/ext/dba/dba_dbm.c
+++ b/ext/dba/dba_dbm.c
@@ -177,6 +177,11 @@ DBA_SYNC_FUNC(dbm)
return SUCCESS;
}
+DBA_INFO_FUNC(dbm)
+{
+ return estrdup("DBM");
+}
+
#endif
/*
diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c
index 30a6e9dea0..3134603259 100644
--- a/ext/dba/dba_flatfile.c
+++ b/ext/dba/dba_flatfile.c
@@ -163,6 +163,11 @@ DBA_SYNC_FUNC(flatfile)
return SUCCESS;
}
+DBA_INFO_FUNC(flatfile)
+{
+ return estrdup(flatfile_version());
+}
+
#endif
/*
diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c
index 0dda322eca..40332ad44e 100644
--- a/ext/dba/dba_gdbm.c
+++ b/ext/dba/dba_gdbm.c
@@ -180,6 +180,12 @@ DBA_SYNC_FUNC(gdbm)
gdbm_sync(dba->dbf);
return SUCCESS;
}
+
+DBA_INFO_FUNC(gdbm)
+{
+ return estrdup(gdbm_version);
+}
+
#endif
/*
diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c
index 7d2e5c3d3f..c8cf540944 100644
--- a/ext/dba/dba_ndbm.c
+++ b/ext/dba/dba_ndbm.c
@@ -153,6 +153,12 @@ DBA_SYNC_FUNC(ndbm)
{
return SUCCESS;
}
+
+DBA_INFO_FUNC(ndbm)
+{
+ return estrdup("NDBM" );
+}
+
#endif
/*
diff --git a/ext/dba/libcdb/cdb.c b/ext/dba/libcdb/cdb.c
index 5e40f86607..da3de2ff34 100644
--- a/ext/dba/libcdb/cdb.c
+++ b/ext/dba/libcdb/cdb.c
@@ -193,3 +193,10 @@ int cdb_find(struct cdb *c, char *key, unsigned int len TSRMLS_DC)
return cdb_findnext(c, key, len TSRMLS_CC);
}
/* }}} */
+
+/* {{{ cdb_version */
+char *cdb_version()
+{
+ return "0.75, $Revision$";
+}
+/* }}} */
diff --git a/ext/dba/libcdb/cdb.h b/ext/dba/libcdb/cdb.h
index ca8cd23b7b..6a3b08db34 100644
--- a/ext/dba/libcdb/cdb.h
+++ b/ext/dba/libcdb/cdb.h
@@ -52,4 +52,6 @@ int cdb_find(struct cdb *, char *, unsigned int TSRMLS_DC);
#define cdb_datapos(c) ((c)->dpos)
#define cdb_datalen(c) ((c)->dlen)
+char *cdb_version();
+
#endif
diff --git a/ext/dba/libcdb/cdb_make.c b/ext/dba/libcdb/cdb_make.c
index 65ef385d21..1c3402e908 100644
--- a/ext/dba/libcdb/cdb_make.c
+++ b/ext/dba/libcdb/cdb_make.c
@@ -238,3 +238,9 @@ int cdb_make_finish(struct cdb_make *c TSRMLS_DC)
return php_stream_flush(c->fp);
}
/* }}} */
+
+/* {{{ cdb_make_version */
+char *cdb_make_version()
+{
+ return "0.75, $Revision$";
+}
diff --git a/ext/dba/libcdb/cdb_make.h b/ext/dba/libcdb/cdb_make.h
index 0a54befec3..ea3f40d314 100644
--- a/ext/dba/libcdb/cdb_make.h
+++ b/ext/dba/libcdb/cdb_make.h
@@ -59,5 +59,6 @@ int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int TSRMLS_DC);
int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, uint32 TSRMLS_DC);
int cdb_make_add(struct cdb_make *, char *, unsigned int, char *, unsigned int TSRMLS_DC);
int cdb_make_finish(struct cdb_make * TSRMLS_DC);
+char *cdb_make_version();
#endif
diff --git a/ext/dba/libflatfile/flatfile.c b/ext/dba/libflatfile/flatfile.c
index 1cd13fceaa..055256144d 100644
--- a/ext/dba/libflatfile/flatfile.c
+++ b/ext/dba/libflatfile/flatfile.c
@@ -295,6 +295,13 @@ datum flatfile_nextkey(flatfile *dba TSRMLS_DC) {
}
/* }}} */
+/* {{{ flatfile_version */
+char *flatfile_version()
+{
+ return "1.0, $Revision$";
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
diff --git a/ext/dba/libflatfile/flatfile.h b/ext/dba/libflatfile/flatfile.h
index 8963f64f82..d4187d810a 100644
--- a/ext/dba/libflatfile/flatfile.h
+++ b/ext/dba/libflatfile/flatfile.h
@@ -43,5 +43,6 @@ int flatfile_delete(flatfile *dba, datum key_datum TSRMLS_DC);
int flatfile_findkey(flatfile *dba, datum key_datum TSRMLS_DC);
datum flatfile_firstkey(flatfile *dba TSRMLS_DC);
datum flatfile_nextkey(flatfile *dba TSRMLS_DC);
+char *flatfile_version();
#endif
diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h
index dc90902088..18ace81984 100644
--- a/ext/dba/php_dba.h
+++ b/ext/dba/php_dba.h
@@ -81,6 +81,8 @@ typedef struct dba_handler {
char* (*nextkey)(dba_info *, int * TSRMLS_DC);
int (*optimize)(dba_info * TSRMLS_DC);
int (*sync)(dba_info * TSRMLS_DC);
+ char* (*info)(struct dba_handler *hnd, dba_info * TSRMLS_DC);
+ /* dba_info==NULL: Handler info, dba_info!=NULL: Database info */
} dba_handler;
/* common prototypes which must be supplied by modules */
@@ -105,6 +107,8 @@ typedef struct dba_handler {
int dba_optimize_##x(dba_info *info TSRMLS_DC)
#define DBA_SYNC_FUNC(x) \
int dba_sync_##x(dba_info *info TSRMLS_DC)
+#define DBA_INFO_FUNC(x) \
+ char *dba_info_##x(dba_handler *hnd, dba_info *info TSRMLS_DC)
#define DBA_FUNCS(x) \
DBA_OPEN_FUNC(x); \
@@ -116,7 +120,8 @@ typedef struct dba_handler {
DBA_FIRSTKEY_FUNC(x); \
DBA_NEXTKEY_FUNC(x); \
DBA_OPTIMIZE_FUNC(x); \
- DBA_SYNC_FUNC(x)
+ DBA_SYNC_FUNC(x); \
+ DBA_INFO_FUNC(x)
#define VALLEN(p) Z_STRVAL_PP(p), Z_STRLEN_PP(p)