From 82b96d99f3a153fc8be9d39b0c7b408462d3eaa4 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Thu, 24 Oct 2002 20:43:03 +0000 Subject: [PATCH] implemented dba_handlers() @Added dba_handlers() that lists all installed handlers in an array. (marcus) --- ext/dba/dba.c | 22 ++++++++++++++++++++++ ext/dba/php_dba.h | 1 + 2 files changed, 23 insertions(+) diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 48d5e784c51..eed953b5c9f 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -51,6 +51,7 @@ function_entry dba_functions[] = { PHP_FE(dba_nextkey, NULL) PHP_FE(dba_optimize, NULL) PHP_FE(dba_sync, NULL) + PHP_FE(dba_handlers, NULL) {NULL, NULL, NULL} }; /* }}} */ @@ -512,6 +513,27 @@ PHP_FUNCTION(dba_sync) } /* }}} */ +/* {{{ proto array dba_list() + List configured databases */ +PHP_FUNCTION(dba_handlers) +{ + dba_handler *hptr; + + if (ZEND_NUM_ARGS()!=0) { + 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; + } + for(hptr = handler; hptr->name; hptr++) { + add_next_index_string(return_value, hptr->name, 1); + } +} +/* }}} */ + #endif /* diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h index 3a9b726fdce..c1bc6f1dd06 100644 --- a/ext/dba/php_dba.h +++ b/ext/dba/php_dba.h @@ -94,6 +94,7 @@ PHP_FUNCTION(dba_exists); PHP_FUNCTION(dba_fetch); PHP_FUNCTION(dba_optimize); PHP_FUNCTION(dba_sync); +PHP_FUNCTION(dba_handlers); #else #define dba_module_ptr NULL