return ast_extension_match(cidpattern, callerid);
}
-static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, const char *context, const char *exten, int priority, const char *label, const char *callerid, int action, char *incstack[], int *stacklen, int *status, struct ast_switch **swo, char **data, const char **foundcontext)
+static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
+ struct ast_context *bypass,
+ const char *context, const char *exten, int priority,
+ const char *label, const char *callerid, int action,
+ char *incstack[], int *stacklen, int *status, struct ast_switch **swo,
+ char **data, const char **foundcontext)
{
int x, res;
struct ast_context *tmp;
struct ast_sw *sw;
struct ast_switch *asw;
+ struct ast_exten *earlymatch = NULL;
+
/* Initialize status if appropriate */
if (!*stacklen) {
*status = STATUS_NO_CONTEXT;
if (!strcasecmp(incstack[x], context))
return NULL;
}
- if (bypass)
+ if (bypass) /* bypass means we only look there */
tmp = bypass;
- else
- tmp = contexts;
- for (; tmp; tmp = tmp->next) {
- /* Match context */
- if (bypass || !strcmp(tmp->name, context)) {
- struct ast_exten *earlymatch = NULL;
+ else { /* look in contexts */
+ for (tmp = contexts; tmp; tmp = tmp->next) {
+ if (!strcmp(tmp->name, context))
+ break;
+ }
+ if (!tmp)
+ return NULL;
+ }
+ /* XXX fix indentation */
if (*status < STATUS_NO_EXTENSION)
*status = STATUS_NO_EXTENSION;
return NULL;
}
}
- break;
- }
- }
+
return NULL;
}
ast_copy_string(workspace, value, workspace_len); /* always make a copy */
+ /* Quick check if no need to do anything */
if (offset == 0 && length < 0) /* take the whole string */
return ret;