gnurl_slist_append(3)
gnurl_slist_append(3) π
okay so this page is from the libgnurl Manual, and it's giving βtiny helper, huge slayβ energy. No cap, bestie: it's all about adding a string to an slist. Let's go. β¨
πΈ NAME πΈ
curl_slist_append β add a string to an slist
β¨ SYNOPSIS β¨
copy-paste this exactly, okay? π«Ά
#include <gnurl/curl.h>
struct curl_slist *curl_slist_append(struct curl_slist *list, const char
* string);
π DESCRIPTION π
okay so curl_slist_append(3) appends a string to a linked list of strings. The existing list should be passed as the first argument, and the new list is returned from this function. Pass in NULL in the list argument to create a new list. The specified string has been appended when this function returns. curl_slist_append(3) copies the string. iconic. π¦
The list should be freed again (after usage) with curl_slist_free_all(3). don't forget, bestie β that's the cleanup era. π§Ή
π₯ RETURN VALUE π₯
A null pointer is returned if anything went wrong, otherwise the new list pointer is returned. red flag alert: to avoid overwriting an existing non-empty list on failure, the new list should be returned to a temporary variable which can be tested for NULL before updating the original list pointer. literally protect the original list at all costs. π
π§ EXAMPLE π§
here's the example. keep the code exactly as it is β yes, every line. π
CURL *handle;
struct curl_slist *slist=NULL;
struct curl_slist *temp=NULL;
slist = curl_slist_append(slist, "pragma:");
if (slist == NULL)
return -1;
temp = curl_slist_append(slist, "Accept:")
if (temp == NULL) {
curl_slist_free_all(slist);
return -1;
}
slist = temp;
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
curl_easy_perform(handle);
curl_slist_free_all(slist); /* free the list again */
π SEE ALSO π
that's the whole SEE ALSO, periodt. π
mwah π β signed off from libcurl 7.10.4, dated 19 Jun 2003, and filed under gnurl_slist_append(3). periodt. π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms