diff options
| author | Marcus Boerger <helly@php.net> | 2002-10-25 10:06:35 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2002-10-25 10:06:35 +0000 |
| commit | 63cffd7eae5e64d19e6303e183314232a6085277 (patch) | |
| tree | f4b65f259b5de61e9e4584a3db2fccac5ded79c5 /ext/dba/dba.c | |
| parent | a707e77a1b9d57fdd8bce556aeba7e8fadfa543a (diff) | |
| download | php-git-63cffd7eae5e64d19e6303e183314232a6085277.tar.gz | |
Implemented dba_list() that returns an array rsrcid=>filename and a test.
Diffstat (limited to 'ext/dba/dba.c')
| -rw-r--r-- | ext/dba/dba.c | 33 |
1 files changed, 32 insertions, 1 deletions
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; i<numitems; i++) { + if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) { + continue; + } + if (Z_TYPE_P(le) == le_db || Z_TYPE_P(le) == le_pdb) { + info = (dba_info *)(le->ptr); + add_index_string(return_value, i, info->path, 1); + } + } +} +/* }}} */ + #endif /* |
