[asterisk-commits] branch russell/config-macros - r7295 in
/team/russell/config-macros: ./ chann...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Dec 2 17:53:54 CST 2005
Author: russell
Date: Fri Dec 2 17:53:50 2005
New Revision: 7295
URL: http://svn.digium.com/view/asterisk?rev=7295&view=rev
Log:
convert build_user to use config parsing macros
Modified:
team/russell/config-macros/acl.c
team/russell/config-macros/channel.c
team/russell/config-macros/channels/chan_iax2.c
team/russell/config-macros/channels/chan_oss.c
team/russell/config-macros/channels/chan_sip.c
team/russell/config-macros/include/asterisk/acl.h
team/russell/config-macros/include/asterisk/channel.h
team/russell/config-macros/include/asterisk/config.h
Modified: team/russell/config-macros/acl.c
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/acl.c?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/acl.c (original)
+++ team/russell/config-macros/acl.c Fri Dec 2 17:53:50 2005
@@ -247,7 +247,7 @@
return 0;
}
-int ast_str2tos(const char *value, int *tos, int lineno, const char *file)
+int ast_str2tos(const char *value, int *tos)
{
int fval;
@@ -264,10 +264,10 @@
else if (!strcasecmp(value, "none"))
*tos = 0;
else {
- ast_log(LOG_WARNING, "Invalid tos value at line '%d' of '%s', should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", lineno, file);
- return -1;
- }
-
+ ast_log(LOG_WARNING, "Invalid tos value - '%s', should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", value);
+ return -1;
+ }
+
return 0;
}
Modified: team/russell/config-macros/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/channel.c?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/channel.c (original)
+++ team/russell/config-macros/channel.c Fri Dec 2 17:53:50 2005
@@ -3685,7 +3685,7 @@
return 0;
}
-ast_group_t ast_get_group(char *s)
+ast_group_t ast_get_group(const char *s)
{
char *copy;
char *piece;
Modified: team/russell/config-macros/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/channels/chan_iax2.c?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/channels/chan_iax2.c (original)
+++ team/russell/config-macros/channels/chan_iax2.c Fri Dec 2 17:53:50 2005
@@ -8609,7 +8609,7 @@
/* Seed initial tos value */
tosval = ast_variable_retrieve(cfg, "general", "tos");
if (tosval)
- ast_str2tos(tosval, &tos, 0, __FILE__);
+ ast_str2tos(tosval, &tos);
while (v) {
if (!strcasecmp(v->name, "bindport")){
Modified: team/russell/config-macros/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/channels/chan_oss.c?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/channels/chan_oss.c (original)
+++ team/russell/config-macros/channels/chan_oss.c Fri Dec 2 17:53:50 2005
@@ -1299,8 +1299,8 @@
AST_CONFIG_STR("context", o->ctx)
AST_CONFIG_STR("language", o->language)
AST_CONFIG_STR("extension", o->ext)
- AST_CONFIG_CUSTOM("mixer", store_mixer(o, val))
- AST_CONFIG_CUSTOM("callerid", store_callerid(o, val))
+ AST_CONFIG_CUSTOM("mixer", store_mixer(o, value))
+ AST_CONFIG_CUSTOM("callerid", store_callerid(o, value))
AST_CONFIG_PARSE_END
if (ast_strlen_zero(o->device))
Modified: team/russell/config-macros/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/channels/chan_sip.c?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/channels/chan_sip.c (original)
+++ team/russell/config-macros/channels/chan_sip.c Fri Dec 2 17:53:50 2005
@@ -600,19 +600,19 @@
AST_CONFIG_VAL_FLAG_DIRECT("rfc2833", dst, SIP_DTMF_RFC2833) \
AST_CONFIG_VAL_FLAG_DIRECT("info", dst, SIP_DTMF_INFO) \
AST_CONFIG_VAL_FLAG_DIRECT("auto", dst, SIP_DTMF_AUTO) \
- AST_CONFIG_VAL_DEFAULT_FLAG(dst, SIP_DTMF_RFC2833, ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n", val)) \
+ AST_CONFIG_VAL_DEFAULT_FLAG(dst, SIP_DTMF_RFC2833, ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n", value)) \
AST_CONFIG_CHECK_VAL_END \
AST_CONFIG_CHECK_VAL_BEGIN("nat") \
AST_CONFIG_VAL_FLAG_DIRECT("never", dst, SIP_NAT_NEVER) \
AST_CONFIG_VAL_FLAG_DIRECT("route", dst, SIP_NAT_ROUTE) \
AST_CONFIG_VAL_FLAG_DIRECT("rfc3581", dst, SIP_NAT_RFC3581) \
AST_CONFIG_VAL_FLAG(dst, SIP_NAT_ALWAYS) \
- AST_CONFIG_VAL_DEFAULT_FLAG(dst, SIP_NAT_RFC3581, ast_log(LOG_WARNING, "Unkown nat mode '%s', using rfc3581\n", val)) \
+ AST_CONFIG_VAL_DEFAULT_FLAG(dst, SIP_NAT_RFC3581, ast_log(LOG_WARNING, "Unkown nat mode '%s', using rfc3581\n", value)) \
AST_CONFIG_CHECK_VAL_END \
AST_CONFIG_CHECK_VAL_BEGIN("canreinvite") \
AST_CONFIG_VAL_FLAG_DIRECT("update", dst, SIP_REINVITE_UPDATE | SIP_CAN_REINVITE) \
AST_CONFIG_VAL_FLAG(dst, SIP_CAN_REINVITE) \
- AST_CONFIG_VAL_DEFAULT(ast_log(LOG_WARNING, "Unknown canreinvite setting '%s'\n", val)) \
+ AST_CONFIG_VAL_DEFAULT(ast_log(LOG_WARNING, "Unknown canreinvite setting '%s'\n", value)) \
AST_CONFIG_CHECK_VAL_END \
AST_CONFIG_CHECK_VAL_BEGIN("insecure") \
AST_CONFIG_VAL_FLAG_DIRECT("very", dst, SIP_INSECURE_PORTINVITE) \
@@ -621,7 +621,7 @@
AST_CONFIG_VAL_FLAG_DIRECT("invite", dst, SIP_INSECURE_INVITE) \
AST_CONFIG_VAL_FLAG_DIRECT("port,invite", dst, SIP_INSECURE_PORTINVITE) \
AST_CONFIG_VAL_FLAG_DIRECT("invite,port", dst, SIP_INSECURE_PORTINVITE) \
- AST_CONFIG_VAL_DEFAULT(ast_log(LOG_WARNING, "Unknown insecure mode '%s'\n", val)) \
+ AST_CONFIG_VAL_DEFAULT(ast_log(LOG_WARNING, "Unknown insecure mode '%s'\n", value)) \
AST_CONFIG_CHECK_VAL_END \
AST_CONFIG_CHECK_VAL_BEGIN("progressinband") \
AST_CONFIG_VAL_FLAG(dst, SIP_PROG_INBAND_YES) \
@@ -629,7 +629,7 @@
AST_CONFIG_CHECK_VAL_END \
AST_CONFIG_CHECK_VAL_BEGIN("allowguest") \
OSP_ALLOWGUEST_OPTION \
- AST_CONFIG_VAL_DEFAULT(global_allowguest = ast_true(val)) \
+ AST_CONFIG_VAL_DEFAULT(global_allowguest = ast_true(value)) \
AST_CONFIG_CHECK_VAL_END \
OSP_AUTH_OPTIONS
@@ -969,7 +969,7 @@
static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static int sip_senddigit(struct ast_channel *ast, char digit);
static int clear_realm_authentication(struct sip_auth *authlist); /* Clear realm authentication list (at reload) */
-static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno); /* Add realm authentication in list */
+static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, const char *configuration, int lineno); /* Add realm authentication in list */
static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, char *realm); /* Find authentication for a specific realm */
static int check_sip_domain(const char *domain, char *context, size_t len); /* Check if domain is one of our local domains */
static void append_date(struct sip_request *req); /* Append date to SIP packet */
@@ -1852,8 +1852,6 @@
tmp = tmp->next;
}
-
-
user = build_user(username, var, !ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS));
if (!user) { /* No user found */
@@ -11780,7 +11778,7 @@
/*! \brief add_realm_authentication: Add realm authentication in list ---*/
-static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno)
+static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, const char *configuration, int lineno)
{
char authcopy[256];
char *username=NULL, *realm=NULL, *secret=NULL, *md5secret=NULL;
@@ -11876,19 +11874,57 @@
return a;
}
+void parse_setvar(const char *value, int lineno, struct ast_variable **varlist)
+{
+ char *varname, *varval;
+ struct ast_variable *newvar;
+
+ varval = ast_strdupa(value);
+ if (!varval) {
+ ast_log(LOG_ERROR, "Out of memory!\n");
+ return;
+ }
+
+ varname = strsep(&varval, "=");
+ if (!varval) {
+ ast_log(LOG_WARNING, "No value specified for variable '%s' at line '%d' - ignoring!\n", value, lineno);
+ }
+
+ newvar = ast_variable_new(varname, varval);
+ if (newvar) {
+ newvar->next = *varlist;
+ *varlist = newvar;
+ }
+}
+
+void parse_amaflags(const char *value, int lineno, int *dst)
+{
+ int flags;
+
+ flags = ast_cdr_amaflags2int(value);
+
+ if (flags < 0) {
+ ast_log(LOG_WARNING, "Invalid AMA Flags '%s' at line '%d'\n", value, lineno);
+ } else {
+ *dst = flags;
+ }
+}
+
+void parse_callingpres(const char *value, int *dst)
+{
+ *dst = ast_parse_caller_presentation(value);
+
+ if (*dst == -1)
+ *dst = atoi(value);
+}
+
/*! \brief build_user: Initiate a SIP user structure from sip.conf ---*/
static struct sip_user *build_user(const char *name, struct ast_variable *v, int realtime)
{
struct sip_user *user;
- int format;
struct ast_ha *oldha = NULL;
- char *varname = NULL, *varval = NULL;
- struct ast_variable *tmpvar = NULL;
- struct ast_flags userflags = {(0)};
- struct ast_flags mask = {(0)};
-
-
- user = (struct sip_user *)malloc(sizeof(struct sip_user));
+
+ user = malloc(sizeof(struct sip_user));
if (!user) {
return NULL;
}
@@ -11905,72 +11941,33 @@
strcpy(user->context, default_context);
strcpy(user->language, default_language);
strcpy(user->musicclass, global_musicclass);
- while(v) {
- if (handle_common_options(&userflags, &mask, v)) {
- v = v->next;
- continue;
- }
-
- if (!strcasecmp(v->name, "context")) {
- ast_copy_string(user->context, v->value, sizeof(user->context));
- } else if (!strcasecmp(v->name, "subscribecontext")) {
- ast_copy_string(user->subscribecontext, v->value, sizeof(user->subscribecontext));
- } else if (!strcasecmp(v->name, "setvar")) {
- varname = ast_strdupa(v->value);
- if (varname && (varval = strchr(varname,'='))) {
- *varval = '\0';
- varval++;
- if ((tmpvar = ast_variable_new(varname, varval))) {
- tmpvar->next = user->chanvars;
- user->chanvars = tmpvar;
- }
- }
- } else if (!strcasecmp(v->name, "permit") ||
- !strcasecmp(v->name, "deny")) {
- user->ha = ast_append_ha(v->name, v->value, user->ha);
- } else if (!strcasecmp(v->name, "secret")) {
- ast_copy_string(user->secret, v->value, sizeof(user->secret));
- } else if (!strcasecmp(v->name, "md5secret")) {
- ast_copy_string(user->md5secret, v->value, sizeof(user->md5secret));
- } else if (!strcasecmp(v->name, "callerid")) {
- ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
- } else if (!strcasecmp(v->name, "callgroup")) {
- user->callgroup = ast_get_group(v->value);
- } else if (!strcasecmp(v->name, "pickupgroup")) {
- user->pickupgroup = ast_get_group(v->value);
- } else if (!strcasecmp(v->name, "language")) {
- ast_copy_string(user->language, v->value, sizeof(user->language));
- } else if (!strcasecmp(v->name, "musicclass") || !strcasecmp(v->name, "musiconhold")) {
- ast_copy_string(user->musicclass, v->value, sizeof(user->musicclass));
- } else if (!strcasecmp(v->name, "accountcode")) {
- ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
- } else if (!strcasecmp(v->name, "call-limit") || !strcasecmp(v->name, "incominglimit")) {
- user->call_limit = atoi(v->value);
- if (user->call_limit < 0)
- user->call_limit = 0;
- } else if (!strcasecmp(v->name, "amaflags")) {
- format = ast_cdr_amaflags2int(v->value);
- if (format < 0) {
- ast_log(LOG_WARNING, "Invalid AMA Flags: %s at line %d\n", v->value, v->lineno);
- } else {
- user->amaflags = format;
- }
- } else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 1);
- } else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 0);
- } else if (!strcasecmp(v->name, "callingpres")) {
- user->callingpres = ast_parse_caller_presentation(v->value);
- if (user->callingpres == -1)
- user->callingpres = atoi(v->value);
- }
- /*else if (strcasecmp(v->name,"type"))
- * ast_log(LOG_WARNING, "Ignoring %s\n", v->name);
- */
- v = v->next;
- }
- ast_copy_flags(user, &userflags, mask.flags);
+
+ AST_CONFIG_PARSE_VARS_BEGIN(v)
+ SIP_COMMON_OPTIONS(user)
+ AST_CONFIG_STR("context", user->context)
+ AST_CONFIG_STR("subscribecontext", user->subscribecontext)
+ AST_CONFIG_CUSTOM("setvar", parse_setvar(value, lineno, &user->chanvars))
+ AST_CONFIG_CUSTOM("permit", user->ha = ast_append_ha("permit", value, user->ha))
+ AST_CONFIG_CUSTOM("deny", user->ha = ast_append_ha("deny", value, user->ha))
+ AST_CONFIG_STR("secret", user->secret)
+ AST_CONFIG_STR("md5secret", user->md5secret)
+ AST_CONFIG_CUSTOM("callerid", ast_callerid_split(value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num)))
+ AST_CONFIG_GROUP("callgroup", user->callgroup)
+ AST_CONFIG_GROUP("pickupgroup", user->pickupgroup)
+ AST_CONFIG_STR("language", user->language)
+ AST_CONFIG_STR("musicclass", user->musicclass)
+ AST_CONFIG_STR("musiconhold", user->musicclass)
+ AST_CONFIG_STR("accountcode", user->accountcode)
+ AST_CONFIG_INT("call-limit", &user->call_limit, 0, 0)
+ AST_CONFIG_INT("incominglimit", &user->call_limit, 0, 0)
+ AST_CONFIG_CUSTOM("amaflags", parse_amaflags(value, lineno, &user->amaflags))
+ AST_CONFIG_CUSTOM("allow", ast_parse_allow_disallow(&user->prefs, &user->capability, value, 1))
+ AST_CONFIG_CUSTOM("disallow", ast_parse_allow_disallow(&user->prefs, &user->capability, value, 0))
+ AST_CONFIG_CUSTOM("callingpres", parse_callingpres(value, &user->callingpres))
+ AST_CONFIG_PARSE_END
+
ast_free_ha(oldha);
+
return user;
}
@@ -12022,7 +12019,6 @@
struct ast_variable *tmpvar = NULL;
struct ast_flags peerflags = {(0)};
struct ast_flags mask = {(0)};
-
if (!realtime)
/* Note we do NOT use find_peer here, to avoid realtime recursion */
@@ -12274,88 +12270,88 @@
return peer;
}
-void parse_rtautoclear(const char *val)
+void parse_rtautoclear(const char *value)
{
int i;
- i = atoi(val);
+ i = atoi(value);
if (i > 0)
global_rtautoclear = i;
else
i = 0;
- ast_set2_flag((&global_flags_page2), i || ast_true(val), SIP_PAGE2_RTAUTOCLEAR);
-}
-
-void parse_regcontext(const char *val)
-{
- ast_copy_string(regcontext, val, sizeof(regcontext));
+ ast_set2_flag((&global_flags_page2), i || ast_true(value), SIP_PAGE2_RTAUTOCLEAR);
+}
+
+void parse_regcontext(const char *value)
+{
+ ast_copy_string(regcontext, value, sizeof(regcontext));
/* Create context if it doesn't exist already */
if (!ast_context_find(regcontext))
ast_context_create(NULL, regcontext, channeltype);
}
-void parse_outboundproxy(const char *val)
-{
- if (ast_get_ip_or_srv(&outboundproxyip, val, "_sip._udp") < 0)
- ast_log(LOG_WARNING, "Unable to locate host '%s'\n", val);
-}
-
-void parse_outboundproxyport(const char *val)
+void parse_outboundproxy(const char *value)
+{
+ if (ast_get_ip_or_srv(&outboundproxyip, value, "_sip._udp") < 0)
+ ast_log(LOG_WARNING, "Unable to locate host '%s'\n", value);
+}
+
+void parse_outboundproxyport(const char *value)
{
int port;
/* Port needs to be after IP */
- if (sscanf(val, "%d", &port) != 1)
+ if (sscanf(value, "%d", &port) != 1)
port = 5060;
outboundproxyip.sin_port = htons(port);
}
-void parse_bindaddr(const char *val)
+void parse_bindaddr(const char *value)
{
struct hostent *hp;
struct ast_hostent ahp;
- if (!(hp = ast_gethostbyname(val, &ahp))) {
- ast_log(LOG_WARNING, "Invalid address: %s\n", val);
+ if (!(hp = ast_gethostbyname(value, &ahp))) {
+ ast_log(LOG_WARNING, "Invalid address for binaddr: '%s'\n", value);
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
}
}
-void parse_localnet(const char *val)
+void parse_localnet(const char *value)
{
struct ast_ha *na;
- if (!(na = ast_append_ha("d", val, localaddr)))
- ast_log(LOG_WARNING, "Invalid localnet value: %s\n", val);
+ if (!(na = ast_append_ha("d", value, localaddr)))
+ ast_log(LOG_WARNING, "Invalid localnet value: %s\n", value);
else
localaddr = na;
}
-void parse_externip(const char *val)
+void parse_externip(const char *value)
{
struct hostent *hp;
struct ast_hostent ahp;
- if (!(hp = ast_gethostbyname(val, &ahp)))
- ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", val);
+ if (!(hp = ast_gethostbyname(value, &ahp)))
+ ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", value);
else
memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
externexpire = 0;
}
-void parse_externhost(const char *val)
+void parse_externhost(const char *value)
{
struct hostent *hp;
struct ast_hostent ahp;
- ast_copy_string(externhost, val, sizeof(externhost));
+ ast_copy_string(externhost, value, sizeof(externhost));
if (!(hp = ast_gethostbyname(externhost, &ahp)))
ast_log(LOG_WARNING, "Invalid address for externhost keyword: %s\n", externhost);
@@ -12365,12 +12361,12 @@
time(&externexpire);
}
-void parse_domain(const char *val, int lineno)
-{
- char *domain = ast_strdupa(val);
- char *context = strchr(domain, ',');
-
- context = ast_strdupa(val);
+void parse_domain(const char *value, int lineno)
+{
+ char *domain;
+ char *context;
+
+ context = ast_strdupa(value);
if (!context) {
ast_log(LOG_ERROR, "Out of Memory!\n");
return;
@@ -12386,12 +12382,12 @@
add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, ast_strip(context));
}
-void parse_bindport(const char *val, int lineno)
-{
- if (sscanf(val, "%d", &ourport) == 1) {
+void parse_bindport(const char *value, int lineno)
+{
+ if (sscanf(value, "%d", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
} else {
- ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", val, lineno, config);
+ ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", value, lineno, config);
}
}
@@ -12404,7 +12400,6 @@
static int reload_config(void)
{
struct ast_config *cfg;
- struct ast_variable *v;
struct sip_peer *peer;
struct sip_user *user;
char *cat;
@@ -12482,14 +12477,14 @@
AST_CONFIG_FLAG("rtcachefriends", &global_flags_page2, SIP_PAGE2_RTCACHEFRIENDS)
AST_CONFIG_FLAG("rtupdate", &global_flags_page2, SIP_PAGE2_RTUPDATE)
AST_CONFIG_FLAG("ignoregexpire", &global_flags_page2, SIP_PAGE2_IGNOREREGEXPIRE)
- AST_CONFIG_CUSTOM("rtautoclear", parse_rtautoclear(val))
+ AST_CONFIG_CUSTOM("rtautoclear", parse_rtautoclear(value))
AST_CONFIG_FLAG("usereqphone", &global_flags, SIP_USEREQPHONE)
AST_CONFIG_BOOL("relaxdtmf", relaxdtmf)
- AST_CONFIG_UINT("checkmwi", global_mwitime)
+ AST_CONFIG_INT("checkmwi", &global_mwitime, 0, DEFAULT_MWITIME)
AST_CONFIG_STR("vmexten", global_vmexten)
- AST_CONFIG_UINT("rtptimeout", global_rtptimeout)
- AST_CONFIG_UINT("rtpholdtimeout", global_rtpholdtimeout)
- AST_CONFIG_UINT("rtpkeepalive", global_rtpkeepalive)
+ AST_CONFIG_INT("rtptimeout", &global_rtptimeout, 0, 0)
+ AST_CONFIG_INT("rtpholdtimeout", &global_rtpholdtimeout, 0, 0)
+ AST_CONFIG_INT("rtpkeepalive", &global_rtpkeepalive, 0, 0)
AST_CONFIG_BOOL("videosupport", videosupport)
AST_CONFIG_BOOL("compactheaders", compactheaders)
AST_CONFIG_STR("notifymimetype", default_notifymime)
@@ -12497,38 +12492,37 @@
AST_CONFIG_STR("musicclass", global_musicclass)
AST_CONFIG_STR("musiconhold", global_musicclass)
AST_CONFIG_STR("language", default_language)
- AST_CONFIG_CUSTOM("regcontext", parse_regcontext(val))
+ AST_CONFIG_CUSTOM("regcontext", parse_regcontext(value))
AST_CONFIG_STR("callerid", default_callerid)
AST_CONFIG_STR("fromdomain", default_fromdomain)
- AST_CONFIG_CUSTOM("outboundproxy", parse_outboundproxy(val))
- AST_CONFIG_CUSTOM("outboundproxyport", parse_outboundproxyport(val))
+ AST_CONFIG_CUSTOM("outboundproxy", parse_outboundproxy(value))
+ AST_CONFIG_CUSTOM("outboundproxyport", parse_outboundproxyport(value))
AST_CONFIG_BOOL("autocreatepeer", autocreatepeer)
AST_CONFIG_BOOL("srvlookup", srvlookup)
AST_CONFIG_BOOL("pedantic", pedanticsipchecking)
- AST_CONFIG_UINT("maxexpirey", max_expiry)
- AST_CONFIG_UINT("maxexpiry", max_expiry)
- AST_CONFIG_UINT("defaultexpirey", default_expiry)
- AST_CONFIG_UINT("defaultexpiry", default_expiry)
- AST_CONFIG_CUSTOM("sipdebug", if (ast_true(val)) sipdebug |= SIP_DEBUG_CONFIG)
+ AST_CONFIG_INT("maxexpirey", &max_expiry, 1, DEFAULT_MAX_EXPIRY)
+ AST_CONFIG_INT("maxexpiry", &max_expiry, 1, DEFAULT_MAX_EXPIRY)
+ AST_CONFIG_INT("defaultexpirey", &default_expiry, 1, DEFAULT_DEFAULT_EXPIRY)
+ AST_CONFIG_INT("defaultexpiry", &default_expiry, 1, DEFAULT_DEFAULT_EXPIRY)
+ AST_CONFIG_CUSTOM("sipdebug", if (ast_true(value)) sipdebug |= SIP_DEBUG_CONFIG)
AST_CONFIG_BOOL("dumphistory", dumphistory)
AST_CONFIG_BOOL("recordhistory", recordhistory)
- /* XXX a lot of these UINT opts want something > 1, and a default val otherwise ... XXX */
- AST_CONFIG_UINT("registertimeout", global_reg_timeout)
+ AST_CONFIG_INT("registertimeout", &global_reg_timeout, 1, DEFAULT_REGISTRATION_TIMEOUT)
AST_CONFIG_BOOL("registerattempts", global_regattempts_max)
- AST_CONFIG_CUSTOM("bindaddr", parse_bindaddr(val))
- AST_CONFIG_CUSTOM("localnet", parse_localnet(val))
+ AST_CONFIG_CUSTOM("bindaddr", parse_bindaddr(value))
+ AST_CONFIG_CUSTOM("localnet", parse_localnet(value))
AST_CONFIG_CUSTOM("localmask", ast_log(LOG_WARNING, "Use of localmask is no long supported -- use localnet with mask syntax\n"))
- AST_CONFIG_CUSTOM("externip", parse_externip(val))
- AST_CONFIG_CUSTOM("externhost", parse_externhost(val))
- AST_CONFIG_UINT("externrefresh", externrefresh)
- AST_CONFIG_CUSTOM("allow", ast_parse_allow_disallow(&prefs, &global_capability, val, 1))
- AST_CONFIG_CUSTOM("disallow", ast_parse_allow_disallow(&prefs, &global_capability, val, 0))
+ AST_CONFIG_CUSTOM("externip", parse_externip(value))
+ AST_CONFIG_CUSTOM("externhost", parse_externhost(value))
+ AST_CONFIG_INT("externrefresh", &externrefresh, 0, 10)
+ AST_CONFIG_CUSTOM("allow", ast_parse_allow_disallow(&prefs, &global_capability, value, 1))
+ AST_CONFIG_CUSTOM("disallow", ast_parse_allow_disallow(&prefs, &global_capability, value, 0))
AST_CONFIG_BOOL("allowexternaldomains", allow_external_domains)
AST_CONFIG_BOOL("autodomain", auto_sip_domains)
- AST_CONFIG_CUSTOM("domain", parse_domain(val, lineno))
- AST_CONFIG_CUSTOM("register", sip_register(val, lineno))
- AST_CONFIG_CUSTOM("tos", ast_str2tos(val, &tos, lineno, __FILE__))
- AST_CONFIG_CUSTOM("bindport", parse_bindport(val, lineno))
+ AST_CONFIG_CUSTOM("domain", parse_domain(value, lineno))
+ AST_CONFIG_CUSTOM("register", sip_register(value, lineno))
+ AST_CONFIG_CUSTOM("tos", ast_str2tos(value, &tos))
+ AST_CONFIG_CUSTOM("bindport", parse_bindport(value, lineno))
AST_CONFIG_CHECK_VAL_BEGIN("qualify")
AST_CONFIG_VAL_CUSTOM("no", default_qualify = 0)
AST_CONFIG_VAL_CUSTOM("yes", default_qualify = DEFAULT_MAXMS)
@@ -12543,13 +12537,9 @@
}
/* Build list of authentication to various SIP realms, i.e. service providers */
- v = ast_variable_browse(cfg, "authentication");
- for (; v; v = v->next) {
- /* Format for authentication is auth = username:password at realm */
- if (!strcasecmp(v->name, "auth")) {
- authl = add_realm_authentication(authl, v->value, v->lineno);
- }
- }
+ AST_CONFIG_PARSE_BEGIN(cfg, "authentication")
+ AST_CONFIG_CUSTOM("auth", authl = add_realm_authentication(authl, value, lineno))
+ AST_CONFIG_PARSE_END
/* Load peers, users and friends */
cat = ast_category_browse(cfg, NULL);
Modified: team/russell/config-macros/include/asterisk/acl.h
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/include/asterisk/acl.h?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/include/asterisk/acl.h (original)
+++ team/russell/config-macros/include/asterisk/acl.h Fri Dec 2 17:53:50 2005
@@ -47,7 +47,7 @@
extern int ast_lookup_iface(char *iface, struct in_addr *address);
extern struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
extern int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
-extern int ast_str2tos(const char *value, int *tos, int lineno, const char *file);
+extern int ast_str2tos(const char *value, int *tos);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/russell/config-macros/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/include/asterisk/channel.h?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/include/asterisk/channel.h (original)
+++ team/russell/config-macros/include/asterisk/channel.h Fri Dec 2 17:53:50 2005
@@ -1193,7 +1193,7 @@
ast_set_flag(c, AST_FLAG_BLOCKING); \
} }
-extern ast_group_t ast_get_group(char *s);
+extern ast_group_t ast_get_group(const char *s);
/* print call- and pickup groups into buffer */
extern char *ast_print_group(char *buf, int buflen, ast_group_t group);
Modified: team/russell/config-macros/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/include/asterisk/config.h?rev=7295&r1=7294&r2=7295&view=diff
==============================================================================
--- team/russell/config-macros/include/asterisk/config.h (original)
+++ team/russell/config-macros/include/asterisk/config.h Fri Dec 2 17:53:50 2005
@@ -210,9 +210,10 @@
There are also cases where another function should be called should an option
be found in a configuration file. It would also be common in this case to
need to be able to access to option's value directly. This can be done with
- the variable 'val', which is defined in AST_CONFIG_PARSE_BEGIN.
+ the variable 'value', which is defined in AST_CONFIG_PARSE_BEGIN.
For example:
- AST_CONFIG_CUSTOM("mixer", store_mixer(o, val))
+ AST_CONFIG_CUSTOM("mixer", store_mixer(o, value))
+ Similary, an integer 'lineno' is defined for direct use.
NOTE: It is very important that semicolons *ARE NOT* specified after the use
of any of these macros.
@@ -221,18 +222,16 @@
/*!
\brief Begin parsing options from the given context in the configuration file
that has already been loaded.
-
- If at any point during the parsing of configuration options, the value of of
- the option needs to be directly accessed, it can be done with the variable,
- 'val'.
*/
#define AST_CONFIG_PARSE_BEGIN(cfg, context) \
do { \
struct ast_variable *__v; \
int lineno; \
- const char *val; \
+ const char *value; \
+ const char *name; \
for (__v = ast_variable_browse(cfg, context); __v; __v = __v->next) { \
- val = __v->value; \
+ value = __v->value; \
+ name = __v->name; \
lineno = __v->lineno;
/*!
@@ -242,49 +241,67 @@
*/
#define AST_CONFIG_PARSE_END ; } } while (0);
+#define AST_CONFIG_PARSE_VARS_BEGIN(v) \
+ do { \
+ int lineno; \
+ const char *value; \
+ const char *name; \
+ for (; v; v = v->next) { \
+ value = v->value; \
+ name = v->name; \
+ lineno = v->lineno;
+
#define AST_CONFIG_CHECK(name, tag, f) if (!strcasecmp(name, tag)) { f; } else
/*!
\brief If 'tag' matches the current option, execute the function 'f'.
*/
-#define AST_CONFIG_CUSTOM(tag, f) AST_CONFIG_CHECK(__v->name, tag, f)
+#define AST_CONFIG_CUSTOM(tag, f) AST_CONFIG_CHECK(name, tag, f)
/*!
\brief If 'tag' matches the current option, set 'dst' to the result of ast_true()
*/
-#define AST_CONFIG_BOOL(tag, dst) AST_CONFIG_CUSTOM(tag, (dst) = ast_true(val))
+#define AST_CONFIG_BOOL(tag, dst) AST_CONFIG_CUSTOM(tag, (dst) = ast_true(value))
/*!
\brief If 'tag' matches the current option, set the 'flag' in the 'flags'
member of the structure pointed to by 'dst'.
*/
-#define AST_CONFIG_FLAG(tag, dst, flag) AST_CONFIG_CUSTOM(tag, ast_set2_flag(dst, ast_true(val), flag))
+#define AST_CONFIG_FLAG(tag, dst, flag) AST_CONFIG_CUSTOM(tag, ast_set2_flag(dst, ast_true(value), flag))
/*!
\brief If 'tag' matches the current option, interpret the value as an unsigned
integer and store it in 'dst'.
*/
-#define AST_CONFIG_UINT(tag, dst) AST_CONFIG_CUSTOM(tag, (dst) = strtoul(val, NULL, 0))
+#define AST_CONFIG_UINT(tag, dst) AST_CONFIG_CUSTOM(tag, (dst) = strtoul(value, NULL, 0))
+
+#define AST_CONFIG_INT(tag, dst, min, def) \
+ AST_CONFIG_CUSTOM(tag, if (sscanf(value, "%d", dst) !=1 || *(dst) < min) { \
+ ast_log(LOG_WARNING, "'%s' is an invalid value for option '%s' at line '%d', using default value of '%d'!\n", value, tag, lineno, def); \
+ *(dst) = def; \
+ })
/*!
\brief If 'tag' matches the current option, copy the value directly to 'dst'.
*/
-#define AST_CONFIG_STR(tag, dst) AST_CONFIG_CUSTOM(tag, ast_copy_string(dst, val, sizeof(dst)))
-
-#define AST_CONFIG_CHECK_VAL_BEGIN(tag) if (!strcasecmp(__v->name, tag)) {
+#define AST_CONFIG_STR(tag, dst) AST_CONFIG_CUSTOM(tag, ast_copy_string(dst, value, sizeof(dst)))
+
+#define AST_CONFIG_GROUP(tag, dst) AST_CONFIG_CUSTOM(tag, dst = ast_get_group(value))
+
+#define AST_CONFIG_CHECK_VAL_BEGIN(tag) if (!strcasecmp(name, tag)) {
#define AST_CONFIG_CHECK_VAL_END ; } else
#define AST_CONFIG_VAL_FLAG_DIRECT(tag, dst, flag) \
- AST_CONFIG_CHECK(val, tag, ast_set_flag(dst, flag))
-
-#define AST_CONFIG_VAL_FLAG(dst, flag) if (ast_true(val)) { ast_set_flag(dst, flag); } else
-
-#define AST_CONFIG_VAL_UINT(dst) (dst) = strtoul(val, NULL, 0)
+ AST_CONFIG_CHECK(value, tag, ast_set_flag(dst, flag))
+
+#define AST_CONFIG_VAL_FLAG(dst, flag) if (ast_true(value)) { ast_set_flag(dst, flag); } else
+
+#define AST_CONFIG_VAL_UINT(dst) (dst) = strtoul(value, NULL, 0)
#define AST_CONFIG_VAL_DEFAULT(f) f
-#define AST_CONFIG_VAL_CUSTOM(tag, f) AST_CONFIG_CHECK(val, tag, f)
+#define AST_CONFIG_VAL_CUSTOM(tag, f) AST_CONFIG_CHECK(value, tag, f)
#define AST_CONFIG_VAL_DEFAULT_FLAG(dst, flag, f) \
f; ast_set_flag(dst, flag)
More information about the asterisk-commits
mailing list