gnurl_mime_data(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… gnurl_mime_data(3) β€” aka the libgnurl Manual moment

okay so bestie, welcome to the gnurl_mime_data page ✨ this is the one that lives in the libgnurl Manual, and it's literally about shoving some in-memory bytes into a mime part's body. iconic behavior, no cap πŸŽ€


🌸 NAME 🌸

curl_mime_data β€” set a mime part's body data from memory 🫢


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_mime_data(curl_mimepart * part, const char * data , size_t
datasize);

like, that's the whole vibe. three args, one return, let's GO πŸ’…


πŸ’– DESCRIPTION πŸ’–

curl_mime_data(3) sets a mime part's body content from memory data. that's it, that's the whole job, and it ate πŸ”₯

data points to the data bytes: those are copied to the part, so their storage may safely be reused after the call β€” like, you can go ahead and free/reuse your buffer, she has her own copy now, main character energy πŸ‘‘

datasize is the number of data bytes: it can be set to CURL_ZERO_TERMINATED to indicate data is a null-terminated character string 🧡

part is the part's to assign contents to. yes, that's the actual phrasing, I'm not fixing it, she's perfect πŸ™ˆ

Setting a part's contents twice is valid: only the value set by the last call is retained β€” last write wins, periodt πŸ’€

It is possible to unassign a part's contents by setting data to NULL πŸ•³οΈ

setting very large data is memory consuming: one might consider using curl_mime_data_cb(3) in such a case. like fr fr, if your data is huge, maybe don't hold it all in memory, that's not the slay you think it is 😭

πŸ¦‹ AVAILABILITY πŸ¦‹

As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0 ⭐


🌈 RETURN VALUE 🌈

CURLE_OK or a CURL error code upon failure πŸ’œ


πŸ“ EXAMPLE πŸ“

curl_mime *mime;
curl_mimepart *part;

/* create a mime handle */
mime = curl_mime_init(easy);

/* add a part */
part = curl_mime_addpart(mime);

/* add data to the part  */
curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);

look at her go, so clean, so demure 🌸


πŸ‘‘ SEE ALSO πŸ‘‘


kk that's the page!! πŸ’– this was brought to you by libcurl 7.56.0, dated 22 August 2017, and my undying love for well-documented C APIs πŸŽ€ bye bestie, go set some mime data πŸ¦‹βœ¨

πŸ“¦ where this page comes from