1curl_slist_append(3)            libcurl Manual            curl_slist_append(3)
2
3
4

NAME

6       curl_slist_append - add a string to an slist
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       struct curl_slist *curl_slist_append(struct curl_slist *list,
12                                            const char *string);
13

DESCRIPTION

15       curl_slist_append(3)  appends a string to a linked list of strings. The
16       existing list should be passed as the first argument and the  new  list
17       is  returned  from  this function. Pass in NULL in the list argument to
18       create a new list. The specified string has  been  appended  when  this
19       function returns. curl_slist_append(3) copies the string.
20
21       The    list    should    be    freed    again    (after   usage)   with
22       curl_slist_free_all(3).
23

EXAMPLE

25       CURL *handle;
26       struct curl_slist *slist=NULL;
27       struct curl_slist *temp=NULL;
28
29       slist = curl_slist_append(slist, "pragma:");
30
31       if (slist == NULL)
32         return -1;
33
34       temp = curl_slist_append(slist, "Accept:")
35
36       if (temp == NULL) {
37         curl_slist_free_all(slist);
38         return -1;
39       }
40
41       slist = temp;
42
43       curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
44
45       curl_easy_perform(handle);
46
47       curl_slist_free_all(slist); /* free the list again */
48

AVAILABILITY

50       Always
51

RETURN VALUE

53       A null pointer is returned if anything went wrong,  otherwise  the  new
54       list  pointer  is  returned. To avoid overwriting an existing non-empty
55       list on failure, the new list should be returned to a  temporary  vari‐
56       able  which  can  be  tested for NULL before updating the original list
57       pointer.
58

SEE ALSO

60       curl_slist_free_all(3),
61
62
63
64libcurl 8.0.1                  January 02, 2023           curl_slist_append(3)
Impressum