[asterisk-commits] rmudgett: branch 12 r403559 - /branches/12/res/res_sorcery_astdb.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 9 13:23:51 CST 2013


Author: rmudgett
Date: Mon Dec  9 13:23:49 2013
New Revision: 403559

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403559
Log:
Reverting regex part of -r403545 at request of file.

res_sorcery_astdb.c: Fix get multiple records by regex.

* Fix sorcery_astdb_retrieve_regex() pattern matching.  Let the regexec()
function match the stored key values instead of having astdb prefilter
them.  Previoiusly you could only use a simple regex pattern when the
pattern began with '^'.

Modified:
    branches/12/res/res_sorcery_astdb.c

Modified: branches/12/res/res_sorcery_astdb.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_sorcery_astdb.c?view=diff&rev=403559&r1=403558&r2=403559
==============================================================================
--- branches/12/res/res_sorcery_astdb.c (original)
+++ branches/12/res/res_sorcery_astdb.c Mon Dec  9 13:23:49 2013
@@ -218,14 +218,20 @@
 static void sorcery_astdb_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
 {
 	const char *prefix = data;
-	char family[strlen(prefix) + strlen(type) + 2];
+	char family[strlen(prefix) + strlen(type) + 2], tree[strlen(regex) + 1];
 	RAII_VAR(struct ast_db_entry *, entries, NULL, ast_db_freetree);
 	regex_t expression;
 	struct ast_db_entry *entry;
 
 	snprintf(family, sizeof(family), "%s/%s", prefix, type);
 
-	if (!(entries = ast_db_gettree(family, NULL)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
+	if (regex[0] == '^') {
+		snprintf(tree, sizeof(tree), "%s%%", regex + 1);
+	} else {
+		tree[0] = '\0';
+	}
+
+	if (!(entries = ast_db_gettree(family, tree)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
 		return;
 	}
 




More information about the asterisk-commits mailing list