[asterisk-commits] russell: branch russell/func_config r107785 - /team/russell/func_config/funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 11 16:56:55 CDT 2008


Author: russell
Date: Tue Mar 11 16:56:55 2008
New Revision: 107785

URL: http://svn.digium.com/view/asterisk?view=rev&rev=107785
Log:
check in some progress

Modified:
    team/russell/func_config/funcs/func_config.c

Modified: team/russell/func_config/funcs/func_config.c
URL: http://svn.digium.com/view/asterisk/team/russell/func_config/funcs/func_config.c?view=diff&rev=107785&r1=107784&r2=107785
==============================================================================
--- team/russell/func_config/funcs/func_config.c (original)
+++ team/russell/func_config/funcs/func_config.c Tue Mar 11 16:56:55 2008
@@ -33,6 +33,14 @@
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/app.h"
+#include "asterisk/astobj2.h"
+
+struct open_config {
+	struct ast_config *cfg;
+	char filename[1];
+};
+
+static struct ao2_container *open_configs;
 
 static int config_function_read(struct ast_channel *chan, const char *cmd, char *data, 
 	char *buf, size_t len) 
@@ -53,9 +61,38 @@
 	parse = ast_strdupa(data);
 	AST_STANDARD_APP_ARGS(args, parse);
 
+	if (ast_strlen_zero(args.file)) {
+		ast_log(LOG_ERROR, "AST_CONFIG() requires a filename\n");
+		return -1;
+	}
+	
+	if (ast_strlen_zero(args.category)) {
+		ast_log(LOG_ERROR, "AST_CONFIG() requires a category\n");
+		return -1;
+	}
+	
+	if (ast_strlen_zero(args.variable)) {
+		ast_log(LOG_ERROR, "AST_CONFIG() requires a variable\n");
+		return -1;
+	}
+
 	/* XXX */
 
 	return 0;
+}
+
+static int open_config_hash(const void *obj, const int flags)
+{
+	const struct open_config *oc = obj;
+
+	return ast_str_hash(oc->filename);
+}
+
+static int open_config_cmp(void *obj, void *arg, int flags)
+{
+	struct open_config *oc1 = obj, *oc2 = arg;
+
+	return !strcasecmp(oc1->filename, oc2->filename) ? CMP_MATCH : 0;
 }
 
 static struct ast_custom_function config_function = {
@@ -75,11 +112,16 @@
 
 static int unload_module(void)
 {
+	ao2_ref(open_configs, -1);
+
 	return ast_custom_function_unregister(&config_function);
 }
 
 static int load_module(void)
 {
+	if (!(open_configs = ao2_container_alloc(17, open_config_hash, open_config_cmp)))
+		return AST_MODULE_LOAD_DECLINE;
+
 	return ast_custom_function_register(&config_function);
 }
 




More information about the asterisk-commits mailing list