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

📄 osip_from.c

📁 libosip2-3.0.3最新版本
💻 C
📖 第 1 页 / 共 2 页
字号:
  }  *dest = buf;  return 0;}char *osip_from_get_displayname (osip_from_t * from){  if (from == NULL)    return NULL;  return from->displayname;}voidosip_from_set_displayname (osip_from_t * from, char *displayname){  from->displayname = displayname;}osip_uri_t *osip_from_get_url (osip_from_t * from){  if (from == NULL)    return NULL;  return from->url;}voidosip_from_set_url (osip_from_t * from, osip_uri_t * url){  from->url = url;}intosip_from_param_get (osip_from_t * from, int pos, osip_generic_param_t ** fparam){  *fparam = NULL;  if (from == NULL)    return -1;  if (osip_list_size (&from->gen_params) <= pos)    return -1;                  /* does not exist */  *fparam = (osip_generic_param_t *) osip_list_get (&from->gen_params, pos);  return pos;}intosip_from_clone (const osip_from_t * from, osip_from_t ** dest){  int i;  osip_from_t *fr;  *dest = NULL;  if (from == NULL)    return -1;  i = osip_from_init (&fr);  if (i != 0)                   /* allocation failed */    return -1;  if (from->displayname != NULL)    fr->displayname = osip_strdup (from->displayname);  if (from->url != NULL)    {      i = osip_uri_clone (from->url, &(fr->url));      if (i != 0)        {          osip_from_free (fr);          return -1;        }    }  i = osip_list_clone(&from->gen_params, &fr->gen_params, (int *(*)(void *, void *)) &osip_generic_param_clone);  if (i != 0)    {      osip_from_free (fr);      return -1;    }  *dest = fr;  return 0;}intosip_from_compare (osip_from_t * from1, osip_from_t * from2){  char *tag1;  char *tag2;  if (from1 == NULL || from2 == NULL)    return -1;  if (from1->url == NULL || from2->url == NULL)    return -1;  /* we could have a sip or sips url, but if string!=NULL,     host part will be NULL. */  if (from1->url->host == NULL && from2->url->host == NULL)    {      if (from1->url->string == NULL || from2->url->string == NULL)        return -1;      if (0 == strcmp (from1->url->string, from2->url->string))        return 0;    }  if (from1->url->host == NULL || from2->url->host == NULL)    return -1;  /* compare url including tag */  if (0 != strcmp (from1->url->host, from2->url->host))    return -1;  if (from1->url->username != NULL && from2->url->username != NULL)    if (0 != strcmp (from1->url->username, from2->url->username))      return -1;  tag1 = NULL;  tag2 = NULL;  {    int pos = 0;    osip_generic_param_t *u_param;    while (!osip_list_eol (&from1->gen_params, pos))      {        u_param = (osip_generic_param_t *) osip_list_get (&from1->gen_params, pos);        if (0 == strncmp (u_param->gname, "tag", 3))          {            tag1 = u_param->gvalue;            break;          }        pos++;      }  }  {    int pos = 0;    osip_generic_param_t *u_param;    while (!osip_list_eol (&from2->gen_params, pos))      {        u_param = (osip_generic_param_t *) osip_list_get (&from2->gen_params, pos);        if (0 == strncmp (u_param->gname, "tag", 3))          {            tag2 = u_param->gvalue;            break;          }        pos++;      }  }  /* sounds like a BUG!     if tag2 exists and tag1 does not, then it will     return 0;     in the first request, (INVITE) the To field does not     contain any tag. The response contains one! and the     response must match the request....   */  /* so we test the tags only when both exist! */  if (tag1 != NULL && tag2 != NULL)    if (0 != strcmp (tag1, tag2))      return -1;  /* We could return a special case, when */  /* only one tag exists?? */  return 0;                     /* return code changed to 0 from release 0.6.1 */}int__osip_generic_param_parseall (osip_list_t * gen_params, const char *params){  char *pname;  char *pvalue;  const char *comma;  const char *equal;  /* find '=' wich is the separator for one param */  /* find ';' wich is the separator for multiple params */  equal = next_separator (params + 1, '=', ';');  comma = strchr (params + 1, ';');  while (comma != NULL)    {      if (equal == NULL)        {          equal = comma;          pvalue = NULL;      } else        {          const char *tmp;          /* check for NULL param with an '=' character */          tmp = equal + 1;          for (; *tmp == '\t' || *tmp == ' '; tmp++)            {            }          pvalue = NULL;          if (*tmp != ',' && *tmp != '\0')            {              if (comma - equal < 2)                return -1;              pvalue = (char *) osip_malloc (comma - equal);              if (pvalue == NULL)                return -1;              osip_strncpy (pvalue, equal + 1, comma - equal - 1);            }        }      if (equal - params < 2)        {          osip_free (pvalue);          return -1;        }      pname = (char *) osip_malloc (equal - params);      if (pname == NULL)        {          osip_free (pvalue);          return -1;        }      osip_strncpy (pname, params + 1, equal - params - 1);      osip_generic_param_add (gen_params, pname, pvalue);      params = comma;      equal = next_separator (params + 1, '=', ';');      comma = strchr (params + 1, ';');    }  /* this is the last header (comma==NULL) */  comma = params + strlen (params);  if (equal == NULL)    {      equal = comma;            /* at the end */      pvalue = NULL;  } else    {      const char *tmp;      /* check for NULL param with an '=' character */      tmp = equal + 1;      for (; *tmp == '\t' || *tmp == ' '; tmp++)        {        }      pvalue = NULL;      if (*tmp != ',' && *tmp != '\0')        {          if (comma - equal < 2)            return -1;          pvalue = (char *) osip_malloc (comma - equal);          if (pvalue == NULL)            return -1;          osip_strncpy (pvalue, equal + 1, comma - equal - 1);        }    }  if (equal - params < 2)    {      osip_free (pvalue);      return -1;    }  pname = (char *) osip_malloc (equal - params);  if (pname == NULL)    {      osip_free (pvalue);      return -1;    }  osip_strncpy (pname, params + 1, equal - params - 1);  osip_generic_param_add (gen_params, pname, pvalue);  return 0;}voidosip_generic_param_set_value (osip_generic_param_t * fparam, char *value){  fparam->gvalue = value;}char *osip_generic_param_get_name (const osip_generic_param_t * fparam){  if (fparam == NULL)    return NULL;  return fparam->gname;}voidosip_generic_param_set_name (osip_generic_param_t * fparam, char *name){  fparam->gname = name;}char *osip_generic_param_get_value (const osip_generic_param_t * fparam){  if (fparam == NULL)    return NULL;  if (fparam->gname == NULL)    return NULL;                /* name is mandatory */  return fparam->gvalue;}intosip_from_tag_match (osip_from_t * from1, osip_from_t * from2){  osip_generic_param_t *tag_from1;  osip_generic_param_t *tag_from2;  osip_from_param_get_byname (from1, "tag", &tag_from1);  osip_from_param_get_byname (from2, "tag", &tag_from2);  if (tag_from1 == NULL && tag_from2 == NULL)    return 0;  if ((tag_from1 != NULL && tag_from2 == NULL)      || (tag_from1 == NULL && tag_from2 != NULL))    return -1;  if (tag_from1->gvalue == NULL || tag_from2->gvalue == NULL)    return -1;  if (0 != strcmp (tag_from1->gvalue, tag_from2->gvalue))    return -1;  return 0;}

⌨️ 快捷键说明

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