From: Marcus Boerger Date: Fri, 25 Oct 2002 10:06:35 +0000 (+0000) Subject: Implemented dba_list() that returns an array rsrcid=>filename and a test. X-Git-Tag: php-4.3.0pre2~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63cffd7eae5e64d19e6303e183314232a6085277;p=php Implemented dba_list() that returns an array rsrcid=>filename and a test. --- diff --git a/ext/dba/dba.c b/ext/dba/dba.c index eed953b5c9..71f21ad4e7 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -52,6 +52,7 @@ function_entry dba_functions[] = { PHP_FE(dba_optimize, NULL) PHP_FE(dba_sync, NULL) PHP_FE(dba_handlers, NULL) + PHP_FE(dba_list, NULL) {NULL, NULL, NULL} }; /* }}} */ @@ -513,7 +514,7 @@ PHP_FUNCTION(dba_sync) } /* }}} */ -/* {{{ proto array dba_list() +/* {{{ proto array dba_handlers() List configured databases */ PHP_FUNCTION(dba_handlers) { @@ -534,6 +535,36 @@ PHP_FUNCTION(dba_handlers) } /* }}} */ +/* {{{ proto array dba_list() + List configured databases */ +PHP_FUNCTION(dba_list) +{ + ulong numitems, i; + zend_rsrc_list_entry *le; + dba_info *info; + + 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; + } + numitems = zend_hash_next_free_element(&EG(regular_list)); + for (i=1; iptr); + add_index_string(return_value, i, info->path, 1); + } + } +} +/* }}} */ + #endif /* diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h index c1bc6f1dd0..832e66638c 100644 --- a/ext/dba/php_dba.h +++ b/ext/dba/php_dba.h @@ -95,6 +95,7 @@ PHP_FUNCTION(dba_fetch); PHP_FUNCTION(dba_optimize); PHP_FUNCTION(dba_sync); PHP_FUNCTION(dba_handlers); +PHP_FUNCTION(dba_list); #else #define dba_module_ptr NULL diff --git a/ext/dba/tests/007.phpt b/ext/dba/tests/007.phpt new file mode 100644 index 0000000000..82316cfd01 --- /dev/null +++ b/ext/dba/tests/007.phpt @@ -0,0 +1,40 @@ +--TEST-- +DBA Multiple File Creation Test +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +database file created with %s. +array(3) { + [%d]=> + string(%d) "%sext/dba/tests/test.dbm" + [%d]=> + string(%d) "%sext/dba/tests/test1.dbm" + [%d]=> + string(%d) "%sext/dba/tests/test2.dbm" +} \ No newline at end of file