00001 /*************************************************************************** 00002 * _ _ ____ _ 00003 * Project ___| | | | _ \| | 00004 * / __| | | | |_) | | 00005 * | (__| |_| | _ <| |___ 00006 * \___|\___/|_| \_\_____| 00007 * 00008 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. 00009 * 00010 * This software is licensed as described in the file COPYING, which 00011 * you should have received as part of this distribution. The terms 00012 * are also available at https://curl.haxx.se/docs/copyright.html. 00013 * 00014 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 00015 * copies of the Software, and permit persons to whom the Software is 00016 * furnished to do so, under the terms of the COPYING file. 00017 * 00018 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 00019 * KIND, either express or implied. 00020 * 00021 ***************************************************************************/ 00022 00023 #include "tool_setup.h" 00024 00025 #ifndef CURL_DISABLE_LIBCURL_OPTION 00026 00027 #include "slist_wc.h" 00028 00029 /* The last #include files should be: */ 00030 #include "memdebug.h" 00031 00032 /* 00033 * slist_wc_append() appends a string to the linked list. This function can be 00034 * used as an initialization function as well as an append function. 00035 */ 00036 struct slist_wc *slist_wc_append(struct slist_wc *list, 00037 const char *data) 00038 { 00039 struct curl_slist *new_item = curl_slist_append(NULL, data); 00040 00041 if(!new_item) 00042 return NULL; 00043 00044 if(!list) { 00045 list = malloc(sizeof(struct slist_wc)); 00046 00047 if(!list) { 00048 curl_slist_free_all(new_item); 00049 return NULL; 00050 } 00051 00052 list->first = new_item; 00053 list->last = new_item; 00054 return list; 00055 } 00056 00057 list->last->next = new_item; 00058 list->last = list->last->next; 00059 return list; 00060 } 00061 00062 /* be nice and clean up resources */ 00063 void slist_wc_free_all(struct slist_wc *list) 00064 { 00065 if(!list) 00066 return; 00067 00068 curl_slist_free_all(list->first); 00069 free(list); 00070 } 00071 00072 #endif /* CURL_DISABLE_LIBCURL_OPTION */