return 0;
}
-static int handle_boundary(int *filter_stage, int *header_stage)
+static int handle_boundary(struct strbuf *line, int *filter_stage, int *header_stage)
{
struct strbuf newline = STRBUF_INIT;
strbuf_addch(&newline, '\n');
again:
- if (line.len >= (*content_top)->len + 2 &&
- !memcmp(line.buf + (*content_top)->len, "--", 2)) {
+ if (line->len >= (*content_top)->len + 2 &&
+ !memcmp(line->buf + (*content_top)->len, "--", 2)) {
/* we hit an end boundary */
/* pop the current boundary off the stack */
strbuf_release(*content_top);
strbuf_reset(&charset);
/* slurp in this section's info */
- while (read_one_header_line(&line, fin))
- check_header(&line, p_hdr_data, 0);
+ while (read_one_header_line(line, fin))
+ check_header(line, p_hdr_data, 0);
strbuf_release(&newline);
/* replenish line */
- if (strbuf_getline(&line, fin, '\n'))
+ if (strbuf_getline(line, fin, '\n'))
return 0;
- strbuf_addch(&line, '\n');
+ strbuf_addch(line, '\n');
return 1;
}
-static void handle_body(void)
+static void handle_body(struct strbuf *line)
{
struct strbuf prev = STRBUF_INIT;
int filter_stage = 0;
do {
/* process any boundary lines */
- if (*content_top && is_multipart_boundary(&line)) {
+ if (*content_top && is_multipart_boundary(line)) {
/* flush any leftover */
if (prev.len) {
handle_filter(&prev, &filter_stage, &header_stage);
strbuf_reset(&prev);
}
- if (!handle_boundary(&filter_stage, &header_stage))
+ if (!handle_boundary(line, &filter_stage, &header_stage))
goto handle_body_out;
}
/* Unwrap transfer encoding */
- decode_transfer_encoding(&line);
+ decode_transfer_encoding(line);
switch (transfer_encoding) {
case TE_BASE64:
struct strbuf **lines, **it, *sb;
/* Prepend any previous partial lines */
- strbuf_insert(&line, 0, prev.buf, prev.len);
+ strbuf_insert(line, 0, prev.buf, prev.len);
strbuf_reset(&prev);
/*
* multiple new lines. Pass only one chunk
* at a time to handle_filter()
*/
- lines = strbuf_split(&line, '\n');
+ lines = strbuf_split(line, '\n');
for (it = lines; (sb = *it); it++) {
if (*(it + 1) == NULL) /* The last line */
if (sb->buf[sb->len - 1] != '\n') {
break;
}
default:
- handle_filter(&line, &filter_stage, &header_stage);
+ handle_filter(line, &filter_stage, &header_stage);
}
- } while (!strbuf_getwholeline(&line, fin, '\n'));
+ } while (!strbuf_getwholeline(line, fin, '\n'));
handle_body_out:
strbuf_release(&prev);
while (read_one_header_line(&line, fin))
check_header(&line, p_hdr_data, 1);
- handle_body();
+ handle_body(&line);
fclose(patchfile);
handle_info();