1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

mime: use CURL_ZERO_TERMINATED in examples

and some minor whitespace fixes
This commit is contained in:
Viktor Szakats 2017-09-04 13:58:10 +00:00
parent 202c1cc22f
commit 841a09ea19
6 changed files with 19 additions and 19 deletions

View File

@ -51,18 +51,18 @@ int main(void)
/* Fill in the file upload field */
field = curl_mime_addpart(form);
curl_mime_name(field, "sendfile", -1);
curl_mime_name(field, "sendfile", CURL_ZERO_TERMINATED);
curl_mime_filedata(field, "multi-post.c");
/* Fill in the filename field */
field = curl_mime_addpart(form);
curl_mime_name(field, "filename", -1);
curl_mime_data(field, "multi-post.c", -1);
curl_mime_name(field, "filename", CURL_ZERO_TERMINATED);
curl_mime_data(field, "multi-post.c", CURL_ZERO_TERMINATED);
/* Fill in the submit field too, even if this is rarely needed */
field = curl_mime_addpart(form);
curl_mime_name(field, "submit", -1);
curl_mime_data(field, "send", -1);
curl_mime_name(field, "submit", CURL_ZERO_TERMINATED);
curl_mime_data(field, "send", CURL_ZERO_TERMINATED);
/* initialize custom header list (stating that Expect: 100-continue is not
wanted */

View File

@ -61,18 +61,18 @@ int main(int argc, char *argv[])
/* Fill in the file upload field */
field = curl_mime_addpart(form);
curl_mime_name(field, "sendfile", -1);
curl_mime_name(field, "sendfile", CURL_ZERO_TERMINATED);
curl_mime_filedata(field, "postit2.c");
/* Fill in the filename field */
field = curl_mime_addpart(form);
curl_mime_name(field, "filename", -1);
curl_mime_data(field, "postit2.c", -1);
curl_mime_name(field, "filename", CURL_ZERO_TERMINATED);
curl_mime_data(field, "postit2.c", CURL_ZERO_TERMINATED);
/* Fill in the submit field too, even if this is rarely needed */
field = curl_mime_addpart(form);
curl_mime_name(field, "submit", -1);
curl_mime_data(field, "send", -1);
curl_mime_name(field, "submit", CURL_ZERO_TERMINATED);
curl_mime_data(field, "send", CURL_ZERO_TERMINATED);
/* initialize custom header list (stating that Expect: 100-continue is not
wanted */

View File

@ -113,12 +113,12 @@ int main(void)
/* HTML message. */
part = curl_mime_addpart(alt);
curl_mime_data(part, inline_html, -1);
curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED);
curl_mime_type(part, "text/html");
/* Text message. */
part = curl_mime_addpart(alt);
curl_mime_data(part, inline_text, -1);
curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED);
/* Create the inline part. */
part = curl_mime_addpart(mime);

View File

@ -142,7 +142,7 @@ int seek_callback(void *arg, curl_off_t offset, int origin)
p->position = offset;
return CURL_SEEKFUNC_OK;
}
CURL *easy = curl_easy_init();
curl_mime *mime = curl_mime_init(easy);
curl_mimepart *part = curl_mime_addpart(mime);

View File

@ -34,7 +34,7 @@ subsequently filled using the mime API, then attached to \fIeasy_handle\fP
using option \fICURLOPT_MIMEPOST(3)\fP within a \fIcurl_easy_setopt(3)\fP
call.
Using a mime handle is the recommended way to post an HTTP form, format and
Using a mime handle is the recommended way to post an HTTP form, format and
send a multi-part e-mail with SMTP or upload such an e-mail to an IMAP server.
.SH AVAILABILITY
@ -51,8 +51,8 @@ A mime struct handle, or NULL upon failure.
/* Build an HTTP form with a single field named "data", */
mime = curl_mime_init(easy);
part = curl_mime_addpart(mime);
curl_mime_data(part, "This is the field data", -1);
curl_mime_name(part, "data", -1);
curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
curl_mime_name(part, "data", CURL_ZERO_TERMINATED);
/* Post and send it. */
curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);

View File

@ -771,9 +771,9 @@ struct Curl_mime *curl_mime_init(struct Curl_easy *easy)
/* Initialize a mime part. */
void Curl_mime_initpart(struct Curl_mimepart *part, struct Curl_easy *easy)
{
memset((char *) part, 0, sizeof *part);
part->easy = easy;
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
memset((char *) part, 0, sizeof *part);
part->easy = easy;
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
}
/* Create a mime part and append it to a mime handle's part list. */