Asterisk - The Open Source Telephony Project GIT-master-0deac78
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"
Include dependency graph for pbx_config.c:

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)
 
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. More...
 
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 ... More...
 
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 More...
 
static int lookup_ci (struct ast_context *c, const char *name)
 return true if 'name' is included by context c More...
 
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 More...
 
static int pbx_load_config (const char *config_file)
 
static int pbx_load_module (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 More...
 
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 More...
 
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 = AST_BUILDOPT_SUM, .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 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.

Macro Definition Documentation

◆ AMI_EXTENSION_ADD

#define AMI_EXTENSION_ADD   "DialplanExtensionAdd"

Definition at line 1625 of file pbx_config.c.

◆ AMI_EXTENSION_REMOVE

#define AMI_EXTENSION_REMOVE   "DialplanExtensionRemove"

Definition at line 1626 of file pbx_config.c.

◆ PUT_CTX_HDR

#define PUT_CTX_HDR

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 2046 of file pbx_config.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 2046 of file pbx_config.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 2046 of file pbx_config.c.

◆ complete_dialplan_add_extension()

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 1312 of file pbx_config.c.

1313{
1314 int which = 0;
1315
1316 if (a->pos == 4) { /* complete 'into' word ... */
1317 return (a->n == 0) ? ast_strdup("into") : NULL;
1318 } else if (a->pos == 5) { /* complete context */
1319 struct ast_context *c = NULL;
1320 int len = strlen(a->word);
1321 char *res = NULL;
1322
1323 /* try to lock contexts list ... */
1324 if (ast_rdlock_contexts()) {
1325 ast_log(LOG_WARNING, "Failed to lock contexts list\n");
1326 return NULL;
1327 }
1328
1329 /* walk through all contexts */
1330 while ( !res && (c = ast_walk_contexts(c)) )
1331 if (partial_match(ast_get_context_name(c), a->word, len) && ++which > a->n)
1334 return res;
1335 } else if (a->pos == 6) {
1336 return a->n == 0 ? ast_strdup("replace") : NULL;
1337 }
1338 return NULL;
1339}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_log
Definition: astobj2.c:42
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define LOG_WARNING
struct ast_context * ast_walk_contexts(struct ast_context *con)
Definition: extconf.c:4022
const char * ast_get_context_name(struct ast_context *con)
Definition: ael_main.c:421
int ast_rdlock_contexts(void)
Read locks the context list.
Definition: pbx.c:8493
int ast_unlock_contexts(void)
Unlocks contexts.
Definition: pbx.c:8498
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:257
#define NULL
Definition: resample.c:96
ast_context: An extension context
Definition: pbx.c:299
static struct test_val a
static struct test_val c

References a, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, NULL, and partial_match().

Referenced by handle_cli_dialplan_add_extension().

◆ complete_dialplan_add_ignorepat()

static char * complete_dialplan_add_ignorepat ( struct ast_cli_args a)
static

Definition at line 1398 of file pbx_config.c.

1399{
1400 if (a->pos == 4)
1401 return a->n == 0 ? ast_strdup("into") : NULL;
1402 else if (a->pos == 5) {
1403 struct ast_context *c;
1404 int which = 0;
1405 char *dupline, *ignorepat = NULL;
1406 const char *s;
1407 char *ret = NULL;
1408 int len = strlen(a->word);
1409
1410 /* XXX skip first three words 'dialplan' 'add' 'ignorepat' */
1411 s = skip_words(a->line, 3);
1412 if (s == NULL)
1413 return NULL;
1414 dupline = ast_strdup(s);
1415 if (!dupline) {
1416 ast_log(LOG_ERROR, "Malloc failure\n");
1417 return NULL;
1418 }
1419 ignorepat = strsep(&dupline, " ");
1420
1421 if (ast_rdlock_contexts()) {
1422 ast_log(LOG_ERROR, "Failed to lock contexts list\n");
1423 return NULL;
1424 }
1425
1426 for (c = NULL; !ret && (c = ast_walk_contexts(c));) {
1427 int found = 0;
1428
1429 if (!partial_match(ast_get_context_name(c), a->word, len))
1430 continue; /* not mine */
1431 if (ignorepat) /* there must be one, right ? */
1432 found = lookup_c_ip(c, ignorepat);
1433 if (!found && ++which > a->n)
1435 }
1436
1437 ast_free(ignorepat);
1439 return ret;
1440 }
1441
1442 return NULL;
1443}
char * strsep(char **str, const char *delims)
#define ast_free(a)
Definition: astmm.h:180
#define LOG_ERROR
static const char * skip_words(const char *p, int n)
moves to the n-th word in the string, or empty string if none
Definition: pbx_config.c:242
static int lookup_c_ip(struct ast_context *c, const char *name)
return true if 'name' is in the ignorepats for context c
Definition: pbx_config.c:218

References a, ast_free, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_ERROR, lookup_c_ip(), NULL, partial_match(), skip_words(), and strsep().

Referenced by handle_cli_dialplan_add_ignorepat().

◆ complete_dialplan_add_include()

static char * complete_dialplan_add_include ( struct ast_cli_args a)
static

Definition at line 750 of file pbx_config.c.

751{
752 struct ast_context *c;
753 int which = 0;
754 char *ret = NULL;
755 int len = strlen(a->word);
756
757 if (a->pos == 3) { /* 'dialplan add include _X_' (context) ... */
758 if (ast_rdlock_contexts()) {
759 ast_log(LOG_ERROR, "Failed to lock context list\n");
760 return NULL;
761 }
762 for (c = NULL; !ret && (c = ast_walk_contexts(c)); )
763 if (partial_match(ast_get_context_name(c), a->word, len) && ++which > a->n)
766 return ret;
767 } else if (a->pos == 4) { /* dialplan add include CTX _X_ */
768 /* always complete as 'into' */
769 return (a->n == 0) ? ast_strdup("into") : NULL;
770 } else if (a->pos == 5) { /* 'dialplan add include CTX into _X_' (dst context) */
771 char *context, *dupline, *into;
772 const char *s = skip_words(a->line, 3); /* should not fail */
773 context = dupline = ast_strdup(s);
774
775 if (!dupline) {
776 ast_log(LOG_ERROR, "Out of free memory\n");
777 return NULL;
778 }
779
780 strsep(&dupline, " "); /* skip context */
781 into = strsep(&dupline, " ");
782 /* error if missing context or fifth word is not 'into' */
783 if (!strlen(context) || strcmp(into, "into")) {
784 ast_log(LOG_ERROR, "bad context %s or missing into %s\n",
785 context, into);
786 goto error3;
787 }
788
789 if (ast_rdlock_contexts()) {
790 ast_log(LOG_ERROR, "Failed to lock context list\n");
791 goto error3;
792 }
793
794 for (c = NULL; !ret && (c = ast_walk_contexts(c)); ) {
795 if (!strcmp(context, ast_get_context_name(c)))
796 continue; /* skip ourselves */
797 if (partial_match(ast_get_context_name(c), a->word, len) &&
798 !lookup_ci(c, context) /* not included yet */ &&
799 ++which > a->n) {
801 }
802 }
804 error3:
806 return ret;
807 }
808
809 return NULL;
810}
static int lookup_ci(struct ast_context *c, const char *name)
return true if 'name' is included by context c
Definition: pbx_config.c:194

References a, ast_free, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, voicemailpwcheck::context, len(), LOG_ERROR, lookup_ci(), NULL, partial_match(), skip_words(), and strsep().

Referenced by handle_cli_dialplan_add_include().

◆ complete_dialplan_remove_context()

static char * complete_dialplan_remove_context ( struct ast_cli_args a)
static

Definition at line 1283 of file pbx_config.c.

1284{
1285 struct ast_context *c = NULL;
1286 int len = strlen(a->word);
1287 char *res = NULL;
1288 int which = 0;
1289
1290 if (a->pos != 3) {
1291 return NULL;
1292 }
1293
1294
1295 /* try to lock contexts list ... */
1296 if (ast_rdlock_contexts()) {
1297 ast_log(LOG_WARNING, "Failed to lock contexts list\n");
1298 return NULL;
1299 }
1300
1301 /* walk through all contexts */
1302 while ( !res && (c = ast_walk_contexts(c)) ) {
1303 if (partial_match(ast_get_context_name(c), a->word, len) && ++which > a->n) {
1305 }
1306 }
1308 return res;
1309}

References a, ast_get_context_name(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, NULL, and partial_match().

Referenced by handle_cli_dialplan_remove_context().

◆ complete_dialplan_remove_extension()

static char * complete_dialplan_remove_extension ( struct ast_cli_args a)
static

Definition at line 556 of file pbx_config.c.

557{
558 char *ret = NULL;
559 int which = 0;
560
561 if (a->pos == 3) { /* 'dialplan remove extension _X_' (exten@context ... */
562 struct ast_context *c = NULL;
563 char *context = NULL, *exten = NULL, *cid = NULL;
564 int le = 0; /* length of extension */
565 int lc = 0; /* length of context */
566 int lcid = 0; /* length of cid */
567
568 lc = split_ec(a->word, &exten, &context, &cid);
569 if (lc) { /* error */
570 return NULL;
571 }
572 le = strlen(exten);
573 lc = strlen(context);
574 lcid = cid ? strlen(cid) : -1;
575
576 if (ast_rdlock_contexts()) {
577 ast_log(LOG_ERROR, "Failed to lock context list\n");
578 goto error2;
579 }
580
581 /* find our context ... */
582 while ( (c = ast_walk_contexts(c)) ) { /* match our context if any */
583 struct ast_exten *e = NULL;
584 /* XXX locking ? */
586 continue; /* context not matched */
587 while ( (e = ast_walk_context_extensions(c, e)) ) { /* try to complete extensions ... */
588 if ( !strchr(a->word, '/') ||
589 (!strchr(a->word, '@') && partial_match(ast_get_extension_cidmatch(e), cid, lcid)) ||
590 (strchr(a->word, '@') && !strcmp(ast_get_extension_cidmatch(e), cid))) {
591 if ( ((strchr(a->word, '/') || strchr(a->word, '@')) && !strcmp(ast_get_extension_name(e), exten)) ||
592 (!strchr(a->word, '/') && !strchr(a->word, '@') && partial_match(ast_get_extension_name(e), exten, le))) { /* n-th match */
593 if (++which > a->n) {
594 /* If there is an extension then return exten@context. */
595 if (ast_get_extension_matchcid(e) && (!strchr(a->word, '@') || strchr(a->word, '/'))) {
597 ret = NULL;
598 }
599 break;
600 } else if (!ast_get_extension_matchcid(e) && !strchr(a->word, '/')) {
601 if (ast_asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)) < 0) {
602 ret = NULL;
603 }
604 break;
605 }
606 }
607 }
608 }
609 }
610 if (e) /* got a match */
611 break;
612 }
613
615 error2:
617 } else if (a->pos == 4) { /* 'dialplan remove extension EXT _X_' (priority) */
618 char *exten = NULL, *context, *cid, *p;
619 struct ast_context *c;
620 int le, lc, len;
621 const char *s = skip_words(a->line, 3); /* skip 'dialplan' 'remove' 'extension' */
622 int i = split_ec(s, &exten, &context, &cid); /* parse ext@context */
623
624 if (i) /* error */
625 goto error3;
626 if ( (p = strchr(exten, ' ')) ) /* remove space after extension */
627 *p = '\0';
628 if ( (p = strchr(context, ' ')) ) /* remove space after context */
629 *p = '\0';
630 le = strlen(exten);
631 lc = strlen(context);
632 len = strlen(a->word);
633 if (le == 0 || lc == 0)
634 goto error3;
635
636 if (ast_rdlock_contexts()) {
637 ast_log(LOG_ERROR, "Failed to lock context list\n");
638 goto error3;
639 }
640
641 /* walk contexts */
642 c = NULL;
643 while ( (c = ast_walk_contexts(c)) ) {
644 /* XXX locking on c ? */
645 struct ast_exten *e;
646 if (strcmp(ast_get_context_name(c), context) != 0)
647 continue;
648 /* got it, we must match here */
649 e = NULL;
650 while ( (e = ast_walk_context_extensions(c, e)) ) {
651 struct ast_exten *priority;
652 char buffer[10];
653
654 if (cid && strcmp(ast_get_extension_cidmatch(e), cid) != 0) {
655 continue;
656 }
657 if (strcmp(ast_get_extension_name(e), exten) != 0)
658 continue;
659 /* XXX lock e ? */
660 priority = NULL;
661 while ( !ret && (priority = ast_walk_extension_priorities(e, priority)) ) {
662 snprintf(buffer, sizeof(buffer), "%d", ast_get_extension_priority(priority));
663 if (partial_match(buffer, a->word, len) && ++which > a->n) /* n-th match */
664 ret = ast_strdup(buffer);
665 }
666 break;
667 }
668 break;
669 }
671 error3:
673 }
674 return ret;
675}
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
static int priority
int ast_get_extension_priority(struct ast_exten *exten)
Definition: pbx.c:8544
int ast_get_extension_matchcid(struct ast_exten *e)
Definition: pbx.c:8572
const char * ast_get_extension_cidmatch(struct ast_exten *e)
Definition: pbx.c:8577
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
Definition: extconf.c:4059
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority)
Definition: ael_main.c:427
const char * ast_get_extension_name(struct ast_exten *exten)
Definition: pbx.c:8534
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:265
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Definition: pbx.c:252
char * exten
Definition: pbx.c:253

References a, ast_asprintf, ast_free, ast_get_context_name(), ast_get_extension_cidmatch(), ast_get_extension_matchcid(), ast_get_extension_name(), ast_get_extension_priority(), ast_log, ast_rdlock_contexts(), ast_strdup, ast_unlock_contexts(), ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), c, voicemailpwcheck::context, ast_exten::exten, len(), LOG_ERROR, NULL, partial_match(), priority, skip_words(), and split_ec().

Referenced by handle_cli_dialplan_remove_extension().

◆ complete_dialplan_remove_ignorepat()

static char * complete_dialplan_remove_ignorepat ( struct ast_cli_args a)
static

Definition at line 1494 of file pbx_config.c.

1495{
1496 struct ast_context *c;
1497 int which = 0;
1498 char *ret = NULL;
1499
1500 if (a->pos == 3) {
1501 int len = strlen(a->word);
1502 if (ast_rdlock_contexts()) {
1503 ast_log(LOG_WARNING, "Failed to lock contexts list\n");
1504 return NULL;
1505 }
1506
1507 for (c = NULL; !ret && (c = ast_walk_contexts(c));) {
1508 int idx;
1509
1510 if (ast_rdlock_context(c)) /* error, skip it */
1511 continue;
1512 for (idx = 0; idx < ast_context_ignorepats_count(c); idx++) {
1513 const struct ast_ignorepat *ip = ast_context_ignorepats_get(c, idx);
1514
1515 if (partial_match(ast_get_ignorepat_name(ip), a->word, len) && ++which > a->n) {
1516 /* n-th match */
1517 struct ast_context *cw = NULL;
1518 int found = 0;
1519 while ( (cw = ast_walk_contexts(cw)) && cw != c && !found) {
1520 /* XXX do i stop on c, or skip it ? */
1521 found = lookup_c_ip(cw, ast_get_ignorepat_name(ip));
1522 }
1523 if (!found)
1525 }
1526 }
1528 }
1530 return ret;
1531 } else if (a->pos == 4) {
1532 return a->n == 0 ? ast_strdup("from") : NULL;
1533 } else if (a->pos == 5) { /* XXX check this */
1534 char *dupline, *duplinet, *ignorepat;
1535 int len = strlen(a->word);
1536
1537 dupline = ast_strdup(a->line);
1538 if (!dupline) {
1539 ast_log(LOG_WARNING, "Out of free memory\n");
1540 return NULL;
1541 }
1542
1543 duplinet = dupline;
1544 strsep(&duplinet, " ");
1545 strsep(&duplinet, " ");
1546 ignorepat = strsep(&duplinet, " ");
1547
1548 if (!ignorepat) {
1549 ast_free(dupline);
1550 return NULL;
1551 }
1552
1553 if (ast_rdlock_contexts()) {
1554 ast_log(LOG_WARNING, "Failed to lock contexts list\n");
1555 ast_free(dupline);
1556 return NULL;
1557 }
1558
1559 for (c = NULL; !ret && (c = ast_walk_contexts(c)); ) {
1560 if (ast_rdlock_context(c)) {
1561 /* fail, skip it */
1562 continue;
1563 }
1564 if (!partial_match(ast_get_context_name(c), a->word, len)) {
1566 continue;
1567 }
1568 if (lookup_c_ip(c, ignorepat) && ++which > a->n)
1571 }
1573 ast_free(dupline);
1574 return ret;
1575 }
1576
1577 return NULL;
1578}
int ast_unlock_context(struct ast_context *con)
Definition: pbx.c:8516
int ast_context_ignorepats_count(const struct ast_context *con)
Definition: pbx.c:8747
const struct ast_ignorepat * ast_context_ignorepats_get(const struct ast_context *con, int idx)
Definition: pbx.c:8752
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
Definition: pbx.c:8511
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:42
ast_ignorepat: Ignore patterns in dial plan
Definition: pbx_ignorepat.c:37

References a, ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_free, ast_get_context_name(), ast_get_ignorepat_name(), ast_log, ast_rdlock_context(), ast_rdlock_contexts(), ast_strdup, ast_unlock_context(), ast_unlock_contexts(), ast_walk_contexts(), c, len(), LOG_WARNING, lookup_c_ip(), NULL, partial_match(), and strsep().

Referenced by handle_cli_dialplan_remove_ignorepat().

◆ complete_dialplan_remove_include()

static char * complete_dialplan_remove_include ( struct ast_cli_args a)
static

Definition at line 295 of file pbx_config.c.

296{
297 int which = 0;
298 char *res = NULL;
299 int len = strlen(a->word); /* how many bytes to match */
300 struct ast_context *c = NULL;
301
302 if (a->pos == 3) { /* "dialplan remove include _X_" */
303 if (ast_wrlock_contexts()) {
304 ast_log(LOG_ERROR, "Failed to lock context list\n");
305 return NULL;
306 }
307 /* walk contexts and their includes, return the n-th match */
308 while (!res && (c = ast_walk_contexts(c))) {
309 int idx;
310
311 if (ast_rdlock_context(c)) /* error ? skip this one */
312 continue;
313
314 for (idx = 0; idx < ast_context_includes_count(c); idx++) {
315 const struct ast_include *i = ast_context_includes_get(c, idx);
316 const char *i_name = ast_get_include_name(i);
317 struct ast_context *nc = NULL;
318 int already_served = 0;
319
320 if (!partial_match(i_name, a->word, len))
321 continue; /* not matched */
322
323 /* check if this include is already served or not */
324
325 /* go through all contexts again till we reach actual
326 * context or already_served = 1
327 */
328 while ( (nc = ast_walk_contexts(nc)) && nc != c && !already_served)
329 already_served = lookup_ci(nc, i_name);
330
331 if (!already_served && ++which > a->n) {
332 res = ast_strdup(i_name);
333 break;
334 }
335 }
337 }
338
340 return res;
341 } else if (a->pos == 4) { /* "dialplan remove include CTX _X_" */
342 /*
343 * complete as 'from', but only if previous context is really
344 * included somewhere
345 */
346 char *context, *dupline;
347 const char *s = skip_words(a->line, 3); /* skip 'dialplan' 'remove' 'include' */
348
349 if (a->n > 0)
350 return NULL;
351 context = dupline = ast_strdup(s);
352 if (!dupline) {
353 ast_log(LOG_ERROR, "Out of free memory\n");
354 return NULL;
355 }
356 strsep(&dupline, " ");
357
358 if (ast_rdlock_contexts()) {
359 ast_log(LOG_ERROR, "Failed to lock contexts list\n");
361 return NULL;
362 }
363
364 /* go through all contexts and check if is included ... */
365 while (!res && (c = ast_walk_contexts(c)))
366 if (lookup_ci(c, context)) /* context is really included, complete "from" command */
367 res = ast_strdup("from");
369 if (!res)
370 ast_log(LOG_WARNING, "%s not included anywhere\n", context);
372 return res;
373 } else if (a->pos == 5) { /* "dialplan remove include CTX from _X_" */
374 /*
375 * Context from which we removing include ...
376 */
377 char *context, *dupline, *from;
378 const char *s = skip_words(a->line, 3); /* skip 'dialplan' 'remove' 'include' */
379 context = dupline = ast_strdup(s);
380 if (!dupline) {
381 ast_log(LOG_ERROR, "Out of free memory\n");
382 return NULL;
383 }
384
385 strsep(&dupline, " "); /* skip context */
386
387 /* fourth word must be 'from' */
388 from = strsep(&dupline, " ");
389 if (!from || strcmp(from, "from")) {
391 return NULL;
392 }
393
394 if (ast_rdlock_contexts()) {
395 ast_log(LOG_ERROR, "Failed to lock context list\n");
397 return NULL;
398 }
399
400 /* walk through all contexts ... */
401 c = NULL;
402 while ( !res && (c = ast_walk_contexts(c))) {
403 const char *c_name = ast_get_context_name(c);
404 if (!partial_match(c_name, a->word, len)) /* not a good target */
405 continue;
406 /* walk through all includes and check if it is our context */
407 if (lookup_ci(c, context) && ++which > a->n)
408 res = ast_strdup(c_name);
409 }
412 return res;
413 }
414
415 return NULL;
416}
int ast_wrlock_contexts(void)
Write locks the context list.
Definition: pbx.c:8488
const char * ast_get_include_name(const struct ast_include *include)
Definition: pbx_include.c:50
const struct ast_include * ast_context_includes_get(const struct ast_context *con, int idx)
Definition: pbx.c:8709
int ast_context_includes_count(const struct ast_context *con)
Definition: pbx.c:8704
ast_include: include= support in extensions.conf
Definition: pbx_include.c:37

References a, ast_context_includes_count(), ast_context_includes_get(), ast_free, ast_get_context_name(), ast_get_include_name(), ast_log, ast_rdlock_context(), ast_rdlock_contexts(), ast_strdup, ast_unlock_context(), ast_unlock_contexts(), ast_walk_contexts(), ast_wrlock_contexts(), c, voicemailpwcheck::context, len(), LOG_ERROR, LOG_WARNING, lookup_ci(), NULL, partial_match(), skip_words(), and strsep().

Referenced by handle_cli_dialplan_remove_include().

◆ handle_cli_dialplan_add_extension()

static char * handle_cli_dialplan_add_extension ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

ADD EXTENSION command stuff.

Definition at line 1069 of file pbx_config.c.

1070{
1071 char *whole_exten;
1072 char *exten, *prior;
1073 int iprior = -2;
1074 char *cidmatch, *app, *app_data;
1075 char *start, *end;
1076 const char *into_context;
1077
1078 switch (cmd) {
1079 case CLI_INIT:
1080 e->command = "dialplan add extension";
1081 e->usage =
1082 "Usage: dialplan add extension <exten>,<priority>,<app> into <context> [replace]\n"
1083 "\n"
1084 " app can be either:\n"
1085 " app-name\n"
1086 " app-name(app-data)\n"
1087 " app-name,<app-data>\n"
1088 "\n"
1089 " This command will add the new extension into <context>. If\n"
1090 " an extension with the same priority already exists and the\n"
1091 " 'replace' option is given we will replace the extension.\n"
1092 "\n"
1093 "Example: dialplan add extension 6123,1,Dial,IAX/216.207.245.56/6123 into local\n"
1094 " Now, you can dial 6123 and talk to Markster :)\n";
1095 return NULL;
1096 case CLI_GENERATE:
1098 }
1099
1100 /* check for arguments at first */
1101 if (a->argc != 6 && a->argc != 7)
1102 return CLI_SHOWUSAGE;
1103 if (strcmp(a->argv[4], "into"))
1104 return CLI_SHOWUSAGE;
1105 if (a->argc == 7)
1106 if (strcmp(a->argv[6], "replace"))
1107 return CLI_SHOWUSAGE;
1108
1109 whole_exten = ast_strdupa(a->argv[3]);
1110 exten = strsep(&whole_exten,",");
1111 if (strchr(exten, '/')) {
1112 cidmatch = exten;
1113 strsep(&cidmatch,"/");
1114 } else {
1115 cidmatch = NULL;
1116 }
1117 prior = strsep(&whole_exten,",");
1118 if (prior) {
1119 if (!strcmp(prior, "hint")) {
1120 iprior = PRIORITY_HINT;
1121 } else {
1122 if (sscanf(prior, "%30d", &iprior) != 1) {
1123 ast_cli(a->fd, "'%s' is not a valid priority\n", prior);
1124 prior = NULL;
1125 }
1126 }
1127 }
1128 app = whole_exten;
1129 if (app) {
1130 if ((start = strchr(app, '(')) && (end = strrchr(app, ')'))) {
1131 *start = *end = '\0';
1132 app_data = start + 1;
1133 } else {
1134 app_data = strchr(app, ',');
1135 if (app_data) {
1136 *app_data++ = '\0';
1137 }
1138 }
1139 } else {
1140 app_data = NULL;
1141 }
1142
1143 if (!exten || !prior || !app) {
1144 return CLI_SHOWUSAGE;
1145 }
1146
1147 if (!app_data) {
1148 app_data = "";
1149 }
1150 into_context = a->argv[5];
1151
1152 if (!ast_context_find(into_context)) {
1153 ast_cli(a->fd, "Context '%s' did not exist prior to add extension - the context will be created.\n", into_context);
1154 }
1155
1156 if (!ast_context_find_or_create(NULL, NULL, into_context, registrar)) {
1157 ast_cli(a->fd, "Failed to add '%s,%s,%s(%s)' extension into '%s' context\n",
1158 exten, prior, app, app_data, into_context);
1159 return CLI_FAILURE;
1160 }
1161
1162 if (ast_add_extension(into_context, a->argc == 7 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
1164 switch (errno) {
1165 case ENOMEM:
1166 ast_cli(a->fd, "Out of free memory\n");
1167 break;
1168
1169 case EBUSY:
1170 ast_cli(a->fd, "Failed to lock context(s) list, please try again later\n");
1171 break;
1172
1173 case ENOENT:
1174 ast_cli(a->fd, "No existence of '%s' context\n", into_context);
1175 break;
1176
1177 case EEXIST:
1178 ast_cli(a->fd, "Extension %s@%s with priority %s already exists\n",
1179 exten, into_context, prior);
1180 break;
1181
1182 default:
1183 ast_cli(a->fd, "Failed to add '%s,%s,%s(%s)' extension into '%s' context\n",
1184 exten, prior, app, app_data, into_context);
1185 break;
1186 }
1187 return CLI_FAILURE;
1188 }
1189
1190 if (a->argc == 7) {
1191 ast_cli(a->fd, "Extension %s@%s (%s) replace by '%s,%s,%s(%s)'\n",
1192 exten, into_context, prior, exten, prior, app, app_data);
1193 } else {
1194 ast_cli(a->fd, "Extension '%s,%s,%s(%s)' added into '%s' context\n",
1195 exten, prior, app, app_data, into_context);
1196 }
1197
1198 return CLI_SUCCESS;
1199}
static const char app[]
Definition: app_adsiprog.c:56
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1739
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define CLI_SUCCESS
Definition: cli.h:44
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
@ CLI_INIT
Definition: cli.h:152
@ CLI_GENERATE
Definition: cli.h:153
#define CLI_FAILURE
Definition: cli.h:46
char * end
Definition: eagi_proxy.c:73
int errno
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.
Definition: pbx.c:6949
struct ast_context * ast_context_find(const char *name)
Find a context.
Definition: extconf.c:4170
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:6170
#define PRIORITY_HINT
Definition: pbx.h:54
static char * complete_dialplan_add_extension(struct ast_cli_args *)
Definition: pbx_config.c:1312
static const char registrar[]
Definition: pbx_config.c:103
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177

References a, app, ast_add_extension(), ast_cli(), ast_context_find(), ast_context_find_or_create(), ast_free_ptr(), ast_strdup, ast_strdupa, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_add_extension(), end, errno, NULL, PRIORITY_HINT, registrar, strsep(), and ast_cli_entry::usage.

◆ handle_cli_dialplan_add_ignorepat()

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 1344 of file pbx_config.c.

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

References a, ast_cli(), ast_context_add_ignorepat(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_add_ignorepat(), errno, NULL, registrar, and ast_cli_entry::usage.

◆ handle_cli_dialplan_add_include()

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 680 of file pbx_config.c.

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

References a, ast_cli(), ast_context_add_include(), ast_context_find(), ast_context_find_or_create(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_add_include(), errno, NULL, registrar, and ast_cli_entry::usage.

◆ handle_cli_dialplan_reload()

static char * handle_cli_dialplan_reload ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1582 of file pbx_config.c.

1583{
1584 switch (cmd) {
1585 case CLI_INIT:
1586 e->command = "dialplan reload";
1587 e->usage =
1588 "Usage: dialplan reload\n"
1589 " Reload extensions.conf without reloading any other\n"
1590 " modules. This command does not delete global variables\n"
1591 " unless clearglobalvars is set to yes in extensions.conf\n";
1592 return NULL;
1593 case CLI_GENERATE:
1594 return NULL;
1595 }
1596
1597 if (a->argc != 2)
1598 return CLI_SHOWUSAGE;
1599
1602
1604 ast_cli(a->fd, "Dialplan reloaded.\n");
1605 return CLI_SUCCESS;
1606}
void pbx_builtin_clear_globals(void)
static int pbx_load_module(void)
Definition: pbx_config.c:1971
static int clearglobalvars_config
Definition: pbx_config.c:109

References a, ast_cli(), clearglobalvars_config, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, pbx_builtin_clear_globals(), pbx_load_module(), and ast_cli_entry::usage.

◆ handle_cli_dialplan_remove_context()

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 138 of file pbx_config.c.

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

References a, ast_cli(), ast_context_destroy_by_name(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_context(), NULL, and ast_cli_entry::usage.

◆ handle_cli_dialplan_remove_extension()

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 421 of file pbx_config.c.

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

References a, ast_cli(), ast_context_remove_extension_callerid(), ast_free, c, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_extension(), voicemailpwcheck::context, NULL, PRIORITY_HINT, registrar, split_ec(), and ast_cli_entry::usage.

◆ handle_cli_dialplan_remove_ignorepat()

static char * handle_cli_dialplan_remove_ignorepat ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1445 of file pbx_config.c.

1446{
1447 switch (cmd) {
1448 case CLI_INIT:
1449 e->command = "dialplan remove ignorepat";
1450 e->usage =
1451 "Usage: dialplan remove ignorepat <pattern> from <context>\n"
1452 " This command removes an ignore pattern from context <context>\n"
1453 "\n"
1454 "Example: dialplan remove ignorepat _3XX from local\n";
1455 return NULL;
1456 case CLI_GENERATE:
1458 }
1459
1460 if (a->argc != 6)
1461 return CLI_SHOWUSAGE;
1462
1463 if (strcmp(a->argv[4], "from"))
1464 return CLI_SHOWUSAGE;
1465
1466 if (ast_context_remove_ignorepat(a->argv[5], a->argv[3], registrar)) {
1467 switch (errno) {
1468 case EBUSY:
1469 ast_cli(a->fd, "Failed to lock context(s) list, please try again later\n");
1470 break;
1471
1472 case ENOENT:
1473 ast_cli(a->fd, "There is no existence of '%s' context\n", a->argv[5]);
1474 break;
1475
1476 case EINVAL:
1477 ast_cli(a->fd, "There is no existence of '%s' ignore pattern in '%s' context\n",
1478 a->argv[3], a->argv[5]);
1479 break;
1480
1481 default:
1482 ast_cli(a->fd, "Failed to remove ignore pattern '%s' from '%s' context\n",
1483 a->argv[3], a->argv[5]);
1484 break;
1485 }
1486 return CLI_FAILURE;
1487 }
1488
1489 ast_cli(a->fd, "Ignore pattern '%s' removed from '%s' context\n",
1490 a->argv[3], a->argv[5]);
1491 return CLI_SUCCESS;
1492}
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Remove an ignorepat.
Definition: pbx.c:6816
static char * complete_dialplan_remove_ignorepat(struct ast_cli_args *)
Definition: pbx_config.c:1494

References a, ast_cli(), ast_context_remove_ignorepat(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_ignorepat(), errno, NULL, registrar, and ast_cli_entry::usage.

◆ handle_cli_dialplan_remove_include()

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 166 of file pbx_config.c.

167{
168 switch (cmd) {
169 case CLI_INIT:
170 e->command = "dialplan remove include";
171 e->usage =
172 "Usage: dialplan remove include <context> from <context>\n"
173 " Remove an included context from another context.\n";
174 return NULL;
175 case CLI_GENERATE:
177 }
178
179 if (a->argc != 6 || strcmp(a->argv[4], "from"))
180 return CLI_SHOWUSAGE;
181
182 if (!ast_context_remove_include(a->argv[5], a->argv[3], registrar)) {
183 ast_cli(a->fd, "We are not including '%s' into '%s' now\n",
184 a->argv[3], a->argv[5]);
185 return CLI_SUCCESS;
186 }
187
188 ast_cli(a->fd, "Failed to remove '%s' include from '%s' context\n",
189 a->argv[3], a->argv[5]);
190 return CLI_FAILURE;
191}
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
Definition: pbx.c:4857
static char * complete_dialplan_remove_include(struct ast_cli_args *)
Definition: pbx_config.c:295

References a, ast_cli(), ast_context_remove_include(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_dialplan_remove_include(), NULL, registrar, and ast_cli_entry::usage.

◆ handle_cli_dialplan_save()

static char * handle_cli_dialplan_save ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

'save dialplan' CLI command implementation functions ...

Definition at line 815 of file pbx_config.c.

816{
817 char filename[256], overrideswitch[256] = "";
818 struct ast_context *c;
819 struct ast_config *cfg;
820 struct ast_variable *v;
821 int incomplete = 0; /* incomplete config write? */
822 FILE *output;
823 struct ast_flags config_flags = { 0 };
824 const char *base, *slash;
825
826 switch (cmd) {
827 case CLI_INIT:
828 e->command = "dialplan save";
829 e->usage =
830 "Usage: dialplan save [/path/to/extension/file]\n"
831 " Save dialplan created by pbx_config module.\n"
832 "\n"
833 "Example: dialplan save (/etc/asterisk/extensions.conf)\n"
834 " dialplan save /home/markster (/home/markster/extensions.conf)\n";
835 return NULL;
836 case CLI_GENERATE:
837 return NULL;
838 }
839
841 ast_cli(a->fd,
842 "I can't save dialplan now, see '%s' example file.\n",
843 config);
844 return CLI_FAILURE;
845 }
846
847 if (a->argc != 2 && a->argc != 3)
848 return CLI_SHOWUSAGE;
849
851 ast_cli(a->fd,
852 "Failed to lock dialplan saving (another process saving?)\n");
853 return CLI_FAILURE;
854 }
855 /* XXX the code here is quite loose, a pathname with .conf in it
856 * is assumed to be a complete pathname
857 */
858 if (a->argc == 3) { /* have config path. Look for *.conf */
859 base = a->argv[2];
860 if (!strstr(a->argv[2], ".conf")) { /*no, this is assumed to be a pathname */
861 /* if filename ends with '/', do not add one */
862 slash = (*(a->argv[2] + strlen(a->argv[2]) -1) == '/') ? "/" : "";
863 } else { /* yes, complete file name */
864 slash = "";
865 }
866 } else {
867 /* no config file, default one */
869 slash = "/";
870 }
871 snprintf(filename, sizeof(filename), "%s%s%s", base, slash, config);
872
873 cfg = ast_config_load("extensions.conf", config_flags);
874 if (!cfg) {
875 ast_cli(a->fd, "Failed to load extensions.conf\n");
877 return CLI_FAILURE;
878 }
879
880 /* try to lock contexts list */
881 if (ast_rdlock_contexts()) {
882 ast_cli(a->fd, "Failed to lock contexts list\n");
885 return CLI_FAILURE;
886 }
887
888 /* create new file ... */
889 if (!(output = fopen(filename, "wt"))) {
890 ast_cli(a->fd, "Failed to create file '%s'\n",
891 filename);
895 return CLI_FAILURE;
896 }
897
898 /* fireout general info */
900 snprintf(overrideswitch, sizeof(overrideswitch), "overrideswitch=%s\n", overrideswitch_config);
901 }
902 fprintf(output, "[general]\nstatic=%s\nwriteprotect=%s\nautofallthrough=%s\nclearglobalvars=%s\n%sextenpatternmatchnew=%s\n\n",
903 static_config ? "yes" : "no",
904 write_protect_config ? "yes" : "no",
905 autofallthrough_config ? "yes" : "no",
906 clearglobalvars_config ? "yes" : "no",
908 extenpatternmatchnew_config ? "yes" : "no");
909
910 if ((v = ast_variable_browse(cfg, "globals"))) {
911 fprintf(output, "[globals]\n");
912 while(v) {
913 int escaped_len = 2 * strlen(v->value) + 1;
914 char escaped[escaped_len];
915
916 ast_escape_semicolons(v->value, escaped, escaped_len);
917 fprintf(output, "%s => %s\n", v->name, escaped);
918 v = v->next;
919 }
920 fprintf(output, "\n");
921 }
922
924
925#define PUT_CTX_HDR do { \
926 if (!context_header_written) { \
927 fprintf(output, "[%s]\n", ast_get_context_name(c)); \
928 context_header_written = 1; \
929 } \
930 } while (0)
931
932 /* walk all contexts */
933 for (c = NULL; (c = ast_walk_contexts(c)); ) {
934 int context_header_written = 0;
935 struct ast_exten *ext, *last_written_e = NULL;
936 int idx;
937
938 /* try to lock context and fireout all info */
939 if (ast_rdlock_context(c)) { /* lock failure */
940 incomplete = 1;
941 continue;
942 }
943 /* registered by this module? */
944 /* XXX do we need this ? */
945 if (!strcmp(ast_get_context_registrar(c), registrar)) {
946 fprintf(output, "[%s]\n", ast_get_context_name(c));
947 context_header_written = 1;
948 }
949
950 /* walk extensions ... */
951 for (ext = NULL; (ext = ast_walk_context_extensions(c, ext)); ) {
952 struct ast_exten *p = NULL;
953
954 /* fireout priorities */
955 while ( (p = ast_walk_extension_priorities(ext, p)) ) {
956 if (strcmp(ast_get_extension_registrar(p), registrar) != 0) /* not this source */
957 continue;
958
959 /* make empty line between different extensions */
960 if (last_written_e != NULL &&
961 strcmp(ast_get_extension_name(last_written_e),
963 fprintf(output, "\n");
964 last_written_e = p;
965
967
968 if (ast_get_extension_priority(p) == PRIORITY_HINT) { /* easy */
969 fprintf(output, "exten => %s,hint,%s\n",
972 } else {
973 const char *sep, *cid;
974 const char *el = ast_get_extension_label(p);
975 char label[128] = "";
976 char *appdata = ast_get_extension_app_data(p);
977
978 int escaped_len = (!ast_strlen_zero(appdata)) ? 2 * strlen(appdata) + 1 : 1;
979 char escaped[escaped_len];
980
982 sep = "/";
984 } else {
985 sep = cid = "";
986 }
987
988 if (el && (snprintf(label, sizeof(label), "(%s)", el) != (strlen(el) + 2))) {
989 incomplete = 1; /* error encountered or label > 125 chars */
990 }
991
992 if (!ast_strlen_zero(appdata)) {
993 ast_escape_semicolons(appdata, escaped, escaped_len);
994 } else {
995 escaped[0] = '\0';
996 }
997
998 fprintf(output, "exten => %s%s%s,%d%s,%s(%s)\n",
999 ast_get_extension_name(p), (ast_strlen_zero(sep) ? "" : sep), (ast_strlen_zero(cid) ? "" : cid),
1001 ast_get_extension_app(p), escaped);
1002 }
1003 }
1004 }
1005
1006 /* written any extensions? ok, write space between exten & inc */
1007 if (last_written_e)
1008 fprintf(output, "\n");
1009
1010 /* walk through includes */
1011 for (idx = 0; idx < ast_context_includes_count(c); idx++) {
1012 const struct ast_include *i = ast_context_includes_get(c, idx);
1013
1014 if (strcmp(ast_get_include_registrar(i), registrar) != 0)
1015 continue; /* not mine */
1017 fprintf(output, "include => %s\n", ast_get_include_name(i));
1018 }
1020 fprintf(output, "\n");
1021 }
1022
1023 /* walk through switches */
1024 for (idx = 0; idx < ast_context_switches_count(c); idx++) {
1025 const struct ast_sw *sw = ast_context_switches_get(c, idx);
1026
1027 if (strcmp(ast_get_switch_registrar(sw), registrar) != 0)
1028 continue; /* not mine */
1030 fprintf(output, "switch => %s/%s\n",
1032 }
1033
1035 fprintf(output, "\n");
1036 }
1037
1038 /* fireout ignorepats ... */
1039 for (idx = 0; idx < ast_context_ignorepats_count(c); idx++) {
1040 const struct ast_ignorepat *ip = ast_context_ignorepats_get(c, idx);
1041
1042 if (strcmp(ast_get_ignorepat_registrar(ip), registrar) != 0)
1043 continue; /* not mine */
1045 fprintf(output, "ignorepat => %s\n",
1047 }
1048
1050 }
1051
1054 fclose(output);
1055
1056 if (incomplete) {
1057 ast_cli(a->fd, "Saved dialplan is incomplete\n");
1058 return CLI_FAILURE;
1059 }
1060
1061 ast_cli(a->fd, "Dialplan successfully saved into '%s'\n",
1062 filename);
1063 return CLI_SUCCESS;
1064}
static EditLine * el
Definition: asterisk.c:347
const char * ext
Definition: http.c:150
#define ast_config_load(filename, flags)
Load a config file.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1287
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1213
#define ast_mutex_unlock(a)
Definition: lock.h:197
#define ast_mutex_lock(a)
Definition: lock.h:196
const char * ast_config_AST_CONFIG_DIR
Definition: options.c:152
static char * overrideswitch
Definition: pbx.c:785
void * ast_get_extension_app_data(struct ast_exten *e)
Definition: pbx.c:8587
const struct ast_sw * ast_context_switches_get(const struct ast_context *con, int idx)
Definition: pbx.c:8664
const char * ast_get_extension_app(struct ast_exten *e)
Definition: pbx.c:8582
const char * ast_get_switch_name(const struct ast_sw *sw)
Definition: pbx_sw.c:48
const char * ast_get_extension_label(struct ast_exten *e)
Definition: pbx.c:8539
const char * ast_get_switch_data(const struct ast_sw *sw)
Definition: pbx_sw.c:53
const char * ast_get_context_registrar(struct ast_context *c)
Definition: pbx.c:8552
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
Definition: pbx_ignorepat.c:47
int ast_context_switches_count(const struct ast_context *con)
Definition: pbx.c:8659
const char * ast_get_include_registrar(const struct ast_include *i)
Definition: pbx_include.c:60
const char * ast_get_extension_registrar(struct ast_exten *e)
Definition: pbx.c:8557
const char * ast_get_switch_registrar(const struct ast_sw *sw)
Definition: pbx_sw.c:63
static char * overrideswitch_config
Definition: pbx_config.c:111
static int extenpatternmatchnew_config
Definition: pbx_config.c:110
static int autofallthrough_config
Definition: pbx_config.c:108
static const char config[]
Definition: pbx_config.c:102
static int static_config
Definition: pbx_config.c:106
static ast_mutex_t save_dialplan_lock
Definition: pbx_config.c:113
#define PUT_CTX_HDR
static int write_protect_config
Definition: pbx_config.c:107
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
const char * label
Definition: pbx.c:259
Structure used to handle boolean flags.
Definition: utils.h:217
ast_sw: Switch statement in extensions.conf
Definition: pbx_sw.c:37
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
char * ast_escape_semicolons(const char *string, char *outbuf, int buflen)
Escape semicolons found in a string.
Definition: utils.c:847

References a, ast_cli(), ast_config_AST_CONFIG_DIR, ast_config_destroy(), ast_config_load, ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_context_includes_count(), ast_context_includes_get(), ast_context_switches_count(), ast_context_switches_get(), ast_escape_semicolons(), ast_get_context_name(), ast_get_context_registrar(), ast_get_extension_app(), ast_get_extension_app_data(), ast_get_extension_cidmatch(), ast_get_extension_label(), ast_get_extension_matchcid(), ast_get_extension_name(), ast_get_extension_priority(), ast_get_extension_registrar(), ast_get_ignorepat_name(), ast_get_ignorepat_registrar(), ast_get_include_name(), ast_get_include_registrar(), ast_get_switch_data(), ast_get_switch_name(), ast_get_switch_registrar(), ast_mutex_lock, ast_mutex_unlock, ast_rdlock_context(), ast_rdlock_contexts(), ast_strlen_zero(), ast_unlock_context(), ast_unlock_contexts(), ast_variable_browse(), ast_walk_context_extensions(), ast_walk_contexts(), ast_walk_extension_priorities(), autofallthrough_config, c, clearglobalvars_config, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, config, el, ext, extenpatternmatchnew_config, ast_exten::label, ast_variable::name, ast_variable::next, NULL, overrideswitch, overrideswitch_config, PRIORITY_HINT, PUT_CTX_HDR, registrar, save_dialplan_lock, static_config, ast_cli_entry::usage, ast_variable::value, and write_protect_config.

◆ load_module()

static int load_module ( void  )
static

Definition at line 2008 of file pbx_config.c.

2009{
2010 int res;
2011
2012 if (pbx_load_module()) {
2013 unload_module();
2015 }
2016
2020
2025
2026 if (res) {
2027 unload_module();
2029 }
2030
2032}
#define ast_cli_register(e)
Registers a command or an array of commands.
Definition: cli.h:256
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define EVENT_FLAG_SYSTEM
Definition: manager.h:75
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:192
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static int manager_dialplan_extension_add(struct mansession *s, const struct message *m)
Definition: pbx_config.c:1201
static struct ast_cli_entry cli_dialplan_save
Definition: pbx_config.c:1622
#define AMI_EXTENSION_ADD
Definition: pbx_config.c:1625
static struct ast_cli_entry cli_pbx_config[]
Definition: pbx_config.c:1611
#define AMI_EXTENSION_REMOVE
Definition: pbx_config.c:1626
static int unload_module(void)
Definition: pbx_config.c:1631
static int manager_dialplan_extension_remove(struct mansession *s, const struct message *m)
Definition: pbx_config.c:508
#define ARRAY_LEN(a)
Definition: utils.h:703

References AMI_EXTENSION_ADD, AMI_EXTENSION_REMOVE, ARRAY_LEN, ast_cli_register, ast_cli_register_multiple, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, cli_dialplan_save, cli_pbx_config, EVENT_FLAG_SYSTEM, manager_dialplan_extension_add(), manager_dialplan_extension_remove(), pbx_load_module(), static_config, unload_module(), and write_protect_config.

◆ lookup_c_ip()

static int lookup_c_ip ( struct ast_context c,
const char *  name 
)
static

return true if 'name' is in the ignorepats for context c

Definition at line 218 of file pbx_config.c.

219{
220 int idx;
221 int ret = 0;
222
223 if (ast_rdlock_context(c)) {
224 /* error, skip */
225 return 0;
226 }
227
228 for (idx = 0; idx < ast_context_ignorepats_count(c); idx++) {
229 const struct ast_ignorepat *ip = ast_context_ignorepats_get(c, idx);
230
231 if (!strcmp(name, ast_get_ignorepat_name(ip))) {
232 ret = -1;
233 break;
234 }
235 }
237
238 return ret;
239}
static const char name[]
Definition: format_mp3.c:68

References ast_context_ignorepats_count(), ast_context_ignorepats_get(), ast_get_ignorepat_name(), ast_rdlock_context(), ast_unlock_context(), c, and name.

Referenced by complete_dialplan_add_ignorepat(), and complete_dialplan_remove_ignorepat().

◆ lookup_ci()

static int lookup_ci ( struct ast_context c,
const char *  name 
)
static

return true if 'name' is included by context c

Definition at line 194 of file pbx_config.c.

195{
196 int idx;
197 int ret = 0;
198
199 if (ast_rdlock_context(c)) {
200 /* error, skip */
201 return 0;
202 }
203
204 for (idx = 0; idx < ast_context_includes_count(c); idx++) {
205 const struct ast_include *i = ast_context_includes_get(c, idx);
206
207 if (!strcmp(name, ast_get_include_name(i))) {
208 ret = -1;
209 break;
210 }
211 }
213
214 return ret;
215}

References ast_context_includes_count(), ast_context_includes_get(), ast_get_include_name(), ast_rdlock_context(), ast_unlock_context(), c, and name.

Referenced by complete_dialplan_add_include(), and complete_dialplan_remove_include().

◆ manager_dialplan_extension_add()

static int manager_dialplan_extension_add ( struct mansession s,
const struct message m 
)
static

Definition at line 1201 of file pbx_config.c.

1202{
1203 const char *context = astman_get_header(m, "Context");
1204 const char *extension = astman_get_header(m, "Extension");
1205 const char *priority = astman_get_header(m, "Priority");
1206 const char *application = astman_get_header(m, "Application");
1207 const char *application_data = astman_get_header(m, "ApplicationData");
1208 int replace = ast_true(astman_get_header(m, "Replace"));
1209 int ipriority;
1210 char *exten;
1211 char *cidmatch = NULL;
1212 struct ast_context *add_context;
1213
1215 ast_strlen_zero(priority) || ast_strlen_zero(application)) {
1216 astman_send_error(s, m, "Context, Extension, Priority, and "
1217 "Application must be defined for DialplanExtensionAdd.");
1218 return 0;
1219 }
1220
1221 /* Priority conversion/validation */
1222 if (!strcmp(priority, "hint")) {
1223 ipriority = PRIORITY_HINT;
1224 } else if ((sscanf(priority, "%30d", &ipriority) != 1) || (ipriority < 0)) {
1225 astman_send_error(s, m, "The priority specified was invalid.");
1226 return 0;
1227 }
1228
1229 /* Split extension from cidmatch */
1230 exten = ast_strdupa(extension);
1231
1232 if (strchr(exten, '/')) {
1233 cidmatch = exten;
1234 strsep(&cidmatch, "/");
1235 }
1236
1237 if (ast_wrlock_contexts()) {
1238 astman_send_error(s, m, "Failed to lock contexts list. Try again later.");
1239 return 0;
1240 }
1241
1243 if (!add_context) {
1244 astman_send_error(s, m, "Could not find or create context specified "
1245 "for the extension.");
1247 return 0;
1248 }
1249
1250 if (ast_add_extension2(add_context, replace, exten, ipriority, NULL, cidmatch,
1251 application, ast_strdup(application_data), ast_free_ptr, registrar, NULL, 0)) {
1253 switch (errno) {
1254 case ENOMEM:
1255 astman_send_error(s, m, "Out of Memory");
1256 break;
1257
1258 case EBUSY:
1259 astman_send_error(s, m, "Failed to lock context(s) list");
1260 break;
1261
1262 case ENOENT:
1263 astman_send_error(s, m, "Context does not exist");
1264 break;
1265
1266 case EEXIST:
1267 astman_send_error(s, m, "That extension and priority already exist at that context");
1268 break;
1269
1270 default:
1271 astman_send_error(s, m, "Failed to add extension");
1272 break;
1273 }
1274 return 0;
1275 }
1277
1278 astman_send_ack(s, m, "Added requested extension");
1279
1280 return 0;
1281}
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:980
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:1982
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:2014
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition: manager.c:1643
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:7282
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2235
structure to hold extensions

References ast_add_extension2(), ast_context_find_or_create(), ast_free_ptr(), ast_strdup, ast_strdupa, ast_strlen_zero(), ast_true(), ast_unlock_contexts(), ast_wrlock_contexts(), astman_get_header(), astman_send_ack(), astman_send_error(), voicemailpwcheck::context, errno, NULL, priority, PRIORITY_HINT, registrar, replace(), and strsep().

Referenced by load_module().

◆ manager_dialplan_extension_remove()

static int manager_dialplan_extension_remove ( struct mansession s,
const struct message m 
)
static

Definition at line 508 of file pbx_config.c.

509{
510 const char *context = astman_get_header(m, "Context");
511 const char *extension = astman_get_header(m, "Extension");
512 const char *priority = astman_get_header(m, "Priority");
513
514 int ipriority;
515 char *exten;
516 char *cidmatch = NULL;
517
519 astman_send_error(s, m, "Context and Extension must be provided "
520 "for DialplanExtensionRemove");
521 return 0;
522 }
523
524 exten = ast_strdupa(extension);
525
526 if (strchr(exten, '/')) {
527 cidmatch = exten;
528 strsep(&cidmatch, "/");
529 }
530
532 ipriority = 0;
533 } else if (!strcmp("hint", priority)) {
534 ipriority = PRIORITY_HINT;
535 } else if ((sscanf(priority, "%30d", &ipriority) != 1) || ipriority <= 0) {
536 astman_send_error(s, m, "The priority specified was invalid.");
537 return 0;
538 }
539
540 if (!ast_context_remove_extension_callerid(context, exten, ipriority,
541 /* Do not substitute S_OR; it is not the same thing */
542 !ast_strlen_zero(cidmatch) ? cidmatch : (ipriority ? "" : NULL),
543 !ast_strlen_zero(cidmatch) ? 1 : 0, registrar)) {
544 if (ipriority) {
545 astman_send_ack(s, m, "Removed the requested priority from the extension");
546 } else {
547 astman_send_ack(s, m, "Removed the requested extension");
548 }
549 } else {
550 astman_send_error(s, m, "Failed to remove requested extension");
551 }
552
553 return 0;
554}

References ast_context_remove_extension_callerid(), ast_strdupa, ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), voicemailpwcheck::context, NULL, priority, PRIORITY_HINT, registrar, and strsep().

Referenced by load_module().

◆ partial_match()

static int partial_match ( const char *  s,
const char *  word,
int  len 
)
static

match the first 'len' chars of word. len==0 always succeeds

Definition at line 257 of file pbx_config.c.

258{
259 return (len == 0 || !strncmp(s, word, len));
260}
short word

References len().

Referenced by complete_dialplan_add_extension(), complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_context(), complete_dialplan_remove_extension(), complete_dialplan_remove_ignorepat(), and complete_dialplan_remove_include().

◆ pbx_load_config()

static int pbx_load_config ( const char *  config_file)
static

Definition at line 1680 of file pbx_config.c.

1681{
1682 struct ast_config *cfg;
1683 char *end;
1684 char *label;
1685#ifdef LOW_MEMORY
1686 char realvalue[256];
1687#else
1688 char realvalue[8192];
1689#endif
1690 int lastpri = -2;
1691 struct ast_context *con;
1692 struct ast_variable *v;
1693 const char *cxt;
1694 const char *aft;
1695 const char *newpm, *ovsw;
1696 struct ast_flags config_flags = { 0 };
1697 char lastextension[256];
1698 cfg = ast_config_load(config_file, config_flags);
1699 if (!cfg || cfg == CONFIG_STATUS_FILEINVALID)
1700 return 0;
1701
1702 /* Use existing config to populate the PBX table */
1703 static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
1704 write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", "writeprotect"));
1705 if ((aft = ast_variable_retrieve(cfg, "general", "autofallthrough")))
1707 if ((newpm = ast_variable_retrieve(cfg, "general", "extenpatternmatchnew")))
1709 clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
1710 if ((ovsw = ast_variable_retrieve(cfg, "general", "overrideswitch"))) {
1713 }
1714 if (!ast_strlen_zero(ovsw)) {
1716 } else {
1718 }
1719 }
1720
1721 ast_copy_string(userscontext, ast_variable_retrieve(cfg, "general", "userscontext") ?: "default", sizeof(userscontext));
1722
1723 /* ast_variable_browse does not merge multiple [globals] sections */
1724 for (cxt = ast_category_browse(cfg, NULL);
1725 cxt;
1726 cxt = ast_category_browse(cfg, cxt)) {
1727 if (strcasecmp(cxt, "globals")) {
1728 continue;
1729 }
1730
1731 for (v = ast_variable_browse(cfg, cxt); v; v = v->next) {
1732 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
1733 pbx_builtin_setvar_helper(NULL, v->name, realvalue);
1734 }
1735 }
1736
1737 for (cxt = ast_category_browse(cfg, NULL);
1738 cxt;
1739 cxt = ast_category_browse(cfg, cxt)) {
1740 /* All categories but "general" or "globals" are considered contexts */
1741 if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals")) {
1742 continue;
1743 }
1745 continue;
1746 }
1747
1748 /* Reset continuation items at the beginning of each context */
1749 lastextension[0] = '\0';
1750 lastpri = -2;
1751
1752 for (v = ast_variable_browse(cfg, cxt); v; v = v->next) {
1753 char *tc = NULL;
1754 char realext[256] = "";
1755 char *stringp, *ext;
1756 const char *vfile;
1757
1758 /* get filename for error reporting from top level or an #include */
1759 vfile = !*v->file ? config_file : v->file;
1760
1761 if (!strncasecmp(v->name, "same", 4)) {
1762 if (ast_strlen_zero(lastextension)) {
1764 "No previous pattern in the first entry of context '%s' to match '%s' at line %d of %s!\n",
1765 cxt, v->name, v->lineno, vfile);
1766 continue;
1767 }
1768 if ((stringp = tc = ast_strdup(v->value))) {
1769 ast_copy_string(realext, lastextension, sizeof(realext));
1770 goto process_extension;
1771 }
1772 } else if (!strcasecmp(v->name, "exten")) {
1773 int ipri;
1774 char *plus;
1775 char *pri, *appl, *data, *cidmatch;
1776
1777 if (!(stringp = tc = ast_strdup(v->value))) {
1778 continue;
1779 }
1780
1781 ext = S_OR(pbx_strsep(&stringp, ","), "");
1782 pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
1783 ast_copy_string(lastextension, realext, sizeof(lastextension));
1784process_extension:
1785 ipri = -2;
1786 if ((cidmatch = strchr(realext, '/'))) {
1787 *cidmatch++ = '\0';
1788 ast_shrink_phone_number(cidmatch);
1789 }
1790 pri = ast_strip(S_OR(strsep(&stringp, ","), ""));
1791 if ((label = strchr(pri, '('))) {
1792 *label++ = '\0';
1793 if ((end = strchr(label, ')'))) {
1794 *end = '\0';
1795 } else {
1797 "Label missing trailing ')' at line %d of %s\n",
1798 v->lineno, vfile);
1799 ast_free(tc);
1800 continue;
1801 }
1802 }
1803 if ((plus = strchr(pri, '+'))) {
1804 *plus++ = '\0';
1805 }
1806 if (!strcmp(pri,"hint")) {
1807 ipri = PRIORITY_HINT;
1808 } else if (!strcmp(pri, "next") || !strcmp(pri, "n")) {
1809 if (lastpri > -2) {
1810 ipri = lastpri + 1;
1811 } else {
1813 "Can't use 'next' priority on the first entry at line %d of %s!\n",
1814 v->lineno, vfile);
1815 ast_free(tc);
1816 continue;
1817 }
1818 } else if (!strcmp(pri, "same") || !strcmp(pri, "s")) {
1819 if (lastpri > -2) {
1820 ipri = lastpri;
1821 } else {
1823 "Can't use 'same' priority on the first entry at line %d of %s!\n",
1824 v->lineno, vfile);
1825 ast_free(tc);
1826 continue;
1827 }
1828 } else if (sscanf(pri, "%30d", &ipri) != 1 &&
1829 (ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) {
1831 "Invalid priority/label '%s' at line %d of %s\n",
1832 pri, v->lineno, vfile);
1833 ipri = 0;
1834 ast_free(tc);
1835 continue;
1836 } else if (ipri < 1) {
1837 ast_log(LOG_WARNING, "Invalid priority '%s' at line %d of %s\n",
1838 pri, v->lineno, vfile);
1839 ast_free(tc);
1840 continue;
1841 }
1842 appl = S_OR(stringp, "");
1843 /* Find the first occurrence of '(' */
1844 if (!strchr(appl, '(')) {
1845 /* No arguments */
1846 data = "";
1847 } else {
1848 char *orig_appl = ast_strdup(appl);
1849
1850 if (!orig_appl) {
1851 ast_free(tc);
1852 continue;
1853 }
1854
1855 appl = strsep(&stringp, "(");
1856
1857 /* check if there are variables or expressions without an application, like: exten => 100,hint,DAHDI/g0/${GLOBAL(var)} */
1858 if (strstr(appl, "${") || strstr(appl, "$[")){
1859 /* set appl to original one */
1860 strcpy(appl, orig_appl);
1861 /* set no data */
1862 data = "";
1863 /* no variable before application found -> go ahead */
1864 } else {
1865 data = S_OR(stringp, "");
1866 if ((end = strrchr(data, ')'))) {
1867 *end = '\0';
1868 } else {
1870 "No closing parenthesis found? '%s(%s' at line %d of %s\n",
1871 appl, data, v->lineno, vfile);
1872 }
1873 }
1874 ast_free(orig_appl);
1875 }
1876
1877 appl = ast_skip_blanks(appl);
1878 if (ipri) {
1879 const char *registrar_file;
1880 if (plus) {
1881 ipri += atoi(plus);
1882 }
1883 lastpri = ipri;
1884 if (!ast_opt_dont_warn && (!strcmp(realext, "_.") || !strcmp(realext, "_!"))) {
1886 "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",
1887 realext, realext[1], v->lineno, vfile);
1888 }
1889 /* Don't include full path if the configuration file includes slashes */
1890 registrar_file = strrchr(vfile, '/');
1891 if (!registrar_file) {
1892 registrar_file = vfile;
1893 } else {
1894 registrar_file++; /* Skip past the end slash */
1895 }
1896 if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, ast_strdup(data), ast_free_ptr, registrar, registrar_file, v->lineno)) {
1898 "Unable to register extension at line %d of %s\n",
1899 v->lineno, vfile);
1900 }
1901 }
1902 ast_free(tc);
1903 } else if (!strcasecmp(v->name, "include")) {
1904 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
1905 if (ast_context_add_include2(con, realvalue, registrar)) {
1906 switch (errno) {
1907 case ENOMEM:
1908 ast_log(LOG_WARNING, "Out of memory for context addition\n");
1909 break;
1910
1911 case EBUSY:
1912 ast_log(LOG_WARNING, "Failed to lock context(s) list, please try again later\n");
1913 break;
1914
1915 case EEXIST:
1917 "Context '%s' already included in '%s' context on include at line %d of %s\n",
1918 v->value, cxt, v->lineno, vfile);
1919 break;
1920
1921 case ENOENT:
1922 case EINVAL:
1924 "There is no existence of context '%s' included at line %d of %s\n",
1925 errno == ENOENT ? v->value : cxt, v->lineno, vfile);
1926 break;
1927
1928 default:
1930 "Failed to include '%s' in '%s' context at line %d of %s\n",
1931 v->value, cxt, v->lineno, vfile);
1932 break;
1933 }
1934 }
1935 } else if (!strcasecmp(v->name, "ignorepat")) {
1936 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
1937 if (ast_context_add_ignorepat2(con, realvalue, registrar)) {
1939 "Unable to include ignorepat '%s' in context '%s' at line %d of %s\n",
1940 v->value, cxt, v->lineno, vfile);
1941 }
1942 } else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch") || !strcasecmp(v->name, "eswitch")) {
1943 char *appl, *data;
1944 stringp = realvalue;
1945
1946 if (!strcasecmp(v->name, "switch")) {
1947 pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
1948 } else {
1949 ast_copy_string(realvalue, v->value, sizeof(realvalue));
1950 }
1951 appl = strsep(&stringp, "/");
1952 data = S_OR(stringp, "");
1953 if (ast_context_add_switch2(con, appl, data, !strcasecmp(v->name, "eswitch"), registrar)) {
1955 "Unable to include switch '%s' in context '%s' at line %d of %s\n",
1956 v->value, cxt, v->lineno, vfile);
1957 }
1958 } else if (!strcasecmp(v->name, "autohints")) {
1960 } else {
1962 "==!!== Unknown directive: %s at line %d of %s -- IGNORING!!!\n",
1963 v->name, v->lineno, vfile);
1964 }
1965 }
1966 }
1967 ast_config_destroy(cfg);
1968 return 1;
1969}
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
Definition: callerid.c:1101
static const char config_file[]
Definition: cdr_odbc.c:54
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3324
#define CONFIG_STATUS_FILEINVALID
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:869
#define ast_opt_dont_warn
Definition: options.h:135
void ast_context_set_autohints(struct ast_context *con, int enabled)
Enable or disable autohints support on a context.
Definition: pbx.c:6251
int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Add a context include.
Definition: ael_main.c:359
int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
Definition: ael_main.c:348
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.
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)
Definition: ael_main.c:370
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.
Definition: extconf.c:4973
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
Definition: ael_main.c:211
static char * pbx_strsep(char **destructible, const char *delim)
Definition: pbx_config.c:1650
static struct ast_context * local_contexts
Definition: pbx_config.c:117
static char userscontext[AST_MAX_EXTENSION]
Definition: pbx_config.c:104
static struct ast_hashtab * local_table
Definition: pbx_config.c:118
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161

References ast_add_extension2(), ast_category_browse(), ast_config_destroy(), ast_config_load, ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_find_or_create(), ast_context_set_autohints(), ast_copy_string(), ast_findlabel_extension2(), ast_free, ast_free_ptr(), ast_log, ast_opt_dont_warn, ast_shrink_phone_number(), ast_skip_blanks(), ast_strdup, ast_strip(), ast_strlen_zero(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), autofallthrough_config, clearglobalvars_config, config_file, CONFIG_STATUS_FILEINVALID, end, errno, ext, extenpatternmatchnew_config, ast_variable::file, ast_variable::lineno, local_contexts, local_table, LOG_ERROR, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, overrideswitch_config, pbx_builtin_setvar_helper(), pbx_strsep(), pbx_substitute_variables_helper(), PRIORITY_HINT, registrar, S_OR, static_config, strsep(), userscontext, ast_variable::value, and write_protect_config.

Referenced by pbx_load_module().

◆ pbx_load_module()

static int pbx_load_module ( void  )
static

Definition at line 1971 of file pbx_config.c.

1972{
1973 struct ast_context *con;
1974
1976
1977 if (!local_table) {
1979 if (!local_table) {
1982 }
1983 }
1984
1985 if (!pbx_load_config(config)) {
1987 local_table = NULL;
1990 }
1991
1993 local_table = NULL; /* the local table has been moved into the global one. */
1995
1997
1998 for (con = NULL; (con = ast_walk_contexts(con));)
2000
2004
2006}
void ast_hashtab_destroy(struct ast_hashtab *tab, void(*objdestroyfunc)(void *obj))
This func will free the hash table and all its memory.
Definition: hashtab.c:363
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
Definition: hashtab.c:127
#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking)
Create the hashtable list.
Definition: hashtab.h:254
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...
Definition: hashtab.c:84
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
Definition: ael_main.c:589
unsigned int ast_hashtab_hash_contexts(const void *obj)
Definition: ael_main.c:596
void pbx_set_overrideswitch(const char *newval)
Definition: pbx.c:4805
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...
Definition: pbx.c:6447
int pbx_set_extenpatternmatchnew(int newval)
Definition: pbx.c:4798
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
Definition: pbx.c:8757
int pbx_set_autofallthrough(int newval)
Definition: pbx.c:4791
static int pbx_load_config(const char *config_file)
Definition: pbx_config.c:1680
static ast_mutex_t reload_lock
Definition: pbx_config.c:115

References ast_context_verify_includes(), ast_hashtab_compare_contexts(), ast_hashtab_create, ast_hashtab_destroy(), ast_hashtab_hash_contexts(), ast_hashtab_newsize_java(), ast_hashtab_resize_java(), ast_merge_contexts_and_delete(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mutex_lock, ast_mutex_unlock, ast_walk_contexts(), autofallthrough_config, config, extenpatternmatchnew_config, local_contexts, local_table, NULL, overrideswitch_config, pbx_load_config(), pbx_set_autofallthrough(), pbx_set_extenpatternmatchnew(), pbx_set_overrideswitch(), registrar, and reload_lock.

Referenced by handle_cli_dialplan_reload(), load_module(), and reload().

◆ pbx_strsep()

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 1650 of file pbx_config.c.

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

References NULL.

Referenced by pbx_load_config().

◆ reload()

static int reload ( void  )
static

Definition at line 2034 of file pbx_config.c.

2035{
2038 return pbx_load_module();
2039}

References clearglobalvars_config, pbx_builtin_clear_globals(), and pbx_load_module().

◆ skip_words()

static const char * skip_words ( const char *  p,
int  n 
)
static

moves to the n-th word in the string, or empty string if none

Definition at line 242 of file pbx_config.c.

243{
244 int in_blank = 0;
245 for (;n && *p; p++) {
246 if (isblank(*p) /* XXX order is important */ && !in_blank) {
247 n--; /* one word is gone */
248 in_blank = 1;
249 } else if (/* !is_blank(*p), we know already, && */ in_blank) {
250 in_blank = 0;
251 }
252 }
253 return p;
254}

Referenced by complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_extension(), and complete_dialplan_remove_include().

◆ split_ec()

static int split_ec ( const char *  src,
char **  ext,
char **const  ctx,
char **const  cid 
)
static

split extension@context in two parts, return -1 on error. The return string is malloc'ed and pointed by *ext

Definition at line 265 of file pbx_config.c.

266{
267 char *i, *c, *e = ast_strdup(src); /* now src is not used anymore */
268
269 if (e == NULL)
270 return -1; /* malloc error */
271 /* now, parse values from 'exten@context' */
272 *ext = e;
273 c = strchr(e, '@');
274 if (c == NULL) /* no context part */
275 *ctx = ""; /* it is not overwritten, anyways */
276 else { /* found context, check for duplicity ... */
277 *c++ = '\0';
278 *ctx = c;
279 if (strchr(c, '@')) { /* two @, not allowed */
280 ast_free(e);
281 return -1;
282 }
283 }
284 if (cid && (i = strchr(e, '/'))) {
285 *i++ = '\0';
286 *cid = i;
287 } else if (cid) {
288 /* Signal none detected */
289 *cid = NULL;
290 }
291 return 0;
292}

References ast_free, ast_strdup, c, ext, and NULL.

Referenced by complete_dialplan_remove_extension(), and handle_cli_dialplan_remove_extension().

◆ unload_module()

static int unload_module ( void  )
static

Standard module functions ...

Definition at line 1631 of file pbx_config.c.

1632{
1636
1641
1642 return 0;
1643}
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
Definition: main/cli.c:2408
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7695
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:8246

References AMI_EXTENSION_ADD, AMI_EXTENSION_REMOVE, ARRAY_LEN, ast_cli_unregister(), ast_cli_unregister_multiple(), ast_context_destroy(), ast_free, ast_manager_unregister(), cli_dialplan_save, cli_pbx_config, NULL, overrideswitch_config, and registrar.

Referenced by load_module().

Variable Documentation

◆ __mod_info

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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, }
static

Definition at line 2046 of file pbx_config.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 2046 of file pbx_config.c.

◆ autofallthrough_config

int autofallthrough_config = 1
static

Definition at line 108 of file pbx_config.c.

Referenced by handle_cli_dialplan_save(), pbx_load_config(), and pbx_load_module().

◆ clearglobalvars_config

int clearglobalvars_config = 0
static

◆ cli_dialplan_save

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:815

Definition at line 1622 of file pbx_config.c.

Referenced by load_module(), and unload_module().

◆ cli_pbx_config

struct ast_cli_entry cli_pbx_config[]
static

CLI entries for commands provided by this module

Definition at line 1611 of file pbx_config.c.

Referenced by load_module(), and unload_module().

◆ config

const char config[] = "extensions.conf"
static

Definition at line 102 of file pbx_config.c.

Referenced by handle_cli_dialplan_save(), and pbx_load_module().

◆ extenpatternmatchnew_config

int extenpatternmatchnew_config = 0
static

Definition at line 110 of file pbx_config.c.

Referenced by handle_cli_dialplan_save(), pbx_load_config(), and pbx_load_module().

◆ local_contexts

struct ast_context* local_contexts = NULL
static

◆ local_table

struct ast_hashtab* local_table = NULL
static

Definition at line 118 of file pbx_config.c.

Referenced by ast_compile_ael2(), pbx_load_config(), and pbx_load_module().

◆ overrideswitch_config

char* overrideswitch_config = NULL
static

◆ registrar

const char registrar[] = "pbx_config"
static

◆ reload_lock

ast_mutex_t reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
static

Definition at line 115 of file pbx_config.c.

Referenced by pbx_load_module().

◆ save_dialplan_lock

ast_mutex_t save_dialplan_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
static

Definition at line 113 of file pbx_config.c.

Referenced by handle_cli_dialplan_save().

◆ static_config

int static_config = 0
static

Definition at line 106 of file pbx_config.c.

Referenced by handle_cli_dialplan_save(), load_module(), and pbx_load_config().

◆ userscontext

char userscontext[AST_MAX_EXTENSION] = "default"
static

Definition at line 104 of file pbx_config.c.

Referenced by pbx_load_config().

◆ write_protect_config

int write_protect_config = 1
static

Definition at line 107 of file pbx_config.c.

Referenced by handle_cli_dialplan_save(), load_module(), and pbx_load_config().