quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl_mime_subparts.md (2327B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_mime_subparts
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - curl_mime_addpart (3)
      9   - curl_mime_init (3)
     10 Protocol:
     11   - HTTP
     12   - IMAP
     13   - SMTP
     14 Added-in: 7.56.0
     15 ---
     16 
     17 # NAME
     18 
     19 curl_mime_subparts - set sub-parts of a multipart mime part
     20 
     21 # SYNOPSIS
     22 
     23 ~~~c
     24 #include <curl/curl.h>
     25 
     26 CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts);
     27 ~~~
     28 
     29 # DESCRIPTION
     30 
     31 curl_mime_subparts(3) sets a multipart mime part's content from a mime
     32 structure.
     33 
     34 *part* is a handle to the multipart part.
     35 
     36 *subparts* is a mime structure handle holding the sub-parts. After
     37 curl_mime_subparts(3) succeeds, the mime structure handle belongs to the
     38 multipart part and must not be freed explicitly. It may however be updated by
     39 subsequent calls to mime API functions.
     40 
     41 Setting a part's contents multiple times is valid: only the value set by the
     42 last call is retained. It is possible to unassign previous part's contents by
     43 setting *subparts* to NULL.
     44 
     45 # %PROTOCOLS%
     46 
     47 # EXAMPLE
     48 
     49 ~~~c
     50 
     51 static char *inline_html = "<title>example</title>";
     52 static char *inline_text = "once upon the time";
     53 
     54 int main(void)
     55 {
     56   CURL *curl = curl_easy_init();
     57   if(curl) {
     58     struct curl_slist *slist;
     59 
     60     /* The inline part is an alternative proposing the html and the text
     61        versions of the email. */
     62     curl_mime *alt = curl_mime_init(curl);
     63     curl_mimepart *part;
     64 
     65     /* HTML message. */
     66     part = curl_mime_addpart(alt);
     67     curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED);
     68     curl_mime_type(part, "text/html");
     69 
     70     /* Text message. */
     71     part = curl_mime_addpart(alt);
     72     curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED);
     73 
     74     /* Create the inline part. */
     75     part = curl_mime_addpart(alt);
     76     curl_mime_subparts(part, alt);
     77     curl_mime_type(part, "multipart/alternative");
     78     slist = curl_slist_append(NULL, "Content-Disposition: inline");
     79     curl_mime_headers(part, slist, 1);
     80   }
     81 }
     82 ~~~
     83 
     84 # %AVAILABILITY%
     85 
     86 # RETURN VALUE
     87 
     88 This function returns a CURLcode indicating success or error.
     89 
     90 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     91 libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
     92 there can be an error message stored in the error buffer when non-zero is
     93 returned.