summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-04-10 10:22:42 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-04-10 10:22:42 +0000
commit104c2b0a3a6ff2788460b8459927752b1fa960ef (patch)
tree1fdec63a0d2b68dbe7dc4fdaf89d67d2bd1c607d /channels
parent9b4e33543973b6d6b4b62a4831f2b4a0e7e0b502 (diff)
more cleanup: remove useless braces, replace "if" with "?",
localize a couple of variables, remove trailing whitespace. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@18786 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 4b408e43c..abee70e6d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2918,26 +2918,20 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
tmp->cid.cid_dnid = ast_strdup(i->exten);
tmp->priority = 1;
- if (!ast_strlen_zero(i->uri)) {
+ if (!ast_strlen_zero(i->uri))
pbx_builtin_setvar_helper(tmp, "SIPURI", i->uri);
- }
- if (!ast_strlen_zero(i->domain)) {
+ if (!ast_strlen_zero(i->domain))
pbx_builtin_setvar_helper(tmp, "SIPDOMAIN", i->domain);
- }
- if (!ast_strlen_zero(i->useragent)) {
+ if (!ast_strlen_zero(i->useragent))
pbx_builtin_setvar_helper(tmp, "SIPUSERAGENT", i->useragent);
- }
- if (!ast_strlen_zero(i->callid)) {
+ if (!ast_strlen_zero(i->callid))
pbx_builtin_setvar_helper(tmp, "SIPCALLID", i->callid);
- }
ast_setstate(tmp, state);
- if (state != AST_STATE_DOWN) {
- if (ast_pbx_start(tmp)) {
- ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
- tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
- ast_hangup(tmp);
- tmp = NULL;
- }
+ if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
+ ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
+ tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+ ast_hangup(tmp);
+ tmp = NULL;
}
/* Set channel variables for this call from configuration */
for (v = i->chanvars ; v ; v = v->next)
@@ -2963,10 +2957,9 @@ static char *get_sdp(struct sip_request *req, char *name)
{
int x;
int len = strlen(name);
- char *r;
for (x = 0; x < req->lines; x++) {
- r = get_sdp_by_line(req->line[x], name, len);
+ char *r = get_sdp_by_line(req->line[x], name, len);
if (r[0] != '\0')
return r;
}
@@ -2983,10 +2976,9 @@ static char* get_sdp_iterate(int* iterator,
struct sip_request *req, char *name)
{
int len = strlen(name);
- char *r;
while (*iterator < req->lines) {
- r = get_sdp_by_line(req->line[(*iterator)++], name, len);
+ char *r = get_sdp_by_line(req->line[(*iterator)++], name, len);
if (r[0] != '\0')
return r;
}
@@ -3274,11 +3266,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
ast_set_flag(req, SIP_PKT_WITH_TOTAG); /* Used in handle_request/response */
gettag(req, "From", fromtag, sizeof(fromtag));
- if (req->method == SIP_RESPONSE)
- tag = totag;
- else
- tag = fromtag;
-
+ tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
if (option_debug > 4 )
ast_log(LOG_DEBUG, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
@@ -3342,10 +3330,8 @@ static int sip_register(char *value, int lineno)
stringp=copy;
username = stringp;
hostname = strrchr(stringp, '@');
- if (hostname) {
- *hostname = '\0';
- hostname++;
- }
+ if (hostname)
+ *hostname++ = '\0';
if (ast_strlen_zero(username) || ast_strlen_zero(hostname)) {
ast_log(LOG_WARNING, "Format for registration is user[:secret[:authuser]]@host[:port][/contact] at line %d\n", lineno);
return -1;
@@ -3407,7 +3393,7 @@ static int sip_register(char *value, int lineno)
/*! \brief Parse multiline SIP headers into one header
This is enabled if pedanticsipchecking is enabled */
static int lws2sws(char *msgbuf, int len)
-{
+{
int h = 0, t = 0;
int lws = 0;