curl_mime_subparts.3 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. .\" generated by cd2nroff 0.1 from curl_mime_subparts.md
  2. .TH curl_mime_subparts 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_mime_subparts \- set sub\-parts of a multipart mime part
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts);
  9. .fi
  10. .SH DESCRIPTION
  11. \fIcurl_mime_subparts(3)\fP sets a multipart mime part\(aqs content from a mime
  12. structure.
  13. \fIpart\fP is a handle to the multipart part.
  14. \fIsubparts\fP is a mime structure handle holding the sub\-parts. After
  15. \fIcurl_mime_subparts(3)\fP succeeds, the mime structure handle belongs to the
  16. multipart part and must not be freed explicitly. It may however be updated by
  17. subsequent calls to mime API functions.
  18. Setting a part\(aqs contents multiple times is valid: only the value set by the
  19. last call is retained. It is possible to unassign previous part\(aqs contents by
  20. setting \fIsubparts\fP to NULL.
  21. .SH PROTOCOLS
  22. This functionality affects http, imap and smtp
  23. .SH EXAMPLE
  24. .nf
  25. static char *inline_html = "<title>example</title>";
  26. static char *inline_text = "once upon the time";
  27. int main(void)
  28. {
  29. CURL *curl = curl_easy_init();
  30. if(curl) {
  31. struct curl_slist *slist;
  32. /* The inline part is an alternative proposing the html and the text
  33. versions of the email. */
  34. curl_mime *alt = curl_mime_init(curl);
  35. curl_mimepart *part;
  36. /* HTML message. */
  37. part = curl_mime_addpart(alt);
  38. curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED);
  39. curl_mime_type(part, "text/html");
  40. /* Text message. */
  41. part = curl_mime_addpart(alt);
  42. curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED);
  43. /* Create the inline part. */
  44. part = curl_mime_addpart(alt);
  45. curl_mime_subparts(part, alt);
  46. curl_mime_type(part, "multipart/alternative");
  47. slist = curl_slist_append(NULL, "Content-Disposition: inline");
  48. curl_mime_headers(part, slist, 1);
  49. }
  50. }
  51. .fi
  52. .SH AVAILABILITY
  53. Added in curl 7.56.0
  54. .SH RETURN VALUE
  55. CURLE_OK or a CURL error code upon failure.
  56. .SH SEE ALSO
  57. .BR curl_mime_addpart (3),
  58. .BR curl_mime_init (3)