int osip_content_length_clone (const osip_content_length_t * ctl, osip_content_length_t ** dest) { int i; osip_content_length_t *cl; *dest = NULL; if (ctl == NULL) return OSIP_BADPARAMETER; /* empty headers are allowed: if (ctl->value==NULL) return -1; */ i = osip_content_length_init (&cl); if (i != 0) /* allocation failed */ return i; if (ctl->value != NULL) { cl->value = osip_strdup (ctl->value); if (cl->value == NULL) { osip_content_length_free (cl); return OSIP_NOMEM; } } *dest = cl; return OSIP_SUCCESS; }
/* returns -1 on error. */ int osip_message_set_content_length (osip_message_t * sip, const char *hvalue) { int i; if (hvalue == NULL || hvalue[0] == '\0') return OSIP_SUCCESS; if (sip->content_length != NULL) return OSIP_SYNTAXERROR; i = osip_content_length_init (&(sip->content_length)); if (i != 0) return i; sip->message_property = 2; i = osip_content_length_parse (sip->content_length, hvalue); if (i != 0) { osip_content_length_free (sip->content_length); sip->content_length = NULL; return i; } return OSIP_SUCCESS; }
int osip_content_length_clone (const osip_content_length_t * ctl, osip_content_length_t ** dest) { int i; osip_content_length_t *cl; *dest = NULL; if (ctl == NULL) return -1; /* empty headers are allowed: if (ctl->value==NULL) return -1; */ i = osip_content_length_init (&cl); if (i == -1) /* allocation failed */ return -1; if (ctl->value != NULL) cl->value = osip_strdup (ctl->value); *dest = cl; return 0; }