Index: pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c	(revision 4537)
+++ pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -138,5 +138,5 @@
 /*
  * Create response digest based on the parameters and store the
- * digest ASCII in 'result'. 
+ * digest ASCII in 'result'.
  */
 PJ_DEF(void) pjsip_auth_create_digest( pj_str_t *result,
@@ -160,6 +160,6 @@
 
     if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_PLAIN_PASSWD) {
-	/*** 
-	 *** ha1 = MD5(username ":" realm ":" password) 
+	/***
+	 *** ha1 = MD5(username ":" realm ":" password)
 	 ***/
 	pj_md5_init(&pms);
@@ -183,5 +183,5 @@
 
     /***
-     *** ha2 = MD5(method ":" req_uri) 
+     *** ha2 = MD5(method ":" req_uri)
      ***/
     pj_md5_init(&pms);
@@ -196,5 +196,5 @@
     /***
      *** When qop is not used:
-     ***    response = MD5(ha1 ":" nonce ":" ha2) 
+     ***    response = MD5(ha1 ":" nonce ":" ha2)
      ***
      *** When qop=auth is used:
@@ -218,5 +218,5 @@
     /* This is the final response digest. */
     pj_md5_final(&pms, digest);
-    
+
     /* Convert digest to string and store in chal->response. */
     result->slen = PJSIP_MD5STRLEN;
@@ -259,5 +259,5 @@
 
 /*
- * Generate response digest. 
+ * Generate response digest.
  * Most of the parameters to generate the digest (i.e. username, realm, uri,
  * and nonce) are expected to be in the credential. Additional parameters (i.e.
@@ -308,16 +308,16 @@
 	if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
 	    /* Call application callback to create the response digest */
-	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info, 
+	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info,
 					    method, cred);
-	} 
+	}
 	else {
 	    /* Convert digest to string and store in chal->response. */
-	    pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL, 
-				      NULL,  NULL, uri, &chal->realm, 
+	    pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL,
+				      NULL,  NULL, uri, &chal->realm,
 				      cred_info, method);
 	}
 
     } else if (has_auth_qop(pool, &chal->qop)) {
-	/* Server requires quality of protection. 
+	/* Server requires quality of protection.
 	 * We respond with selecting "qop=auth" protection.
 	 */
@@ -335,10 +335,10 @@
 	if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
 	    /* Call application callback to create the response digest */
-	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info, 
+	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info,
 					    method, cred);
 	}
 	else {
-	    pjsip_auth_create_digest( &cred->response, &cred->nonce, 
-				      &cred->nc, cnonce, &pjsip_AUTH_STR, 
+	    pjsip_auth_create_digest( &cred->response, &cred->nonce,
+				      &cred->nc, cnonce, &pjsip_AUTH_STR,
 				      uri, &chal->realm, cred_info, method );
 	}
@@ -346,5 +346,5 @@
     } else {
 	/* Server requires quality protection that we don't support. */
-	PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s", 
+	PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s",
 		  chal->qop.slen, chal->qop.ptr));
 	return PJSIP_EINVALIDQOP;
@@ -358,5 +358,5 @@
  * Update authentication session with a challenge.
  */
-static void update_digest_session( pj_pool_t *ses_pool, 
+static void update_digest_session( pj_pool_t *ses_pool,
 				   pjsip_cached_auth *cached_auth,
 				   const pjsip_www_authenticate_hdr *hdr )
@@ -371,5 +371,5 @@
 	     * than the one in the cache, to reduce memory usage.
 	     */
-	    const pjsip_digest_challenge *d1 = 
+	    const pjsip_digest_challenge *d1 =
 			&cached_auth->last_chal->challenge.digest;
 	    const pjsip_digest_challenge *d2 = &hdr->challenge.digest;
@@ -407,5 +407,5 @@
 	*/
 	if (cached_auth->realm.slen == 0) {
-	    pj_strdup(ses_pool, &cached_auth->realm, 
+	    pj_strdup(ses_pool, &cached_auth->realm,
 		      &hdr->challenge.digest.realm);
 	}
@@ -413,6 +413,6 @@
     } else {
 	/* Update last_nonce and nonce-count */
-	if (!pj_strcmp(&hdr->challenge.digest.nonce, 
-		       &cached_auth->last_chal->challenge.digest.nonce)) 
+	if (!pj_strcmp(&hdr->challenge.digest.nonce,
+		       &cached_auth->last_chal->challenge.digest.nonce))
 	{
 	    /* Same nonce, increment nonce-count */
@@ -424,7 +424,7 @@
 	    /* Has the opaque changed? */
 	    if (pj_strcmp(&cached_auth->last_chal->challenge.digest.opaque,
-			  &hdr->challenge.digest.opaque)) 
+			  &hdr->challenge.digest.opaque))
 	    {
-		pj_strdup(ses_pool, 
+		pj_strdup(ses_pool,
 			  &cached_auth->last_chal->challenge.digest.opaque,
 			  &hdr->challenge.digest.opaque);
@@ -485,5 +485,5 @@
 PJ_DEF(pj_status_t) pjsip_auth_clt_init(  pjsip_auth_clt_sess *sess,
 					  pjsip_endpoint *endpt,
-					  pj_pool_t *pool, 
+					  pj_pool_t *pool,
 					  unsigned options)
 {
@@ -510,13 +510,13 @@
 
     pjsip_auth_clt_init(sess, (pjsip_endpoint*)rhs->endpt, pool, 0);
-    
+
     sess->cred_cnt = rhs->cred_cnt;
     sess->cred_info = (pjsip_cred_info*)
-    		      pj_pool_alloc(pool, 
+    		      pj_pool_alloc(pool,
 				    sess->cred_cnt*sizeof(pjsip_cred_info));
     for (i=0; i<rhs->cred_cnt; ++i) {
 	pj_strdup(pool, &sess->cred_info[i].realm, &rhs->cred_info[i].realm);
 	pj_strdup(pool, &sess->cred_info[i].scheme, &rhs->cred_info[i].scheme);
-	pj_strdup(pool, &sess->cred_info[i].username, 
+	pj_strdup(pool, &sess->cred_info[i].username,
 		  &rhs->cred_info[i].username);
 	sess->cred_info[i].data_type = rhs->cred_info[i].data_type;
@@ -553,5 +553,5 @@
 	    sess->cred_info[i].data_type = c[i].data_type;
 
-	    /* When data_type is PJSIP_CRED_DATA_EXT_AKA, 
+	    /* When data_type is PJSIP_CRED_DATA_EXT_AKA,
 	     * callback must be specified.
 	     */
@@ -569,9 +569,9 @@
 
 		/* Verify K len */
-		PJ_ASSERT_RETURN(c[i].ext.aka.k.slen <= PJSIP_AKA_KLEN, 
+		PJ_ASSERT_RETURN(c[i].ext.aka.k.slen <= PJSIP_AKA_KLEN,
 				 PJSIP_EAUTHINAKACRED);
 
 		/* Verify OP len */
-		PJ_ASSERT_RETURN(c[i].ext.aka.op.slen <= PJSIP_AKA_OPLEN, 
+		PJ_ASSERT_RETURN(c[i].ext.aka.op.slen <= PJSIP_AKA_OPLEN,
 				 PJSIP_EAUTHINAKACRED);
 
@@ -631,5 +631,5 @@
 
 
-/* 
+/*
  * Create Authorization/Proxy-Authorization response header based on the challege
  * in WWW-Authenticate/Proxy-Authenticate header.
@@ -786,5 +786,5 @@
     if (status != PJ_SUCCESS)
 	return status;
-    
+
     pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)hauth);
 
@@ -832,4 +832,5 @@
     /* Get the method. */
     method = &tdata->msg->line.req.method;
+    PJ_UNUSED_ARG(method); /* Warning about unused var caused by #if below */
 
     auth = sess->cached_auth.next;
@@ -870,10 +871,10 @@
 #	    endif
 
-	} 
+	}
 #	if defined(PJSIP_AUTH_QOP_SUPPORT) && \
 	   defined(PJSIP_AUTH_AUTO_SEND_NEXT) && \
 	   (PJSIP_AUTH_QOP_SUPPORT && PJSIP_AUTH_AUTO_SEND_NEXT)
 	else if (auth->qop_value == PJSIP_AUTH_QOP_AUTH) {
-	    /* For qop="auth", we have to re-create the authorization header. 
+	    /* For qop="auth", we have to re-create the authorization header.
 	     */
 	    const pjsip_cred_info *cred;
@@ -881,5 +882,5 @@
 	    pj_status_t status;
 
-	    cred = auth_find_cred(sess, &auth->realm, 
+	    cred = auth_find_cred(sess, &auth->realm,
 				  &auth->last_chal->scheme);
 	    if (!cred) {
@@ -888,6 +889,6 @@
 	    }
 
-	    status = auth_respond( tdata->pool, auth->last_chal, 
-				   tdata->msg->line.req.uri, 
+	    status = auth_respond( tdata->pool, auth->last_chal,
+				   tdata->msg->line.req.uri,
 				   cred,
 				   &tdata->msg->line.req.method,
@@ -895,5 +896,5 @@
 	    if (status != PJ_SUCCESS)
 		return status;
-	    
+
 	    //pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hauth);
 	    pj_list_push_back(&added, hauth);
@@ -984,5 +985,5 @@
 	{
 	    sent_auth = (pjsip_authorization_hdr*) hdr;
-	    if (pj_stricmp(&hchal->challenge.common.realm, 
+	    if (pj_stricmp(&hchal->challenge.common.realm,
 			   &sent_auth->credential.common.realm )==0)
 	    {
@@ -1055,11 +1056,11 @@
 
     /* Find credential to be used for the challenge. */
-    cred = auth_find_cred( sess, &hchal->challenge.common.realm, 
+    cred = auth_find_cred( sess, &hchal->challenge.common.realm,
 			   &hchal->scheme);
     if (!cred) {
 	const pj_str_t *realm = &hchal->challenge.common.realm;
-	PJ_LOG(4,(THIS_FILE, 
+	PJ_LOG(4,(THIS_FILE,
 		  "Unable to set auth for %s: can not find credential for %.*s/%.*s",
-		  tdata->obj_name, 
+		  tdata->obj_name,
 		  realm->slen, realm->ptr,
 		  hchal->scheme.slen, hchal->scheme.ptr));
@@ -1068,6 +1069,6 @@
 
     /* Respond to authorization challenge. */
-    status = auth_respond( req_pool, hchal, uri, cred, 
-			   &tdata->msg->line.req.method, 
+    status = auth_respond( req_pool, hchal, uri, cred,
+			   &tdata->msg->line.req.method,
 			   sess->pool, cached_auth, h_auth);
     return status;
@@ -1148,5 +1149,5 @@
 	 * authorization session.
 	 */
-	status = process_auth( tdata->pool, hchal, tdata->msg->line.req.uri, 
+	status = process_auth( tdata->pool, hchal, tdata->msg->line.req.uri,
 			       tdata, sess, cached_auth, &hauth);
 	if (status != PJ_SUCCESS)
