Annotation of embedaddon/curl/docs/libcurl/curl_slist_append.3, revision 1.1
1.1 ! misho 1: .\" **************************************************************************
! 2: .\" * _ _ ____ _
! 3: .\" * Project ___| | | | _ \| |
! 4: .\" * / __| | | | |_) | |
! 5: .\" * | (__| |_| | _ <| |___
! 6: .\" * \___|\___/|_| \_\_____|
! 7: .\" *
! 8: .\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
! 9: .\" *
! 10: .\" * This software is licensed as described in the file COPYING, which
! 11: .\" * you should have received as part of this distribution. The terms
! 12: .\" * are also available at https://curl.haxx.se/docs/copyright.html.
! 13: .\" *
! 14: .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
! 15: .\" * copies of the Software, and permit persons to whom the Software is
! 16: .\" * furnished to do so, under the terms of the COPYING file.
! 17: .\" *
! 18: .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
! 19: .\" * KIND, either express or implied.
! 20: .\" *
! 21: .\" **************************************************************************
! 22: .TH curl_slist_append 3 "January 02, 2019" "libcurl 7.70.0" "libcurl Manual"
! 23:
! 24: .SH NAME
! 25: curl_slist_append - add a string to an slist
! 26: .SH SYNOPSIS
! 27: .B #include <curl/curl.h>
! 28: .sp
! 29: .BI "struct curl_slist *curl_slist_append(struct curl_slist *" list,
! 30: .BI "const char * "string ");"
! 31: .ad
! 32: .SH DESCRIPTION
! 33: \fIcurl_slist_append(3)\fP appends a string to a linked list of strings. The
! 34: existing \fBlist\fP should be passed as the first argument and the new list is
! 35: returned from this function. Pass in NULL in the \fBlist\fP argument to create
! 36: a new list. The specified \fBstring\fP has been appended when this function
! 37: returns. \fIcurl_slist_append(3)\fP copies the string.
! 38:
! 39: The list should be freed again (after usage) with
! 40: \fIcurl_slist_free_all(3)\fP.
! 41: .SH RETURN VALUE
! 42: A null pointer is returned if anything went wrong, otherwise the new list
! 43: pointer is returned. To avoid overwriting an existing non-empty list on
! 44: failure, the new list should be returned to a temporary variable which can
! 45: be tested for NULL before updating the original list pointer.
! 46: .SH EXAMPLE
! 47: .nf
! 48: CURL *handle;
! 49: struct curl_slist *slist=NULL;
! 50: struct curl_slist *temp=NULL;
! 51:
! 52: slist = curl_slist_append(slist, "pragma:");
! 53:
! 54: if (slist == NULL)
! 55: return -1;
! 56:
! 57: temp = curl_slist_append(slist, "Accept:")
! 58:
! 59: if (temp == NULL) {
! 60: curl_slist_free_all(slist);
! 61: return -1;
! 62: }
! 63:
! 64: slist = temp;
! 65:
! 66: curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
! 67:
! 68: curl_easy_perform(handle);
! 69:
! 70: curl_slist_free_all(slist); /* free the list again */
! 71: .fi
! 72: .SH "SEE ALSO"
! 73: .BR curl_slist_free_all "(3), "
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>