96 static const char config[] =
"extensions.conf";
136 e->
command =
"dialplan remove context";
138 "Usage: dialplan remove context <context>\n" 139 " Removes all extensions from a specified context.\n";
150 ast_cli(a->
fd,
"There is no such context as '%s'\n", a->
argv[3]);
164 e->
command =
"dialplan remove include";
166 "Usage: dialplan remove include <context> from <context>\n" 167 " Remove an included context from another context.\n";
173 if (a->
argc != 6 || strcmp(a->
argv[4],
"from"))
177 ast_cli(a->
fd,
"We are not including '%s' into '%s' now\n",
182 ast_cli(a->
fd,
"Failed to remove '%s' include from '%s' context\n",
239 for (;n && *p; p++) {
240 if (isblank(*p) && !in_blank) {
243 }
else if ( in_blank) {
253 return (len == 0 || !strncmp(s, word, len));
259 static int split_ec(
const char *src,
char **
ext,
char **
const ctx,
char **
const cid)
273 if (strchr(c,
'@')) {
278 if (cid && (i = strchr(e,
'/'))) {
312 int already_served = 0;
325 if (!already_served && ++which > a->
n) {
335 }
else if (a->
pos == 4) {
367 }
else if (a->
pos == 5) {
371 char *
context, *dupline, *from;
382 from =
strsep(&dupline,
" ");
383 if (!from || strcmp(from,
"from")) {
417 int removing_priority = 0;
423 e->
command =
"dialplan remove extension";
425 "Usage: dialplan remove extension exten[/cid]@context [priority]\n" 426 " Remove an extension from a given context. If a priority\n" 427 " is given, only that specific priority from the given extension\n" 428 " will be removed.\n";
441 const char *
c = a->
argv[4];
447 if (!strcmp(
"hint", c))
450 while (*c && isdigit(*c))
456 removing_priority = atoi(a->
argv[4]);
459 if (removing_priority == 0) {
460 ast_cli(a->
fd,
"If you want to remove whole extension, please " \
461 "omit priority argument\n");
472 if ((!strlen(exten)) || (!(strlen(context)))) {
473 ast_cli(a->
fd,
"Missing extension or context name in third argument '%s'\n",
481 cid ? cid : (removing_priority ?
"" :
NULL), cid ? 1 : 0,
registrar)) {
482 if (!removing_priority)
483 ast_cli(a->
fd,
"Whole extension %s@%s removed\n",
486 ast_cli(a->
fd,
"Extension %s@%s with priority %d removed\n",
487 exten, context, removing_priority);
492 ast_cli(a->
fd,
"Failed to remove extension %s/%s@%s\n", exten, cid, context);
494 ast_cli(a->
fd,
"Failed to remove extension %s@%s\n", exten, context);
510 char *cidmatch =
NULL;
514 "for DialplanExtensionRemove");
520 if (strchr(exten,
'/')) {
527 }
else if (!strcmp(
"hint", priority)) {
529 }
else if ((sscanf(priority,
"%30d", &ipriority) != 1) || ipriority <= 0) {
539 astman_send_ack(s, m,
"Removed the requested priority from the extension");
567 lc = strlen(context);
568 lcid = cid ? strlen(cid) : -1;
582 if ( !strchr(a->
word,
'/') ||
587 if (++which > a->
n) {
611 }
else if (a->
pos == 4) {
616 int i =
split_ec(s, &exten, &context, &cid);
620 if ( (p = strchr(exten,
' ')) )
622 if ( (p = strchr(context,
' ')) )
625 lc = strlen(context);
626 len = strlen(a->
word);
627 if (le == 0 || lc == 0)
676 const char *into_context;
680 e->
command =
"dialplan add include";
682 "Usage: dialplan add include <context> into <context>\n" 683 " Include a context in another context.\n";
693 if (strcmp(a->
argv[4],
"into"))
696 into_context = a->
argv[5];
699 ast_cli(a->
fd,
"Context '%s' did not exist prior to add include - the context will be created.\n", into_context);
703 ast_cli(a->
fd,
"ast_context_find_or_create() failed\n");
704 ast_cli(a->
fd,
"Failed to include '%s' in '%s' context\n",a->
argv[3], a->
argv[5]);
711 ast_cli(a->
fd,
"Out of memory for context addition\n");
715 ast_cli(a->
fd,
"Failed to lock context(s) list, please try again later\n");
719 ast_cli(a->
fd,
"Context '%s' already included in '%s' context\n",
725 ast_cli(a->
fd,
"There is no existence of context '%s'\n",
730 ast_cli(a->
fd,
"Failed to include '%s' in '%s' context\n",
738 ast_cli(a->
fd,
"Context '%s' included in '%s' context\n",
761 }
else if (a->
pos == 4) {
764 }
else if (a->
pos == 5) {
765 char *
context, *dupline, *into;
775 into =
strsep(&dupline,
" ");
777 if (!strlen(context) || strcmp(into,
"into")) {
818 const char *base, *slash;
824 "Usage: dialplan save [/path/to/extension/file]\n" 825 " Save dialplan created by pbx_config module.\n" 827 "Example: dialplan save (/etc/asterisk/extensions.conf)\n" 828 " dialplan save /home/markster (/home/markster/extensions.conf)\n";
836 "I can't save dialplan now, see '%s' example file.\n",
846 "Failed to lock dialplan saving (another proccess saving?)\n");
854 if (!strstr(a->
argv[2],
".conf")) {
856 slash = (*(a->
argv[2] + strlen(a->
argv[2]) -1) ==
'/') ?
"/" :
"";
865 snprintf(filename,
sizeof(filename),
"%s%s%s", base, slash,
config);
869 ast_cli(a->
fd,
"Failed to load extensions.conf\n");
876 ast_cli(a->
fd,
"Failed to lock contexts list\n");
883 if (!(output = fopen(filename,
"wt"))) {
884 ast_cli(a->
fd,
"Failed to create file '%s'\n",
896 fprintf(output,
"[general]\nstatic=%s\nwriteprotect=%s\nautofallthrough=%s\nclearglobalvars=%s\n%sextenpatternmatchnew=%s\n\n",
905 fprintf(output,
"[globals]\n");
907 int escaped_len = 2 * strlen(v->
value) + 1;
908 char escaped[escaped_len];
911 fprintf(output,
"%s => %s\n", v->
name, escaped);
914 fprintf(output,
"\n");
919 #define PUT_CTX_HDR do { \ 920 if (!context_header_written) { \ 921 fprintf(output, "[%s]\n", ast_get_context_name(c)); \ 922 context_header_written = 1; \ 928 int context_header_written = 0;
941 context_header_written = 1;
954 if (last_written_e !=
NULL &&
957 fprintf(output,
"\n");
963 fprintf(output,
"exten => %s,hint,%s\n",
967 const char *sep, *cid;
969 char label[128] =
"";
972 int escaped_len = (!
ast_strlen_zero(appdata)) ? 2 * strlen(appdata) + 1 : 1;
973 char escaped[escaped_len];
982 if (el && (snprintf(label,
sizeof(label),
"(%s)", el) != (strlen(el) + 2))) {
992 fprintf(output,
"exten => %s%s%s,%d%s,%s(%s)\n",
1002 fprintf(output,
"\n");
1014 fprintf(output,
"\n");
1024 fprintf(output,
"switch => %s/%s\n",
1029 fprintf(output,
"\n");
1039 fprintf(output,
"ignorepat => %s\n",
1051 ast_cli(a->
fd,
"Saved dialplan is incomplete\n");
1055 ast_cli(a->
fd,
"Dialplan successfully saved into '%s'\n",
1066 char *
exten, *prior;
1070 const char *into_context;
1074 e->
command =
"dialplan add extension";
1076 "Usage: dialplan add extension <exten>,<priority>,<app> into <context> [replace]\n" 1078 " app can be either:\n" 1080 " app-name(app-data)\n" 1081 " app-name,<app-data>\n" 1083 " This command will add the new extension into <context>. If\n" 1084 " an extension with the same priority already exists and the\n" 1085 " 'replace' option is given we will replace the extension.\n" 1087 "Example: dialplan add extension 6123,1,Dial,IAX/216.207.245.56/6123 into local\n" 1088 " Now, you can dial 6123 and talk to Markster :)\n";
1097 if (strcmp(a->
argv[4],
"into"))
1100 if (strcmp(a->
argv[6],
"replace"))
1104 exten =
strsep(&whole_exten,
",");
1105 if (strchr(exten,
'/')) {
1111 prior =
strsep(&whole_exten,
",");
1113 if (!strcmp(prior,
"hint")) {
1116 if (sscanf(prior,
"%30d", &iprior) != 1) {
1117 ast_cli(a->
fd,
"'%s' is not a valid priority\n", prior);
1124 if ((start = strchr(app,
'(')) && (end = strrchr(app,
')'))) {
1125 *start = *end =
'\0';
1126 app_data = start + 1;
1128 app_data = strchr(app,
',');
1137 if (!exten || !prior || !app) {
1144 into_context = a->
argv[5];
1147 ast_cli(a->
fd,
"Context '%s' did not exist prior to add extension - the context will be created.\n", into_context);
1151 ast_cli(a->
fd,
"Failed to add '%s,%s,%s(%s)' extension into '%s' context\n",
1152 exten, prior, app, app_data, into_context);
1164 ast_cli(a->
fd,
"Failed to lock context(s) list, please try again later\n");
1168 ast_cli(a->
fd,
"No existence of '%s' context\n", into_context);
1172 ast_cli(a->
fd,
"Extension %s@%s with priority %s already exists\n",
1173 exten, into_context, prior);
1177 ast_cli(a->
fd,
"Failed to add '%s,%s,%s(%s)' extension into '%s' context\n",
1178 exten, prior, app, app_data, into_context);
1185 ast_cli(a->
fd,
"Extension %s@%s (%s) replace by '%s,%s,%s(%s)'\n",
1186 exten, into_context, prior, exten, prior, app, app_data);
1188 ast_cli(a->
fd,
"Extension '%s,%s,%s(%s)' added into '%s' context\n",
1189 exten, prior, app, app_data, into_context);
1205 char *cidmatch =
NULL;
1211 "Application must be defined for DialplanExtensionAdd.");
1216 if (!strcmp(priority,
"hint")) {
1218 }
else if ((sscanf(priority,
"%30d", &ipriority) != 1) || (ipriority < 0)) {
1226 if (strchr(exten,
'/')) {
1239 "for the extension.");
1261 astman_send_error(s, m,
"That extension and priority already exist at that context");
1312 }
else if (a->
pos == 5) {
1329 }
else if (a->
pos == 6) {
1342 e->
command =
"dialplan add ignorepat";
1344 "Usage: dialplan add ignorepat <pattern> into <context>\n" 1345 " This command adds a new ignore pattern into context <context>\n" 1347 "Example: dialplan add ignorepat _3XX into local\n";
1356 if (strcmp(a->
argv[4],
"into"))
1366 ast_cli(a->
fd,
"There is no existence of '%s' context\n", a->
argv[5]);
1370 ast_cli(a->
fd,
"Ignore pattern '%s' already included in '%s' context\n",
1375 ast_cli(a->
fd,
"Failed to lock context(s) list, please, try again later\n");
1379 ast_cli(a->
fd,
"Failed to add ingore pattern '%s' into '%s' context\n",
1386 ast_cli(a->
fd,
"Ignore pattern '%s' added into '%s' context\n",
1396 else if (a->
pos == 5) {
1399 char *dupline, *ignorepat =
NULL;
1413 ignorepat =
strsep(&dupline,
" ");
1427 if (!found && ++which > a->
n)
1443 e->
command =
"dialplan remove ignorepat";
1445 "Usage: dialplan remove ignorepat <pattern> from <context>\n" 1446 " This command removes an ignore pattern from context <context>\n" 1448 "Example: dialplan remove ignorepat _3XX from local\n";
1457 if (strcmp(a->
argv[4],
"from"))
1463 ast_cli(a->
fd,
"Failed to lock context(s) list, please try again later\n");
1467 ast_cli(a->
fd,
"There is no existence of '%s' context\n", a->
argv[5]);
1471 ast_cli(a->
fd,
"There is no existence of '%s' ignore pattern in '%s' context\n",
1476 ast_cli(a->
fd,
"Failed to remove ignore pattern '%s' from '%s' context\n",
1483 ast_cli(a->
fd,
"Ignore pattern '%s' removed from '%s' context\n",
1525 }
else if (a->
pos == 4) {
1527 }
else if (a->
pos == 5) {
1528 char *dupline, *duplinet, *ignorepat;
1540 ignorepat =
strsep(&duplinet,
" ");
1580 e->
command =
"dialplan reload";
1582 "Usage: dialplan reload\n" 1583 " Reload extensions.conf without reloading any other\n" 1584 " modules. This command does not delete global variables\n" 1585 " unless clearglobalvars is set to yes in extensions.conf\n";
1619 #define AMI_EXTENSION_ADD "DialplanExtensionAdd" 1620 #define AMI_EXTENSION_REMOVE "DialplanExtensionRemove" 1649 if (!destructible || !*destructible) {
1652 res = *destructible;
1653 for (; **destructible; (*destructible)++) {
1654 if (**destructible ==
'[' && !strchr(delim,
'[')) {
1656 }
else if (**destructible ==
']' && !strchr(delim,
']')) {
1660 }
else if (**destructible ==
'\\' && !strchr(delim,
'\\')) {
1662 }
else if (strchr(delim, **destructible) && !square) {
1663 **destructible =
'\0';
1668 if (**destructible ==
'\0') {
1669 *destructible =
NULL;
1680 char realvalue[256];
1682 char realvalue[8192];
1689 const char *newpm, *ovsw;
1691 char lastextension[256];
1721 if (strcasecmp(cxt,
"globals")) {
1735 if (!strcasecmp(cxt,
"general") || !strcasecmp(cxt,
"globals")) {
1743 lastextension[0] =
'\0';
1748 char realext[256] =
"";
1749 char *stringp, *
ext;
1755 if (!strncasecmp(v->
name,
"same", 4)) {
1758 "No previous pattern in the first entry of context '%s' to match '%s' at line %d of %s!\n",
1764 goto process_extension;
1766 }
else if (!strcasecmp(v->
name,
"exten")) {
1769 char *pri, *appl, *data, *cidmatch;
1780 if ((cidmatch = strchr(realext,
'/'))) {
1785 if ((label = strchr(pri,
'('))) {
1787 if ((end = strchr(label,
')'))) {
1791 "Label missing trailing ')' at line %d of %s\n",
1797 if ((plus = strchr(pri,
'+'))) {
1800 if (!strcmp(pri,
"hint")) {
1802 }
else if (!strcmp(pri,
"next") || !strcmp(pri,
"n")) {
1807 "Can't use 'next' priority on the first entry at line %d of %s!\n",
1812 }
else if (!strcmp(pri,
"same") || !strcmp(pri,
"s")) {
1817 "Can't use 'same' priority on the first entry at line %d of %s!\n",
1822 }
else if (sscanf(pri,
"%30d", &ipri) != 1 &&
1825 "Invalid priority/label '%s' at line %d of %s\n",
1830 }
else if (ipri < 1) {
1836 appl =
S_OR(stringp,
"");
1838 if (!strchr(appl,
'(')) {
1849 appl =
strsep(&stringp,
"(");
1852 if (strstr(appl,
"${") || strstr(appl,
"$[")){
1854 strcpy(appl, orig_appl);
1859 data =
S_OR(stringp,
"");
1860 if ((end = strrchr(data,
')'))) {
1864 "No closing parenthesis found? '%s(%s' at line %d of %s\n",
1865 appl, data, v->
lineno, vfile);
1873 const char *registrar_file;
1880 "The use of '%s' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X%c' instead at line %d of %s\n",
1881 realext, realext[1], v->
lineno, vfile);
1884 registrar_file = strrchr(vfile,
'/');
1885 if (!registrar_file) {
1886 registrar_file = vfile;
1890 if (
ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl,
ast_strdup(data),
ast_free_ptr,
registrar, registrar_file, v->
lineno)) {
1892 "Unable to register extension at line %d of %s\n",
1897 }
else if (!strcasecmp(v->
name,
"include")) {
1911 "Context '%s' already included in '%s' context on include at line %d of %s\n",
1918 "There is no existence of context '%s' included at line %d of %s\n",
1924 "Failed to include '%s' in '%s' context at line %d of %s\n",
1929 }
else if (!strcasecmp(v->
name,
"ignorepat")) {
1933 "Unable to include ignorepat '%s' in context '%s' at line %d of %s\n",
1936 }
else if (!strcasecmp(v->
name,
"switch") || !strcasecmp(v->
name,
"lswitch") || !strcasecmp(v->
name,
"eswitch")) {
1938 stringp = realvalue;
1940 if (!strcasecmp(v->
name,
"switch")) {
1945 appl =
strsep(&stringp,
"/");
1946 data =
S_OR(stringp,
"");
1949 "Unable to include switch '%s' in context '%s' at line %d of %s\n",
1952 }
else if (!strcasecmp(v->
name,
"autohints")) {
1956 "==!!== Unknown directive: %s at line %d of %s -- IGNORING!!!\n",
1967 int len = strlen(iface);
1968 if (strlen(add) + len < maxlen - 2) {
1969 if (strlen(iface)) {
1971 strcpy(iface + len + 1, add);
1981 const char *dahdichan;
1982 const char *hasexten, *altexts;
1985 char dahdicopy[256];
1986 char *
ext, altcopy[256];
1989 int start, finish, x;
1998 if (!strcasecmp(cat,
"general"))
2002 snprintf(tmp,
sizeof(tmp),
"SIP/%s", cat);
2006 snprintf(tmp,
sizeof(tmp),
"IAX2/%s", cat);
2010 snprintf(tmp,
sizeof(tmp),
"H323/%s", cat);
2014 if (hasexten && !
ast_true(hasexten))
2025 if (sscanf(chan,
"%30d-%30d", &start, &finish) == 2) {
2027 }
else if (sscanf(chan,
"%30d", &start)) {
2031 start = 0; finish = 0;
2033 if (finish < start) {
2038 for (x = start; x <= finish; x++) {
2039 snprintf(tmp,
sizeof(tmp),
"DAHDI/%d", x);
2057 ast_add_extension2(con, 0, cat, -1,
NULL,
NULL, iface,
NULL,
NULL,
registrar,
NULL, 0);
2062 snprintf(tmp,
sizeof(tmp),
"stdexten,%s,${HINT}", cat);
2063 ast_add_extension2(con, 0, cat, 1,
NULL,
NULL,
"Macro",
ast_strdup(tmp),
ast_free_ptr,
registrar,
NULL, 0);
2065 snprintf(tmp,
sizeof(tmp),
"%s,stdexten(${HINT})", cat);
2066 ast_add_extension2(con, 0, cat, 1,
NULL,
NULL,
"Gosub",
ast_strdup(tmp),
ast_free_ptr,
registrar,
NULL, 0);
2069 ast_add_extension2(con, 0, cat, 1,
NULL,
NULL,
"Dial",
ast_strdup(
"${HINT}"),
ast_free_ptr,
registrar,
NULL, 0);
2073 snprintf(tmp,
sizeof(tmp),
"%s,1", cat);
2078 ast_add_extension2(con, 0, ext, 1,
NULL,
NULL,
"Goto",
ast_strdup(tmp),
ast_free_ptr,
registrar,
NULL, 0);
2112 local_contexts =
NULL;
ast_include: include= support in extensions.conf
struct ast_variable * next
static int clearglobalvars_config
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
static char * complete_dialplan_remove_context(struct ast_cli_args *)
int ast_unlock_context(struct ast_context *con)
const char * ast_get_switch_name(const struct ast_sw *sw)
const char * ast_get_switch_registrar(const struct ast_sw *sw)
static char exten[AST_MAX_EXTENSION]
static int pbx_load_config(const char *config_file)
static char * handle_cli_dialplan_remove_include(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_CLI_DEFINE(fn, txt,...)
static int autofallthrough_config
int ast_get_extension_priority(struct ast_exten *exten)
static int manager_dialplan_extension_remove(struct mansession *s, const struct message *m)
Asterisk main include file. File version handling, generic pbx functions.
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
static const char config_file[]
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
void pbx_builtin_clear_globals(void)
const char * ast_get_extension_registrar(struct ast_exten *e)
const char * ast_get_context_name(struct ast_context *con)
static char * handle_cli_dialplan_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
static char * complete_dialplan_add_include(struct ast_cli_args *)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
static char * complete_dialplan_remove_include(struct ast_cli_args *)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static int write_protect_config
static int extenpatternmatchnew_config
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
descriptor for a cli entry.
#define AMI_EXTENSION_REMOVE
int ast_context_switches_count(const struct ast_context *con)
const char * ast_get_extension_app(struct ast_exten *e)
#define CONFIG_STATUS_FILEINVALID
Structure for variables, used for configurations and for channel variables.
int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar)
Adds a switch (first param is a ast_context)
static char * handle_cli_dialplan_remove_context(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_context * ast_walk_contexts(struct ast_context *con)
static char * complete_dialplan_add_extension(struct ast_cli_args *)
static char userscontext[AST_MAX_EXTENSION]
void * ast_get_extension_app_data(struct ast_exten *e)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int ast_rdlock_contexts(void)
Read locks the context list.
const char * ast_get_extension_label(struct ast_exten *e)
const char * ast_get_include_registrar(const struct ast_include *i)
#define ast_mutex_lock(a)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
int ast_wrlock_contexts(void)
Write locks the context list.
char * ast_escape_semicolons(const char *string, char *outbuf, int buflen)
Escape semicolons found in a string.
#define ast_strdup(str)
A wrapper for strdup()
static int load_module(void)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
const char * ast_get_context_registrar(struct ast_context *c)
void ast_cli(int fd, const char *fmt,...)
static int pbx_load_module(void)
static int partial_match(const char *s, const char *word, int len)
match the first 'len' chars of word. len==0 always succeeds
void ast_free_ptr(void *ptr)
free() wrapper
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
int ast_hashtab_resize_java(struct ast_hashtab *tab)
Determines if a table resize should occur using the Java algorithm (if the table load factor is 75% o...
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
#define ast_cli_register(e)
Registers a command or an array of commands.
static char * handle_cli_dialplan_add_extension(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
ADD EXTENSION command stuff.
static int lookup_ci(struct ast_context *c, const char *name)
return true if 'name' is included by context c
int ast_context_add_include2(struct ast_context *con, const char *include, const char *registrar)
Add a context include.
Configuration File Parser.
#define ast_opt_dont_warn
static void pbx_load_users(void)
const struct ast_sw * ast_context_switches_get(const struct ast_context *con, int idx)
#define EVENT_FLAG_SYSTEM
struct ast_context * ast_context_find(const char *name)
Find a context.
#define ast_config_load(filename, flags)
Load a config file.
ast_sw: Switch statement in extensions.conf
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Add an ignorepat.
static char * handle_cli_dialplan_save(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
'save dialplan' CLI command implementation functions ...
#define AMI_EXTENSION_ADD
#define AST_MAX_EXTENSION
int pbx_set_extenpatternmatchnew(int newval)
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
structure to hold extensions
void ast_config_destroy(struct ast_config *config)
Destroys a config.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
#define ast_strdupa(s)
duplicate a string in memory from the stack
static const char registrar[]
int pbx_set_autofallthrough(int newval)
const char * ast_get_extension_cidmatch(struct ast_exten *e)
static char * complete_dialplan_remove_ignorepat(struct ast_cli_args *)
Core PBX routines and definitions.
#define ast_opt_stdexten_macro
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
static char * overrideswitch_config
static char * handle_cli_dialplan_remove_extension(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
int ast_context_includes_count(const struct ast_context *con)
static char * handle_cli_dialplan_add_ignorepat(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int lookup_c_ip(struct ast_context *c, const char *name)
return true if 'name' is in the ignorepats for context c
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static struct ast_cli_entry cli_dialplan_save
const char * ast_config_AST_CONFIG_DIR
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
Merge the temporary contexts into a global contexts list and delete from the global list the ones tha...
ast_ignorepat: Ignore patterns in dial plan
int ast_unlock_contexts(void)
Unlocks contexts.
static int split_ec(const char *src, char **ext, char **const ctx, char **const cid)
split extension@context in two parts, return -1 on error. The return string is malloc'ed and pointed ...
static ast_mutex_t reload_lock
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int unload_module(void)
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar)
static char * pbx_strsep(char **destructible, const char *delim)
static void append_interface(char *iface, int maxlen, char *add)
const char * ast_get_extension_name(struct ast_exten *exten)
static struct ast_hashtab * local_table
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority)
unsigned int ast_hashtab_hash_contexts(const void *obj)
const char * ast_get_switch_data(const struct ast_sw *sw)
static ast_mutex_t save_dialplan_lock
Module has failed to load, may be in an inconsistent state.
static const char config[]
static struct ast_cli_entry cli_pbx_config[]
Structure used to handle boolean flags.
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
const char * ast_get_include_name(const struct ast_include *include)
static char * complete_dialplan_add_ignorepat(struct ast_cli_args *)
char * strsep(char **str, const char *delims)
int ast_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar, const char *registrar_file, int registrar_line)
Add an extension to an extension context, this time with an ast_context *.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
Standard Command Line Interface.
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static struct ast_context * local_contexts
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static char * overrideswitch
void pbx_set_overrideswitch(const char *newval)
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
int ast_context_ignorepats_count(const struct ast_context *con)
static char * handle_cli_dialplan_add_include(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking)
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
static char context[AST_MAX_CONTEXT]
static const char * skip_words(const char *p, int n)
moves to the n-th word in the string, or empty string if none
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
void ast_context_set_autohints(struct ast_context *con, int enabled)
Enable or disable autohints support on a context.
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
static char * handle_cli_dialplan_remove_ignorepat(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_get_extension_matchcid(struct ast_exten *e)
static int manager_dialplan_extension_add(struct mansession *s, const struct message *m)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
ast_context: An extension context - must remain in sync with fake_context
static char * complete_dialplan_remove_extension(struct ast_cli_args *)
const struct ast_include * ast_context_includes_get(const struct ast_context *con, int idx)
#define AST_MUTEX_DEFINE_STATIC(mutex)
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
const struct ast_ignorepat * ast_context_ignorepats_get(const struct ast_context *con, int idx)
#define ast_mutex_unlock(a)
void ast_hashtab_destroy(struct ast_hashtab *tab, void(*objdestroyfunc)(void *obj))
This func will free the hash table and all its memory.