Lines Matching refs:part
69 curl_mimepart *part);
70 static curl_off_t encoder_nop_size(curl_mimepart *part);
72 curl_mimepart *part);
74 curl_mimepart *part);
75 static curl_off_t encoder_base64_size(curl_mimepart *part);
77 curl_mimepart *part);
78 static curl_off_t encoder_qp_size(curl_mimepart *part);
79 static curl_off_t mime_size(curl_mimepart *part);
385 struct curl_mimepart *part) in encoder_nop_read() argument
387 struct mime_encoder_state *st = &part->encstate; in encoder_nop_read()
405 static curl_off_t encoder_nop_size(curl_mimepart *part) in encoder_nop_size() argument
407 return part->datasize; in encoder_nop_size()
413 curl_mimepart *part) in encoder_7bit_read() argument
415 struct mime_encoder_state *st = &part->encstate; in encoder_7bit_read()
439 curl_mimepart *part) in encoder_base64_read() argument
441 struct mime_encoder_state *st = &part->encstate; in encoder_base64_read()
517 static curl_off_t encoder_base64_size(curl_mimepart *part) in encoder_base64_size() argument
519 curl_off_t size = part->datasize; in encoder_base64_size()
552 curl_mimepart *part) in encoder_qp_read() argument
554 struct mime_encoder_state *st = &part->encstate; in encoder_qp_read()
652 static curl_off_t encoder_qp_size(curl_mimepart *part) in encoder_qp_size() argument
656 return part->datasize ? -1 : 0; in encoder_qp_size()
665 curl_mimepart *part = (curl_mimepart *) instream; in mime_mem_read() local
666 size_t sz = curlx_sotouz(part->datasize - part->state.offset); in mime_mem_read()
676 memcpy(buffer, part->data + curlx_sotouz(part->state.offset), sz); in mime_mem_read()
683 curl_mimepart *part = (curl_mimepart *) instream; in mime_mem_seek() local
687 offset += part->state.offset; in mime_mem_seek()
690 offset += part->datasize; in mime_mem_seek()
694 if(offset < 0 || offset > part->datasize) in mime_mem_seek()
697 part->state.offset = offset; in mime_mem_seek()
709 static int mime_open_file(curl_mimepart *part) in mime_open_file() argument
713 if(part->fp) in mime_open_file()
715 part->fp = fopen_read(part->data, "rb"); in mime_open_file()
716 return part->fp ? 0 : -1; in mime_open_file()
722 curl_mimepart *part = (curl_mimepart *) instream; in mime_file_read() local
727 if(mime_open_file(part)) in mime_file_read()
730 return fread(buffer, size, nitems, part->fp); in mime_file_read()
735 curl_mimepart *part = (curl_mimepart *) instream; in mime_file_seek() local
737 if(whence == SEEK_SET && !offset && !part->fp) in mime_file_seek()
740 if(mime_open_file(part)) in mime_file_seek()
743 return fseek(part->fp, (long) offset, whence) ? in mime_file_seek()
749 curl_mimepart *part = (curl_mimepart *) ptr; in mime_file_free() local
751 if(part->fp) { in mime_file_free()
752 fclose(part->fp); in mime_file_free()
753 part->fp = NULL; in mime_file_free()
755 Curl_safefree(part->data); in mime_file_free()
792 static size_t read_part_content(curl_mimepart *part, in read_part_content() argument
797 switch(part->lastreadstatus) { in read_part_content()
802 return part->lastreadstatus; in read_part_content()
808 if(part->datasize != (curl_off_t) -1 && in read_part_content()
809 part->state.offset >= part->datasize) { in read_part_content()
813 switch(part->kind) { in read_part_content()
819 sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread); in read_part_content()
822 if(part->fp && feof(part->fp)) in read_part_content()
826 if(part->readfunc) { in read_part_content()
827 if(!(part->flags & MIME_FAST_READ)) { in read_part_content()
832 sz = part->readfunc(buffer, 1, bufsize, part->arg); in read_part_content()
845 part->lastreadstatus = sz; in read_part_content()
848 part->state.offset += sz; in read_part_content()
849 part->lastreadstatus = sz; in read_part_content()
857 static size_t read_encoded_part_content(curl_mimepart *part, char *buffer, in read_encoded_part_content() argument
860 struct mime_encoder_state *st = &part->encstate; in read_encoded_part_content()
868 sz = part->encoder->encodefunc(buffer, bufsize, ateof, part); in read_encoded_part_content()
896 sz = read_part_content(part, st->buf + st->bufend, in read_encoded_part_content()
917 static size_t readback_part(curl_mimepart *part, in readback_part() argument
926 struct curl_slist *hdr = (struct curl_slist *) part->state.ptr; in readback_part()
927 switch(part->state.state) { in readback_part()
929 mimesetstate(&part->state, in readback_part()
930 (part->flags & MIME_BODY_ONLY) ? in readback_part()
932 part->curlheaders); in readback_part()
936 mimesetstate(&part->state, MIMESTATE_EOH, NULL); in readback_part()
940 mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next); in readback_part()
946 mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders); in readback_part()
948 sz = readback_bytes(&part->state, buffer, bufsize, in readback_part()
951 mimesetstate(&part->state, part->state.state, hdr->next); in readback_part()
955 sz = readback_bytes(&part->state, buffer, bufsize, STRCONST("\r\n"), in readback_part()
958 mimesetstate(&part->state, MIMESTATE_BODY, NULL); in readback_part()
961 cleanup_encoder_state(&part->encstate); in readback_part()
962 mimesetstate(&part->state, MIMESTATE_CONTENT, NULL); in readback_part()
965 if(part->encoder) in readback_part()
966 sz = read_encoded_part_content(part, buffer, bufsize, hasread); in readback_part()
968 sz = read_part_content(part, buffer, bufsize, hasread); in readback_part()
971 mimesetstate(&part->state, MIMESTATE_END, NULL); in readback_part()
973 if(part->kind == MIMEKIND_FILE && part->fp) { in readback_part()
974 fclose(part->fp); in readback_part()
975 part->fp = NULL; in readback_part()
1010 curl_mimepart *part = mime->state.ptr; in mime_subparts_read() local
1024 mimesetstate(&mime->state, MIMESTATE_BOUNDARY2, part); in mime_subparts_read()
1027 if(part) in mime_subparts_read()
1034 mimesetstate(&mime->state, MIMESTATE_CONTENT, part); in mime_subparts_read()
1038 if(!part) { in mime_subparts_read()
1042 sz = readback_part(part, buffer, nitems, hasread); in mime_subparts_read()
1050 mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, part->nextpart); in mime_subparts_read()
1069 static int mime_part_rewind(curl_mimepart *part) in mime_part_rewind() argument
1074 if(part->flags & MIME_BODY_ONLY) in mime_part_rewind()
1076 cleanup_encoder_state(&part->encstate); in mime_part_rewind()
1077 if(part->state.state > targetstate) { in mime_part_rewind()
1079 if(part->seekfunc) { in mime_part_rewind()
1080 res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET); in mime_part_rewind()
1097 mimesetstate(&part->state, targetstate, NULL); in mime_part_rewind()
1099 part->lastreadstatus = 1; /* Successful read status. */ in mime_part_rewind()
1106 curl_mimepart *part; in mime_subparts_seek() local
1115 for(part = mime->firstpart; part; part = part->nextpart) { in mime_subparts_seek()
1116 int res = mime_part_rewind(part); in mime_subparts_seek()
1128 static void cleanup_part_content(curl_mimepart *part) in cleanup_part_content() argument
1130 if(part->freefunc) in cleanup_part_content()
1131 part->freefunc(part->arg); in cleanup_part_content()
1133 part->readfunc = NULL; in cleanup_part_content()
1134 part->seekfunc = NULL; in cleanup_part_content()
1135 part->freefunc = NULL; in cleanup_part_content()
1136 part->arg = (void *) part; /* Defaults to part itself. */ in cleanup_part_content()
1137 part->data = NULL; in cleanup_part_content()
1138 part->fp = NULL; in cleanup_part_content()
1139 part->datasize = (curl_off_t) 0; /* No size yet. */ in cleanup_part_content()
1140 cleanup_encoder_state(&part->encstate); in cleanup_part_content()
1141 part->kind = MIMEKIND_NONE; in cleanup_part_content()
1142 part->flags &= ~(unsigned int)MIME_FAST_READ; in cleanup_part_content()
1143 part->lastreadstatus = 1; /* Successful read status. */ in cleanup_part_content()
1144 part->state.state = MIMESTATE_BEGIN; in cleanup_part_content()
1171 void Curl_mime_cleanpart(curl_mimepart *part) in Curl_mime_cleanpart() argument
1173 if(part) { in Curl_mime_cleanpart()
1174 cleanup_part_content(part); in Curl_mime_cleanpart()
1175 curl_slist_free_all(part->curlheaders); in Curl_mime_cleanpart()
1176 if(part->flags & MIME_USERHEADERS_OWNER) in Curl_mime_cleanpart()
1177 curl_slist_free_all(part->userheaders); in Curl_mime_cleanpart()
1178 Curl_safefree(part->mimetype); in Curl_mime_cleanpart()
1179 Curl_safefree(part->name); in Curl_mime_cleanpart()
1180 Curl_safefree(part->filename); in Curl_mime_cleanpart()
1181 Curl_mime_initpart(part); in Curl_mime_cleanpart()
1188 curl_mimepart *part; in curl_mime_free() local
1193 part = mime->firstpart; in curl_mime_free()
1194 mime->firstpart = part->nextpart; in curl_mime_free()
1195 Curl_mime_cleanpart(part); in curl_mime_free()
1196 free(part); in curl_mime_free()
1310 void Curl_mime_initpart(curl_mimepart *part) in Curl_mime_initpart() argument
1312 memset((char *) part, 0, sizeof(*part)); in Curl_mime_initpart()
1313 part->lastreadstatus = 1; /* Successful read status. */ in Curl_mime_initpart()
1314 mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); in Curl_mime_initpart()
1320 curl_mimepart *part; in curl_mime_addpart() local
1325 part = (curl_mimepart *) malloc(sizeof(*part)); in curl_mime_addpart()
1327 if(part) { in curl_mime_addpart()
1328 Curl_mime_initpart(part); in curl_mime_addpart()
1329 part->parent = mime; in curl_mime_addpart()
1332 mime->lastpart->nextpart = part; in curl_mime_addpart()
1334 mime->firstpart = part; in curl_mime_addpart()
1336 mime->lastpart = part; in curl_mime_addpart()
1339 return part; in curl_mime_addpart()
1343 CURLcode curl_mime_name(curl_mimepart *part, const char *name) in curl_mime_name() argument
1345 if(!part) in curl_mime_name()
1348 Curl_safefree(part->name); in curl_mime_name()
1351 part->name = strdup(name); in curl_mime_name()
1352 if(!part->name) in curl_mime_name()
1360 CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) in curl_mime_filename() argument
1362 if(!part) in curl_mime_filename()
1365 Curl_safefree(part->filename); in curl_mime_filename()
1368 part->filename = strdup(filename); in curl_mime_filename()
1369 if(!part->filename) in curl_mime_filename()
1377 CURLcode curl_mime_data(curl_mimepart *part, in curl_mime_data() argument
1380 if(!part) in curl_mime_data()
1383 cleanup_part_content(part); in curl_mime_data()
1389 part->data = Curl_memdup0(ptr, datasize); in curl_mime_data()
1390 if(!part->data) in curl_mime_data()
1393 part->datasize = datasize; in curl_mime_data()
1394 part->readfunc = mime_mem_read; in curl_mime_data()
1395 part->seekfunc = mime_mem_seek; in curl_mime_data()
1396 part->freefunc = mime_mem_free; in curl_mime_data()
1397 part->flags |= MIME_FAST_READ; in curl_mime_data()
1398 part->kind = MIMEKIND_DATA; in curl_mime_data()
1405 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) in curl_mime_filedata() argument
1409 if(!part) in curl_mime_filedata()
1412 cleanup_part_content(part); in curl_mime_filedata()
1421 part->data = strdup(filename); in curl_mime_filedata()
1422 if(!part->data) in curl_mime_filedata()
1425 part->datasize = -1; in curl_mime_filedata()
1427 part->datasize = filesize(filename, sbuf); in curl_mime_filedata()
1428 part->seekfunc = mime_file_seek; in curl_mime_filedata()
1431 part->readfunc = mime_file_read; in curl_mime_filedata()
1432 part->freefunc = mime_file_free; in curl_mime_filedata()
1433 part->kind = MIMEKIND_FILE; in curl_mime_filedata()
1443 result = curl_mime_filename(part, base); in curl_mime_filedata()
1453 CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) in curl_mime_type() argument
1455 if(!part) in curl_mime_type()
1458 Curl_safefree(part->mimetype); in curl_mime_type()
1461 part->mimetype = strdup(mimetype); in curl_mime_type()
1462 if(!part->mimetype) in curl_mime_type()
1470 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) in curl_mime_encoder() argument
1475 if(!part) in curl_mime_encoder()
1478 part->encoder = NULL; in curl_mime_encoder()
1485 part->encoder = mep; in curl_mime_encoder()
1493 CURLcode curl_mime_headers(curl_mimepart *part, in curl_mime_headers() argument
1496 if(!part) in curl_mime_headers()
1499 if(part->flags & MIME_USERHEADERS_OWNER) { in curl_mime_headers()
1500 if(part->userheaders != headers) /* Allow setting twice the same list. */ in curl_mime_headers()
1501 curl_slist_free_all(part->userheaders); in curl_mime_headers()
1502 part->flags &= ~(unsigned int)MIME_USERHEADERS_OWNER; in curl_mime_headers()
1504 part->userheaders = headers; in curl_mime_headers()
1506 part->flags |= MIME_USERHEADERS_OWNER; in curl_mime_headers()
1511 CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize, in curl_mime_data_cb() argument
1516 if(!part) in curl_mime_data_cb()
1519 cleanup_part_content(part); in curl_mime_data_cb()
1522 part->readfunc = readfunc; in curl_mime_data_cb()
1523 part->seekfunc = seekfunc; in curl_mime_data_cb()
1524 part->freefunc = freefunc; in curl_mime_data_cb()
1525 part->arg = arg; in curl_mime_data_cb()
1526 part->datasize = datasize; in curl_mime_data_cb()
1527 part->kind = MIMEKIND_CALLBACK; in curl_mime_data_cb()
1534 CURLcode Curl_mime_set_subparts(curl_mimepart *part, in Curl_mime_set_subparts() argument
1539 if(!part) in Curl_mime_set_subparts()
1543 if(part->kind == MIMEKIND_MULTIPART && part->arg == subparts) in Curl_mime_set_subparts()
1546 cleanup_part_content(part); in Curl_mime_set_subparts()
1554 root = part->parent; in Curl_mime_set_subparts()
1564 subparts->parent = part; in Curl_mime_set_subparts()
1566 part->seekfunc = mime_subparts_seek; in Curl_mime_set_subparts()
1567 part->freefunc = take_ownership ? mime_subparts_free : in Curl_mime_set_subparts()
1569 part->arg = subparts; in Curl_mime_set_subparts()
1570 part->datasize = -1; in Curl_mime_set_subparts()
1571 part->kind = MIMEKIND_MULTIPART; in Curl_mime_set_subparts()
1577 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) in curl_mime_subparts() argument
1579 return Curl_mime_set_subparts(part, subparts, TRUE); in curl_mime_subparts()
1587 curl_mimepart *part = (curl_mimepart *) instream; in Curl_mime_read() local
1597 ret = readback_part(part, buffer, nitems, &hasread); in Curl_mime_read()
1610 static CURLcode mime_rewind(curl_mimepart *part) in mime_rewind() argument
1612 return mime_part_rewind(part) == CURL_SEEKFUNC_OK ? in mime_rewind()
1633 curl_mimepart *part; in multipart_size() local
1641 for(part = mime->firstpart; part; part = part->nextpart) { in multipart_size()
1642 curl_off_t sz = mime_size(part); in multipart_size()
1655 static curl_off_t mime_size(curl_mimepart *part) in mime_size() argument
1659 if(part->kind == MIMEKIND_MULTIPART) in mime_size()
1660 part->datasize = multipart_size(part->arg); in mime_size()
1662 size = part->datasize; in mime_size()
1664 if(part->encoder) in mime_size()
1665 size = part->encoder->sizefunc(part); in mime_size()
1667 if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) { in mime_size()
1669 size += slist_size(part->curlheaders, 2, NULL, 0); in mime_size()
1670 size += slist_size(part->userheaders, 2, in mime_size()
1764 curl_mimepart *part, in Curl_mime_prepare_headers() argument
1776 curl_slist_free_all(part->curlheaders); in Curl_mime_prepare_headers()
1777 part->curlheaders = NULL; in Curl_mime_prepare_headers()
1780 if(part->state.state == MIMESTATE_CURLHEADERS) in Curl_mime_prepare_headers()
1781 mimesetstate(&part->state, MIMESTATE_CURLHEADERS, NULL); in Curl_mime_prepare_headers()
1784 customct = part->mimetype; in Curl_mime_prepare_headers()
1786 customct = search_header(part->userheaders, STRCONST("Content-Type")); in Curl_mime_prepare_headers()
1792 switch(part->kind) { in Curl_mime_prepare_headers()
1797 contenttype = Curl_mime_contenttype(part->filename); in Curl_mime_prepare_headers()
1799 contenttype = Curl_mime_contenttype(part->data); in Curl_mime_prepare_headers()
1800 if(!contenttype && part->filename) in Curl_mime_prepare_headers()
1804 contenttype = Curl_mime_contenttype(part->filename); in Curl_mime_prepare_headers()
1809 if(part->kind == MIMEKIND_MULTIPART) { in Curl_mime_prepare_headers()
1810 mime = (curl_mime *) part->arg; in Curl_mime_prepare_headers()
1816 if(strategy == MIMESTRATEGY_MAIL || !part->filename) in Curl_mime_prepare_headers()
1820 if(!search_header(part->userheaders, STRCONST("Content-Disposition"))) { in Curl_mime_prepare_headers()
1822 if(part->filename || part->name || in Curl_mime_prepare_headers()
1826 !part->name && !part->filename) in Curl_mime_prepare_headers()
1832 if(part->name) { in Curl_mime_prepare_headers()
1833 name = escape_string(data, part->name, strategy); in Curl_mime_prepare_headers()
1837 if(!ret && part->filename) { in Curl_mime_prepare_headers()
1838 filename = escape_string(data, part->filename, strategy); in Curl_mime_prepare_headers()
1843 ret = Curl_mime_add_header(&part->curlheaders, in Curl_mime_prepare_headers()
1861 ret = add_content_type(&part->curlheaders, contenttype, boundary); in Curl_mime_prepare_headers()
1867 if(!search_header(part->userheaders, in Curl_mime_prepare_headers()
1869 if(part->encoder) in Curl_mime_prepare_headers()
1870 cte = part->encoder->name; in Curl_mime_prepare_headers()
1872 part->kind != MIMEKIND_MULTIPART) in Curl_mime_prepare_headers()
1875 ret = Curl_mime_add_header(&part->curlheaders, in Curl_mime_prepare_headers()
1884 if(part->state.state == MIMESTATE_CURLHEADERS) in Curl_mime_prepare_headers()
1885 mimesetstate(&part->state, MIMESTATE_CURLHEADERS, part->curlheaders); in Curl_mime_prepare_headers()
1888 if(part->kind == MIMEKIND_MULTIPART && mime) { in Curl_mime_prepare_headers()
1905 static void mime_unpause(curl_mimepart *part) in mime_unpause() argument
1907 if(part) { in mime_unpause()
1908 if(part->lastreadstatus == CURL_READFUNC_PAUSE) in mime_unpause()
1909 part->lastreadstatus = 1; /* Successful read status. */ in mime_unpause()
1910 if(part->kind == MIMEKIND_MULTIPART) { in mime_unpause()
1911 curl_mime *mime = (curl_mime *) part->arg; in mime_unpause()
1925 curl_mimepart *part; member
1987 nread = Curl_mime_read(buf, 1, blen, ctx->part); in cr_mime_read()
2087 nread = Curl_mime_read(scratch, 1, readthisamountnow, ctx->part); in cr_mime_resume_from()
2116 CURLcode result = mime_rewind(ctx->part); in cr_mime_rewind()
2127 mime_unpause(ctx->part); in cr_mime_unpause()
2136 return (ctx->part && ctx->part->lastreadstatus == CURL_READFUNC_PAUSE); in cr_mime_is_paused()
2154 CURLcode Curl_creader_set_mime(struct Curl_easy *data, curl_mimepart *part) in Curl_creader_set_mime() argument
2164 ctx->part = part; in Curl_creader_set_mime()
2166 result = mime_rewind(ctx->part); in Curl_creader_set_mime()
2171 ctx->total_len = mime_size(ctx->part); in Curl_creader_set_mime()
2197 CURLcode curl_mime_name(curl_mimepart *part, const char *name) in curl_mime_name() argument
2199 (void) part; in curl_mime_name()
2204 CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) in curl_mime_filename() argument
2206 (void) part; in curl_mime_filename()
2211 CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) in curl_mime_type() argument
2213 (void) part; in curl_mime_type()
2218 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) in curl_mime_encoder() argument
2220 (void) part; in curl_mime_encoder()
2225 CURLcode curl_mime_data(curl_mimepart *part, in curl_mime_data() argument
2228 (void) part; in curl_mime_data()
2234 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) in curl_mime_filedata() argument
2236 (void) part; in curl_mime_filedata()
2241 CURLcode curl_mime_data_cb(curl_mimepart *part, in curl_mime_data_cb() argument
2248 (void) part; in curl_mime_data_cb()
2257 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) in curl_mime_subparts() argument
2259 (void) part; in curl_mime_subparts()
2264 CURLcode curl_mime_headers(curl_mimepart *part, in curl_mime_headers() argument
2267 (void) part; in curl_mime_headers()