Asterisk - The Open Source Telephony Project  21.4.1
Macros | Functions | Variables
pbx_config.c File Reference

Populate and remember extensions from static config file. More...

#include "asterisk.h"
#include <ctype.h>
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/cli.h"
#include "asterisk/channel.h"
#include "asterisk/callerid.h"

Go to the source code of this file.

Macros

#define AMI_EXTENSION_ADD   "DialplanExtensionAdd"
 
#define AMI_EXTENSION_REMOVE   "DialplanExtensionRemove"
 
#define PUT_CTX_HDR
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static void append_interface (char *iface, int maxlen, char *add)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static char * complete_dialplan_add_extension (struct ast_cli_args *)
 
static char * complete_dialplan_add_ignorepat (struct ast_cli_args *)
 
static char * complete_dialplan_add_include (struct ast_cli_args *)
 
static char * complete_dialplan_remove_context (struct ast_cli_args *)
 
static char * complete_dialplan_remove_extension (struct ast_cli_args *)
 
static char * complete_dialplan_remove_ignorepat (struct ast_cli_args *)
 
static char * complete_dialplan_remove_include (struct ast_cli_args *)
 
static char * handle_cli_dialplan_add_extension (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 ADD EXTENSION command stuff.
 
static char * handle_cli_dialplan_add_ignorepat (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_add_include (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_remove_context (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_remove_extension (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_remove_ignorepat (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_remove_include (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_dialplan_save (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 'save dialplan' CLI command implementation functions ...
 
static int load_module (void)
 
static int lookup_c_ip (struct ast_context *c, const char *name)
 return true if 'name' is in the ignorepats for context c
 
static int lookup_ci (struct ast_context *c, const char *name)
 return true if 'name' is included by context c
 
static int manager_dialplan_extension_add (struct mansession *s, const struct message *m)
 
static int manager_dialplan_extension_remove (struct mansession *s, const struct message *m)
 
static int partial_match (const char *s, const char *word, int len)
 match the first 'len' chars of word. len==0 always succeeds
 
static int pbx_load_config (const char *config_file)
 
static int pbx_load_module (void)
 
static void pbx_load_users (void)
 
static char * pbx_strsep (char **destructible, const char *delim)
 
static int reload (void)
 
static const char * skip_words (const char *p, int n)
 moves to the n-th word in the string, or empty string if none
 
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 by *ext
 
static void startup_event_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Text Extension Configuration" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static int autofallthrough_config = 1
 
static int clearglobalvars_config = 0
 
static struct ast_cli_entry cli_dialplan_save
 
static struct ast_cli_entry cli_pbx_config []
 
static const char config [] = "extensions.conf"
 
static int extenpatternmatchnew_config = 0
 
static struct stasis_subscriptionfully_booted_subscription
 
static struct ast_contextlocal_contexts = NULL
 
static struct ast_hashtablocal_table = NULL
 
static char * overrideswitch_config = NULL
 
static const char registrar [] = "pbx_config"
 
static ast_mutex_t reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static ast_mutex_t save_dialplan_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static int static_config = 0
 
static char userscontext [AST_MAX_EXTENSION] = "default"
 
static int write_protect_config = 1
 

Detailed Description

Populate and remember extensions from static config file.

Definition in file pbx_config.c.

Function Documentation

static char * complete_dialplan_add_extension ( struct ast_cli_args a)
static

dialplan add extension 6123,1,Dial,IAX/212.71.138.13/6123 into local

Definition at line 1308 of file pbx_config.c.

References ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), and partial_match().

Referenced by handle_cli_dialplan_add_extension().

1309 {
1310  int which = 0;
1311 
1312  if (a->pos == 4) { /* complete 'into' word ... */
1313  return (a->n == 0) ? ast_strdup("into") : NULL;
1314  } else if (a->pos == 5) { /* complete context */
1315  struct ast_context *c = NULL;
1316  int len = strlen(a->word);
1317  char *res = NULL;
1318 
1319  /* try to lock contexts list ... */
1320  if (ast_rdlock_contexts()) {
1321  ast_log(LOG_WARNING, "Failed to lock contexts list\n");
1322  return NULL;
1323  }
1324 
1325  /* walk through all contexts */
1326  while ( !res && (c = ast_walk_contexts(c)) )
1327  if (partial_match(ast_get_context_name(c), a->word, len) && ++which > a->n)
1328  res = ast_strdup(ast_get_context_name(c));
1330  return res;
1331  } else if (a->pos == 6) {
1332  return a->n == 0 ? ast_strdup("replace") : NULL;
1333  }
1334  return NULL;
1335 }
int ast_rdlock_contexts(void)
Read locks the context list.
Definition: pbx.c:8468
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
static int partial_match(const char *s, const char *word, int len)
match the first 'len' chars of word. len==0 always succeeds
Definition: pbx_config.c:253
int ast_unlock_contexts(void)
Unlocks contexts.
Definition: pbx.c:8473
ast_context: An extension context
Definition: pbx.c:284
static char* handle_cli_dialplan_add_ignorepat ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

IGNOREPAT CLI stuff

Definition at line 1340 of file pbx_config.c.

References ast_context_add_ignorepat(), ast_cli_entry::command, ast_context::registrar, and ast_cli_entry::usage.

1341 {
1342  switch (cmd) {
1343  case CLI_INIT:
1344  e->command = "dialplan add ignorepat";
1345  e->usage =
1346  "Usage: dialplan add ignorepat <pattern> into <context>\n"
1347  " This command adds a new ignore pattern into context <context>\n"
1348  "\n"
1349  "Example: dialplan add ignorepat _3XX into local\n";
1350  return NULL;
1351  case CLI_GENERATE:
1352  return complete_dialplan_add_ignorepat(a);
1353  }
1354 
1355  if (a->argc != 6)
1356  return CLI_SHOWUSAGE;
1357 
1358  if (strcmp(a->argv[4], "into"))
1359  return CLI_SHOWUSAGE;
1360 
1361  if (ast_context_add_ignorepat(a->argv[5], a->argv[3], registrar)) {
1362  switch (errno) {
1363  case ENOMEM:
1364  ast_cli(a->fd, "Out of free memory\n");
1365  break;
1366 
1367  case ENOENT:
1368  ast_cli(a->fd, "There is no existence of '%s' context\n", a->argv[5]);
1369  break;
1370 
1371  case EEXIST:
1372  ast_cli(a->fd, "Ignore pattern '%s' already included in '%s' context\n",
1373  a->argv[3], a->argv[5]);
1374  break;
1375 
1376  case EBUSY:
1377  ast_cli(a->fd, "Failed to lock context(s) list, please, try again later\n");
1378  break;
1379 
1380  default:
1381  ast_cli(a->fd, "Failed to add ignore pattern '%s' into '%s' context\n",
1382  a->argv[3], a->argv[5]);
1383  break;
1384  }
1385  return CLI_FAILURE;
1386  }
1387 
1388  ast_cli(a->fd, "Ignore pattern '%s' added into '%s' context\n",
1389  a->argv[3], a->argv[5]);
1390 
1391  return CLI_SUCCESS;
1392 }
int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Add an ignorepat.
Definition: pbx.c:6835
const char * registrar
Definition: pbx.c:286
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static char* handle_cli_dialplan_add_include ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Include context ...

Definition at line 676 of file pbx_config.c.

References ast_context_add_include(), ast_context_find(), ast_context_find_or_create(), ast_cli_entry::command, ast_exten::registrar, and ast_cli_entry::usage.

677 {
678  const char *into_context;
679 
680  switch (cmd) {
681  case CLI_INIT:
682  e->command = "dialplan add include";
683  e->usage =
684  "Usage: dialplan add include <context> into <context>\n"
685  " Include a context in another context.\n";
686  return NULL;
687  case CLI_GENERATE:
688  return complete_dialplan_add_include(a);
689  }
690 
691  if (a->argc != 6) /* dialplan add include CTX in CTX */
692  return CLI_SHOWUSAGE;
693 
694  /* fifth arg must be 'into' ... */
695  if (strcmp(a->argv[4], "into"))
696  return CLI_SHOWUSAGE;
697 
698  into_context = a->argv[5];
699 
700  if (!ast_context_find(into_context)) {
701  ast_cli(a->fd, "Context '%s' did not exist prior to add include - the context will be created.\n", into_context);
702  }
703 
704  if (!ast_context_find_or_create(NULL, NULL, into_context, registrar)) {
705  ast_cli(a->fd, "ast_context_find_or_create() failed\n");
706  ast_cli(a->fd, "Failed to include '%s' in '%s' context\n",a->argv[3], a->argv[5]);
707  return CLI_FAILURE;
708  }
709 
710  if (ast_context_add_include(a->argv[5], a->argv[3], registrar)) {
711  switch (errno) {
712  case ENOMEM:
713  ast_cli(a->fd, "Out of memory for context addition\n");
714  break;
715 
716  case EBUSY:
717  ast_cli(a->fd, "Failed to lock context(s) list, please try again later\n");
718  break;
719 
720  case EEXIST:
721  ast_cli(a->fd, "Context '%s' already included in '%s' context\n",
722  a->argv[3], a->argv[5]);
723  break;
724 
725  case ENOENT:
726  case EINVAL:
727  ast_cli(a->fd, "There is no existence of context '%s'\n",
728  errno == ENOENT ? a->argv[5] : a->argv[3]);
729  break;
730 
731  default:
732  ast_cli(a->fd, "Failed to include '%s' in '%s' context\n",
733  a->argv[3], a->argv[5]);
734  break;
735  }
736  return CLI_FAILURE;
737  }
738 
739  /* show some info ... */
740  ast_cli(a->fd, "Context '%s' included in '%s' context\n",
741  a->argv[3], a->argv[5]);
742 
743  return CLI_SUCCESS;
744 }
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
Definition: pbx.c:6664
struct ast_context * ast_context_find(const char *name)
Find a context.
Definition: extconf.c:4172
const char * registrar
Definition: pbx.c:286
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
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.
Definition: pbx.c:6149
static char* handle_cli_dialplan_remove_context ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static
  • REMOVE context command stuff

Definition at line 134 of file pbx_config.c.

References ast_context_destroy_by_name(), ast_cli_entry::command, and ast_cli_entry::usage.

135 {
136  switch (cmd) {
137  case CLI_INIT:
138  e->command = "dialplan remove context";
139  e->usage =
140  "Usage: dialplan remove context <context>\n"
141  " Removes all extensions from a specified context.\n";
142  return NULL;
143  case CLI_GENERATE:
144  return complete_dialplan_remove_context(a);
145  }
146 
147  if (a->argc != 4) {
148  return CLI_SHOWUSAGE;
149  }
150 
151  if (ast_context_destroy_by_name(a->argv[3], NULL)) {
152  ast_cli(a->fd, "There is no such context as '%s'\n", a->argv[3]);
153  return CLI_SUCCESS;
154  } else {
155  ast_cli(a->fd, "Removed context '%s'\n", a->argv[3]);
156  return CLI_SUCCESS;
157  }
158 }
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
Definition: pbx.c:8205
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static char* handle_cli_dialplan_remove_extension ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

REMOVE EXTENSION command stuff

Definition at line 417 of file pbx_config.c.

References ast_cli_entry::command, PRIORITY_HINT, ast_context::registrar, split_ec(), and ast_cli_entry::usage.

418 {
419  int removing_priority = 0;
420  char *exten, *context, *cid;
421  char *ret = CLI_FAILURE;
422 
423  switch (cmd) {
424  case CLI_INIT:
425  e->command = "dialplan remove extension";
426  e->usage =
427  "Usage: dialplan remove extension exten[/cid]@context [priority]\n"
428  " Remove an extension from a given context. If a priority\n"
429  " is given, only that specific priority from the given extension\n"
430  " will be removed.\n";
431  return NULL;
432  case CLI_GENERATE:
433  return complete_dialplan_remove_extension(a);
434  }
435 
436  if (a->argc != 5 && a->argc != 4)
437  return CLI_SHOWUSAGE;
438 
439  /*
440  * Priority input checking ...
441  */
442  if (a->argc == 5) {
443  const char *c = a->argv[4];
444 
445  /* check for digits in whole parameter for right priority ...
446  * why? because atoi (strtol) returns 0 if any characters in
447  * string and whole extension will be removed, it's not good
448  */
449  if (!strcmp("hint", c))
450  removing_priority = PRIORITY_HINT;
451  else {
452  while (*c && isdigit(*c))
453  c++;
454  if (*c) { /* non-digit in string */
455  ast_cli(a->fd, "Invalid priority '%s'\n", a->argv[4]);
456  return CLI_FAILURE;
457  }
458  removing_priority = atoi(a->argv[4]);
459  }
460 
461  if (removing_priority == 0) {
462  ast_cli(a->fd, "If you want to remove whole extension, please " \
463  "omit priority argument\n");
464  return CLI_FAILURE;
465  }
466  }
467 
468  /* XXX original overwrote argv[3] */
469  /*
470  * Format exten@context checking ...
471  */
472  if (split_ec(a->argv[3], &exten, &context, &cid))
473  return CLI_FAILURE; /* XXX malloc failure */
474  if ((!strlen(exten)) || (!(strlen(context)))) {
475  ast_cli(a->fd, "Missing extension or context name in third argument '%s'\n",
476  a->argv[3]);
477  ast_free(exten);
478  return CLI_FAILURE;
479  }
480 
481  if (!ast_context_remove_extension_callerid(context, exten, removing_priority,
482  /* Do NOT substitute S_OR; it is NOT the same thing */
483  cid ? cid : (removing_priority ? "" : NULL), cid ? 1 : 0, registrar)) {
484  if (!removing_priority)
485  ast_cli(a->fd, "Whole extension %s@%s removed\n",
486  exten, context);
487  else
488  ast_cli(a->fd, "Extension %s@%s with priority %d removed\n",
489  exten, context, removing_priority);
490 
491  ret = CLI_SUCCESS;
492  } else {
493  if (cid) {
494  ast_cli(a->fd, "Failed to remove extension %s/%s@%s\n", exten, cid, context);
495  } else {
496  ast_cli(a->fd, "Failed to remove extension %s@%s\n", exten, context);
497  }
498  ret = CLI_FAILURE;
499  }
500  ast_free(exten);
501  return ret;
502 }
const char * registrar
Definition: pbx.c:286
#define PRIORITY_HINT
Definition: pbx.h:54
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 ...
Definition: pbx_config.c:261
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static char* handle_cli_dialplan_remove_include ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

REMOVE INCLUDE command stuff

Definition at line 162 of file pbx_config.c.

References ast_context_remove_include(), ast_cli_entry::command, and ast_cli_entry::usage.

163 {
164  switch (cmd) {
165  case CLI_INIT:
166  e->command = "dialplan remove include";
167  e->usage =
168  "Usage: dialplan remove include <context> from <context>\n"
169  " Remove an included context from another context.\n";
170  return NULL;
171  case CLI_GENERATE:
172  return complete_dialplan_remove_include(a);
173  }
174 
175  if (a->argc != 6 || strcmp(a->argv[4], "from"))
176  return CLI_SHOWUSAGE;
177 
178  if (!ast_context_remove_include(a->argv[5], a->argv[3], registrar)) {
179  ast_cli(a->fd, "We are not including '%s' into '%s' now\n",
180  a->argv[3], a->argv[5]);
181  return CLI_SUCCESS;
182  }
183 
184  ast_cli(a->fd, "Failed to remove '%s' include from '%s' context\n",
185  a->argv[3], a->argv[5]);
186  return CLI_FAILURE;
187 }
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
Definition: pbx.c:4836
const char * registrar
Definition: pbx.c:286
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
static void pbx_load_users ( void  )
static
Todo:
Remove users.conf support in Asterisk 23

Definition at line 2002 of file pbx_config.c.

References ast_add_extension2(), ast_category_browse(), ast_config_destroy(), ast_config_load, ast_config_option(), ast_context_find_or_create(), ast_copy_string(), ast_free_ptr(), ast_manager_get_topic(), ast_strdup, and ast_true().

2003 {
2004  struct ast_config *cfg;
2005  char *cat, *chan;
2006  const char *dahdichan;
2007  const char *hasexten, *altexts;
2008  char tmp[256];
2009  char iface[256];
2010  char dahdicopy[256];
2011  char *ext, altcopy[256];
2012  char *c;
2013  int hasvoicemail;
2014  int start, finish, x;
2015  struct ast_context *con = NULL;
2016  struct ast_flags config_flags = { 0 };
2017 
2018  cfg = ast_config_load("users.conf", config_flags);
2019  if (!cfg)
2020  return;
2021 
2022  /*! \todo Remove users.conf support in Asterisk 23 */
2023  fully_booted_subscription =
2024  stasis_subscribe_pool(ast_manager_get_topic(), startup_event_cb, NULL);
2025 
2026  for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) {
2027  if (!strcasecmp(cat, "general"))
2028  continue;
2029  iface[0] = '\0';
2030  if (ast_true(ast_config_option(cfg, cat, "hasiax"))) {
2031  snprintf(tmp, sizeof(tmp), "IAX2/%s", cat);
2032  append_interface(iface, sizeof(iface), tmp);
2033  }
2034  if (ast_true(ast_config_option(cfg, cat, "hash323"))) {
2035  snprintf(tmp, sizeof(tmp), "H323/%s", cat);
2036  append_interface(iface, sizeof(iface), tmp);
2037  }
2038  hasexten = ast_config_option(cfg, cat, "hasexten");
2039  if (hasexten && !ast_true(hasexten))
2040  continue;
2041  hasvoicemail = ast_true(ast_config_option(cfg, cat, "hasvoicemail"));
2042  dahdichan = ast_variable_retrieve(cfg, cat, "dahdichan");
2043  if (!dahdichan)
2044  dahdichan = ast_variable_retrieve(cfg, "general", "dahdichan");
2045  if (!ast_strlen_zero(dahdichan)) {
2046  ast_copy_string(dahdicopy, dahdichan, sizeof(dahdicopy));
2047  c = dahdicopy;
2048  chan = strsep(&c, ",");
2049  while (chan) {
2050  if (sscanf(chan, "%30d-%30d", &start, &finish) == 2) {
2051  /* Range */
2052  } else if (sscanf(chan, "%30d", &start)) {
2053  /* Just one */
2054  finish = start;
2055  } else {
2056  start = 0; finish = 0;
2057  }
2058  if (finish < start) {
2059  x = finish;
2060  finish = start;
2061  start = x;
2062  }
2063  for (x = start; x <= finish; x++) {
2064  snprintf(tmp, sizeof(tmp), "DAHDI/%d", x);
2065  append_interface(iface, sizeof(iface), tmp);
2066  }
2067  chan = strsep(&c, ",");
2068  }
2069  }
2070  if (!ast_strlen_zero(iface)) {
2071  /* Only create a context here when it is really needed. Otherwise default empty context
2072  created by pbx_config may conflict with the one explicitly created by pbx_ael */
2073  if (!con)
2074  con = ast_context_find_or_create(&local_contexts, local_table, userscontext, registrar);
2075 
2076  if (!con) {
2077  ast_log(LOG_ERROR, "Can't find/create user context '%s'\n", userscontext);
2078  return;
2079  }
2080 
2081  /* Add hint */
2082  ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar, NULL, 0);
2083  /* If voicemail, use "stdexten" else use plain old dial */
2084  if (hasvoicemail) {
2085  snprintf(tmp, sizeof(tmp), "%s,stdexten(${HINT})", cat);
2086  ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Gosub", ast_strdup(tmp), ast_free_ptr, registrar, NULL, 0);
2087  } else {
2088  ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", ast_strdup("${HINT}"), ast_free_ptr, registrar, NULL, 0);
2089  }
2090  altexts = ast_variable_retrieve(cfg, cat, "alternateexts");
2091  if (!ast_strlen_zero(altexts)) {
2092  snprintf(tmp, sizeof(tmp), "%s,1", cat);
2093  ast_copy_string(altcopy, altexts, sizeof(altcopy));
2094  c = altcopy;
2095  ext = strsep(&c, ",");
2096  while (ext) {
2097  ast_add_extension2(con, 0, ext, 1, NULL, NULL, "Goto", ast_strdup(tmp), ast_free_ptr, registrar, NULL, 0);
2098  ext = strsep(&c, ",");
2099  }
2100  }
2101  }
2102  }
2103  ast_config_destroy(cfg);
2104 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3326
void ast_free_ptr(void *ptr)
free() wrapper
Definition: main/astmm.c:1739
#define ast_config_load(filename, flags)
Load a config file.
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".
Definition: utils.c:2199
Structure used to handle boolean flags.
Definition: utils.h:199
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition: manager.c:1880
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 *.
Definition: pbx.c:7257
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
Definition: main/config.c:773
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.
Definition: pbx.c:6149
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
ast_context: An extension context
Definition: pbx.c:284
static char* pbx_strsep ( char **  destructible,
const char *  delim 
)
static
Note
Protect against misparsing based upon commas in the middle of fields like character classes. We've taken steps to permit pretty much every other printable character in a character class, so properly handling a comma at this level is a natural extension. This is almost like the standard application parser in app.c, except that it handles square brackets.

Definition at line 1648 of file pbx_config.c.

1649 {
1650  int square = 0;
1651  char *res;
1652 
1653  if (!destructible || !*destructible) {
1654  return NULL;
1655  }
1656  res = *destructible;
1657  for (; **destructible; (*destructible)++) {
1658  if (**destructible == '[' && !strchr(delim, '[')) {
1659  square++;
1660  } else if (**destructible == ']' && !strchr(delim, ']')) {
1661  if (square) {
1662  square--;
1663  }
1664  } else if (**destructible == '\\' && !strchr(delim, '\\')) {
1665  (*destructible)++;
1666  } else if (strchr(delim, **destructible) && !square) {
1667  **destructible = '\0';
1668  (*destructible)++;
1669  break;
1670  }
1671  }
1672  if (**destructible == '\0') {
1673  *destructible = NULL;
1674  }
1675  return res;
1676 }
static int unload_module ( void  )
static

Standard module functions ...

Definition at line 1627 of file pbx_config.c.

References ast_cli_unregister(), ast_cli_unregister_multiple(), ast_context_destroy(), ast_manager_unregister(), and stasis_unsubscribe_and_join().

1628 {
1629  ast_cli_unregister(&cli_dialplan_save);
1630  ast_free(overrideswitch_config);
1631  overrideswitch_config = NULL;
1632 
1634  ast_manager_unregister(AMI_EXTENSION_ADD);
1635  ast_manager_unregister(AMI_EXTENSION_REMOVE);
1636  ast_context_destroy(NULL, registrar);
1637 
1638  stasis_unsubscribe_and_join(fully_booted_subscription);
1639 
1640  return 0;
1641 }
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
Definition: main/cli.c:2432
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:8057
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Definition: stasis.c:1134
static struct ast_cli_entry cli_pbx_config[]
Definition: pbx_config.c:1607
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
Definition: pbx.c:8221

Variable Documentation

struct ast_cli_entry cli_dialplan_save
static
Initial value:
=
{ .handler = handle_cli_dialplan_save , .summary = "Save current dialplan into a file" ,}
static char * handle_cli_dialplan_save(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
'save dialplan' CLI command implementation functions ...
Definition: pbx_config.c:811

Definition at line 1618 of file pbx_config.c.

struct ast_cli_entry cli_pbx_config[]
static

CLI entries for commands provided by this module

Definition at line 1607 of file pbx_config.c.