/* looks inside the message, gets the Content-Disposition hdr, parse it, builds * and fills a disposition structure for it what will be attached to hdr as * parsed link. * Returns: -1 : error * 0 : success * 1 : hdr not found */ int parse_content_disposition( struct sip_msg *msg ) { struct disposition *disp; /* look for Content-Disposition header */ if (msg->content_disposition==0) { if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1) goto error; if (msg->content_disposition==0) { LM_DBG("hdr not found\n"); return 1; } } /* now, we have the header -> look if it isn't already parsed */ if (msg->content_disposition->parsed!=0) { /* already parsed, nothing more to be done */ return 0; } /* parse the body */ disp = (struct disposition*)pkg_malloc(sizeof(struct disposition)); if (disp==0) { LM_ERR("no more pkg memory\n"); goto error; } memset(disp,0,sizeof(struct disposition)); switch (parse_disposition( &(msg->content_disposition->body), disp)) { case -2: /* TODO - error set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM, "error parsing DISPOSITION header"); set_err_reply(400, "bad headers"); */ case -1: /* error when parsing the body */ free_disposition( &disp ); goto error; } /* attach the parsed form to the header */ msg->content_disposition->parsed = (void*)disp; return 0; error: return -1; }
/*! \brief looks inside the message, gets the Content-Disposition hdr, parse it, builds * and fills a disposition structure for it what will be attached to hdr as * parsed link. * Returns: -1 : error * 0 : success * 1 : hdr not found */ int parse_content_disposition( struct sip_msg *msg ) { struct disposition *disp; /* look for Content-Disposition header */ if (msg->content_disposition==0) { if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1) goto error; if (msg->content_disposition==0) { DBG("DEBUG:parse_content_disposition: hdr not found\n"); return 1; } } /* now, we have the header -> look if it isn't already parsed */ if (msg->content_disposition->parsed!=0) { /* already parsed, nothing more to be done */ return 0; } /* parse the body */ disp = (struct disposition*)pkg_malloc(sizeof(struct disposition)); if (disp==0) { LOG(L_ERR,"ERROR:parse_content_disposition: no more pkg memory\n"); goto error; } memset(disp,0,sizeof(struct disposition)); if (parse_disposition( &(msg->content_disposition->body), disp)==-1) { /* error when parsing the body */ free_disposition( &disp ); goto error; } /* attach the parsed form to the header */ msg->content_disposition->parsed = (void*)disp; return 0; error: return -1; }