• Home
  • Raw
  • Download

Lines Matching refs:part

63                                 curl_mimepart *part);
64 static curl_off_t encoder_nop_size(curl_mimepart *part);
66 curl_mimepart *part);
68 curl_mimepart *part);
69 static curl_off_t encoder_base64_size(curl_mimepart *part);
71 curl_mimepart *part);
72 static curl_off_t encoder_qp_size(curl_mimepart *part);
356 struct curl_mimepart *part) in encoder_nop_read() argument
358 struct mime_encoder_state *st = &part->encstate; in encoder_nop_read()
376 static curl_off_t encoder_nop_size(curl_mimepart *part) in encoder_nop_size() argument
378 return part->datasize; in encoder_nop_size()
384 curl_mimepart *part) in encoder_7bit_read() argument
386 struct mime_encoder_state *st = &part->encstate; in encoder_7bit_read()
410 curl_mimepart *part) in encoder_base64_read() argument
412 struct mime_encoder_state *st = &part->encstate; in encoder_base64_read()
486 if(part->easy && cursize) { in encoder_base64_read()
487 CURLcode result = Curl_convert_to_network(part->easy, buffer, cursize); in encoder_base64_read()
496 static curl_off_t encoder_base64_size(curl_mimepart *part) in encoder_base64_size() argument
498 curl_off_t size = part->datasize; in encoder_base64_size()
531 curl_mimepart *part) in encoder_qp_read() argument
533 struct mime_encoder_state *st = &part->encstate; in encoder_qp_read()
631 static curl_off_t encoder_qp_size(curl_mimepart *part) in encoder_qp_size() argument
635 return part->datasize? -1: 0; in encoder_qp_size()
644 curl_mimepart *part = (curl_mimepart *) instream; in mime_mem_read() local
645 size_t sz = curlx_sotouz(part->datasize - part->state.offset); in mime_mem_read()
655 memcpy(buffer, part->data + curlx_sotouz(part->state.offset), sz); in mime_mem_read()
662 curl_mimepart *part = (curl_mimepart *) instream; in mime_mem_seek() local
666 offset += part->state.offset; in mime_mem_seek()
669 offset += part->datasize; in mime_mem_seek()
673 if(offset < 0 || offset > part->datasize) in mime_mem_seek()
676 part->state.offset = offset; in mime_mem_seek()
688 static int mime_open_file(curl_mimepart *part) in mime_open_file() argument
692 if(part->fp) in mime_open_file()
694 part->fp = fopen_read(part->data, "rb"); in mime_open_file()
695 return part->fp? 0: -1; in mime_open_file()
701 curl_mimepart *part = (curl_mimepart *) instream; in mime_file_read() local
706 if(mime_open_file(part)) in mime_file_read()
709 return fread(buffer, size, nitems, part->fp); in mime_file_read()
714 curl_mimepart *part = (curl_mimepart *) instream; in mime_file_seek() local
716 if(whence == SEEK_SET && !offset && !part->fp) in mime_file_seek()
719 if(mime_open_file(part)) in mime_file_seek()
722 return fseek(part->fp, (long) offset, whence)? in mime_file_seek()
728 curl_mimepart *part = (curl_mimepart *) ptr; in mime_file_free() local
730 if(part->fp) { in mime_file_free()
731 fclose(part->fp); in mime_file_free()
732 part->fp = NULL; in mime_file_free()
734 Curl_safefree(part->data); in mime_file_free()
735 part->data = NULL; in mime_file_free()
774 static size_t read_part_content(curl_mimepart *part, in read_part_content() argument
779 switch(part->lastreadstatus) { in read_part_content()
784 return part->lastreadstatus; in read_part_content()
790 if(part->datasize != (curl_off_t) -1 && in read_part_content()
791 part->state.offset >= part->datasize) { in read_part_content()
795 switch(part->kind) { in read_part_content()
801 sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread); in read_part_content()
804 if(part->fp && feof(part->fp)) in read_part_content()
808 if(part->readfunc) { in read_part_content()
809 if(!(part->flags & MIME_FAST_READ)) { in read_part_content()
814 sz = part->readfunc(buffer, 1, bufsize, part->arg); in read_part_content()
827 part->lastreadstatus = sz; in read_part_content()
830 part->state.offset += sz; in read_part_content()
831 part->lastreadstatus = sz; in read_part_content()
839 static size_t read_encoded_part_content(curl_mimepart *part, char *buffer, in read_encoded_part_content() argument
842 struct mime_encoder_state *st = &part->encstate; in read_encoded_part_content()
850 sz = part->encoder->encodefunc(buffer, bufsize, ateof, part); in read_encoded_part_content()
878 sz = read_part_content(part, st->buf + st->bufend, in read_encoded_part_content()
899 static size_t readback_part(curl_mimepart *part, in readback_part() argument
911 struct curl_slist *hdr = (struct curl_slist *) part->state.ptr; in readback_part()
912 switch(part->state.state) { in readback_part()
914 mimesetstate(&part->state, in readback_part()
915 (part->flags & MIME_BODY_ONLY)? in readback_part()
917 part->curlheaders); in readback_part()
921 mimesetstate(&part->state, MIMESTATE_EOH, NULL); in readback_part()
925 mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next); in readback_part()
931 mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders); in readback_part()
933 sz = readback_bytes(&part->state, buffer, bufsize, in readback_part()
936 mimesetstate(&part->state, part->state.state, hdr->next); in readback_part()
940 sz = readback_bytes(&part->state, buffer, bufsize, "\r\n", 2, ""); in readback_part()
942 mimesetstate(&part->state, MIMESTATE_BODY, NULL); in readback_part()
946 if(part->easy && convbuf < buffer) { in readback_part()
947 CURLcode result = Curl_convert_to_network(part->easy, convbuf, in readback_part()
954 cleanup_encoder_state(&part->encstate); in readback_part()
955 mimesetstate(&part->state, MIMESTATE_CONTENT, NULL); in readback_part()
958 if(part->encoder) in readback_part()
959 sz = read_encoded_part_content(part, buffer, bufsize, hasread); in readback_part()
961 sz = read_part_content(part, buffer, bufsize, hasread); in readback_part()
964 mimesetstate(&part->state, MIMESTATE_END, NULL); in readback_part()
966 if(part->kind == MIMEKIND_FILE && part->fp) { in readback_part()
967 fclose(part->fp); in readback_part()
968 part->fp = NULL; in readback_part()
991 if(part->easy && convbuf < buffer && in readback_part()
992 part->state.state < MIMESTATE_BODY) { in readback_part()
993 CURLcode result = Curl_convert_to_network(part->easy, convbuf, in readback_part()
1017 curl_mimepart *part = mime->state.ptr; in mime_subparts_read() local
1033 mimesetstate(&mime->state, MIMESTATE_BOUNDARY2, part); in mime_subparts_read()
1037 strlen(mime->boundary), part? "\r\n": "--\r\n"); in mime_subparts_read()
1048 mimesetstate(&mime->state, MIMESTATE_CONTENT, part); in mime_subparts_read()
1052 if(!part) { in mime_subparts_read()
1056 sz = readback_part(part, buffer, nitems, hasread); in mime_subparts_read()
1067 mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, part->nextpart); in mime_subparts_read()
1096 static int mime_part_rewind(curl_mimepart *part) in mime_part_rewind() argument
1101 if(part->flags & MIME_BODY_ONLY) in mime_part_rewind()
1103 cleanup_encoder_state(&part->encstate); in mime_part_rewind()
1104 if(part->state.state > targetstate) { in mime_part_rewind()
1106 if(part->seekfunc) { in mime_part_rewind()
1107 res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET); in mime_part_rewind()
1124 mimesetstate(&part->state, targetstate, NULL); in mime_part_rewind()
1126 part->lastreadstatus = 1; /* Successful read status. */ in mime_part_rewind()
1133 curl_mimepart *part; in mime_subparts_seek() local
1142 for(part = mime->firstpart; part; part = part->nextpart) { in mime_subparts_seek()
1143 int res = mime_part_rewind(part); in mime_subparts_seek()
1155 static void cleanup_part_content(curl_mimepart *part) in cleanup_part_content() argument
1157 if(part->freefunc) in cleanup_part_content()
1158 part->freefunc(part->arg); in cleanup_part_content()
1160 part->readfunc = NULL; in cleanup_part_content()
1161 part->seekfunc = NULL; in cleanup_part_content()
1162 part->freefunc = NULL; in cleanup_part_content()
1163 part->arg = (void *) part; /* Defaults to part itself. */ in cleanup_part_content()
1164 part->data = NULL; in cleanup_part_content()
1165 part->fp = NULL; in cleanup_part_content()
1166 part->datasize = (curl_off_t) 0; /* No size yet. */ in cleanup_part_content()
1167 cleanup_encoder_state(&part->encstate); in cleanup_part_content()
1168 part->kind = MIMEKIND_NONE; in cleanup_part_content()
1169 part->flags &= ~MIME_FAST_READ; in cleanup_part_content()
1170 part->lastreadstatus = 1; /* Successful read status. */ in cleanup_part_content()
1197 void Curl_mime_cleanpart(curl_mimepart *part) in Curl_mime_cleanpart() argument
1199 cleanup_part_content(part); in Curl_mime_cleanpart()
1200 curl_slist_free_all(part->curlheaders); in Curl_mime_cleanpart()
1201 if(part->flags & MIME_USERHEADERS_OWNER) in Curl_mime_cleanpart()
1202 curl_slist_free_all(part->userheaders); in Curl_mime_cleanpart()
1203 Curl_safefree(part->mimetype); in Curl_mime_cleanpart()
1204 Curl_safefree(part->name); in Curl_mime_cleanpart()
1205 Curl_safefree(part->filename); in Curl_mime_cleanpart()
1206 Curl_mime_initpart(part, part->easy); in Curl_mime_cleanpart()
1212 curl_mimepart *part; in curl_mime_free() local
1217 part = mime->firstpart; in curl_mime_free()
1218 mime->firstpart = part->nextpart; in curl_mime_free()
1219 Curl_mime_cleanpart(part); in curl_mime_free()
1220 free(part); in curl_mime_free()
1332 void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy) in Curl_mime_initpart() argument
1334 memset((char *) part, 0, sizeof(*part)); in Curl_mime_initpart()
1335 part->easy = easy; in Curl_mime_initpart()
1336 part->lastreadstatus = 1; /* Successful read status. */ in Curl_mime_initpart()
1337 mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); in Curl_mime_initpart()
1343 curl_mimepart *part; in curl_mime_addpart() local
1348 part = (curl_mimepart *) malloc(sizeof(*part)); in curl_mime_addpart()
1350 if(part) { in curl_mime_addpart()
1351 Curl_mime_initpart(part, mime->easy); in curl_mime_addpart()
1352 part->parent = mime; in curl_mime_addpart()
1355 mime->lastpart->nextpart = part; in curl_mime_addpart()
1357 mime->firstpart = part; in curl_mime_addpart()
1359 mime->lastpart = part; in curl_mime_addpart()
1362 return part; in curl_mime_addpart()
1366 CURLcode curl_mime_name(curl_mimepart *part, const char *name) in curl_mime_name() argument
1368 if(!part) in curl_mime_name()
1371 Curl_safefree(part->name); in curl_mime_name()
1372 part->name = NULL; in curl_mime_name()
1375 part->name = strdup(name); in curl_mime_name()
1376 if(!part->name) in curl_mime_name()
1384 CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) in curl_mime_filename() argument
1386 if(!part) in curl_mime_filename()
1389 Curl_safefree(part->filename); in curl_mime_filename()
1390 part->filename = NULL; in curl_mime_filename()
1393 part->filename = strdup(filename); in curl_mime_filename()
1394 if(!part->filename) in curl_mime_filename()
1402 CURLcode curl_mime_data(curl_mimepart *part, in curl_mime_data() argument
1405 if(!part) in curl_mime_data()
1408 cleanup_part_content(part); in curl_mime_data()
1414 part->data = malloc(datasize + 1); in curl_mime_data()
1415 if(!part->data) in curl_mime_data()
1418 part->datasize = datasize; in curl_mime_data()
1421 memcpy(part->data, data, datasize); in curl_mime_data()
1422 part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */ in curl_mime_data()
1424 part->readfunc = mime_mem_read; in curl_mime_data()
1425 part->seekfunc = mime_mem_seek; in curl_mime_data()
1426 part->freefunc = mime_mem_free; in curl_mime_data()
1427 part->flags |= MIME_FAST_READ; in curl_mime_data()
1428 part->kind = MIMEKIND_DATA; in curl_mime_data()
1435 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) in curl_mime_filedata() argument
1439 if(!part) in curl_mime_filedata()
1442 cleanup_part_content(part); in curl_mime_filedata()
1451 part->data = strdup(filename); in curl_mime_filedata()
1452 if(!part->data) in curl_mime_filedata()
1455 part->datasize = -1; in curl_mime_filedata()
1457 part->datasize = filesize(filename, sbuf); in curl_mime_filedata()
1458 part->seekfunc = mime_file_seek; in curl_mime_filedata()
1461 part->readfunc = mime_file_read; in curl_mime_filedata()
1462 part->freefunc = mime_file_free; in curl_mime_filedata()
1463 part->kind = MIMEKIND_FILE; in curl_mime_filedata()
1473 CURLcode res = curl_mime_filename(part, base); in curl_mime_filedata()
1484 CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) in curl_mime_type() argument
1486 if(!part) in curl_mime_type()
1489 Curl_safefree(part->mimetype); in curl_mime_type()
1490 part->mimetype = NULL; in curl_mime_type()
1493 part->mimetype = strdup(mimetype); in curl_mime_type()
1494 if(!part->mimetype) in curl_mime_type()
1502 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) in curl_mime_encoder() argument
1507 if(!part) in curl_mime_encoder()
1510 part->encoder = NULL; in curl_mime_encoder()
1517 part->encoder = mep; in curl_mime_encoder()
1525 CURLcode curl_mime_headers(curl_mimepart *part, in curl_mime_headers() argument
1528 if(!part) in curl_mime_headers()
1531 if(part->flags & MIME_USERHEADERS_OWNER) { in curl_mime_headers()
1532 if(part->userheaders != headers) /* Allow setting twice the same list. */ in curl_mime_headers()
1533 curl_slist_free_all(part->userheaders); in curl_mime_headers()
1534 part->flags &= ~MIME_USERHEADERS_OWNER; in curl_mime_headers()
1536 part->userheaders = headers; in curl_mime_headers()
1538 part->flags |= MIME_USERHEADERS_OWNER; in curl_mime_headers()
1543 CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize, in curl_mime_data_cb() argument
1548 if(!part) in curl_mime_data_cb()
1551 cleanup_part_content(part); in curl_mime_data_cb()
1554 part->readfunc = readfunc; in curl_mime_data_cb()
1555 part->seekfunc = seekfunc; in curl_mime_data_cb()
1556 part->freefunc = freefunc; in curl_mime_data_cb()
1557 part->arg = arg; in curl_mime_data_cb()
1558 part->datasize = datasize; in curl_mime_data_cb()
1559 part->kind = MIMEKIND_CALLBACK; in curl_mime_data_cb()
1566 CURLcode Curl_mime_set_subparts(curl_mimepart *part, in Curl_mime_set_subparts() argument
1571 if(!part) in Curl_mime_set_subparts()
1575 if(part->kind == MIMEKIND_MULTIPART && part->arg == subparts) in Curl_mime_set_subparts()
1578 cleanup_part_content(part); in Curl_mime_set_subparts()
1582 if(part->easy && subparts->easy && part->easy != subparts->easy) in Curl_mime_set_subparts()
1590 root = part->parent; in Curl_mime_set_subparts()
1595 if(part->easy) in Curl_mime_set_subparts()
1596 failf(part->easy, "Can't add itself as a subpart!"); in Curl_mime_set_subparts()
1601 subparts->parent = part; in Curl_mime_set_subparts()
1603 part->seekfunc = mime_subparts_seek; in Curl_mime_set_subparts()
1604 part->freefunc = take_ownership? mime_subparts_free: mime_subparts_unbind; in Curl_mime_set_subparts()
1605 part->arg = subparts; in Curl_mime_set_subparts()
1606 part->datasize = -1; in Curl_mime_set_subparts()
1607 part->kind = MIMEKIND_MULTIPART; in Curl_mime_set_subparts()
1613 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) in curl_mime_subparts() argument
1615 return Curl_mime_set_subparts(part, subparts, TRUE); in curl_mime_subparts()
1623 curl_mimepart *part = (curl_mimepart *) instream; in Curl_mime_read() local
1631 ret = readback_part(part, buffer, nitems, &hasread); in Curl_mime_read()
1644 CURLcode Curl_mime_rewind(curl_mimepart *part) in Curl_mime_rewind() argument
1646 return mime_part_rewind(part) == CURL_SEEKFUNC_OK? in Curl_mime_rewind()
1668 curl_mimepart *part; in multipart_size() local
1676 for(part = mime->firstpart; part; part = part->nextpart) { in multipart_size()
1677 curl_off_t sz = Curl_mime_size(part); in multipart_size()
1690 curl_off_t Curl_mime_size(curl_mimepart *part) in Curl_mime_size() argument
1694 if(part->kind == MIMEKIND_MULTIPART) in Curl_mime_size()
1695 part->datasize = multipart_size(part->arg); in Curl_mime_size()
1697 size = part->datasize; in Curl_mime_size()
1699 if(part->encoder) in Curl_mime_size()
1700 size = part->encoder->sizefunc(part); in Curl_mime_size()
1702 if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) { in Curl_mime_size()
1704 size += slist_size(part->curlheaders, 2, NULL); in Curl_mime_size()
1705 size += slist_size(part->userheaders, 2, "Content-Type"); in Curl_mime_size()
1798 CURLcode Curl_mime_prepare_headers(curl_mimepart *part, in Curl_mime_prepare_headers() argument
1810 curl_slist_free_all(part->curlheaders); in Curl_mime_prepare_headers()
1811 part->curlheaders = NULL; in Curl_mime_prepare_headers()
1814 if(part->state.state == MIMESTATE_CURLHEADERS) in Curl_mime_prepare_headers()
1815 mimesetstate(&part->state, MIMESTATE_CURLHEADERS, NULL); in Curl_mime_prepare_headers()
1818 customct = part->mimetype; in Curl_mime_prepare_headers()
1820 customct = search_header(part->userheaders, "Content-Type"); in Curl_mime_prepare_headers()
1826 switch(part->kind) { in Curl_mime_prepare_headers()
1831 contenttype = Curl_mime_contenttype(part->filename); in Curl_mime_prepare_headers()
1833 contenttype = Curl_mime_contenttype(part->data); in Curl_mime_prepare_headers()
1834 if(!contenttype && part->filename) in Curl_mime_prepare_headers()
1838 contenttype = Curl_mime_contenttype(part->filename); in Curl_mime_prepare_headers()
1843 if(part->kind == MIMEKIND_MULTIPART) { in Curl_mime_prepare_headers()
1844 mime = (curl_mime *) part->arg; in Curl_mime_prepare_headers()
1850 if(strategy == MIMESTRATEGY_MAIL || !part->filename) in Curl_mime_prepare_headers()
1854 if(!search_header(part->userheaders, "Content-Disposition")) { in Curl_mime_prepare_headers()
1856 if(part->filename || part->name || in Curl_mime_prepare_headers()
1860 !part->name && !part->filename) in Curl_mime_prepare_headers()
1866 if(part->name) { in Curl_mime_prepare_headers()
1867 name = escape_string(part->name); in Curl_mime_prepare_headers()
1871 if(!ret && part->filename) { in Curl_mime_prepare_headers()
1872 filename = escape_string(part->filename); in Curl_mime_prepare_headers()
1877 ret = Curl_mime_add_header(&part->curlheaders, in Curl_mime_prepare_headers()
1895 ret = add_content_type(&part->curlheaders, contenttype, boundary); in Curl_mime_prepare_headers()
1901 if(!search_header(part->userheaders, "Content-Transfer-Encoding")) { in Curl_mime_prepare_headers()
1902 if(part->encoder) in Curl_mime_prepare_headers()
1903 cte = part->encoder->name; in Curl_mime_prepare_headers()
1905 part->kind != MIMEKIND_MULTIPART) in Curl_mime_prepare_headers()
1908 ret = Curl_mime_add_header(&part->curlheaders, in Curl_mime_prepare_headers()
1917 if(part->state.state == MIMESTATE_CURLHEADERS) in Curl_mime_prepare_headers()
1918 mimesetstate(&part->state, MIMESTATE_CURLHEADERS, part->curlheaders); in Curl_mime_prepare_headers()
1921 if(part->kind == MIMEKIND_MULTIPART && mime) { in Curl_mime_prepare_headers()
1937 void Curl_mime_unpause(curl_mimepart *part) in Curl_mime_unpause() argument
1939 if(part) { in Curl_mime_unpause()
1940 if(part->lastreadstatus == CURL_READFUNC_PAUSE) in Curl_mime_unpause()
1941 part->lastreadstatus = 1; /* Successful read status. */ in Curl_mime_unpause()
1942 if(part->kind == MIMEKIND_MULTIPART) { in Curl_mime_unpause()
1943 curl_mime *mime = (curl_mime *) part->arg; in Curl_mime_unpause()
1976 CURLcode curl_mime_name(curl_mimepart *part, const char *name) in curl_mime_name() argument
1978 (void) part; in curl_mime_name()
1983 CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) in curl_mime_filename() argument
1985 (void) part; in curl_mime_filename()
1990 CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) in curl_mime_type() argument
1992 (void) part; in curl_mime_type()
1997 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) in curl_mime_encoder() argument
1999 (void) part; in curl_mime_encoder()
2004 CURLcode curl_mime_data(curl_mimepart *part, in curl_mime_data() argument
2007 (void) part; in curl_mime_data()
2013 CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) in curl_mime_filedata() argument
2015 (void) part; in curl_mime_filedata()
2020 CURLcode curl_mime_data_cb(curl_mimepart *part, in curl_mime_data_cb() argument
2027 (void) part; in curl_mime_data_cb()
2036 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) in curl_mime_subparts() argument
2038 (void) part; in curl_mime_subparts()
2043 CURLcode curl_mime_headers(curl_mimepart *part, in curl_mime_headers() argument
2046 (void) part; in curl_mime_headers()