Spacing changes only

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@181027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Tilghman Lesher 17 years ago
parent 1322112da0
commit ac7e490b94

@ -1568,36 +1568,41 @@ static struct ast_exten *trie_find_next_match(struct match_char *node)
struct match_char *m4; struct match_char *m4;
struct ast_exten *e3; struct ast_exten *e3;
if (node && node->x[0] == '.' && !node->x[1]) /* dot and ! will ALWAYS be next match in a matchmore */ if (node && node->x[0] == '.' && !node->x[1]) { /* dot and ! will ALWAYS be next match in a matchmore */
return node->exten; return node->exten;
}
if (node && node->x[0] == '!' && !node->x[1]) if (node && node->x[0] == '!' && !node->x[1]) {
return node->exten; return node->exten;
}
if (!node || !node->next_char) if (!node || !node->next_char) {
return NULL; return NULL;
}
m3 = node->next_char; m3 = node->next_char;
if (m3->exten) if (m3->exten) {
return m3->exten; return m3->exten;
}
for (m4 = m3->alt_char; m4; m4 = m4->alt_char) { for (m4 = m3->alt_char; m4; m4 = m4->alt_char) {
if (m4->exten) if (m4->exten) {
return m4->exten; return m4->exten;
} }
}
for (m4 = m3; m4; m4 = m4->alt_char) { for (m4 = m3; m4; m4 = m4->alt_char) {
e3 = trie_find_next_match(m3); e3 = trie_find_next_match(m3);
if (e3) if (e3) {
return e3; return e3;
} }
}
return NULL; return NULL;
} }
#ifdef DEBUG_THIS #ifdef DEBUG_THIS
static char *action2str(enum ext_match_t action) static char *action2str(enum ext_match_t action)
{ {
switch(action) switch (action) {
{
case E_MATCH: case E_MATCH:
return "MATCH"; return "MATCH";
case E_CANMATCH: case E_CANMATCH:
@ -1768,13 +1773,15 @@ static struct match_char *already_in_tree(struct match_char *current, char *pat)
{ {
struct match_char *t; struct match_char *t;
if (!current) if (!current) {
return 0; return 0;
}
for (t = current; t; t = t->alt_char) { for (t = current; t; t = t->alt_char) {
if (!strcmp(pat, t->x)) /* uh, we may want to sort exploded [] contents to make matching easy */ if (!strcmp(pat, t->x)) { /* uh, we may want to sort exploded [] contents to make matching easy */
return t; return t;
} }
}
return 0; return 0;
} }
@ -1819,8 +1826,9 @@ static struct match_char *add_pattern_node(struct ast_context *con, struct match
{ {
struct match_char *m; struct match_char *m;
if (!(m = ast_calloc(1, sizeof(*m)))) if (!(m = ast_calloc(1, sizeof(*m)))) {
return NULL; return NULL;
}
if (!(m->x = ast_strdup(pattern))) { if (!(m->x = ast_strdup(pattern))) {
ast_free(m); ast_free(m);
@ -1951,7 +1959,7 @@ static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, str
m2 = 0; m2 = 0;
if (already && (m2 = already_in_tree(m1,buf)) && m2->next_char) { if (already && (m2 = already_in_tree(m1,buf)) && m2->next_char) {
if (!(*(s1 + 1))) { /* if this is the end of the pattern, but not the end of the tree, then mark this node with the exten... if (!(*(s1 + 1))) { /* if this is the end of the pattern, but not the end of the tree, then mark this node with the exten...
a shorter pattern might win if the longer one doesn't match */ * a shorter pattern might win if the longer one doesn't match */
m2->exten = e1; m2->exten = e1;
m2->deleted = 0; m2->deleted = 0;
} }
@ -1959,12 +1967,14 @@ static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, str
m0 = &m2->next_char; /* m0 points to the ptr that points to m1 */ m0 = &m2->next_char; /* m0 points to the ptr that points to m1 */
} else { /* not already OR not m2 OR nor m2->next_char */ } else { /* not already OR not m2 OR nor m2->next_char */
if (m2) { if (m2) {
if (findonly) if (findonly) {
return m2; return m2;
}
m1 = m2; /* while m0 stays the same */ m1 = m2; /* while m0 stays the same */
} else { } else {
if (findonly) if (findonly) {
return m1; return m1;
}
m1 = add_pattern_node(con, m1, buf, pattern, already,specif, m0); /* m1 is the node just added */ m1 = add_pattern_node(con, m1, buf, pattern, already,specif, m0); /* m1 is the node just added */
m0 = &m1->next_char; m0 = &m1->next_char;
} }
@ -1995,11 +2005,12 @@ static void create_match_char_tree(struct ast_context *con)
#endif #endif
t1 = ast_hashtab_start_traversal(con->root_table); t1 = ast_hashtab_start_traversal(con->root_table);
while ((e1 = ast_hashtab_next(t1))) { while ((e1 = ast_hashtab_next(t1))) {
if (e1->exten) if (e1->exten) {
add_exten_to_pattern_tree(con, e1, 0); add_exten_to_pattern_tree(con, e1, 0);
else } else {
ast_log(LOG_ERROR, "Attempt to create extension with no extension name.\n"); ast_log(LOG_ERROR, "Attempt to create extension with no extension name.\n");
} }
}
ast_hashtab_end_traversal(t1); ast_hashtab_end_traversal(t1);
} }
@ -2016,8 +2027,9 @@ static void destroy_pattern_tree(struct match_char *pattern_tree) /* pattern tre
pattern_tree->next_char = 0; pattern_tree->next_char = 0;
} }
pattern_tree->exten = 0; /* never hurts to make sure there's no pointers laying around */ pattern_tree->exten = 0; /* never hurts to make sure there's no pointers laying around */
if (pattern_tree->x) if (pattern_tree->x) {
free(pattern_tree->x); free(pattern_tree->x);
}
free(pattern_tree); free(pattern_tree);
} }
@ -2315,7 +2327,6 @@ static int _extension_match_core(const char *pattern, const char *data, enum ext
#endif #endif
return 0; return 0;
} }
} }
data++; data++;
pattern++; pattern++;
@ -2357,8 +2368,9 @@ static int extension_match_core(const char *pattern, const char *data, enum ext_
{ {
int i; int i;
static int prof_id = -2; /* marker for 'unallocated' id */ static int prof_id = -2; /* marker for 'unallocated' id */
if (prof_id == -2) if (prof_id == -2) {
prof_id = ast_add_profile("ext_match", 0); prof_id = ast_add_profile("ext_match", 0);
}
ast_mark(prof_id, 1); ast_mark(prof_id, 1);
i = _extension_match_core(pattern, data, mode); i = _extension_match_core(pattern, data, mode);
ast_mark(prof_id, 0); ast_mark(prof_id, 0);
@ -2405,10 +2417,11 @@ struct ast_context *ast_context_find(const char *name)
tmp = ast_hashtab_lookup(contexts_table,&item); tmp = ast_hashtab_lookup(contexts_table,&item);
} else { } else {
while ( (tmp = ast_walk_contexts(tmp)) ) { while ( (tmp = ast_walk_contexts(tmp)) ) {
if (!name || !strcasecmp(name, tmp->name)) if (!name || !strcasecmp(name, tmp->name)) {
break; break;
} }
} }
}
ast_unlock_contexts(); ast_unlock_contexts();
return tmp; return tmp;
} }
@ -2424,8 +2437,9 @@ static int matchcid(const char *cidpattern, const char *callerid)
/* If the Caller*ID pattern is empty, then we're matching NO Caller*ID, so /* If the Caller*ID pattern is empty, then we're matching NO Caller*ID, so
failing to get a number should count as a match, otherwise not */ failing to get a number should count as a match, otherwise not */
if (ast_strlen_zero(callerid)) if (ast_strlen_zero(callerid)) {
return ast_strlen_zero(cidpattern) ? 1 : 0; return ast_strlen_zero(cidpattern) ? 1 : 0;
}
return ast_extension_match(cidpattern, callerid); return ast_extension_match(cidpattern, callerid);
} }
@ -2467,9 +2481,9 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
return NULL; return NULL;
} }
if (bypass) /* bypass means we only look there */ if (bypass) { /* bypass means we only look there */
tmp = bypass; tmp = bypass;
else { /* look in contexts */ } else { /* look in contexts */
struct fake_context item; struct fake_context item;
ast_copy_string(item.name, context, sizeof(item.name)); ast_copy_string(item.name, context, sizeof(item.name));
@ -2478,13 +2492,14 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
#ifdef NOTNOW #ifdef NOTNOW
tmp = NULL; tmp = NULL;
while ((tmp = ast_walk_contexts(tmp)) ) { while ((tmp = ast_walk_contexts(tmp)) ) {
if (!strcmp(tmp->name, context)) if (!strcmp(tmp->name, context)) {
break; break;
} }
}
#endif #endif
if (!tmp) if (!tmp) {
return NULL; return NULL;
}
} }
if (q->status < STATUS_NO_EXTENSION) if (q->status < STATUS_NO_EXTENSION)
@ -2496,8 +2511,7 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
score.total_specificity = 0; score.total_specificity = 0;
score.exten = 0; score.exten = 0;
score.total_length = 0; score.total_length = 0;
if (!tmp->pattern_tree && tmp->root_table) if (!tmp->pattern_tree && tmp->root_table) {
{
create_match_char_tree(tmp); create_match_char_tree(tmp);
#ifdef NEED_DEBUG #ifdef NEED_DEBUG
ast_log(LOG_DEBUG, "Tree Created in context %s:\n", context); ast_log(LOG_DEBUG, "Tree Created in context %s:\n", context);
@ -2686,7 +2700,6 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
} }
} }
/* Check alternative switches */ /* Check alternative switches */
AST_LIST_TRAVERSE(&tmp->alts, sw, list) { AST_LIST_TRAVERSE(&tmp->alts, sw, list) {
struct ast_switch *asw = pbx_findswitch(sw->name); struct ast_switch *asw = pbx_findswitch(sw->name);
@ -2697,8 +2710,8 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name); ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name);
continue; continue;
} }
/* Substitute variables now */
/* Substitute variables now */
if (sw->eval) { if (sw->eval) {
if (!(tmpdata = ast_str_thread_get(&switch_data, 512))) { if (!(tmpdata = ast_str_thread_get(&switch_data, 512))) {
ast_log(LOG_WARNING, "Can't evaluate switch?!"); ast_log(LOG_WARNING, "Can't evaluate switch?!");
@ -3179,8 +3192,9 @@ int ast_custom_function_unregister(struct ast_custom_function *acf)
{ {
struct ast_custom_function *cur; struct ast_custom_function *cur;
if (!acf) if (!acf) {
return -1; return -1;
}
AST_RWLIST_WRLOCK(&acf_root); AST_RWLIST_WRLOCK(&acf_root);
if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist))) { if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist))) {
@ -3300,16 +3314,17 @@ static char *func_args(char *function)
{ {
char *args = strchr(function, '('); char *args = strchr(function, '(');
if (!args) if (!args) {
ast_log(LOG_WARNING, "Function doesn't contain parentheses. Assuming null argument.\n"); ast_log(LOG_WARNING, "Function doesn't contain parentheses. Assuming null argument.\n");
else { } else {
char *p; char *p;
*args++ = '\0'; *args++ = '\0';
if ((p = strrchr(args, ')')) ) if ((p = strrchr(args, ')'))) {
*p = '\0'; *p = '\0';
else } else {
ast_log(LOG_WARNING, "Can't find trailing parenthesis?\n"); ast_log(LOG_WARNING, "Can't find trailing parenthesis?\n");
} }
}
return args; return args;
} }
@ -3785,9 +3800,9 @@ int ast_extension_state(struct ast_channel *c, const char *context, const char *
{ {
struct ast_exten *e; struct ast_exten *e;
e = ast_hint_extension(c, context, exten); /* Do we have a hint for this extension ? */ if (!(e = ast_hint_extension(c, context, exten))) { /* Do we have a hint for this extension ? */
if (!e)
return -1; /* No hint, return -1 */ return -1; /* No hint, return -1 */
}
return ast_extension_state2(e); /* Check all devices in the hint */ return ast_extension_state2(e); /* Check all devices in the hint */
} }
@ -3809,17 +3824,20 @@ static int handle_statechange(void *datap)
ast_copy_string(buf, ast_get_extension_app(hint->exten), sizeof(buf)); ast_copy_string(buf, ast_get_extension_app(hint->exten), sizeof(buf));
while ( (cur = strsep(&parse, "&")) ) { while ( (cur = strsep(&parse, "&")) ) {
if (!strcasecmp(cur, sc->dev)) if (!strcasecmp(cur, sc->dev)) {
break; break;
} }
if (!cur) }
if (!cur) {
continue; continue;
}
/* Get device state for this hint */ /* Get device state for this hint */
state = ast_extension_state2(hint->exten); state = ast_extension_state2(hint->exten);
if ((state == -1) || (state == hint->laststate)) if ((state == -1) || (state == hint->laststate)) {
continue; continue;
}
/* Device state changed since last check - notify the watchers */ /* Device state changed since last check - notify the watchers */
@ -4805,7 +4823,6 @@ int ast_context_remove_extension_callerid2(struct ast_context *con, const char *
if (!exten2) if (!exten2)
ast_log(LOG_ERROR,"Trying to delete the exten %s from context %s, but could not remove from the root_table\n", extension, con->name); ast_log(LOG_ERROR,"Trying to delete the exten %s from context %s, but could not remove from the root_table\n", extension, con->name);
if (con->pattern_tree) { if (con->pattern_tree) {
struct match_char *x = add_exten_to_pattern_tree(con, exten, 1); struct match_char *x = add_exten_to_pattern_tree(con, exten, 1);
if (x->exten) { /* this test for safety purposes */ if (x->exten) { /* this test for safety purposes */
@ -4959,8 +4976,9 @@ int ast_context_lockmacro(const char *context)
ast_unlock_contexts(); ast_unlock_contexts();
/* if we found context, lock macrolock */ /* if we found context, lock macrolock */
if (ret == 0) if (ret == 0) {
ret = ast_mutex_lock(&c->macrolock); ret = ast_mutex_lock(&c->macrolock);
}
return ret; return ret;
} }
@ -4996,8 +5014,9 @@ int ast_context_unlockmacro(const char *context)
ast_unlock_contexts(); ast_unlock_contexts();
/* if we found context, unlock macrolock */ /* if we found context, unlock macrolock */
if (ret == 0) if (ret == 0) {
ret = ast_mutex_unlock(&c->macrolock); ret = ast_mutex_unlock(&c->macrolock);
}
return ret; return ret;
} }

Loading…
Cancel
Save