diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-22 02:02:57 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-22 02:02:57 +0000 |
commit | d049133c402464ce48b488948884a5e55d8f1314 (patch) | |
tree | d1ec95173218843901be9289c51985462ae26cc3 /channels | |
parent | 5029123572aef744eb12c31d4a2e4b979d4c3d8b (diff) |
simplify register_peer_exten() removing some duplicated code.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@29315 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index cce89c636..bb57c49d6 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1946,32 +1946,32 @@ static void register_peer_exten(struct sip_peer *peer, int onoff) { char multi[256]; char *stringp, *ext, *context; - if (!ast_strlen_zero(global_regcontext)) { + + /* XXX note that global_regcontext is both a global 'enable' flag and + * the name of the global regexten context, if not specified + * individually. + */ + if (ast_strlen_zero(global_regcontext)) + return; ast_copy_string(multi, S_OR(peer->regexten, peer->name), sizeof(multi)); stringp = multi; - while((ext = strsep(&stringp, "&"))) { - if((context = strchr(ext, '@'))) { - context++; + while ((ext = strsep(&stringp, "&"))) { + if ((context = strchr(ext, '@'))) { + *context++ = '\0'; /* split ext@context */ if (!ast_context_find(context)) { ast_log(LOG_WARNING, "Context %s must exist in regcontext= in sip.conf!\n", context); continue; } - ext = strsep(&ext, "@"); - if (onoff) - ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop", - ast_strdup(peer->name), free, "SIP"); - else - ast_context_remove_extension(context, ext, 1, NULL); } else { + context = global_regcontext; + } if (onoff) - ast_add_extension(global_regcontext, 1, ext, 1, NULL, NULL, "Noop", - ast_strdup(peer->name), free, "SIP"); + ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop", + ast_strdup(peer->name), free, "SIP"); else - ast_context_remove_extension(global_regcontext, ext, 1, NULL); - } + ast_context_remove_extension(context, ext, 1, NULL); } - } } /*! \brief Destroy peer object from memory */ |