add support for named sections in zapata.conf, and fix a few bugs in config file parsing
(closes issue #9503) Reported by: tzafrir Patches: fix_cleanups uploaded by tzafrir (license 46) zapata_sections uploaded by tzafrir (license 46) skipchannel_options uploaded by tzafrir (license 46) conf_sample uploaded by tzafrir (license 46) patches updated by me to better conform to coding guidelines and fix some problems git-svn-id: http://svn.digium.com/svn/asterisk/trunk@108286 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
18f3f082ad
commit
faf90b0c03
5
CHANGES
5
CHANGES
|
@ -7,6 +7,11 @@ Dialplan Functions
|
|||
* Added a new dialplan function, AST_CONFIG(), which allows you to access
|
||||
variables from an Asterisk configuration file.
|
||||
|
||||
Zaptel channel driver (chan_zap) Changes
|
||||
----------------------------------------
|
||||
* Channels can now be configured using named sections in zapata.conf, just
|
||||
like other channel drivers, including the use of templates.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
--- Functionality changes from Asterisk 1.4.X to Asterisk 1.6.0 -------------
|
||||
------------------------------------------------------------------------------
|
||||
|
|
|
@ -13196,7 +13196,12 @@ static void process_echocancel(struct zt_chan_conf *confp, const char *data, uns
|
|||
}
|
||||
#endif /* defined(HAVE_ZAPTEL_ECHOCANPARAMS) */
|
||||
|
||||
static int process_zap(struct zt_chan_conf *confp, struct ast_variable *v, int reload, int skipchannels)
|
||||
/*! process_zap() - ignore keyword 'channel' and similar */
|
||||
#define PROC_ZAP_OPT_NOCHAN (1 << 0)
|
||||
/*! process_zap() - No warnings on non-existing cofiguration keywords */
|
||||
#define PROC_ZAP_OPT_NOWARN (1 << 1)
|
||||
|
||||
static int process_zap(struct zt_chan_conf *confp, struct ast_variable *v, int reload, int options)
|
||||
{
|
||||
struct zt_pvt *tmp;
|
||||
const char *ringc; /* temporary string for parsing the dring number. */
|
||||
|
@ -13215,7 +13220,7 @@ static int process_zap(struct zt_chan_conf *confp, struct ast_variable *v, int r
|
|||
#endif
|
||||
) {
|
||||
int iscrv;
|
||||
if (skipchannels)
|
||||
if (options && PROC_ZAP_OPT_NOCHAN)
|
||||
continue;
|
||||
iscrv = !strcasecmp(v->name, "crv");
|
||||
if (build_channels(*confp, iscrv, v->value, reload, v->lineno, &found_pseudo))
|
||||
|
@ -13960,7 +13965,7 @@ static int process_zap(struct zt_chan_conf *confp, struct ast_variable *v, int r
|
|||
} else if (!strcasecmp(v->name, "mwilevel")) {
|
||||
mwilevel = atoi(v->value);
|
||||
}
|
||||
} else if (!skipchannels)
|
||||
} else if (!(options && PROC_ZAP_OPT_NOWARN) )
|
||||
ast_log(LOG_WARNING, "Ignoring %s at line %d.\n", v->name, v->lineno);
|
||||
}
|
||||
if (zapchan[0]) {
|
||||
|
@ -13998,6 +14003,7 @@ static int setup_zap(int reload)
|
|||
struct zt_chan_conf base_conf = zt_chan_conf_default();
|
||||
struct zt_chan_conf conf;
|
||||
struct ast_flags config_flags = { reload == 1 ? CONFIG_FLAG_FILEUNCHANGED : 0 };
|
||||
const char *cat;
|
||||
int res;
|
||||
|
||||
#ifdef HAVE_PRI
|
||||
|
@ -14090,35 +14096,74 @@ static int setup_zap(int reload)
|
|||
#endif
|
||||
|
||||
/* Copy the default jb config over global_jbconf */
|
||||
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
|
||||
memcpy(&global_jbconf, &default_jbconf, sizeof(global_jbconf));
|
||||
|
||||
mwimonitornotify[0] = '\0';
|
||||
|
||||
v = ast_variable_browse(cfg, "channels");
|
||||
res = process_zap(&base_conf, v, reload, 0);
|
||||
ast_mutex_unlock(&iflock);
|
||||
ast_config_destroy(cfg);
|
||||
if (res)
|
||||
if ((res = process_zap(&base_conf, v, reload, 0))) {
|
||||
ast_mutex_unlock(&iflock);
|
||||
ast_config_destroy(cfg);
|
||||
if (ucfg) {
|
||||
ast_config_destroy(cfg);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Now get configuration from all normal sections in zapata.conf: */
|
||||
for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) {
|
||||
/* [channels] and [trunkgroups] are used. Let's also reserve
|
||||
* [globals] and [general] for future use
|
||||
*/
|
||||
if (!strcasecmp(cat, "general") ||
|
||||
!strcasecmp(cat, "trunkgroups") ||
|
||||
!strcasecmp(cat, "globals") ||
|
||||
!strcasecmp(cat, "channels")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(&conf, &base_conf, sizeof(conf));
|
||||
|
||||
if ((res = process_zap(&conf, ast_variable_browse(cfg, cat), reload, PROC_ZAP_OPT_NOCHAN))) {
|
||||
ast_mutex_unlock(&iflock);
|
||||
ast_config_destroy(cfg);
|
||||
if (ucfg) {
|
||||
ast_config_destroy(cfg);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
ast_config_destroy(cfg);
|
||||
|
||||
if (ucfg) {
|
||||
char *cat;
|
||||
const char *chans;
|
||||
process_zap(&base_conf, ast_variable_browse(ucfg, "general"), 1, 1);
|
||||
|
||||
process_zap(&base_conf, ast_variable_browse(ucfg, "general"), 1, 0);
|
||||
|
||||
for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
|
||||
if (!strcasecmp(cat, "general"))
|
||||
if (!strcasecmp(cat, "general")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chans = ast_variable_retrieve(ucfg, cat, "zapchan");
|
||||
if (!ast_strlen_zero(chans)) {
|
||||
if (memcpy(&conf, &base_conf, sizeof(conf)) == NULL) {
|
||||
ast_log(LOG_ERROR, "Not enough memory for conf copy\n");
|
||||
ast_config_destroy(ucfg);
|
||||
return -1;
|
||||
}
|
||||
process_zap(&conf, ast_variable_browse(ucfg, cat), reload, 0);
|
||||
|
||||
if (ast_strlen_zero(chans)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(&conf, &base_conf, sizeof(conf));
|
||||
|
||||
if ((res = process_zap(&conf, ast_variable_browse(ucfg, cat), reload, PROC_ZAP_OPT_NOCHAN | PROC_ZAP_OPT_NOWARN))) {
|
||||
ast_config_destroy(ucfg);
|
||||
ast_mutex_unlock(&iflock);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
ast_config_destroy(ucfg);
|
||||
}
|
||||
ast_mutex_unlock(&iflock);
|
||||
|
||||
#ifdef HAVE_PRI
|
||||
if (!reload) {
|
||||
int x;
|
||||
|
|
|
@ -915,3 +915,57 @@ pickupgroup=1
|
|||
; For more information on setting up SS7, see the README file in libss7 or
|
||||
; the doc/ss7.txt file in the Asterisk source tree.
|
||||
; ----------------- SS7 Options ----------------------------------------
|
||||
|
||||
; Configuration Sections
|
||||
; ~~~~~~~~~~~~~~~~~~~~~~
|
||||
; You can also configure channels in a separate zapata.conf section. In
|
||||
; this case the keyword 'channel' is not used. Instead the keyword
|
||||
; 'zapchan' is used (as in users.conf) - configuration is only processed
|
||||
; in a section where the keyword zapchan is used. It will only be
|
||||
; processed in the end of the section. Thus the following section:
|
||||
;
|
||||
;[phones]
|
||||
;echocancel = 64
|
||||
;zapchan = 1-8
|
||||
;group = 1
|
||||
;
|
||||
; Is somewhat equivalent to the following snippet in the section
|
||||
; [channels]:
|
||||
;
|
||||
;echocancel = 64
|
||||
;group = 1
|
||||
;channel => 1-8
|
||||
;
|
||||
; When starting a new section almost all of the configuration values are
|
||||
; copied from their values at the end of the section [channels] in
|
||||
; zapata.conf and [general] in users.conf - one section's configuration
|
||||
; does not affect another one's.
|
||||
;
|
||||
; Instead of letting common configuration values "slide through" you can
|
||||
; use configuration templates to easily keep the common part in one
|
||||
; place and override where needed.
|
||||
;
|
||||
;[phones](!)
|
||||
;echocancel = yes
|
||||
;group = 0,4
|
||||
;callgroup = 3
|
||||
;pickupgroup = 3
|
||||
;threewaycalling = yes
|
||||
;transfer = yes
|
||||
;context = phones
|
||||
;faxdetect = incoming
|
||||
;
|
||||
;[phone-1](phones)
|
||||
;zapchan = 1
|
||||
;callerid = My Name <501>
|
||||
;mailbox = 501@mailboxes
|
||||
;
|
||||
;
|
||||
;[fax](phones)
|
||||
;zapchan = 2
|
||||
;faxdetect = no
|
||||
;context = fax
|
||||
;
|
||||
;[phone-3](phones)
|
||||
;zapchan = 3
|
||||
;pickupgroup = 3,4
|
||||
|
|
Reference in New Issue