[Asterisk-cvs] asterisk-addons/res_sqlite3 Makefile, 1.1,
1.2 res_sqlite.c, 1.1, 1.2
anthm at lists.digium.com
anthm at lists.digium.com
Mon Jan 31 16:03:07 CST 2005
Update of /usr/cvsroot/asterisk-addons/res_sqlite3
In directory mongoose.digium.com:/tmp/cvs-serv19845
Modified Files:
Makefile res_sqlite.c
Log Message:
add kpflemming's patch to make res_sqlite work with his new config changes (#3458)
Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/res_sqlite3/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile 15 Nov 2004 14:42:03 -0000 1.1
+++ Makefile 31 Jan 2005 22:04:31 -0000 1.2
@@ -1,5 +1,5 @@
ASTDIR=/usr/src/asterisk
-ASTXS=/usr/src/asterisk/contrib/scripts/astxs
+ASTXS=$(ASTDIR)/contrib/scripts/astxs
ASTMODS=/usr/lib/asterisk/modules
ASTSQLITE=/var/lib/asterisk/sqlite
SQLITE2=/usr/local/bin/sqlite
@@ -13,7 +13,7 @@
res_sqlite.so:
- $(ASTXS) "-append=CFLAGS:$(CFLAGS)" "-append=EXTOBJ:./sqlite/.libs/libsqlite3.a" res_sqlite.c
+ ASTSRC=$(ASTDIR) $(ASTXS) "-append=CFLAGS:$(CFLAGS)" "-append=EXTOBJ:./sqlite/.libs/libsqlite3.a" res_sqlite.c
.sqlite:
cd sqlite && test -f ./config.status || ./configure --enable-threadsafe
Index: res_sqlite.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/res_sqlite3/res_sqlite.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- res_sqlite.c 15 Nov 2004 14:42:03 -0000 1.1
+++ res_sqlite.c 31 Jan 2005 22:04:31 -0000 1.2
@@ -20,7 +20,6 @@
#include <asterisk/module.h>
#include <asterisk/utils.h>
#include <asterisk/config.h>
-#include <asterisk/config_pvt.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -94,8 +93,6 @@
static int default_timeout = 300;
static int do_reload=1;
-static struct ast_config_reg reg1;
-
static char cdr_table[ARRAY_SIZE];
static char cdr_dbfile[ARRAY_SIZE];
@@ -725,39 +722,28 @@
static struct ast_cli_entry cli_sqlite8 = { { "create", NULL }, sqlite_cli, scmd, shelp};
static struct ast_cli_entry cli_sqlite9 = { { "drop", NULL }, sqlite_cli, scmd, shelp};
-
-
-static struct ast_config *config_sqlite (const char *database, const char *table, const char *file, struct ast_config *new_config_s, struct ast_category **new_cat_p, struct ast_variable **new_v_p, int recur) {
- struct ast_config *config, *new;
- struct ast_variable *v, *cur_v, *new_v;
- struct ast_category *cur_cat, *new_cat;
+static struct ast_config *config_sqlite(const char *database, const char *table, const char *file, struct ast_config *cfg)
+{
+ struct ast_variable *new_v, *v;
+ struct ast_category *cur_cat;
char ttable[ARRAY_SIZE];
int configured = 0, res = 0;
sqlite3_stmt *stmt = NULL;;
int cat_metric=0, last_cat_metric=0;
char sql[ARRAY_SIZE];
- char last[ARRAY_SIZE];
- int cat_started = 0;
- int var_started = 0;
+ char last[ARRAY_SIZE] = "";
char path[ARRAY_SIZE];
sqlite3 *db;
int running=0;
int i=0;
+ struct ast_config *config;
- if (new_config_s) {
- new = new_config_s;
- cat_started++;
- } else {
- new = ast_new_config ();
- }
-
- last[0] = '\0';
/* if the data was not passed from extconfig.conf then get it from sqlite.conf */
if(!database || ast_strlen_zero(database)) {
if (!file || !strcmp (file, "res_sqlite.conf"))
return NULL; // cant configure myself with myself !
- config = ast_load ("res_sqlite.conf");
+ config = ast_config_load ("res_sqlite.conf");
if (config) {
for (v = ast_variable_browse (config, "config"); v; v = v->next) {
if (!strcmp (v->name, "table")) {
@@ -768,7 +754,7 @@
configured++;
}
}
- ast_destroy (config);
+ ast_config_destroy (config);
}
} else {
pick_path((char *)database,path,ARRAY_SIZE);
@@ -791,16 +777,7 @@
return NULL;
}
-
- cat_started = 0;
- cur_cat = *new_cat_p;
- cur_v = *new_v_p;
-
- if (cur_cat)
- cat_started = 1;
- if (cur_v)
- var_started = 1;
-
+ cur_cat = ast_config_get_current_category(cfg);
/*
0 id int
@@ -838,40 +815,23 @@
}
if (strcmp (last, sqlite3_column_text(stmt,5)) || last_cat_metric != cat_metric) {
+ cur_cat = ast_category_new((char *)sqlite3_column_text(stmt,5));
+ if (!cur_cat) {
+ ast_log(LOG_WARNING, "Out of memory!\n");
+ break;
+ }
strcpy (last, sqlite3_column_text(stmt,5));
last_cat_metric = cat_metric;
- new_cat = (struct ast_category *) ast_new_category((char *)sqlite3_column_text(stmt,5));
-
- if (!cat_started) {
- cat_started++;
- new->root = new_cat;
- cur_cat = new->root;
- } else {
- cur_cat->next = new_cat;
- cur_cat = cur_cat->next;
- }
- var_started = 0;
-
- }
- new_v = ast_new_variable ((char *)sqlite3_column_text(stmt,6), (char *)sqlite3_column_text(stmt,7));
-
- if (!var_started) {
- var_started++;
- cur_cat->root = new_v;
- cur_v = cur_cat->root;
- } else {
- cur_v->next = new_v;
- cur_v = cur_v->next;
+ ast_category_append(cfg, cur_cat);
}
-
+ new_v = ast_variable_new ((char *)sqlite3_column_text(stmt,6), (char *)sqlite3_column_text(stmt,7));
+ ast_variable_append(cur_cat, new_v);
}
if ((sqlite3_finalize(stmt)))
ast_log(LOG_ERROR,"ERROR: %s\n",sqlite3_errmsg(db));
-
- return new;
-
+ return cfg;
}
@@ -1057,7 +1017,7 @@
char *sql;
- config = ast_load ("res_sqlite.conf");
+ config = ast_config_load ("res_sqlite.conf");
if (config) {
for (v = ast_variable_browse (config, "general"); v; v = v->next) {
if (!strcmp (v->name, "reload")) {
@@ -1114,7 +1074,7 @@
}
}
- ast_destroy (config);
+ ast_config_destroy (config);
}
@@ -1152,6 +1112,11 @@
return load_config(0);
}
+static struct ast_config_engine sqlite_engine = {
+ .name = "sqlite",
+ .load_func = config_sqlite
+};
+
int load_module(void)
{
int res = 0;
@@ -1159,10 +1124,7 @@
load_config(1);
do_reload = 0;
- memset (®1, 0, sizeof (struct ast_config_reg));
- strcpy (reg1.name, "sqlite");
- reg1.static_func = config_sqlite;
- ast_cust_config_register (®1);
+ ast_config_engine_register(&sqlite_engine);
ast_verbose(VERBOSE_PREFIX_2 "SQLite Config Handler Registered.\n");
@@ -1214,7 +1176,7 @@
int res = 0;
do_reload = 1;
- ast_cust_config_deregister (®1);
+ ast_config_engine_deregister(&sqlite_engine);
if (has_cdr) {
ast_cdr_unregister(cdr_name);
ast_verbose(VERBOSE_PREFIX_2 "SQLite CDR Disabled\n");
More information about the svn-commits
mailing list