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

📄 osip_www_authenticate.c

📁 嵌入式产品中的osip的源代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
      else if (next != space)	{	  space = next;	  parse_ok++;	}      if (__osip_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 = __osip_quote_find (space);	  if ((quote1 != NULL) && (quote1 < tmp))	/* this may be a quoted string! */	    {	      quote2 = __osip_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 : osip_message_t *sip | sip message.   *//* returns null on error. */intosip_message_get_www_authenticate (const osip_message_t * sip, int pos,				   osip_www_authenticate_t ** dest){  osip_www_authenticate_t *www_authenticate;  *dest = NULL;  if (osip_list_size (sip->www_authenticates) <= pos)    return -1;			/* does not exist */  www_authenticate =    (osip_www_authenticate_t *) osip_list_get (sip->www_authenticates, pos);  *dest = www_authenticate;  return pos;}char *osip_www_authenticate_get_auth_type (osip_www_authenticate_t *				     www_authenticate){  return www_authenticate->auth_type;}voidosip_www_authenticate_set_auth_type (osip_www_authenticate_t *				     www_authenticate, char *auth_type){  www_authenticate->auth_type = (char *) auth_type;}char *osip_www_authenticate_get_realm (osip_www_authenticate_t * www_authenticate){  return www_authenticate->realm;}voidosip_www_authenticate_set_realm (osip_www_authenticate_t * www_authenticate,				 char *realm){  www_authenticate->realm = (char *) realm;}char *osip_www_authenticate_get_domain (osip_www_authenticate_t * www_authenticate){  return www_authenticate->domain;}voidosip_www_authenticate_set_domain (osip_www_authenticate_t * www_authenticate,				  char *domain){  www_authenticate->domain = (char *) domain;}char *osip_www_authenticate_get_nonce (osip_www_authenticate_t * www_authenticate){  return www_authenticate->nonce;}voidosip_www_authenticate_set_nonce (osip_www_authenticate_t * www_authenticate,				 char *nonce){  www_authenticate->nonce = (char *) nonce;}char *osip_www_authenticate_get_stale (osip_www_authenticate_t * www_authenticate){  return www_authenticate->stale;}voidosip_www_authenticate_set_stale (osip_www_authenticate_t * www_authenticate,				 char *stale){  www_authenticate->stale = (char *) stale;}char *osip_www_authenticate_get_opaque (osip_www_authenticate_t * www_authenticate){  return www_authenticate->opaque;}voidosip_www_authenticate_set_opaque (osip_www_authenticate_t * www_authenticate,				  char *opaque){  www_authenticate->opaque = (char *) opaque;}char *osip_www_authenticate_get_algorithm (osip_www_authenticate_t *				     www_authenticate){  return www_authenticate->algorithm;}voidosip_www_authenticate_set_algorithm (osip_www_authenticate_t *				     www_authenticate, char *algorithm){  www_authenticate->algorithm = (char *) algorithm;}char *osip_www_authenticate_get_qop_options (osip_www_authenticate_t *				       www_authenticate){  return www_authenticate->qop_options;}voidosip_www_authenticate_set_qop_options (osip_www_authenticate_t *				       www_authenticate, char *qop_options){  www_authenticate->qop_options = (char *) qop_options;}/* returns the www_authenticate header as a string.          *//* INPUT : osip_www_authenticate_t *www_authenticate | www_authenticate header.  *//* returns null on error. */intosip_www_authenticate_to_str (const osip_www_authenticate_t * wwwa,			      char **dest){  size_t 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 *) osip_malloc (len);  if (tmp == NULL)    return -1;  *dest = tmp;  osip_strncpy (tmp, wwwa->auth_type, strlen (wwwa->auth_type));  tmp = tmp + strlen (tmp);  if (wwwa->realm != NULL)    {      osip_strncpy (tmp, " realm=", 7);      tmp = tmp + 7;      osip_strncpy (tmp, wwwa->realm, strlen (wwwa->realm));      tmp = tmp + strlen (tmp);    }  if (wwwa->domain != NULL)    {      osip_strncpy (tmp, ", domain=", 9);      tmp = tmp + 9;      osip_strncpy (tmp, wwwa->domain, strlen (wwwa->domain));      tmp = tmp + strlen (tmp);    }  if (wwwa->nonce != NULL)    {      osip_strncpy (tmp, ", nonce=", 8);      tmp = tmp + 8;      osip_strncpy (tmp, wwwa->nonce, strlen (wwwa->nonce));      tmp = tmp + strlen (tmp);    }  if (wwwa->opaque != NULL)    {      osip_strncpy (tmp, ", opaque=", 9);      tmp = tmp + 9;      osip_strncpy (tmp, wwwa->opaque, strlen (wwwa->opaque));      tmp = tmp + strlen (tmp);    }  if (wwwa->stale != NULL)    {      osip_strncpy (tmp, ", stale=", 8);      tmp = tmp + 8;      osip_strncpy (tmp, wwwa->stale, strlen (wwwa->stale));      tmp = tmp + strlen (tmp);    }  if (wwwa->algorithm != NULL)    {      osip_strncpy (tmp, ", algorithm=", 12);      tmp = tmp + 12;      osip_strncpy (tmp, wwwa->algorithm, strlen (wwwa->algorithm));      tmp = tmp + strlen (tmp);    }  if (wwwa->qop_options != NULL)    {      osip_strncpy (tmp, ", qop=", 6);      tmp = tmp + 6;      osip_strncpy (tmp, wwwa->qop_options, strlen (wwwa->qop_options));      tmp = tmp + strlen (tmp);    }  return 0;}/* deallocates a osip_www_authenticate_t structure.  *//* INPUT : osip_www_authenticate_t *www_authenticate | www_authenticate. */voidosip_www_authenticate_free (osip_www_authenticate_t * www_authenticate){  if (www_authenticate == NULL)    return;  osip_free (www_authenticate->auth_type);  osip_free (www_authenticate->realm);  osip_free (www_authenticate->domain);  osip_free (www_authenticate->nonce);  osip_free (www_authenticate->opaque);  osip_free (www_authenticate->stale);  osip_free (www_authenticate->algorithm);  osip_free (www_authenticate->qop_options);  osip_free (www_authenticate);}intosip_www_authenticate_clone (const osip_www_authenticate_t * wwwa,			     osip_www_authenticate_t ** dest){  int i;  osip_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 = osip_www_authenticate_init (&wa);  if (i == -1)			/* allocation failed */    return -1;  wa->auth_type = osip_strdup (wwwa->auth_type);  wa->realm = osip_strdup (wwwa->realm);  if (wwwa->domain != NULL)    wa->domain = osip_strdup (wwwa->domain);  wa->nonce = osip_strdup (wwwa->nonce);  if (wwwa->opaque != NULL)    wa->opaque = osip_strdup (wwwa->opaque);  if (wwwa->stale != NULL)    wa->stale = osip_strdup (wwwa->stale);  if (wwwa->algorithm != NULL)    wa->algorithm = osip_strdup (wwwa->algorithm);  if (wwwa->qop_options != NULL)    wa->qop_options = osip_strdup (wwwa->qop_options);  *dest = wa;  return 0;}

⌨️ 快捷键说明

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