curl_mime_addpart.md (1455B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_mime_addpart 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_mime_data (3) 9 - curl_mime_data_cb (3) 10 - curl_mime_encoder (3) 11 - curl_mime_filedata (3) 12 - curl_mime_filename (3) 13 - curl_mime_headers (3) 14 - curl_mime_init (3) 15 - curl_mime_name (3) 16 - curl_mime_subparts (3) 17 - curl_mime_type (3) 18 Protocol: 19 - HTTP 20 - IMAP 21 - SMTP 22 Added-in: 7.56.0 23 --- 24 25 # NAME 26 27 curl_mime_addpart - append a new empty part to a mime structure 28 29 # SYNOPSIS 30 31 ~~~c 32 #include <curl/curl.h> 33 34 curl_mimepart *curl_mime_addpart(curl_mime *mime); 35 ~~~ 36 37 # DESCRIPTION 38 39 curl_mime_addpart(3) creates and appends a new empty part to the given 40 mime structure and returns a handle to it. The returned part handle can 41 subsequently be populated using functions from the mime API. 42 43 *mime* is the handle of the mime structure in which the new part must be 44 appended. 45 46 # %PROTOCOLS% 47 48 # EXAMPLE 49 50 ~~~c 51 int main(void) 52 { 53 curl_mime *mime; 54 curl_mimepart *part; 55 56 CURL *curl = curl_easy_init(); 57 if(curl) { 58 /* create a mime handle */ 59 mime = curl_mime_init(curl); 60 61 /* add a part */ 62 part = curl_mime_addpart(mime); 63 64 /* continue and set name + data to the part */ 65 curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED); 66 curl_mime_name(part, "data"); 67 } 68 } 69 ~~~ 70 71 # %AVAILABILITY% 72 73 # RETURN VALUE 74 75 A mime part structure handle, or NULL upon failure.