Lines Matching refs:part

58                                 curl_mimepart *part);
59 static curl_off_t encoder_nop_size(curl_mimepart *part);
61 curl_mimepart *part);
63 curl_mimepart *part);
64 static curl_off_t encoder_base64_size(curl_mimepart *part);
66 curl_mimepart *part);
67 static curl_off_t encoder_qp_size(curl_mimepart *part);
350 curl_mimepart *part) in encoder_nop_read() argument
352 mime_encoder_state *st = &part->encstate; in encoder_nop_read()
365 static curl_off_t encoder_nop_size(curl_mimepart *part) in encoder_nop_size() argument
367 return part->datasize; in encoder_nop_size()
373 curl_mimepart *part) in encoder_7bit_read() argument
375 mime_encoder_state *st = &part->encstate; in encoder_7bit_read()
396 curl_mimepart *part) in encoder_base64_read() argument
398 mime_encoder_state *st = &part->encstate; in encoder_base64_read()
458 if(part->easy && cursize) { in encoder_base64_read()
459 CURLcode result = Curl_convert_to_network(part->easy, buffer, cursize); in encoder_base64_read()
468 static curl_off_t encoder_base64_size(curl_mimepart *part) in encoder_base64_size() argument
470 curl_off_t size = part->datasize; in encoder_base64_size()
503 curl_mimepart *part) in encoder_qp_read() argument
505 mime_encoder_state *st = &part->encstate; in encoder_qp_read()
601 static curl_off_t encoder_qp_size(curl_mimepart *part) in encoder_qp_size() argument
605 return part->datasize? -1: 0; in encoder_qp_size()
614 curl_mimepart *part = (curl_mimepart *) instream; in mime_mem_read() local
615 size_t sz = (size_t) part->datasize - part->state.offset; in mime_mem_read()
622 memcpy(buffer, (char *) &part->data[part->state.offset], sz); in mime_mem_read()
624 part->state.offset += sz; in mime_mem_read()
630 curl_mimepart *part = (curl_mimepart *) instream; in mime_mem_seek() local
634 offset += part->state.offset; in mime_mem_seek()
637 offset += part->datasize; in mime_mem_seek()
641 if(offset < 0 || offset > part->datasize) in mime_mem_seek()
644 part->state.offset = (size_t) offset; in mime_mem_seek()
656 static int mime_open_file(curl_mimepart * part) in mime_open_file() argument
660 if(part->fp) in mime_open_file()
662 part->fp = fopen_read(part->data, "rb"); in mime_open_file()
663 return part->fp? 0: -1; in mime_open_file()
669 curl_mimepart *part = (curl_mimepart *) instream; in mime_file_read() local
671 if(mime_open_file(part)) in mime_file_read()
674 return fread(buffer, size, nitems, part->fp); in mime_file_read()
679 curl_mimepart *part = (curl_mimepart *) instream; in mime_file_seek() local
681 if(whence == SEEK_SET && !offset && !part->fp) in mime_file_seek()
684 if(mime_open_file(part)) in mime_file_seek()
687 return fseek(part->fp, (long) offset, whence)? in mime_file_seek()
693 curl_mimepart *part = (curl_mimepart *) ptr; in mime_file_free() local
695 if(part->fp) { in mime_file_free()
696 fclose(part->fp); in mime_file_free()
697 part->fp = NULL; in mime_file_free()
699 Curl_safefree(part->data); in mime_file_free()
700 part->data = NULL; in mime_file_free()
738 static size_t read_part_content(curl_mimepart *part, in read_part_content() argument
743 if(part->readfunc) in read_part_content()
744 sz = part->readfunc(buffer, 1, bufsize, part->arg); in read_part_content()
749 static size_t read_encoded_part_content(curl_mimepart *part, in read_encoded_part_content() argument
752 mime_encoder_state *st = &part->encstate; in read_encoded_part_content()
760 sz = part->encoder->encodefunc(buffer, bufsize, ateof, part); in read_encoded_part_content()
789 sz = read_part_content(part, st->buf + st->bufend, in read_encoded_part_content()
809 static size_t readback_part(curl_mimepart *part, in readback_part() argument
821 struct curl_slist *hdr = (struct curl_slist *) part->state.ptr; in readback_part()
822 switch(part->state.state) { in readback_part()
824 mimesetstate(&part->state, part->flags & MIME_BODY_ONLY? MIMESTATE_BODY: in readback_part()
825 MIMESTATE_CURLHEADERS, part->curlheaders); in readback_part()
829 mimesetstate(&part->state, MIMESTATE_EOH, NULL); in readback_part()
833 mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next); in readback_part()
839 mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders); in readback_part()
841 sz = readback_bytes(&part->state, buffer, bufsize, in readback_part()
844 mimesetstate(&part->state, part->state.state, hdr->next); in readback_part()
848 sz = readback_bytes(&part->state, buffer, bufsize, "\r\n", 2, ""); in readback_part()
850 mimesetstate(&part->state, MIMESTATE_BODY, NULL); in readback_part()
854 if(part->easy && convbuf < buffer) { in readback_part()
855 CURLcode result = Curl_convert_to_network(part->easy, convbuf, in readback_part()
862 cleanup_encoder_state(&part->encstate); in readback_part()
863 mimesetstate(&part->state, MIMESTATE_CONTENT, NULL); in readback_part()
866 if(part->encoder) in readback_part()
867 sz = read_encoded_part_content(part, buffer, bufsize); in readback_part()
869 sz = read_part_content(part, buffer, bufsize); in readback_part()
872 mimesetstate(&part->state, MIMESTATE_END, NULL); in readback_part()
874 if(part->kind == MIMEKIND_FILE && part->fp) { in readback_part()
875 fclose(part->fp); in readback_part()
876 part->fp = NULL; in readback_part()
898 if(part->easy && convbuf < buffer && in readback_part()
899 part->state.state < MIMESTATE_BODY) { in readback_part()
900 CURLcode result = Curl_convert_to_network(part->easy, convbuf, in readback_part()
924 curl_mimepart *part = mime->state.ptr; in mime_subparts_read() local
940 mimesetstate(&mime->state, MIMESTATE_BOUNDARY2, part); in mime_subparts_read()
944 strlen(mime->boundary), part? "\r\n": "--\r\n"); in mime_subparts_read()
955 mimesetstate(&mime->state, MIMESTATE_CONTENT, part); in mime_subparts_read()
959 if(!part) { in mime_subparts_read()
963 sz = readback_part(part, buffer, nitems); in mime_subparts_read()
973 mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, part->nextpart); in mime_subparts_read()
1002 static int mime_part_rewind(curl_mimepart *part) in mime_part_rewind() argument
1007 if(part->flags & MIME_BODY_ONLY) in mime_part_rewind()
1009 cleanup_encoder_state(&part->encstate); in mime_part_rewind()
1010 if(part->state.state > targetstate) { in mime_part_rewind()
1012 if(part->seekfunc) { in mime_part_rewind()
1013 res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET); in mime_part_rewind()
1030 mimesetstate(&part->state, targetstate, NULL); in mime_part_rewind()
1038 curl_mimepart *part; in mime_subparts_seek() local
1047 for(part = mime->firstpart; part; part = part->nextpart) { in mime_subparts_seek()
1048 int res = mime_part_rewind(part); in mime_subparts_seek()
1060 static void cleanup_part_content(curl_mimepart *part) in cleanup_part_content() argument
1062 if(part->freefunc) in cleanup_part_content()
1063 part->freefunc(part->arg); in cleanup_part_content()
1065 part->readfunc = NULL; in cleanup_part_content()
1066 part->seekfunc = NULL; in cleanup_part_content()
1067 part->freefunc = NULL; in cleanup_part_content()
1068 part->arg = (void *) part; /* Defaults to part itself. */ in cleanup_part_content()
1069 part->data = NULL; in cleanup_part_content()
1070 part->fp = NULL; in cleanup_part_content()
1071 part->datasize = (curl_off_t) 0; /* No size yet. */ in cleanup_part_content()
1072 cleanup_encoder_state(&part->encstate); in cleanup_part_content()
1073 part->kind = MIMEKIND_NONE; in cleanup_part_content()
1100 void Curl_mime_cleanpart(curl_mimepart *part) in Curl_mime_cleanpart() argument
1102 cleanup_part_content(part); in Curl_mime_cleanpart()
1103 curl_slist_free_all(part->curlheaders); in Curl_mime_cleanpart()
1104 if(part->flags & MIME_USERHEADERS_OWNER) in Curl_mime_cleanpart()
1105 curl_slist_free_all(part->userheaders); in Curl_mime_cleanpart()
1106 Curl_safefree(part->mimetype); in Curl_mime_cleanpart()
1107 Curl_safefree(part->name); in Curl_mime_cleanpart()
1108 Curl_safefree(part->filename); in Curl_mime_cleanpart()
1109 Curl_mime_initpart(part, part->easy); in Curl_mime_cleanpart()
1115 curl_mimepart *part; in curl_mime_free() local
1120 part = mime->firstpart; in curl_mime_free()
1121 mime->firstpart = part->nextpart; in curl_mime_free()
1122 Curl_mime_cleanpart(part); in curl_mime_free()
1123 free(part); in curl_mime_free()
1235 void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy) in Curl_mime_initpart() argument
1237 memset((char *) part, 0, sizeof(*part)); in Curl_mime_initpart()
1238 part->easy = easy; in Curl_mime_initpart()
1239 mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); in Curl_mime_initpart()
1245 curl_mimepart *part; in curl_mime_addpart() local
1250 part = (curl_mimepart *) malloc(sizeof(*part)); in curl_mime_addpart()
1252 if(part) { in curl_mime_addpart()
1253 Curl_mime_initpart(part, mime->easy); in curl_mime_addpart()
1254 part->parent = mime; in curl_mime_addpart()
1257 mime->lastpart->nextpart = part; in curl_mime_addpart()
1259 mime->firstpart = part; in curl_mime_addpart()
1261 mime->lastpart = part; in curl_mime_addpart()
1264 return part; in curl_mime_addpart()
1268 CURLcode curl_mime_name(curl_mimepart *part, const char *name) in curl_mime_name() argument
1270 if(!part) in curl_mime_name()
1273 Curl_safefree(part->name); in curl_mime_name()
1274 part->name = NULL; in curl_mime_name()
1277 part->name = strdup(name); in curl_mime_name()
1278 if(!part->name) in curl_mime_name()
1286 CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) in curl_mime_filename() argument
1288 if(!part) in curl_mime_filename()
1291 Curl_safefree(part->filename); in curl_mime_filename()
1292 part->filename = NULL; in curl_mime_filename()
1295 part->filename = strdup(filename); in curl_mime_filename()
1296 if(!part->filename) in curl_mime_filename()
1304 CURLcode curl_mime_data(curl_mimepart *part, in curl_mime_data() argument
1307 if(!part) in curl_mime_data()
1310 cleanup_part_content(part); in curl_mime_data()
1316 part->data = malloc(datasize + 1); in curl_mime_data()
1317 if(!part->data) in curl_mime_data()
1320 part->datasize = datasize; in curl_mime_data()
1323 memcpy(part->data, data, datasize); in curl_mime_data()
1324 part->data[datasize] = '\0'; /* Set a nul terminator as sentinel. */ in curl_mime_data()
1326 part->readfunc = mime_mem_read; in curl_mime_data()
1327 part->seekfunc = mime_mem_seek; in curl_mime_data()
1328 part->freefunc = mime_mem_free; in curl_mime_data()
1329 part->kind = MIMEKIND_DATA; in curl_mime_data()
1336 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) in curl_mime_filedata() argument
1340 if(!part) in curl_mime_filedata()
1343 cleanup_part_content(part); in curl_mime_filedata()
1352 part->data = strdup(filename); in curl_mime_filedata()
1353 if(!part->data) in curl_mime_filedata()
1356 part->datasize = -1; in curl_mime_filedata()
1358 part->datasize = filesize(filename, sbuf); in curl_mime_filedata()
1359 part->seekfunc = mime_file_seek; in curl_mime_filedata()
1362 part->readfunc = mime_file_read; in curl_mime_filedata()
1363 part->freefunc = mime_file_free; in curl_mime_filedata()
1364 part->kind = MIMEKIND_FILE; in curl_mime_filedata()
1374 CURLcode res = curl_mime_filename(part, base); in curl_mime_filedata()
1385 CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) in curl_mime_type() argument
1387 if(!part) in curl_mime_type()
1390 Curl_safefree(part->mimetype); in curl_mime_type()
1391 part->mimetype = NULL; in curl_mime_type()
1394 part->mimetype = strdup(mimetype); in curl_mime_type()
1395 if(!part->mimetype) in curl_mime_type()
1403 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) in curl_mime_encoder() argument
1408 if(!part) in curl_mime_encoder()
1411 part->encoder = NULL; in curl_mime_encoder()
1418 part->encoder = mep; in curl_mime_encoder()
1426 CURLcode curl_mime_headers(curl_mimepart *part, in curl_mime_headers() argument
1429 if(!part) in curl_mime_headers()
1432 if(part->flags & MIME_USERHEADERS_OWNER) { in curl_mime_headers()
1433 if(part->userheaders != headers) /* Allow setting twice the same list. */ in curl_mime_headers()
1434 curl_slist_free_all(part->userheaders); in curl_mime_headers()
1435 part->flags &= ~MIME_USERHEADERS_OWNER; in curl_mime_headers()
1437 part->userheaders = headers; in curl_mime_headers()
1439 part->flags |= MIME_USERHEADERS_OWNER; in curl_mime_headers()
1444 CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize, in curl_mime_data_cb() argument
1449 if(!part) in curl_mime_data_cb()
1452 cleanup_part_content(part); in curl_mime_data_cb()
1455 part->readfunc = readfunc; in curl_mime_data_cb()
1456 part->seekfunc = seekfunc; in curl_mime_data_cb()
1457 part->freefunc = freefunc; in curl_mime_data_cb()
1458 part->arg = arg; in curl_mime_data_cb()
1459 part->datasize = datasize; in curl_mime_data_cb()
1460 part->kind = MIMEKIND_CALLBACK; in curl_mime_data_cb()
1467 CURLcode Curl_mime_set_subparts(curl_mimepart *part, in Curl_mime_set_subparts() argument
1472 if(!part) in Curl_mime_set_subparts()
1476 if(part->kind == MIMEKIND_MULTIPART && part->arg == subparts) in Curl_mime_set_subparts()
1479 cleanup_part_content(part); in Curl_mime_set_subparts()
1483 if(part->easy && subparts->easy && part->easy != subparts->easy) in Curl_mime_set_subparts()
1491 root = part->parent; in Curl_mime_set_subparts()
1496 if(part->easy) in Curl_mime_set_subparts()
1497 failf(part->easy, "Can't add itself as a subpart!"); in Curl_mime_set_subparts()
1502 subparts->parent = part; in Curl_mime_set_subparts()
1503 part->readfunc = mime_subparts_read; in Curl_mime_set_subparts()
1504 part->seekfunc = mime_subparts_seek; in Curl_mime_set_subparts()
1505 part->freefunc = take_ownership? mime_subparts_free: mime_subparts_unbind; in Curl_mime_set_subparts()
1506 part->arg = subparts; in Curl_mime_set_subparts()
1507 part->datasize = -1; in Curl_mime_set_subparts()
1508 part->kind = MIMEKIND_MULTIPART; in Curl_mime_set_subparts()
1514 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) in curl_mime_subparts() argument
1516 return Curl_mime_set_subparts(part, subparts, TRUE); in curl_mime_subparts()
1524 curl_mimepart *part = (curl_mimepart *) instream; in Curl_mime_read() local
1527 return readback_part(part, buffer, nitems); in Curl_mime_read()
1531 CURLcode Curl_mime_rewind(curl_mimepart *part) in Curl_mime_rewind() argument
1533 return mime_part_rewind(part) == CURL_SEEKFUNC_OK? in Curl_mime_rewind()
1555 curl_mimepart *part; in multipart_size() local
1563 for(part = mime->firstpart; part; part = part->nextpart) { in multipart_size()
1564 curl_off_t sz = Curl_mime_size(part); in multipart_size()
1577 curl_off_t Curl_mime_size(curl_mimepart *part) in Curl_mime_size() argument
1581 if(part->kind == MIMEKIND_MULTIPART) in Curl_mime_size()
1582 part->datasize = multipart_size(part->arg); in Curl_mime_size()
1584 size = part->datasize; in Curl_mime_size()
1586 if(part->encoder) in Curl_mime_size()
1587 size = part->encoder->sizefunc(part); in Curl_mime_size()
1589 if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) { in Curl_mime_size()
1591 size += slist_size(part->curlheaders, 2, NULL); in Curl_mime_size()
1592 size += slist_size(part->userheaders, 2, "Content-Type"); in Curl_mime_size()
1668 CURLcode Curl_mime_prepare_headers(curl_mimepart *part, in Curl_mime_prepare_headers() argument
1680 curl_slist_free_all(part->curlheaders); in Curl_mime_prepare_headers()
1681 part->curlheaders = NULL; in Curl_mime_prepare_headers()
1684 if(part->state.state == MIMESTATE_CURLHEADERS) in Curl_mime_prepare_headers()
1685 mimesetstate(&part->state, MIMESTATE_CURLHEADERS, NULL); in Curl_mime_prepare_headers()
1688 customct = part->mimetype; in Curl_mime_prepare_headers()
1690 customct = search_header(part->userheaders, "Content-Type"); in Curl_mime_prepare_headers()
1696 switch(part->kind) { in Curl_mime_prepare_headers()
1701 contenttype = Curl_mime_contenttype(part->filename); in Curl_mime_prepare_headers()
1703 contenttype = Curl_mime_contenttype(part->data); in Curl_mime_prepare_headers()
1704 if(!contenttype && part->filename) in Curl_mime_prepare_headers()
1708 contenttype = Curl_mime_contenttype(part->filename); in Curl_mime_prepare_headers()
1713 if(part->kind == MIMEKIND_MULTIPART) { in Curl_mime_prepare_headers()
1714 mime = (curl_mime *) part->arg; in Curl_mime_prepare_headers()
1720 if(strategy == MIMESTRATEGY_MAIL || !part->filename) in Curl_mime_prepare_headers()
1724 if(!search_header(part->userheaders, "Content-Disposition")) { in Curl_mime_prepare_headers()
1726 if(part->filename || part->name || in Curl_mime_prepare_headers()
1730 !part->name && !part->filename) in Curl_mime_prepare_headers()
1736 if(part->name) { in Curl_mime_prepare_headers()
1737 name = escape_string(part->name); in Curl_mime_prepare_headers()
1741 if(!ret && part->filename) { in Curl_mime_prepare_headers()
1742 filename = escape_string(part->filename); in Curl_mime_prepare_headers()
1747 ret = Curl_mime_add_header(&part->curlheaders, in Curl_mime_prepare_headers()
1765 ret = add_content_type(&part->curlheaders, contenttype, boundary); in Curl_mime_prepare_headers()
1771 if(!search_header(part->userheaders, "Content-Transfer-Encoding")) { in Curl_mime_prepare_headers()
1772 if(part->encoder) in Curl_mime_prepare_headers()
1773 cte = part->encoder->name; in Curl_mime_prepare_headers()
1775 part->kind != MIMEKIND_MULTIPART) in Curl_mime_prepare_headers()
1778 ret = Curl_mime_add_header(&part->curlheaders, in Curl_mime_prepare_headers()
1787 if(part->state.state == MIMESTATE_CURLHEADERS) in Curl_mime_prepare_headers()
1788 mimesetstate(&part->state, MIMESTATE_CURLHEADERS, part->curlheaders); in Curl_mime_prepare_headers()
1791 if(part->kind == MIMEKIND_MULTIPART && mime) { in Curl_mime_prepare_headers()
1826 CURLcode curl_mime_name(curl_mimepart *part, const char *name) in curl_mime_name() argument
1828 (void) part; in curl_mime_name()
1833 CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) in curl_mime_filename() argument
1835 (void) part; in curl_mime_filename()
1840 CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) in curl_mime_type() argument
1842 (void) part; in curl_mime_type()
1847 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) in curl_mime_encoder() argument
1849 (void) part; in curl_mime_encoder()
1854 CURLcode curl_mime_data(curl_mimepart *part, in curl_mime_data() argument
1857 (void) part; in curl_mime_data()
1863 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) in curl_mime_filedata() argument
1865 (void) part; in curl_mime_filedata()
1870 CURLcode curl_mime_data_cb(curl_mimepart *part, in curl_mime_data_cb() argument
1877 (void) part; in curl_mime_data_cb()
1886 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) in curl_mime_subparts() argument
1888 (void) part; in curl_mime_subparts()
1893 CURLcode curl_mime_headers(curl_mimepart *part, in curl_mime_headers() argument
1896 (void) part; in curl_mime_headers()
1902 void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy) in Curl_mime_initpart() argument
1904 (void) part; in Curl_mime_initpart()
1908 void Curl_mime_cleanpart(curl_mimepart *part) in Curl_mime_cleanpart() argument
1910 (void) part; in Curl_mime_cleanpart()
1920 CURLcode Curl_mime_set_subparts(curl_mimepart *part, in Curl_mime_set_subparts() argument
1923 (void) part; in Curl_mime_set_subparts()
1929 CURLcode Curl_mime_prepare_headers(curl_mimepart *part, in Curl_mime_prepare_headers() argument
1934 (void) part; in Curl_mime_prepare_headers()
1941 curl_off_t Curl_mime_size(curl_mimepart *part) in Curl_mime_size() argument
1943 (void) part; in Curl_mime_size()
1956 CURLcode Curl_mime_rewind(curl_mimepart *part) in Curl_mime_rewind() argument
1958 (void) part; in Curl_mime_rewind()