aboutsummaryrefslogtreecommitdiffstats
path: root/pbx
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>1999-10-13 04:15:49 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>1999-10-13 04:15:49 +0000
commitec9eac4236702c90a86b0038b37103e4791be1a9 (patch)
treef97893c0af62b46ff394748ceff88c2e93b233ac /pbx
parent795143ef36d7c9b43ff622e14c0b459ad25cb6a1 (diff)
Version 0.1.0 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rwxr-xr-xpbx/pbx_config.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
new file mode 100755
index 000000000..359cec911
--- /dev/null
+++ b/pbx/pbx_config.c
@@ -0,0 +1,91 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Populate and remember extensions from static config file
+ *
+ * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+ *
+ * Mark Spencer <markster@linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <asterisk/pbx.h>
+#include <asterisk/config.h>
+#include <asterisk/module.h>
+#include <asterisk/logger.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+/* For where to put dynamic tables */
+#include "../asterisk.h"
+
+static char *dtext = "Text Extension Configuration";
+static char *config = "extensions.conf";
+
+static int static_config = 0;
+
+int unload_module(void)
+{
+ return 0;
+}
+
+int load_module(void)
+{
+ struct ast_config *cfg;
+ struct ast_variable *v;
+ char *cxt, *ext, *pri, *appl, *data, *tc;
+ struct ast_context *con;
+
+
+ cfg = ast_load(config);
+ if (cfg) {
+ /* Use existing config to populate the PBX table */
+ static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
+ cxt = ast_category_browse(cfg, NULL);
+ while(cxt) {
+ /* All categories but "general" are considered contexts */
+ if (!strcasecmp(cxt, "general")) {
+ cxt = ast_category_browse(cfg, cxt);
+ continue;
+ }
+ if ((con=ast_context_create(cxt))) {
+ v = ast_variable_browse(cfg, cxt);
+ while(v) {
+ tc = strdup(v->value);
+ ext = strtok(tc, ",");
+ if (!ext)
+ ext="";
+ pri = strtok(NULL, ",");
+ if (!pri)
+ pri="";
+ appl = strtok(NULL, ",");
+ if (!appl)
+ appl="";
+ data = strtok(NULL, ",");
+ if (!data)
+ data="";
+ if (ast_add_extension2(con, 0, ext, atoi(pri), appl, strdup(data), free)) {
+ ast_log(LOG_WARNING, "Unable to register extension\n");
+ }
+ v = v->next;
+ free(tc);
+ }
+ }
+ cxt = ast_category_browse(cfg, cxt);
+ }
+ }
+ ast_destroy(cfg);
+ return 0;
+}
+
+int usecount(void)
+{
+ return 0;
+}
+
+char *description(void)
+{
+ return dtext;
+}