From ad0aa8091ac56f7ab0b8ac9732b735940d27711f Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Mon, 23 Apr 2001 16:50:12 +0000 Subject: Version 0.1.8 from FTP git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@294 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- config.c | 35 ++++++++++++++++++++++++++++++++++- include/asterisk/config.h | 3 +++ pbx/pbx_gtkconsole.c | 8 +++----- sched.c | 14 ++++++++++++-- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/config.c b/config.c index 1e83beffb..386bab480 100755 --- a/config.c +++ b/config.c @@ -123,6 +123,21 @@ char *ast_variable_retrieve(struct ast_config *config, char *category, char *val return NULL; } +int ast_category_exist(struct ast_config *config, char *category_name) +{ + struct ast_category *category = NULL; + + category = config->root; + + while(category) { + if (!strcasecmp(category->name,category_name)) + return 1; + category = category->next; + } + + return 0; +} + struct ast_config *ast_load(char *configfile) { char fn[256]; @@ -133,6 +148,7 @@ struct ast_config *ast_load(char *configfile) FILE *f; char *c, *cur; int lineno=0; + if (configfile[0] == '/') { strncpy(fn, configfile, sizeof(fn)); } else { @@ -167,10 +183,23 @@ struct ast_config *ast_load(char *configfile) /* Actually parse the entry */ if (cur[0] == '[') { /* A category header */ - /* XXX Don't let them use the same category twice XXX */ c = strchr(cur, ']'); if (c) { *c = 0; + /* + * Check category duplicity before structure + * allocation + */ + if (ast_category_exist(tmp,cur+1)) { + ast_destroy(tmp); + ast_log(LOG_WARNING, + "Found duplicit category [%s] in " + "file %s line %d\n", + cur+1,configfile,lineno); + fclose(f); + return NULL; + } + tmpc = malloc(sizeof(struct ast_category)); if (!tmpc) { ast_destroy(tmp); @@ -204,11 +233,15 @@ struct ast_config *ast_load(char *configfile) if (c) { *c = 0; c++; + /* Ignore > in => */ + if (*c== '>') + c++; v = malloc(sizeof(struct ast_variable)); if (v) { v->next = NULL; v->name = strdup(strip(cur)); v->value = strdup(strip(c)); + v->lineno = lineno; if (last) last->next = v; else diff --git a/include/asterisk/config.h b/include/asterisk/config.h index a1e876ecb..d4eccc073 100755 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -23,6 +23,7 @@ struct ast_config; struct ast_variable { char *name; char *value; + int lineno; struct ast_variable *next; }; @@ -38,6 +39,8 @@ struct ast_variable *ast_variable_browse(struct ast_config *config, char *catego char *ast_variable_retrieve(struct ast_config *config, char *category, char *value); /* Determine affermativeness of a boolean value */ int ast_true(char *val); +/* Browse config structure and check for category duplicity Return non-zero if found */ +int ast_category_exist(struct ast_config *config, char *category_name); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/pbx/pbx_gtkconsole.c b/pbx/pbx_gtkconsole.c index f8f233cf8..5d3f05773 100755 --- a/pbx/pbx_gtkconsole.c +++ b/pbx/pbx_gtkconsole.c @@ -124,10 +124,10 @@ static void __verboser(char *stuff, int opos, int replacelast, int complete) static void verboser(char *stuff, int opos, int replacelast, int complete) { - pthread_mutex_lock(&verb_lock); + ast_pthread_mutex_lock(&verb_lock); /* Lock appropriately if we're really being called in verbose mode */ __verboser(stuff, opos, replacelast, complete); - pthread_mutex_unlock(&verb_lock); + ast_pthread_mutex_unlock(&verb_lock); } static void cliinput(void *data, int source, GdkInputCondition ic) @@ -297,7 +297,7 @@ static void exit_now(GtkWidget *widget, gpointer data) ast_unload_resource("pbx_gtkconsole", 0); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "GTK Console Monitor Exiting\n"); - + /* XXX Trying to quit after calling this makes asterisk segfault XXX */ } static void exit_completely(GtkWidget *widget, gpointer data) @@ -467,8 +467,6 @@ int load_module(void) } g_thread_init(NULL); if (gtk_init_check(NULL, NULL)) { - /* XXX Do we need to call this twice? XXX */ - gtk_init(NULL, NULL); if (!show_console()) { inuse++; ast_update_use_count(); diff --git a/sched.c b/sched.c index 42afea5be..a4fb1096a 100755 --- a/sched.c +++ b/sched.c @@ -62,8 +62,10 @@ struct sched_context *sched_context_create(void) tmp->eventcnt = 1; tmp->schedcnt = 0; tmp->schedq = NULL; +#ifdef SCHED_MAX_CACHE tmp->schedc = NULL; tmp->schedccnt = 0; +#endif } return tmp; } @@ -71,6 +73,7 @@ struct sched_context *sched_context_create(void) void sched_context_destroy(struct sched_context *con) { struct sched *s, *sl; +#ifdef SCHED_MAX_CACHE /* Eliminate the cache */ s = con->schedc; while(s) { @@ -78,6 +81,7 @@ void sched_context_destroy(struct sched_context *con) s = s->next; free(sl); } +#endif /* And the queue */ s = con->schedq; while(s) { @@ -255,8 +259,14 @@ void ast_sched_dump(struct sched_context *con) struct timeval tv; time_t s, ms; gettimeofday(&tv, NULL); - ast_log(LOG_DEBUG, "Cheops Schedule Dump (%d in Q, %d Total, %d Cache)\n", - con-> schedcnt, con->eventcnt - 1, con->schedccnt); +#ifdef SCHED_MAX_CACHE + ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", + con-> schedcnt, con->eventcnt - 1, con->schedccnt); +#else + ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", + con-> schedcnt, con->eventcnt - 1); +#endif + ast_log(LOG_DEBUG, "=================================================\n"); ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n"); ast_log(LOG_DEBUG, "+-----+-----------+-----------+-----------------+\n"); -- cgit v1.2.3