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];
FILE *f;
char *c, *cur;
int lineno=0;
+
if (configfile[0] == '/') {
strncpy(fn, configfile, sizeof(fn));
} else {
/* 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);
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
struct ast_variable {
char *name;
char *value;
+ int lineno;
struct ast_variable *next;
};
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)
}
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)
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)
}
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();
tmp->eventcnt = 1;
tmp->schedcnt = 0;
tmp->schedq = NULL;
+#ifdef SCHED_MAX_CACHE
tmp->schedc = NULL;
tmp->schedccnt = 0;
+#endif
}
return tmp;
}
void sched_context_destroy(struct sched_context *con)
{
struct sched *s, *sl;
+#ifdef SCHED_MAX_CACHE
/* Eliminate the cache */
s = con->schedc;
while(s) {
s = s->next;
free(sl);
}
+#endif
/* And the queue */
s = con->schedq;
while(s) {
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");