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

📄 hdr_authorization.c

📁 libosip-0.9.7源码
💻 C
📖 第 1 页 / 共 2 页
字号:
}voidauthorization_setdigest (authorization_t * authorization, char *digest){  authorization->digest = (char *) digest;}char *authorization_getalgorithm (authorization_t * authorization){  return authorization->algorithm;}voidauthorization_setalgorithm (authorization_t * authorization, char *algorithm){  authorization->algorithm = (char *) algorithm;}char *authorization_getcnonce (authorization_t * authorization){  return authorization->cnonce;}voidauthorization_setcnonce (authorization_t * authorization, char *cnonce){  authorization->cnonce = (char *) cnonce;}char *authorization_getopaque (authorization_t * authorization){  return authorization->opaque;}voidauthorization_setopaque (authorization_t * authorization, char *opaque){  authorization->opaque = (char *) opaque;}char *authorization_getmessage_qop (authorization_t * authorization){  return authorization->message_qop;}voidauthorization_setmessage_qop (authorization_t * authorization,			      char *message_qop){  authorization->message_qop = (char *) message_qop;}char *authorization_getnonce_count (authorization_t * authorization){  return authorization->nonce_count;}voidauthorization_setnonce_count (authorization_t * authorization,			      char *nonce_count){  authorization->nonce_count = (char *) nonce_count;}/* returns the authorization header as a string.          *//* INPUT : authorization_t *authorization | authorization header.  *//* returns null on error. */intauthorization_2char (authorization_t * auth, char **dest){  int len;  char *tmp;  *dest = NULL;  /* DO NOT REALLY KNOW THE LIST OF MANDATORY PARAMETER: Please HELP! */  if ((auth == NULL) || (auth->auth_type == NULL) || (auth->realm == NULL)      || (auth->nonce == NULL))    return -1;  len = strlen (auth->auth_type) + 1;  if (auth->username != NULL)    len = len + 10 + strlen (auth->username);  if (auth->realm != NULL)    len = len + 8 + strlen (auth->realm);  if (auth->nonce != NULL)    len = len + 8 + strlen (auth->nonce);  if (auth->uri != NULL)    len = len + 6 + strlen (auth->uri);  if (auth->response != NULL)    len = len + 11 + strlen (auth->response);  len = len + 2;  if (auth->digest != NULL)    len = len + strlen (auth->digest) + 9;  if (auth->algorithm != NULL)    len = len + strlen (auth->algorithm) + 12;  if (auth->cnonce != NULL)    len = len + strlen (auth->cnonce) + 9;  if (auth->opaque != NULL)    len = len + 9 + strlen (auth->opaque);  if (auth->nonce_count != NULL)    len = len + strlen (auth->nonce_count) + 5;  if (auth->message_qop != NULL)    len = len + strlen (auth->message_qop) + 6;  tmp = (char *) smalloc (len);  if (tmp == NULL)    return -1;  *dest = tmp;  sstrncpy (tmp, auth->auth_type, strlen (auth->auth_type));  tmp = tmp + strlen (tmp);  if (auth->username != NULL)    {      sstrncpy (tmp, " username=", 10);      tmp = tmp + 10;      /* !! username-value must be a quoted string !! */      sstrncpy (tmp, auth->username, strlen (auth->username));      tmp = tmp + strlen (tmp);    }  if (auth->realm != NULL)    {      sstrncpy (tmp, ", realm=", 8);      tmp = tmp + 8;      /* !! realm-value must be a quoted string !! */      sstrncpy (tmp, auth->realm, strlen (auth->realm));      tmp = tmp + strlen (tmp);    }  if (auth->nonce != NULL)    {      sstrncpy (tmp, ", nonce=", 8);      tmp = tmp + 8;      /* !! nonce-value must be a quoted string !! */      sstrncpy (tmp, auth->nonce, strlen (auth->nonce));      tmp = tmp + strlen (tmp);    }  if (auth->uri != NULL)    {      sstrncpy (tmp, ", uri=", 6);      tmp = tmp + 6;      /* !! domain-value must be a list of URI in a quoted string !! */      sstrncpy (tmp, auth->uri, strlen (auth->uri));      tmp = tmp + strlen (tmp);    }  if (auth->response != NULL)    {      sstrncpy (tmp, ", response=", 11);      tmp = tmp + 11;      /* !! domain-value must be a list of URI in a quoted string !! */      sstrncpy (tmp, auth->response, strlen (auth->response));      tmp = tmp + strlen (tmp);    }  if (auth->digest != NULL)    {      sstrncpy (tmp, ", digest=", 9);      tmp = tmp + 9;      /* !! domain-value must be a list of URI in a quoted string !! */      sstrncpy (tmp, auth->digest, strlen (auth->digest));      tmp = tmp + strlen (tmp);    }  if (auth->algorithm != NULL)    {      sstrncpy (tmp, ", algorithm=", 12);      tmp = tmp + 12;      sstrncpy (tmp, auth->algorithm, strlen (auth->algorithm));      tmp = tmp + strlen (tmp);    }  if (auth->cnonce != NULL)    {      sstrncpy (tmp, ", cnonce=", 9);      tmp = tmp + 9;      sstrncpy (tmp, auth->cnonce, strlen (auth->cnonce));      tmp = tmp + strlen (tmp);    }  if (auth->opaque != NULL)    {      sstrncpy (tmp, ", opaque=", 9);      tmp = tmp + 9;      sstrncpy (tmp, auth->opaque, strlen (auth->opaque));      tmp = tmp + strlen (tmp);    }  if (auth->message_qop != NULL)    {      sstrncpy (tmp, ", qop=", 6);      tmp = tmp + 6;      sstrncpy (tmp, auth->message_qop, strlen (auth->message_qop));      tmp = tmp + strlen (tmp);    }  if (auth->nonce_count != NULL)    {      sstrncpy (tmp, ", nc=", 5);      tmp = tmp + 5;      sstrncpy (tmp, auth->nonce_count, strlen (auth->nonce_count));      tmp = tmp + strlen (tmp);    }  return 0;}/* deallocates a authorization_t structure.  *//* INPUT : authorization_t *authorization | authorization. */voidauthorization_free (authorization_t * authorization){  if (authorization == NULL)    return;  sfree (authorization->auth_type);  sfree (authorization->username);  sfree (authorization->realm);  sfree (authorization->nonce);  sfree (authorization->uri);  sfree (authorization->response);  sfree (authorization->digest);  sfree (authorization->algorithm);  sfree (authorization->cnonce);  sfree (authorization->opaque);  sfree (authorization->message_qop);  sfree (authorization->nonce_count);}intauthorization_clone (authorization_t * auth, authorization_t ** dest){  int i;  authorization_t *au;  *dest = NULL;  if (auth == NULL)    return -1;  /* to be removed?     if (auth->auth_type==NULL) return -1;     if (auth->username==NULL) return -1;     if (auth->realm==NULL) return -1;     if (auth->nonce==NULL) return -1;     if (auth->uri==NULL) return -1;     if (auth->response==NULL) return -1;     if (auth->opaque==NULL) return -1;   */  i = authorization_init (&au);  if (i == -1)			/* allocation failed */    return -1;  if (auth->auth_type != NULL)    {      au->auth_type = sgetcopy (auth->auth_type);      if (au->auth_type == NULL)	goto ac_error;    }  if (auth->username != NULL)    {      au->username = sgetcopy (auth->username);      if (au->username == NULL)	goto ac_error;    }  if (auth->realm != NULL)    {      au->realm = sgetcopy (auth->realm);      if (auth->realm == NULL)	goto ac_error;    }  if (auth->nonce != NULL)    {      au->nonce = sgetcopy (auth->nonce);      if (auth->nonce == NULL)	goto ac_error;    }  if (auth->uri != NULL)    {      au->uri = sgetcopy (auth->uri);      if (au->uri == NULL)	goto ac_error;    }  if (auth->response != NULL)    {      au->response = sgetcopy (auth->response);      if (auth->response == NULL)	goto ac_error;    }  if (auth->digest != NULL)    {      au->digest = sgetcopy (auth->digest);      if (au->digest == NULL)	goto ac_error;    }  if (auth->algorithm != NULL)    {      au->algorithm = sgetcopy (auth->algorithm);      if (auth->algorithm == NULL)	goto ac_error;    }  if (auth->cnonce != NULL)    {      au->cnonce = sgetcopy (auth->cnonce);      if (au->cnonce == NULL)	goto ac_error;    }  if (auth->opaque != NULL)    {      au->opaque = sgetcopy (auth->opaque);      if (auth->opaque == NULL)	goto ac_error;    }  if (auth->message_qop != NULL)    {      au->message_qop = sgetcopy (auth->message_qop);      if (auth->message_qop == NULL)	goto ac_error;    }  if (auth->nonce_count != NULL)    {      au->nonce_count = sgetcopy (auth->nonce_count);      if (auth->nonce_count == NULL)	goto ac_error;    }  *dest = au;  return 0;ac_error:  authorization_free (au);  sfree (au);  return -1;}

⌨️ 快捷键说明

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