[asterisk-commits] file: branch file/res_sorcery_realtime r383915 - /team/file/res_sorcery_realt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 26 13:52:06 CDT 2013


Author: file
Date: Tue Mar 26 13:52:03 2013
New Revision: 383915

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383915
Log:
It compiles again!

Modified:
    team/file/res_sorcery_realtime/main/config.c

Modified: team/file/res_sorcery_realtime/main/config.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_realtime/main/config.c?view=diff&rev=383915&r1=383914&r2=383915
==============================================================================
--- team/file/res_sorcery_realtime/main/config.c (original)
+++ team/file/res_sorcery_realtime/main/config.c Tue Mar 26 13:52:03 2013
@@ -2511,7 +2511,28 @@
 	return result;
 }
 
-static struct ast_variable *ast_load_realtime_helper(const char *family, va_list ap)
+static struct ast_variable *realtime_arguments_to_fields(va_list ap)
+{
+	struct ast_variable *fields = NULL;
+	const char *newparam;
+
+	while ((newparam = va_arg(ap, const char *))) {
+		const char *newval = va_arg(ap, const char *);
+		struct ast_variable *field = ast_variable_new(newparam, newval, "");
+
+		if (!field) {
+			ast_variables_destroy(fields);
+			return NULL;
+		}
+
+		field->next = fields;
+		fields = field;
+	}
+
+	return fields;
+}
+
+static struct ast_variable *ast_load_realtime_helper(const char *family, const struct ast_variable *fields)
 {
 	struct ast_config_engine *eng;
 	char db[256];
@@ -2521,7 +2542,7 @@
 
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
-			if (eng->realtime_func && (res = eng->realtime_func(db, table, ap))) {
+			if (eng->realtime_func && (res = eng->realtime_func(db, table, fields))) {
 				return res;
 			}
 		} else {
@@ -2534,12 +2555,17 @@
 
 struct ast_variable *ast_load_realtime_all(const char *family, ...)
 {
-	struct ast_variable *res;
+	RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
+	struct ast_variable *res = NULL;
 	va_list ap;
 
 	va_start(ap, family);
-	res = ast_load_realtime_helper(family, ap);
+	fields = realtime_arguments_to_fields(ap);
 	va_end(ap);
+
+	if (fields) {
+		res = ast_load_realtime_helper(family, fields);
+	}
 
 	return res;
 }
@@ -2549,11 +2575,14 @@
 	struct ast_variable *res;
 	struct ast_variable *cur;
 	struct ast_variable **prev;
+	RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
 	va_list ap;
 
 	va_start(ap, family);
-	res = ast_load_realtime_helper(family, ap);
+	fields = realtime_arguments_to_fields(ap);
 	va_end(ap);
+
+	res = ast_load_realtime_helper(family, fields);
 
 	/* Filter the list. */
 	prev = &res;
@@ -2648,6 +2677,7 @@
 
 struct ast_config *ast_load_realtime_multientry(const char *family, ...)
 {
+	RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
 	struct ast_config_engine *eng;
 	char db[256];
 	char table[256];
@@ -2656,9 +2686,12 @@
 	int i;
 
 	va_start(ap, family);
+	fields = realtime_arguments_to_fields(ap);
+	va_end(ap);
+
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
-			if (eng->realtime_multi_func && (res = eng->realtime_multi_func(db, table, ap))) {
+			if (eng->realtime_multi_func && (res = eng->realtime_multi_func(db, table, fields))) {
 				/* If we were returned an empty cfg, destroy it and return NULL */
 				if (!res->root) {
 					ast_config_destroy(res);
@@ -2670,13 +2703,13 @@
 			break;
 		}
 	}
-	va_end(ap);
 
 	return res;
 }
 
 int ast_update_realtime(const char *family, const char *keyfield, const char *lookup, ...)
 {
+	RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
 	struct ast_config_engine *eng;
 	int res = -1, i;
 	char db[256];
@@ -2684,23 +2717,27 @@
 	va_list ap;
 
 	va_start(ap, lookup);
+	fields = realtime_arguments_to_fields(ap);
+	va_end(ap);
+
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
 			/* If the update succeeds, it returns 0. */
-			if (eng->update_func && !(res = eng->update_func(db, table, keyfield, lookup, ap))) {
+			if (eng->update_func && !(res = eng->update_func(db, table, keyfield, lookup, fields))) {
 				break;
 			}
 		} else {
 			break;
 		}
 	}
-	va_end(ap);
 
 	return res;
 }
 
 int ast_update2_realtime(const char *family, ...)
 {
+	RAII_VAR(struct ast_variable *, lookup_fields, NULL, ast_variables_destroy);
+	RAII_VAR(struct ast_variable *, update_fields, NULL, ast_variables_destroy);
 	struct ast_config_engine *eng;
 	int res = -1, i;
 	char db[256];
@@ -2708,22 +2745,26 @@
 	va_list ap;
 
 	va_start(ap, family);
+	lookup_fields = realtime_arguments_to_fields(ap);
+	update_fields = realtime_arguments_to_fields(ap);
+	va_end(ap);
+
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
-			if (eng->update2_func && !(res = eng->update2_func(db, table, ap))) {
+			if (eng->update2_func && !(res = eng->update2_func(db, table, lookup_fields, update_fields))) {
 				break;
 			}
 		} else {
 			break;
 		}
 	}
-	va_end(ap);
 
 	return res;
 }
 
 int ast_store_realtime(const char *family, ...)
 {
+	RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
 	struct ast_config_engine *eng;
 	int res = -1, i;
 	char db[256];
@@ -2731,23 +2772,26 @@
 	va_list ap;
 
 	va_start(ap, family);
+	fields = realtime_arguments_to_fields(ap);
+	va_end(ap);
+
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
 			/* If the store succeeds, it returns 0. */
-			if (eng->store_func && !(res = eng->store_func(db, table, ap))) {
+			if (eng->store_func && !(res = eng->store_func(db, table, fields))) {
 				break;
 			}
 		} else {
 			break;
 		}
 	}
-	va_end(ap);
 
 	return res;
 }
 
 int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup, ...)
 {
+	RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
 	struct ast_config_engine *eng;
 	int res = -1, i;
 	char db[256];
@@ -2755,16 +2799,18 @@
 	va_list ap;
 
 	va_start(ap, lookup);
+	fields = realtime_arguments_to_fields(ap);
+	va_end(ap);
+
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
-			if (eng->destroy_func && !(res = eng->destroy_func(db, table, keyfield, lookup, ap))) {
+			if (eng->destroy_func && !(res = eng->destroy_func(db, table, keyfield, lookup, fields))) {
 				break;
 			}
 		} else {
 			break;
 		}
 	}
-	va_end(ap);
 
 	return res;
 }




More information about the asterisk-commits mailing list