⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hdr_wwwauthenticate.c

📁 libosip-0.9.7源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	return 0;		/* end of header detected! */      else if (next != space)	{	  space = next;	  parse_ok++;	}      if (quoted_string_set ("qop", space, &(wwwa->qop_options), &next))	return -1;      if (next == NULL)	return 0;		/* end of header detected! */      else if (next != space)	{	  space = next;	  parse_ok++;	}      if (0 == parse_ok)	{	  char *quote1, *quote2, *tmp;	  /* CAUTION */	  /* parameter not understood!!! I'm too lazy to handle IT */	  /* let's simply bypass it */	  if (strlen (space) < 1)	    return 0;	  tmp = strchr (space + 1, ',');	  if (tmp == NULL)	/* it was the last header */	    return 0;	  quote1 = quote_find (space);	  if ((quote1 != NULL) && (quote1 < tmp))	/* this may be a quoted string! */	    {	      quote2 = quote_find (quote1 + 1);	      if (quote2 == NULL)		return -1;	/* bad header format... */	      if (tmp < quote2)	/* the comma is inside the quotes! */		space = strchr (quote2, ',');	      else		space = tmp;	      if (space == NULL)	/* it was the last header */		return 0;	    }	  else	    space = tmp;	  /* continue parsing... */	}    }  return 0;			/* ok */}/* returns the www_authenticate header.            *//* INPUT : sip_t *sip | sip message.   *//* returns null on error. */intmsg_getwww_authenticate (sip_t * sip, int pos, www_authenticate_t ** dest){  www_authenticate_t *www_authenticate;  *dest = NULL;  if (list_size (sip->www_authenticates) <= pos)    return -1;			/* does not exist */  www_authenticate =    (www_authenticate_t *) list_get (sip->www_authenticates, pos);  *dest = www_authenticate;  return pos;}char *www_authenticate_getauth_type (www_authenticate_t * www_authenticate){  return www_authenticate->auth_type;}voidwww_authenticate_setauth_type (www_authenticate_t * www_authenticate,			       char *auth_type){  www_authenticate->auth_type = (char *) auth_type;}char *www_authenticate_getrealm (www_authenticate_t * www_authenticate){  return www_authenticate->realm;}voidwww_authenticate_setrealm (www_authenticate_t * www_authenticate, char *realm){  www_authenticate->realm = (char *) realm;}char *www_authenticate_getdomain (www_authenticate_t * www_authenticate){  return www_authenticate->domain;}voidwww_authenticate_setdomain (www_authenticate_t * www_authenticate,			    char *domain){  www_authenticate->domain = (char *) domain;}char *www_authenticate_getnonce (www_authenticate_t * www_authenticate){  return www_authenticate->nonce;}voidwww_authenticate_setnonce (www_authenticate_t * www_authenticate, char *nonce){  www_authenticate->nonce = (char *) nonce;}char *www_authenticate_getstale (www_authenticate_t * www_authenticate){  return www_authenticate->stale;}voidwww_authenticate_setstale (www_authenticate_t * www_authenticate, char *stale){  www_authenticate->stale = (char *) stale;}char *www_authenticate_getopaque (www_authenticate_t * www_authenticate){  return www_authenticate->opaque;}voidwww_authenticate_setopaque (www_authenticate_t * www_authenticate,			    char *opaque){  www_authenticate->opaque = (char *) opaque;}char *www_authenticate_getalgorithm (www_authenticate_t * www_authenticate){  return www_authenticate->algorithm;}voidwww_authenticate_setalgorithm (www_authenticate_t * www_authenticate,			       char *algorithm){  www_authenticate->algorithm = (char *) algorithm;}char *www_authenticate_getqop_options (www_authenticate_t * www_authenticate){  return www_authenticate->qop_options;}voidwww_authenticate_setqop_options (www_authenticate_t * www_authenticate,				 char *qop_options){  www_authenticate->qop_options = (char *) qop_options;}/* returns the www_authenticate header as a string.          *//* INPUT : www_authenticate_t *www_authenticate | www_authenticate header.  *//* returns null on error. */intwww_authenticate_2char (www_authenticate_t * wwwa, char **dest){  int len;  char *tmp;  *dest = NULL;  if ((wwwa == NULL) || (wwwa->auth_type == NULL) || (wwwa->realm == NULL)      || (wwwa->nonce == NULL))    return -1;  len = strlen (wwwa->auth_type) + 1;  if (wwwa->realm != NULL)    len = len + strlen (wwwa->realm) + 7;  if (wwwa->nonce != NULL)    len = len + strlen (wwwa->nonce) + 8;  len = len + 2;  if (wwwa->domain != NULL)    len = len + strlen (wwwa->domain) + 9;  if (wwwa->opaque != NULL)    len = len + strlen (wwwa->opaque) + 9;  if (wwwa->stale != NULL)    len = len + strlen (wwwa->stale) + 8;  if (wwwa->algorithm != NULL)    len = len + strlen (wwwa->algorithm) + 12;  if (wwwa->qop_options != NULL)    len = len + strlen (wwwa->qop_options) + 6;  tmp = (char *) smalloc (len);  if (tmp == NULL)    return -1;  *dest = tmp;  sstrncpy (tmp, wwwa->auth_type, strlen (wwwa->auth_type));  tmp = tmp + strlen (tmp);  if (wwwa->realm != NULL)    {      sstrncpy (tmp, " realm=", 7);      tmp = tmp + 7;      sstrncpy (tmp, wwwa->realm, strlen (wwwa->realm));      tmp = tmp + strlen (tmp);    }  if (wwwa->domain != NULL)    {      sstrncpy (tmp, ", domain=", 9);      tmp = tmp + 9;      sstrncpy (tmp, wwwa->domain, strlen (wwwa->domain));      tmp = tmp + strlen (tmp);    }  if (wwwa->nonce != NULL)    {      sstrncpy (tmp, ", nonce=", 8);      tmp = tmp + 8;      sstrncpy (tmp, wwwa->nonce, strlen (wwwa->nonce));      tmp = tmp + strlen (tmp);    }  if (wwwa->opaque != NULL)    {      sstrncpy (tmp, ", opaque=", 9);      tmp = tmp + 9;      sstrncpy (tmp, wwwa->opaque, strlen (wwwa->opaque));      tmp = tmp + strlen (tmp);    }  if (wwwa->stale != NULL)    {      sstrncpy (tmp, ", stale=", 8);      tmp = tmp + 8;      sstrncpy (tmp, wwwa->stale, strlen (wwwa->stale));      tmp = tmp + strlen (tmp);    }  if (wwwa->algorithm != NULL)    {      sstrncpy (tmp, ", algorithm=", 12);      tmp = tmp + 12;      sstrncpy (tmp, wwwa->algorithm, strlen (wwwa->algorithm));      tmp = tmp + strlen (tmp);    }  if (wwwa->qop_options != NULL)    {      sstrncpy (tmp, ", qop=", 6);      tmp = tmp + 6;      sstrncpy (tmp, wwwa->qop_options, strlen (wwwa->qop_options));      tmp = tmp + strlen (tmp);    }  return 0;}/* deallocates a www_authenticate_t structure.  *//* INPUT : www_authenticate_t *www_authenticate | www_authenticate. */voidwww_authenticate_free (www_authenticate_t * www_authenticate){  if (www_authenticate == NULL)    return;  if (www_authenticate->auth_type != NULL)    sfree (www_authenticate->auth_type);  if (www_authenticate->realm != NULL)    sfree (www_authenticate->realm);  if (www_authenticate->domain != NULL)    sfree (www_authenticate->domain);  sfree (www_authenticate->nonce);  if (www_authenticate->opaque != NULL)    sfree (www_authenticate->opaque);  if (www_authenticate->stale != NULL)    sfree (www_authenticate->stale);  if (www_authenticate->algorithm != NULL)    sfree (www_authenticate->algorithm);  if (www_authenticate->qop_options != NULL)    sfree (www_authenticate->qop_options);}intwww_authenticate_clone (www_authenticate_t * wwwa, www_authenticate_t ** dest){  int i;  www_authenticate_t *wa;  *dest = NULL;  if (wwwa == NULL)    return -1;  if (wwwa->auth_type == NULL)    return -1;  if (wwwa->realm == NULL)    return -1;  if (wwwa->nonce == NULL)    return -1;  i = www_authenticate_init (&wa);  if (i == -1)			/* allocation failed */    return -1;  wa->auth_type = sgetcopy (wwwa->auth_type);  wa->realm = sgetcopy (wwwa->realm);  if (wwwa->domain != NULL)    wa->domain = sgetcopy (wwwa->domain);  wa->nonce = sgetcopy (wwwa->nonce);  if (wwwa->opaque != NULL)    wa->opaque = sgetcopy (wwwa->opaque);  if (wwwa->stale != NULL)    wa->stale = sgetcopy (wwwa->stale);  if (wwwa->algorithm != NULL)    wa->algorithm = sgetcopy (wwwa->algorithm);  if (wwwa->qop_options != NULL)    wa->qop_options = sgetcopy (wwwa->qop_options);  *dest = wa;  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -