quickjs-tart

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

curl_mime_data.md (1939B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_mime_data
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - curl_mime_addpart (3)
      9   - curl_mime_data_cb (3)
     10   - curl_mime_name (3)
     11   - curl_mime_type (3)
     12 Protocol:
     13   - HTTP
     14   - IMAP
     15   - SMTP
     16 Added-in: 7.56.0
     17 ---
     18 
     19 # NAME
     20 
     21 curl_mime_data - set a mime part's body data from memory
     22 
     23 # SYNOPSIS
     24 
     25 ~~~c
     26 #include <curl/curl.h>
     27 
     28 CURLcode curl_mime_data(curl_mimepart *part, const char *data,
     29                         size_t datasize);
     30 ~~~
     31 
     32 # DESCRIPTION
     33 
     34 curl_mime_data(3) sets a mime part's body content from memory data.
     35 
     36 *part* is the mime part to assign contents to, created with
     37 curl_mime_addpart(3).
     38 
     39 *data* points to the data that gets copied by this function. The storage
     40 may safely be reused after the call.
     41 
     42 *datasize* is the number of bytes *data* points to. It can be set to
     43 *CURL_ZERO_TERMINATED* to indicate *data* is a null-terminated
     44 character string.
     45 
     46 Setting a part's contents multiple times is valid: only the value set by the
     47 last call is retained. It is possible to unassign part's contents by setting
     48 *data* to NULL.
     49 
     50 Setting large data is memory consuming: one might consider using
     51 curl_mime_data_cb(3) in such a case.
     52 
     53 # %PROTOCOLS%
     54 
     55 # EXAMPLE
     56 
     57 ~~~c
     58 int main(void)
     59 {
     60   curl_mime *mime;
     61   curl_mimepart *part;
     62 
     63   CURL *curl = curl_easy_init();
     64   if(curl) {
     65     /* create a mime handle */
     66     mime = curl_mime_init(curl);
     67 
     68     /* add a part */
     69     part = curl_mime_addpart(mime);
     70 
     71     /* add data to the part  */
     72     curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
     73   }
     74 }
     75 ~~~
     76 
     77 # %AVAILABILITY%
     78 
     79 # RETURN VALUE
     80 
     81 This function returns a CURLcode indicating success or error.
     82 
     83 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     84 libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
     85 there can be an error message stored in the error buffer when non-zero is
     86 returned.