helly Wed Nov 12 16:43:04 2003 EDT
Modified files:
/php-src/ext/dba dba.c php_dba.h
Log:
Add helper function that splits inifile keys into an array which again
can be used in dba_fetch calls.
Index: php-src/ext/dba/dba.c
diff -u php-src/ext/dba/dba.c:1.100 php-src/ext/dba/dba.c:1.101
--- php-src/ext/dba/dba.c:1.100 Thu Aug 28 13:56:41 2003
+++ php-src/ext/dba/dba.c Wed Nov 12 16:43:03 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.100 2003/08/28 17:56:41 iliaa Exp $ */
+/* $Id: dba.c,v 1.101 2003/11/12 21:43:03 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -66,6 +66,7 @@
PHP_FE(dba_sync, NULL)
PHP_FE(dba_handlers, NULL)
PHP_FE(dba_list, NULL)
+ PHP_FE(dba_key_split, NULL)
{NULL, NULL, NULL}
};
/* }}} */
@@ -907,6 +908,27 @@
}
DBA_ID_DONE;
RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto array dba_key_split(string key)
+ Splits an inifile key into an array of the form array(0=>group,1=>value_name) */
+PHP_FUNCTION(dba_key_split)
+{
+ char *key, *name;
+ int key_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) ==
FAILURE) {
+ return;
+ }
+ array_init(return_value);
+ if (key[0] == '[' && (name = strchr(key, ']')) != NULL) {
+ add_next_index_stringl(return_value, key+1, name - (key + 1), 1);
+ add_next_index_stringl(return_value, name+1, key_len - (name - key +
1), 1);
+ } else {
+ add_next_index_stringl(return_value, "", 0, 1);
+ add_next_index_stringl(return_value, key, key_len, 1);
+ }
}
/* }}} */
Index: php-src/ext/dba/php_dba.h
diff -u php-src/ext/dba/php_dba.h:1.25 php-src/ext/dba/php_dba.h:1.26
--- php-src/ext/dba/php_dba.h:1.25 Tue Jun 10 16:03:26 2003
+++ php-src/ext/dba/php_dba.h Wed Nov 12 16:43:03 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_dba.h,v 1.25 2003/06/10 20:03:26 imajes Exp $ */
+/* $Id: php_dba.h,v 1.26 2003/11/12 21:43:03 helly Exp $ */
#ifndef PHP_DBA_H
#define PHP_DBA_H
@@ -138,6 +138,7 @@
PHP_FUNCTION(dba_sync);
PHP_FUNCTION(dba_handlers);
PHP_FUNCTION(dba_list);
+PHP_FUNCTION(dba_key_split);
#else
#define dba_module_ptr NULL
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php