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

📄 osip_authorization.c

📁 libosip2-3.0.3最新版本
💻 C
📖 第 1 页 / 共 2 页
字号:
  return authorization->response;}voidosip_authorization_set_response (osip_authorization_t * authorization,                                 char *response){  authorization->response = (char *) response;}char *osip_authorization_get_digest (osip_authorization_t * authorization){  return authorization->digest;}voidosip_authorization_set_digest (osip_authorization_t * authorization, char *digest){  authorization->digest = (char *) digest;}char *osip_authorization_get_algorithm (osip_authorization_t * authorization){  return authorization->algorithm;}voidosip_authorization_set_algorithm (osip_authorization_t * authorization,                                  char *algorithm){  authorization->algorithm = (char *) algorithm;}char *osip_authorization_get_cnonce (osip_authorization_t * authorization){  return authorization->cnonce;}voidosip_authorization_set_cnonce (osip_authorization_t * authorization, char *cnonce){  authorization->cnonce = (char *) cnonce;}char *osip_authorization_get_opaque (osip_authorization_t * authorization){  return authorization->opaque;}voidosip_authorization_set_opaque (osip_authorization_t * authorization, char *opaque){  authorization->opaque = (char *) opaque;}char *osip_authorization_get_message_qop (osip_authorization_t * authorization){  return authorization->message_qop;}voidosip_authorization_set_message_qop (osip_authorization_t * authorization,                                    char *message_qop){  authorization->message_qop = (char *) message_qop;}char *osip_authorization_get_nonce_count (osip_authorization_t * authorization){  return authorization->nonce_count;}voidosip_authorization_set_nonce_count (osip_authorization_t * authorization,                                    char *nonce_count){  authorization->nonce_count = (char *) nonce_count;}/* returns the authorization header as a string.          *//* INPUT : osip_authorization_t *authorization | authorization header.  *//* returns null on error. */intosip_authorization_to_str (const osip_authorization_t * auth, char **dest){  size_t 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 *) osip_malloc (len);  if (tmp == NULL)    return -1;  *dest = tmp;  tmp = osip_str_append (tmp, auth->auth_type);  if (auth->username != NULL)    {      tmp = osip_strn_append (tmp, " username=", 10);      /* !! username-value must be a quoted string !! */      tmp = osip_str_append (tmp, auth->username);    }  if (auth->realm != NULL)    {      tmp = osip_strn_append (tmp, ", realm=", 8);      /* !! realm-value must be a quoted string !! */      tmp = osip_str_append (tmp, auth->realm);    }  if (auth->nonce != NULL)    {      tmp = osip_strn_append (tmp, ", nonce=", 8);      /* !! nonce-value must be a quoted string !! */      tmp = osip_str_append (tmp, auth->nonce);    }  if (auth->uri != NULL)    {      tmp = osip_strn_append (tmp, ", uri=", 6);      /* !! domain-value must be a list of URI in a quoted string !! */      tmp = osip_str_append (tmp, auth->uri);    }  if (auth->response != NULL)    {      tmp = osip_strn_append (tmp, ", response=", 11);      /* !! domain-value must be a list of URI in a quoted string !! */      tmp = osip_str_append (tmp, auth->response);    }  if (auth->digest != NULL)    {      tmp = osip_strn_append (tmp, ", digest=", 9);      /* !! domain-value must be a list of URI in a quoted string !! */      tmp = osip_str_append (tmp, auth->digest);    }  if (auth->algorithm != NULL)    {      tmp = osip_strn_append (tmp, ", algorithm=", 12);      tmp = osip_str_append (tmp, auth->algorithm);    }  if (auth->cnonce != NULL)    {      tmp = osip_strn_append (tmp, ", cnonce=", 9);      tmp = osip_str_append (tmp, auth->cnonce);    }  if (auth->opaque != NULL)    {      tmp = osip_strn_append (tmp, ", opaque=", 9);      tmp = osip_str_append (tmp, auth->opaque);    }  if (auth->message_qop != NULL)    {      tmp = osip_strn_append (tmp, ", qop=", 6);      tmp = osip_str_append (tmp, auth->message_qop);    }  if (auth->nonce_count != NULL)    {      tmp = osip_strn_append (tmp, ", nc=", 5);      tmp = osip_str_append (tmp, auth->nonce_count);    }  return 0;}/* deallocates a osip_authorization_t structure.  *//* INPUT : osip_authorization_t *authorization | authorization. */voidosip_authorization_free (osip_authorization_t * authorization){  if (authorization == NULL)    return;  osip_free (authorization->auth_type);  osip_free (authorization->username);  osip_free (authorization->realm);  osip_free (authorization->nonce);  osip_free (authorization->uri);  osip_free (authorization->response);  osip_free (authorization->digest);  osip_free (authorization->algorithm);  osip_free (authorization->cnonce);  osip_free (authorization->opaque);  osip_free (authorization->message_qop);  osip_free (authorization->nonce_count);  osip_free (authorization);}intosip_authorization_clone (const osip_authorization_t * auth,                          osip_authorization_t ** dest){  int i;  osip_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 = osip_authorization_init (&au);  if (i == -1)                  /* allocation failed */    return -1;  if (auth->auth_type != NULL)    {      au->auth_type = osip_strdup (auth->auth_type);      if (au->auth_type == NULL)        goto ac_error;    }  if (auth->username != NULL)    {      au->username = osip_strdup (auth->username);      if (au->username == NULL)        goto ac_error;    }  if (auth->realm != NULL)    {      au->realm = osip_strdup (auth->realm);      if (auth->realm == NULL)        goto ac_error;    }  if (auth->nonce != NULL)    {      au->nonce = osip_strdup (auth->nonce);      if (auth->nonce == NULL)        goto ac_error;    }  if (auth->uri != NULL)    {      au->uri = osip_strdup (auth->uri);      if (au->uri == NULL)        goto ac_error;    }  if (auth->response != NULL)    {      au->response = osip_strdup (auth->response);      if (auth->response == NULL)        goto ac_error;    }  if (auth->digest != NULL)    {      au->digest = osip_strdup (auth->digest);      if (au->digest == NULL)        goto ac_error;    }  if (auth->algorithm != NULL)    {      au->algorithm = osip_strdup (auth->algorithm);      if (auth->algorithm == NULL)        goto ac_error;    }  if (auth->cnonce != NULL)    {      au->cnonce = osip_strdup (auth->cnonce);      if (au->cnonce == NULL)        goto ac_error;    }  if (auth->opaque != NULL)    {      au->opaque = osip_strdup (auth->opaque);      if (auth->opaque == NULL)        goto ac_error;    }  if (auth->message_qop != NULL)    {      au->message_qop = osip_strdup (auth->message_qop);      if (auth->message_qop == NULL)        goto ac_error;    }  if (auth->nonce_count != NULL)    {      au->nonce_count = osip_strdup (auth->nonce_count);      if (auth->nonce_count == NULL)        goto ac_error;    }  *dest = au;  return 0;ac_error:  osip_authorization_free (au);  return -1;}

⌨️ 快捷键说明

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