aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/mime.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:08 +0300
commit4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch)
tree506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/libs/curl/lib/mime.c
parent2d37894b1b037cf24231090eda8589bbb44fb6fc (diff)
downloadydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/curl/lib/mime.c')
-rw-r--r--contrib/libs/curl/lib/mime.c458
1 files changed, 229 insertions, 229 deletions
diff --git a/contrib/libs/curl/lib/mime.c b/contrib/libs/curl/lib/mime.c
index 2ddd9b8b98..1d0867ef41 100644
--- a/contrib/libs/curl/lib/mime.c
+++ b/contrib/libs/curl/lib/mime.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,7 +26,7 @@
#include "mime.h"
#include "non-ascii.h"
-#include "warnless.h"
+#include "warnless.h"
#include "urldata.h"
#include "sendf.h"
@@ -53,11 +53,11 @@
#define READ_ERROR ((size_t) -1)
-#define STOP_FILLING ((size_t) -2)
-
-static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
- void *instream, bool *hasread);
+#define STOP_FILLING ((size_t) -2)
+static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
+ void *instream, bool *hasread);
+
/* Encoders. */
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part);
@@ -71,7 +71,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part);
static curl_off_t encoder_qp_size(curl_mimepart *part);
-static const struct mime_encoder encoders[] = {
+static const struct mime_encoder encoders[] = {
{"binary", encoder_nop_read, encoder_nop_size},
{"8bit", encoder_nop_read, encoder_nop_size},
{"7bit", encoder_7bit_read, encoder_nop_size},
@@ -269,8 +269,8 @@ static char *Curl_basename(char *path)
/* Set readback state. */
-static void mimesetstate(struct mime_state *state,
- enum mimestate tok, void *ptr)
+static void mimesetstate(struct mime_state *state,
+ enum mimestate tok, void *ptr)
{
state->state = tok;
state->ptr = ptr;
@@ -343,7 +343,7 @@ static char *strippath(const char *fullfile)
}
/* Initialize data encoder state. */
-static void cleanup_encoder_state(struct mime_encoder_state *p)
+static void cleanup_encoder_state(struct mime_encoder_state *p)
{
p->pos = 0;
p->bufbeg = 0;
@@ -353,22 +353,22 @@ static void cleanup_encoder_state(struct mime_encoder_state *p)
/* Dummy encoder. This is used for 8bit and binary content encodings. */
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
- struct curl_mimepart *part)
+ struct curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t insize = st->bufend - st->bufbeg;
(void) ateof;
- if(!size)
- return STOP_FILLING;
-
+ if(!size)
+ return STOP_FILLING;
+
if(size > insize)
size = insize;
-
+
if(size)
- memcpy(buffer, st->buf + st->bufbeg, size);
-
+ memcpy(buffer, st->buf + st->bufbeg, size);
+
st->bufbeg += size;
return size;
}
@@ -383,14 +383,14 @@ static curl_off_t encoder_nop_size(curl_mimepart *part)
static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t cursize = st->bufend - st->bufbeg;
(void) ateof;
- if(!size)
- return STOP_FILLING;
-
+ if(!size)
+ return STOP_FILLING;
+
if(size > cursize)
size = cursize;
@@ -409,7 +409,7 @@ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t cursize = 0;
int i;
char *ptr = buffer;
@@ -418,11 +418,11 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
/* Line full ? */
if(st->pos > MAX_ENCODED_LINE_LENGTH - 4) {
/* Yes, we need 2 characters for CRLF. */
- if(size < 2) {
- if(!cursize)
- return STOP_FILLING;
+ if(size < 2) {
+ if(!cursize)
+ return STOP_FILLING;
break;
- }
+ }
*ptr++ = '\r';
*ptr++ = '\n';
st->pos = 0;
@@ -431,13 +431,13 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
}
/* Be sure there is enough space and input data for a base64 group. */
- if(size < 4) {
- if(!cursize)
- return STOP_FILLING;
- break;
- }
- if(st->bufend - st->bufbeg < 3)
+ if(size < 4) {
+ if(!cursize)
+ return STOP_FILLING;
break;
+ }
+ if(st->bufend - st->bufbeg < 3)
+ break;
/* Encode three bytes as four characters. */
i = st->buf[st->bufbeg++] & 0xFF;
@@ -453,30 +453,30 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
}
/* If at eof, we have to flush the buffered data. */
- if(ateof) {
- if(size < 4) {
- if(!cursize)
- return STOP_FILLING;
- }
- else {
- /* Buffered data size can only be 0, 1 or 2. */
- ptr[2] = ptr[3] = '=';
- i = 0;
- switch(st->bufend - st->bufbeg) {
- case 2:
- i = (st->buf[st->bufbeg + 1] & 0xFF) << 8;
- /* FALLTHROUGH */
- case 1:
- i |= (st->buf[st->bufbeg] & 0xFF) << 16;
- ptr[0] = base64[(i >> 18) & 0x3F];
- ptr[1] = base64[(i >> 12) & 0x3F];
- if(++st->bufbeg != st->bufend) {
- ptr[2] = base64[(i >> 6) & 0x3F];
- st->bufbeg++;
- }
- cursize += 4;
- st->pos += 4;
- break;
+ if(ateof) {
+ if(size < 4) {
+ if(!cursize)
+ return STOP_FILLING;
+ }
+ else {
+ /* Buffered data size can only be 0, 1 or 2. */
+ ptr[2] = ptr[3] = '=';
+ i = 0;
+ switch(st->bufend - st->bufbeg) {
+ case 2:
+ i = (st->buf[st->bufbeg + 1] & 0xFF) << 8;
+ /* FALLTHROUGH */
+ case 1:
+ i |= (st->buf[st->bufbeg] & 0xFF) << 16;
+ ptr[0] = base64[(i >> 18) & 0x3F];
+ ptr[1] = base64[(i >> 12) & 0x3F];
+ if(++st->bufbeg != st->bufend) {
+ ptr[2] = base64[(i >> 6) & 0x3F];
+ st->bufbeg++;
+ }
+ cursize += 4;
+ st->pos += 4;
+ break;
}
}
}
@@ -513,7 +513,7 @@ static curl_off_t encoder_base64_size(curl_mimepart *part)
* Check if a CRLF or end of data is in input buffer at current position + n.
* Return -1 if more data needed, 1 if CRLF or end of data, else 0.
*/
-static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
+static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
{
n += st->bufbeg;
if(n >= st->bufend && ateof)
@@ -530,7 +530,7 @@ static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
char *ptr = buffer;
size_t cursize = 0;
int softlinebreak;
@@ -608,11 +608,11 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
}
/* If the output buffer would overflow, do not store. */
- if(len > size) {
- if(!cursize)
- return STOP_FILLING;
+ if(len > size) {
+ if(!cursize)
+ return STOP_FILLING;
break;
- }
+ }
/* Append to output buffer. */
memcpy(ptr, buf, len);
@@ -642,17 +642,17 @@ static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
curl_mimepart *part = (curl_mimepart *) instream;
- size_t sz = curlx_sotouz(part->datasize - part->state.offset);
+ size_t sz = curlx_sotouz(part->datasize - part->state.offset);
(void) size; /* Always 1.*/
- if(!nitems)
- return STOP_FILLING;
-
+ if(!nitems)
+ return STOP_FILLING;
+
if(sz > nitems)
sz = nitems;
if(sz)
- memcpy(buffer, part->data + curlx_sotouz(part->state.offset), sz);
+ memcpy(buffer, part->data + curlx_sotouz(part->state.offset), sz);
return sz;
}
@@ -673,7 +673,7 @@ static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
if(offset < 0 || offset > part->datasize)
return CURL_SEEKFUNC_FAIL;
- part->state.offset = offset;
+ part->state.offset = offset;
return CURL_SEEKFUNC_OK;
}
@@ -685,7 +685,7 @@ static void mime_mem_free(void *ptr)
/* Named file callbacks. */
/* Argument is a pointer to the mime part. */
-static int mime_open_file(curl_mimepart *part)
+static int mime_open_file(curl_mimepart *part)
{
/* Open a MIMEKIND_FILE part. */
@@ -700,9 +700,9 @@ static size_t mime_file_read(char *buffer, size_t size, size_t nitems,
{
curl_mimepart *part = (curl_mimepart *) instream;
- if(!nitems)
- return STOP_FILLING;
-
+ if(!nitems)
+ return STOP_FILLING;
+
if(mime_open_file(part))
return READ_ERROR;
@@ -740,22 +740,22 @@ static void mime_file_free(void *ptr)
/* Argument is a pointer to the mime structure. */
/* Readback a byte string segment. */
-static size_t readback_bytes(struct mime_state *state,
+static size_t readback_bytes(struct mime_state *state,
char *buffer, size_t bufsize,
const char *bytes, size_t numbytes,
const char *trail)
{
size_t sz;
- size_t offset = curlx_sotouz(state->offset);
+ size_t offset = curlx_sotouz(state->offset);
- if(numbytes > offset) {
- sz = numbytes - offset;
- bytes += offset;
+ if(numbytes > offset) {
+ sz = numbytes - offset;
+ bytes += offset;
}
else {
size_t tsz = strlen(trail);
- sz = offset - numbytes;
+ sz = offset - numbytes;
if(sz >= tsz)
return 0;
bytes = trail + sz;
@@ -772,79 +772,79 @@ static size_t readback_bytes(struct mime_state *state,
/* Read a non-encoded part content. */
static size_t read_part_content(curl_mimepart *part,
- char *buffer, size_t bufsize, bool *hasread)
+ char *buffer, size_t bufsize, bool *hasread)
{
size_t sz = 0;
- switch(part->lastreadstatus) {
- case 0:
- case CURL_READFUNC_ABORT:
- case CURL_READFUNC_PAUSE:
- case READ_ERROR:
- return part->lastreadstatus;
- default:
- break;
- }
-
- /* If we can determine we are at end of part data, spare a read. */
- if(part->datasize != (curl_off_t) -1 &&
- part->state.offset >= part->datasize) {
- /* sz is already zero. */
- }
- else {
- switch(part->kind) {
- case MIMEKIND_MULTIPART:
- /*
- * Cannot be processed as other kinds since read function requires
- * an additional parameter and is highly recursive.
- */
- sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
- break;
- case MIMEKIND_FILE:
- if(part->fp && feof(part->fp))
- break; /* At EOF. */
- /* FALLTHROUGH */
- default:
- if(part->readfunc) {
- if(!(part->flags & MIME_FAST_READ)) {
- if(*hasread)
- return STOP_FILLING;
- *hasread = TRUE;
- }
- sz = part->readfunc(buffer, 1, bufsize, part->arg);
- }
- break;
- }
- }
-
- switch(sz) {
- case STOP_FILLING:
- break;
- case 0:
- case CURL_READFUNC_ABORT:
- case CURL_READFUNC_PAUSE:
- case READ_ERROR:
- part->lastreadstatus = sz;
- break;
- default:
- part->state.offset += sz;
- part->lastreadstatus = sz;
- break;
- }
-
+ switch(part->lastreadstatus) {
+ case 0:
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ return part->lastreadstatus;
+ default:
+ break;
+ }
+
+ /* If we can determine we are at end of part data, spare a read. */
+ if(part->datasize != (curl_off_t) -1 &&
+ part->state.offset >= part->datasize) {
+ /* sz is already zero. */
+ }
+ else {
+ switch(part->kind) {
+ case MIMEKIND_MULTIPART:
+ /*
+ * Cannot be processed as other kinds since read function requires
+ * an additional parameter and is highly recursive.
+ */
+ sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
+ break;
+ case MIMEKIND_FILE:
+ if(part->fp && feof(part->fp))
+ break; /* At EOF. */
+ /* FALLTHROUGH */
+ default:
+ if(part->readfunc) {
+ if(!(part->flags & MIME_FAST_READ)) {
+ if(*hasread)
+ return STOP_FILLING;
+ *hasread = TRUE;
+ }
+ sz = part->readfunc(buffer, 1, bufsize, part->arg);
+ }
+ break;
+ }
+ }
+
+ switch(sz) {
+ case STOP_FILLING:
+ break;
+ case 0:
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ part->lastreadstatus = sz;
+ break;
+ default:
+ part->state.offset += sz;
+ part->lastreadstatus = sz;
+ break;
+ }
+
return sz;
}
/* Read and encode part content. */
-static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
- size_t bufsize, bool *hasread)
+static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
+ size_t bufsize, bool *hasread)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t cursize = 0;
size_t sz;
bool ateof = FALSE;
- for(;;) {
+ for(;;) {
if(st->bufbeg < st->bufend || ateof) {
/* Encode buffered data. */
sz = part->encoder->encodefunc(buffer, bufsize, ateof, part);
@@ -854,7 +854,7 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
return cursize;
break;
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
default:
cursize += sz;
@@ -876,7 +876,7 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
if(st->bufend >= sizeof(st->buf))
return cursize? cursize: READ_ERROR; /* Buffer full. */
sz = read_part_content(part, st->buf + st->bufend,
- sizeof(st->buf) - st->bufend, hasread);
+ sizeof(st->buf) - st->bufend, hasread);
switch(sz) {
case 0:
ateof = TRUE;
@@ -884,7 +884,7 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
default:
st->bufend += sz;
@@ -892,12 +892,12 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
}
}
- /* NOTREACHED */
+ /* NOTREACHED */
}
/* Readback a mime part. */
static size_t readback_part(curl_mimepart *part,
- char *buffer, size_t bufsize, bool *hasread)
+ char *buffer, size_t bufsize, bool *hasread)
{
size_t cursize = 0;
#ifdef CURL_DOES_CONVERSIONS
@@ -956,9 +956,9 @@ static size_t readback_part(curl_mimepart *part,
break;
case MIMESTATE_CONTENT:
if(part->encoder)
- sz = read_encoded_part_content(part, buffer, bufsize, hasread);
+ sz = read_encoded_part_content(part, buffer, bufsize, hasread);
else
- sz = read_part_content(part, buffer, bufsize, hasread);
+ sz = read_part_content(part, buffer, bufsize, hasread);
switch(sz) {
case 0:
mimesetstate(&part->state, MIMESTATE_END, NULL);
@@ -971,7 +971,7 @@ static size_t readback_part(curl_mimepart *part,
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
}
break;
@@ -1000,9 +1000,9 @@ static size_t readback_part(curl_mimepart *part,
return cursize;
}
-/* Readback from mime. Warning: not a read callback function. */
+/* Readback from mime. Warning: not a read callback function. */
static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
- void *instream, bool *hasread)
+ void *instream, bool *hasread)
{
curl_mime *mime = (curl_mime *) instream;
size_t cursize = 0;
@@ -1023,7 +1023,7 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
#endif
mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, mime->firstpart);
/* The first boundary always follows the header termination empty line,
- so is always preceded by a CRLF. We can then spare 2 characters
+ so is always preceded by a CRLF. We can then spare 2 characters
by skipping the leading CRLF in boundary. */
mime->state.offset += 2;
break;
@@ -1053,12 +1053,12 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
mimesetstate(&mime->state, MIMESTATE_END, NULL);
break;
}
- sz = readback_part(part, buffer, nitems, hasread);
+ sz = readback_part(part, buffer, nitems, hasread);
switch(sz) {
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
case 0:
#ifdef CURL_DOES_CONVERSIONS
@@ -1123,7 +1123,7 @@ static int mime_part_rewind(curl_mimepart *part)
if(res == CURL_SEEKFUNC_OK)
mimesetstate(&part->state, targetstate, NULL);
- part->lastreadstatus = 1; /* Successful read status. */
+ part->lastreadstatus = 1; /* Successful read status. */
return res;
}
@@ -1166,8 +1166,8 @@ static void cleanup_part_content(curl_mimepart *part)
part->datasize = (curl_off_t) 0; /* No size yet. */
cleanup_encoder_state(&part->encstate);
part->kind = MIMEKIND_NONE;
- part->flags &= ~MIME_FAST_READ;
- part->lastreadstatus = 1; /* Successful read status. */
+ part->flags &= ~MIME_FAST_READ;
+ part->lastreadstatus = 1; /* Successful read status. */
}
static void mime_subparts_free(void *ptr)
@@ -1230,8 +1230,8 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
const curl_mimepart *s;
CURLcode res = CURLE_OK;
- DEBUGASSERT(dst);
-
+ DEBUGASSERT(dst);
+
/* Duplicate content. */
switch(src->kind) {
case MIMEKIND_NONE:
@@ -1281,18 +1281,18 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
}
}
- if(!res) {
- /* Duplicate other fields. */
+ if(!res) {
+ /* Duplicate other fields. */
dst->encoder = src->encoder;
res = curl_mime_type(dst, src->mimetype);
- }
+ }
if(!res)
res = curl_mime_name(dst, src->name);
if(!res)
res = curl_mime_filename(dst, src->filename);
/* If an error occurred, rollback. */
- if(res)
+ if(res)
Curl_mime_cleanpart(dst);
return res;
@@ -1333,7 +1333,7 @@ void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
{
memset((char *) part, 0, sizeof(*part));
part->easy = easy;
- part->lastreadstatus = 1; /* Successful read status. */
+ part->lastreadstatus = 1; /* Successful read status. */
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
}
@@ -1419,12 +1419,12 @@ CURLcode curl_mime_data(curl_mimepart *part,
if(datasize)
memcpy(part->data, data, datasize);
- part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */
+ part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */
part->readfunc = mime_mem_read;
part->seekfunc = mime_mem_seek;
part->freefunc = mime_mem_free;
- part->flags |= MIME_FAST_READ;
+ part->flags |= MIME_FAST_READ;
part->kind = MIMEKIND_DATA;
}
@@ -1502,7 +1502,7 @@ CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
{
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
- const struct mime_encoder *mep;
+ const struct mime_encoder *mep;
if(!part)
return result;
@@ -1599,7 +1599,7 @@ CURLcode Curl_mime_set_subparts(curl_mimepart *part,
}
subparts->parent = part;
- /* Subparts are processed internally: no read callback. */
+ /* Subparts are processed internally: no read callback. */
part->seekfunc = mime_subparts_seek;
part->freefunc = take_ownership? mime_subparts_free: mime_subparts_unbind;
part->arg = subparts;
@@ -1621,23 +1621,23 @@ CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts)
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
{
curl_mimepart *part = (curl_mimepart *) instream;
- size_t ret;
- bool hasread;
+ size_t ret;
+ bool hasread;
(void) size; /* Always 1. */
-
- do {
- hasread = FALSE;
- ret = readback_part(part, buffer, nitems, &hasread);
- /*
- * If this is not possible to get some data without calling more than
- * one read callback (probably because a content encoder is not able to
- * deliver a new bunch for the few data accumulated so far), force another
- * read until we get enough data or a special exit code.
- */
- } while(ret == STOP_FILLING);
-
- return ret;
+
+ do {
+ hasread = FALSE;
+ ret = readback_part(part, buffer, nitems, &hasread);
+ /*
+ * If this is not possible to get some data without calling more than
+ * one read callback (probably because a content encoder is not able to
+ * deliver a new bunch for the few data accumulated so far), force another
+ * read until we get enough data or a special exit code.
+ */
+ } while(ret == STOP_FILLING);
+
+ return ret;
}
/* Rewind mime stream. */
@@ -1778,23 +1778,23 @@ const char *Curl_mime_contenttype(const char *filename)
return NULL;
}
-static bool content_type_match(const char *contenttype, const char *target)
-{
- size_t len = strlen(target);
-
- if(contenttype && strncasecompare(contenttype, target, len))
- switch(contenttype[len]) {
- case '\0':
- case '\t':
- case '\r':
- case '\n':
- case ' ':
- case ';':
- return TRUE;
- }
- return FALSE;
-}
-
+static bool content_type_match(const char *contenttype, const char *target)
+{
+ size_t len = strlen(target);
+
+ if(contenttype && strncasecompare(contenttype, target, len))
+ switch(contenttype[len]) {
+ case '\0':
+ case '\t':
+ case '\r':
+ case '\n':
+ case ' ':
+ case ';':
+ return TRUE;
+ }
+ return FALSE;
+}
+
CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
const char *contenttype,
const char *disposition,
@@ -1846,7 +1846,7 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
boundary = mime->boundary;
}
else if(contenttype && !customct &&
- content_type_match(contenttype, "text/plain"))
+ content_type_match(contenttype, "text/plain"))
if(strategy == MIMESTRATEGY_MAIL || !part->filename)
contenttype = NULL;
@@ -1922,7 +1922,7 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
curl_mimepart *subpart;
disposition = NULL;
- if(content_type_match(contenttype, "multipart/form-data"))
+ if(content_type_match(contenttype, "multipart/form-data"))
disposition = "form-data";
for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart) {
ret = Curl_mime_prepare_headers(subpart, NULL, disposition, strategy);
@@ -1933,26 +1933,26 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
return ret;
}
-/* Recursively reset paused status in the given part. */
-void Curl_mime_unpause(curl_mimepart *part)
-{
- if(part) {
- if(part->lastreadstatus == CURL_READFUNC_PAUSE)
- part->lastreadstatus = 1; /* Successful read status. */
- if(part->kind == MIMEKIND_MULTIPART) {
- curl_mime *mime = (curl_mime *) part->arg;
-
- if(mime) {
- curl_mimepart *subpart;
-
- for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart)
- Curl_mime_unpause(subpart);
- }
- }
- }
-}
-
-
+/* Recursively reset paused status in the given part. */
+void Curl_mime_unpause(curl_mimepart *part)
+{
+ if(part) {
+ if(part->lastreadstatus == CURL_READFUNC_PAUSE)
+ part->lastreadstatus = 1; /* Successful read status. */
+ if(part->kind == MIMEKIND_MULTIPART) {
+ curl_mime *mime = (curl_mime *) part->arg;
+
+ if(mime) {
+ curl_mimepart *subpart;
+
+ for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart)
+ Curl_mime_unpause(subpart);
+ }
+ }
+ }
+}
+
+
#else /* !CURL_DISABLE_HTTP || !CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP */
/* Mime not compiled in: define stubs for externally-referenced functions. */
@@ -2049,11 +2049,11 @@ CURLcode curl_mime_headers(curl_mimepart *part,
return CURLE_NOT_BUILT_IN;
}
-CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
-{
- (void)slp;
- (void)fmt;
- return CURLE_NOT_BUILT_IN;
-}
-
+CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
+{
+ (void)slp;
+ (void)fmt;
+ return CURLE_NOT_BUILT_IN;
+}
+
#endif /* if disabled */