int
osip_accept_encoding_clone (const osip_accept_encoding_t * ctt,
                            osip_accept_encoding_t ** dest)
{
  int i;
  osip_accept_encoding_t *ct;

  *dest = NULL;
  if (ctt == NULL)
    return -1;
  if (ctt->element == NULL)
    return -1;

  i = osip_accept_encoding_init (&ct);
  if (i != 0)                   /* allocation failed */
    return -1;
  ct->element = osip_strdup (ctt->element);
  if (ctt->element != NULL && ct->element == NULL)
    {
      osip_accept_encoding_free (ct);
      return -1;
    }
  {
    int pos = 0;
    osip_generic_param_t *u_param;
    osip_generic_param_t *dest_param;

    while (!osip_list_eol (&ctt->gen_params, pos))
      {
        u_param = (osip_generic_param_t *) osip_list_get (&ctt->gen_params, pos);
        i = osip_generic_param_clone (u_param, &dest_param);
        if (i != 0)
          {
            osip_accept_encoding_free (ct);
            return -1;
          }
        osip_list_add (&ct->gen_params, dest_param, -1);
        pos++;
      }
  }
  *dest = ct;
  return 0;
}
Ejemplo n.º 2
0
/* Accept-Encoding = token
   token possible values are gzip,compress,deflate,identity
*/
int osip_message_set_accept_encoding(osip_message_t * sip, const char *hvalue)
{
	osip_accept_encoding_t *accept_encoding;
	int i;

	if (hvalue == NULL || hvalue[0] == '\0')
		return OSIP_SUCCESS;

	i = osip_accept_encoding_init(&accept_encoding);
	if (i != 0)
		return i;
	i = osip_accept_encoding_parse(accept_encoding, hvalue);
	if (i != 0) {
		osip_accept_encoding_free(accept_encoding);
		return i;
	}
	sip->message_property = 2;
	osip_list_add(&sip->accept_encodings, accept_encoding, -1);
	return OSIP_SUCCESS;
}
Ejemplo n.º 3
0
int
osip_accept_encoding_clone (const osip_accept_encoding_t * ctt, osip_accept_encoding_t ** dest)
{
  int i;
  osip_accept_encoding_t *ct;

  *dest = NULL;
  if (ctt == NULL)
    return OSIP_BADPARAMETER;
  if (ctt->element == NULL)
    return OSIP_BADPARAMETER;

  i = osip_accept_encoding_init (&ct);
  if (i != 0)                   /* allocation failed */
    return i;
  ct->element = osip_strdup (ctt->element);
  if (ct->element == NULL) {
    osip_accept_encoding_free (ct);
    return OSIP_NOMEM;
  }
  {
    osip_generic_param_t *dest_param;
    osip_list_iterator_t it;
    osip_generic_param_t *u_param = (osip_generic_param_t*) osip_list_get_first(&ctt->gen_params, &it);
    while (u_param != OSIP_SUCCESS) {
      i = osip_generic_param_clone (u_param, &dest_param);
      if (i != 0) {
        osip_accept_encoding_free (ct);
        return i;
      }
      osip_list_add (&ct->gen_params, dest_param, -1);
      u_param = (osip_generic_param_t *) osip_list_get_next(&it);
    }
  }
  *dest = ct;
  return OSIP_SUCCESS;
}