diff options
author | Patrick Monnerat <patrick@monnerat.net> | 2017-09-03 16:10:55 +0100 |
---|---|---|
committer | Patrick Monnerat <patrick@monnerat.net> | 2017-09-03 16:10:55 +0100 |
commit | efd93014260e8a7e36e12c1e9c5e4296dd5c5a9e (patch) | |
tree | 6d8f375f3d9a15eea59a4362cb966ec360a416a9 /lib | |
parent | 1a3f4c19919b09ff0fd0ba228b06a217d85d4265 (diff) |
mime: use size_t instead of ssize_t in public API interface.
To support telling a string is nul-terminated, symbol CURL_ZERO_TERMINATED
has been introduced.
Documentation updated accordingly.
symbols in versions updated. Added form API symbols deprecation info.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mime.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/mime.c b/lib/mime.c index 9e1336475..ef2eedae2 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -209,13 +209,15 @@ static void mimesetstate(struct mime_state *state, /* Escape header string into allocated memory. */ -static char *escape_string(const char *src, ssize_t srclen) +static char *escape_string(const char *src, size_t len) { - size_t len = srclen >= 0? (size_t) srclen: strlen(src); size_t bytecount; size_t i; char *dst; + if(len == CURL_ZERO_TERMINATED) + len = strlen(src); + bytecount = len; for(i = 0; i < len; i++) if(src[i] == '"' || src[i] == '\\' || !src[i]) @@ -801,7 +803,7 @@ struct Curl_mimepart *curl_mime_addpart(struct Curl_mime *mime) /* Set mime part name. */ CURLcode curl_mime_name(struct Curl_mimepart *part, - const char *name, ssize_t namesize) + const char *name, size_t namesize) { if(!part) return CURLE_BAD_FUNCTION_ARGUMENT; @@ -811,7 +813,7 @@ CURLcode curl_mime_name(struct Curl_mimepart *part, part->namesize = 0; if(name) { - if(namesize < 0) + if(namesize == CURL_ZERO_TERMINATED) namesize = strlen(name); part->name = malloc(namesize + 1); if(!part->name) @@ -845,7 +847,7 @@ CURLcode curl_mime_filename(struct Curl_mimepart *part, const char *filename) /* Set mime part content from memory data. */ CURLcode curl_mime_data(struct Curl_mimepart *part, - const char *data, ssize_t datasize) + const char *data, size_t datasize) { if(!part) return CURLE_BAD_FUNCTION_ARGUMENT; @@ -853,7 +855,7 @@ CURLcode curl_mime_data(struct Curl_mimepart *part, cleanup_part_content(part); if(data) { - if(datasize < 0) + if(datasize == CURL_ZERO_TERMINATED) datasize = strlen(data); part->data = malloc(datasize + 1); @@ -1284,7 +1286,7 @@ CURLcode Curl_mime_prepare_headers(struct Curl_mimepart *part, ret = CURLE_OUT_OF_MEMORY; } if(!ret && part->filename) { - filename = escape_string(part->filename, -1); + filename = escape_string(part->filename, CURL_ZERO_TERMINATED); if(!filename) ret = CURLE_OUT_OF_MEMORY; } @@ -1364,7 +1366,7 @@ curl_mimepart *curl_mime_addpart(curl_mime *mime) } CURLcode curl_mime_name(curl_mimepart *part, - const char *name, ssize_t namesize) + const char *name, size_t namesize) { (void) part; (void) name; @@ -1394,7 +1396,7 @@ CURLcode curl_mime_encoder(struct Curl_mimepart *part, const char *encoding) } CURLcode curl_mime_data(curl_mimepart *part, - const char *data, ssize_t datasize) + const char *data, size_t datasize) { (void) part; (void) data; |