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

📄 osip_www_authenticate.c

📁 mediastreamer2是开源的网络传输媒体流的库
💻 C
📖 第 1 页 / 共 2 页
字号:
          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 OSIP_SUCCESS;          tmp = strchr (space + 1, ',');          if (tmp == NULL)      /* it was the last header */            return OSIP_SUCCESS;          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 OSIP_SYNTAXERROR;      /* 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 OSIP_SUCCESS;          } else            space = tmp;          /* continue parsing... */        }    }  return OSIP_SUCCESS;                     /* ok */}#ifndef MINISIZE/* 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 OSIP_UNDEFINED_ERROR;     /* does not exist */  www_authenticate =    (osip_www_authenticate_t *) osip_list_get (&sip->www_authenticates, pos);  *dest = www_authenticate;  return pos;}#endifchar *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))    return OSIP_BADPARAMETER;  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 OSIP_NOMEM;  *dest = tmp;  tmp = osip_str_append (tmp, wwwa->auth_type);  if (wwwa->realm != NULL)    {      tmp = osip_strn_append (tmp, " realm=", 7);      tmp = osip_str_append (tmp, wwwa->realm);    }  if (wwwa->domain != NULL)    {      tmp = osip_strn_append (tmp, ", domain=", 9);      tmp = osip_str_append (tmp, wwwa->domain);    }  if (wwwa->nonce != NULL)    {      tmp = osip_strn_append (tmp, ", nonce=", 8);      tmp = osip_str_append (tmp, wwwa->nonce);    }  if (wwwa->opaque != NULL)    {      tmp = osip_strn_append (tmp, ", opaque=", 9);      tmp = osip_str_append (tmp, wwwa->opaque);    }  if (wwwa->stale != NULL)    {      tmp = osip_strn_append (tmp, ", stale=", 8);      tmp = osip_str_append (tmp, wwwa->stale);    }  if (wwwa->algorithm != NULL)    {      tmp = osip_strn_append (tmp, ", algorithm=", 12);      tmp = osip_str_append (tmp, wwwa->algorithm);    }  if (wwwa->qop_options != NULL)    {      tmp = osip_strn_append (tmp, ", qop=", 6);      tmp = osip_str_append (tmp, wwwa->qop_options);    }  if (wwwa->realm == NULL)    {      /* remove comma */      len = strlen (wwwa->auth_type);      if ((*dest)[len] == ',')        (*dest)[len] = ' ';    }  return OSIP_SUCCESS;}/* 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 OSIP_BADPARAMETER;  if (wwwa->auth_type == NULL)    return OSIP_BADPARAMETER;  i = osip_www_authenticate_init (&wa);  if (i != 0)                  /* allocation failed */    return i;  wa->auth_type = osip_strdup (wwwa->auth_type);  if (wa->auth_type==NULL && wwwa->auth_type!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->realm != NULL)    wa->realm = osip_strdup (wwwa->realm);  if (wa->realm==NULL && wwwa->realm!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->domain != NULL)    wa->domain = osip_strdup (wwwa->domain);  if (wa->domain==NULL && wwwa->domain!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->nonce != NULL)    wa->nonce = osip_strdup (wwwa->nonce);  if (wa->nonce==NULL && wwwa->nonce!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->opaque != NULL)    wa->opaque = osip_strdup (wwwa->opaque);  if (wa->opaque==NULL && wwwa->opaque!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->stale != NULL)    wa->stale = osip_strdup (wwwa->stale);  if (wa->stale==NULL && wwwa->stale!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->algorithm != NULL)    wa->algorithm = osip_strdup (wwwa->algorithm);  if (wa->algorithm==NULL && wwwa->algorithm!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  if (wwwa->qop_options != NULL)    wa->qop_options = osip_strdup (wwwa->qop_options);  if (wa->qop_options==NULL && wwwa->qop_options!=NULL)  {	  osip_www_authenticate_free (wa);	  return OSIP_NOMEM;  }  *dest = wa;  return OSIP_SUCCESS;}

⌨️ 快捷键说明

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