Index: pjproject/main/pjsip/src/pjsip/sip_auth_parser.c
===================================================================
--- pjproject/main/pjsip/src/pjsip/sip_auth_parser.c	(revision 3)
+++ pjproject/main/pjsip/src/pjsip/sip_auth_parser.c	(revision 43)
@@ -1,20 +1,24 @@
 /* $Id$
- *
  */
 #include <pjsip/sip_auth_parser.h>
 #include <pjsip/sip_auth_msg.h>
 #include <pjsip/sip_parser.h>
+#include <pj/assert.h>
 #include <pj/string.h>
 #include <pj/except.h>
 
-static pjsip_authorization_hdr*	      parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool);
-static pjsip_proxy_authorization_hdr* parse_hdr_proxy_authorization( pj_scanner *scanner, pj_pool_t *pool);
-static pjsip_www_authenticate_hdr*    parse_hdr_www_authenticate( pj_scanner *scanner, pj_pool_t *pool);
-static pjsip_proxy_authenticate_hdr*  parse_hdr_proxy_authenticate( pj_scanner *scanner, pj_pool_t *pool);
-
-static void parse_digest_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_credential *cred);
-static void parse_pgp_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_credential *cred);
-static void parse_digest_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_challenge *chal);
-static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_challenge *chal);
+static pjsip_hdr* parse_hdr_authorization       ( pjsip_parse_ctx *ctx );
+static pjsip_hdr* parse_hdr_proxy_authorization ( pjsip_parse_ctx *ctx );
+static pjsip_hdr* parse_hdr_www_authenticate    ( pjsip_parse_ctx *ctx );
+static pjsip_hdr* parse_hdr_proxy_authenticate  ( pjsip_parse_ctx *ctx );
+
+static void parse_digest_credential ( pj_scanner *scanner, pj_pool_t *pool, 
+                                      pjsip_digest_credential *cred);
+static void parse_pgp_credential    ( pj_scanner *scanner, pj_pool_t *pool, 
+                                      pjsip_pgp_credential *cred);
+static void parse_digest_challenge  ( pj_scanner *scanner, pj_pool_t *pool, 
+                                      pjsip_digest_challenge *chal);
+static void parse_pgp_challenge     ( pj_scanner *scanner, pj_pool_t *pool,
+                                      pjsip_pgp_challenge *chal);
 
 const pj_str_t	pjsip_USERNAME_STR =	    { "username", 8 },
@@ -44,10 +48,11 @@
 
 
-static void parse_digest_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_credential *cred)
+static void parse_digest_credential( pj_scanner *scanner, pj_pool_t *pool, 
+                                     pjsip_digest_credential *cred)
 {
     for (;;) {
 	pj_str_t name, value;
 
-	pjsip_parse_param_imp(scanner, &name, &value, PJSIP_PARSE_REMOVE_QUOTE);
+	pjsip_parse_param_imp(scanner, &name, &value,PJSIP_PARSE_REMOVE_QUOTE);
 
 	if (!pj_stricmp(&name, &pjsip_USERNAME_STR)) {
@@ -82,9 +87,9 @@
 
 	} else {
-	    pjsip_concat_param_imp(&cred->other_param, pool, &name, &value, ',');
+	    pjsip_concat_param_imp(&cred->other_param,pool,&name,&value, ',');
 	}
 
 	/* Eat comma */
-	if (!pj_scan_is_eof(scanner) && *scanner->current == ',')
+	if (!pj_scan_is_eof(scanner) && *scanner->curptr == ',')
 	    pj_scan_get_char(scanner);
 	else
@@ -93,19 +98,21 @@
 }
 
-static void parse_pgp_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_credential *cred)
-{
-    PJ_UNUSED_ARG(scanner)
-    PJ_UNUSED_ARG(pool)
-    PJ_UNUSED_ARG(cred)
+static void parse_pgp_credential( pj_scanner *scanner, pj_pool_t *pool, 
+                                  pjsip_pgp_credential *cred)
+{
+    PJ_UNUSED_ARG(scanner);
+    PJ_UNUSED_ARG(pool);
+    PJ_UNUSED_ARG(cred);
 
     PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
 }
 
-static void parse_digest_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_challenge *chal)
+static void parse_digest_challenge( pj_scanner *scanner, pj_pool_t *pool, 
+                                    pjsip_digest_challenge *chal)
 {
     for (;;) {
 	pj_str_t name, value;
 
-	pjsip_parse_param_imp(scanner, &name, &value, PJSIP_PARSE_REMOVE_QUOTE);
+	pjsip_parse_param_imp(scanner, &name, &value,PJSIP_PARSE_REMOVE_QUOTE);
 
 	if (!pj_stricmp(&name, &pjsip_REALM_STR)) {
@@ -122,6 +129,9 @@
 
 	} else if (!pj_stricmp(&name, &pjsip_STALE_STR)) {
-	    if (!pj_stricmp(&value, &pjsip_TRUE_STR) || !pj_stricmp(&value, &pjsip_QUOTED_TRUE_STR))
+	    if (!pj_stricmp(&value, &pjsip_TRUE_STR) || 
+                !pj_stricmp(&value, &pjsip_QUOTED_TRUE_STR))
+            {
 		chal->stale = 1;
+            }
 
 	} else if (!pj_stricmp(&name, &pjsip_ALGORITHM_STR)) {
@@ -133,9 +143,10 @@
 
 	} else {
-	    pjsip_concat_param_imp(&chal->other_param, pool, &name, &value, ',');
+	    pjsip_concat_param_imp(&chal->other_param, pool, 
+                                   &name, &value, ',');
 	}
 
 	/* Eat comma */
-	if (!pj_scan_is_eof(scanner) && *scanner->current == ',')
+	if (!pj_scan_is_eof(scanner) && *scanner->curptr == ',')
 	    pj_scan_get_char(scanner);
 	else
@@ -144,22 +155,23 @@
 }
 
-static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_challenge *chal)
-{
-    PJ_UNUSED_ARG(scanner)
-    PJ_UNUSED_ARG(pool)
-    PJ_UNUSED_ARG(chal)
+static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, 
+                                 pjsip_pgp_challenge *chal)
+{
+    PJ_UNUSED_ARG(scanner);
+    PJ_UNUSED_ARG(pool);
+    PJ_UNUSED_ARG(chal);
 
     PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
 }
 
-static void int_parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool, 
+static void int_parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool,
 					 pjsip_authorization_hdr *hdr)
 {
-    if (*scanner->current == '"') {
+    if (*scanner->curptr == '"') {
 	pj_scan_get_quote(scanner, '"', '"', &hdr->scheme);
 	hdr->scheme.ptr++;
 	hdr->scheme.slen -= 2;
     } else {
-	pj_scan_get(scanner, pjsip_TOKEN_SPEC, &hdr->scheme);
+	pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->scheme);
     }
 
@@ -182,10 +194,10 @@
 					pjsip_www_authenticate_hdr *hdr)
 {
-    if (*scanner->current == '"') {
+    if (*scanner->curptr == '"') {
 	pj_scan_get_quote(scanner, '"', '"', &hdr->scheme);
 	hdr->scheme.ptr++;
 	hdr->scheme.slen -= 2;
     } else {
-	pj_scan_get(scanner, pjsip_TOKEN_SPEC, &hdr->scheme);
+	pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->scheme);
     }
 
@@ -206,39 +218,54 @@
 
 
-static pjsip_authorization_hdr *parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool)
-{
-    pjsip_authorization_hdr *hdr = pjsip_authorization_hdr_create(pool);
-    int_parse_hdr_authorization(scanner, pool, hdr);
-    return hdr;
-}
-
-static pjsip_proxy_authorization_hdr *parse_hdr_proxy_authorization( pj_scanner *scanner, pj_pool_t *pool)
-{
-    pjsip_proxy_authorization_hdr *hdr = pjsip_proxy_authorization_hdr_create(pool);
-    int_parse_hdr_authorization(scanner, pool, hdr);
-    return hdr;
-}
-
-static pjsip_www_authenticate_hdr *parse_hdr_www_authenticate( pj_scanner *scanner, pj_pool_t *pool)
-{
-    pjsip_www_authenticate_hdr *hdr = pjsip_www_authenticate_hdr_create(pool);
-    int_parse_hdr_authenticate(scanner, pool, hdr);
-    return hdr;
-}
-
-static pjsip_proxy_authenticate_hdr *parse_hdr_proxy_authenticate( pj_scanner *scanner, pj_pool_t *pool)
-{
-    pjsip_proxy_authenticate_hdr *hdr = pjsip_proxy_authenticate_hdr_create(pool);
-    int_parse_hdr_authenticate(scanner, pool, hdr);
-    return hdr;
-}
-
-
-PJ_DEF(void) pjsip_auth_init_parser()
-{
-    pjsip_register_hdr_parser( "Authorization", NULL, (pjsip_parse_hdr_func*) &parse_hdr_authorization);
-    pjsip_register_hdr_parser( "Proxy-Authorization", NULL, (pjsip_parse_hdr_func*) &parse_hdr_proxy_authorization);
-    pjsip_register_hdr_parser( "WWW-Authenticate", NULL, (pjsip_parse_hdr_func*) &parse_hdr_www_authenticate);
-    pjsip_register_hdr_parser( "Proxy-Authenticate", NULL, (pjsip_parse_hdr_func*) &parse_hdr_proxy_authenticate);
+static pjsip_hdr* parse_hdr_authorization( pjsip_parse_ctx *ctx )
+{
+    pjsip_authorization_hdr *hdr = pjsip_authorization_hdr_create(ctx->pool);
+    int_parse_hdr_authorization(ctx->scanner, ctx->pool, hdr);
+    return (pjsip_hdr*)hdr;
+}
+
+static pjsip_hdr* parse_hdr_proxy_authorization( pjsip_parse_ctx *ctx )
+{
+    pjsip_proxy_authorization_hdr *hdr = 
+        pjsip_proxy_authorization_hdr_create(ctx->pool);
+    int_parse_hdr_authorization(ctx->scanner, ctx->pool, hdr);
+    return (pjsip_hdr*)hdr;
+}
+
+static pjsip_hdr* parse_hdr_www_authenticate( pjsip_parse_ctx *ctx )
+{
+    pjsip_www_authenticate_hdr *hdr = 
+        pjsip_www_authenticate_hdr_create(ctx->pool);
+    int_parse_hdr_authenticate(ctx->scanner, ctx->pool, hdr);
+    return (pjsip_hdr*)hdr;
+}
+
+static pjsip_hdr* parse_hdr_proxy_authenticate( pjsip_parse_ctx *ctx )
+{
+    pjsip_proxy_authenticate_hdr *hdr = 
+        pjsip_proxy_authenticate_hdr_create(ctx->pool);
+    int_parse_hdr_authenticate(ctx->scanner, ctx->pool, hdr);
+    return (pjsip_hdr*)hdr;
+}
+
+
+PJ_DEF(pj_status_t) pjsip_auth_init_parser()
+{
+    pj_status_t status;
+
+    status = pjsip_register_hdr_parser( "Authorization", NULL, 
+                                        &parse_hdr_authorization);
+    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
+    status = pjsip_register_hdr_parser( "Proxy-Authorization", NULL, 
+                                        &parse_hdr_proxy_authorization);
+    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
+    status = pjsip_register_hdr_parser( "WWW-Authenticate", NULL, 
+                                        &parse_hdr_www_authenticate);
+    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
+    status = pjsip_register_hdr_parser( "Proxy-Authenticate", NULL, 
+                                        &parse_hdr_proxy_authenticate);
+    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
+
+    return PJ_SUCCESS;
 }
 
