../lib/warnless.h
CURL_CFILES = \
+ slist_wc.c \
tool_binmode.c \
tool_bname.c \
tool_cb_dbg.c \
tool_xattr.c
CURL_HFILES = \
+ slist_wc.h \
tool_binmode.h \
tool_bname.h \
tool_cb_dbg.h \
rawstrr.obj \\r
strtoofftr.obj \\r
warnless.obj \\r
+ slist_wc.obj \\r
tool_binmoder.obj \\r
tool_bnamer.obj \\r
tool_cb_dbgr.obj \\r
rawstrd.obj \\r
strtoofftd.obj \\r
warnlessd.obj \\r
+ slist_wc.obj \\r
tool_binmoded.obj \\r
tool_bnamed.obj \\r
tool_cb_dbgd.obj \\r
$(CCR) $(CFLAGS) /Fo"$@" ../lib/strtoofft.c\r
warnless.obj: ../lib/warnless.c\r
$(CCR) $(CFLAGS) /Fo"$@" ../lib/warnless.c\r
+slist_wc.obj: slist_wc.c\r
+ $(CCR) $(CFLAGS) /Fo"$@" slist_wc.c\r
tool_binmoder.obj: tool_binmode.c\r
$(CCR) $(CFLAGS) /Fo"$@" tool_binmode.c\r
tool_bnamer.obj: tool_bname.c\r
$(CCD) $(CFLAGS) /Fo"$@" ../lib/strtoofft.c\r
warnlessd.obj: ../lib/warnless.c\r
$(CCD) $(CFLAGS) /Fo"$@" ../lib/warnless.c\r
+slist_wc.obj: slist_wc.c\r
+ $(CCD) $(CFLAGS) /Fo"$@" slist_wc.c\r
tool_binmoded.obj: tool_binmode.c\r
$(CCD) $(CFLAGS) /Fo"$@" tool_binmode.c\r
tool_bnamed.obj: tool_bname.c\r
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "tool_setup.h"
+
+#ifndef CURL_DISABLE_LIBCURL_OPTION
+
+#include "slist_wc.h"
+
+/* The last #include files should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+
+/*
+ * slist_wc_append() appends a string to the linked list. This function can be
+ * used as an initialization function as well as an append function.
+ */
+struct slist_wc *slist_wc_append(struct slist_wc *list,
+ const char *data)
+{
+ struct curl_slist *new_item = curl_slist_append(NULL, data);
+
+ if(!new_item)
+ return NULL;
+
+ if(!list) {
+ list = malloc(sizeof(struct slist_wc));
+
+ if(!list) {
+ free(new_item);
+ return NULL;
+ }
+
+ list->first = new_item;
+ list->last = new_item;
+ return list;
+ }
+
+ list->last->next = new_item;
+ list->last = list->last->next;
+ return list;
+}
+
+/* be nice and clean up resources */
+void slist_wc_free_all(struct slist_wc *list)
+{
+ if(!list)
+ return;
+
+ curl_slist_free_all(list->first);
+ free(list);
+}
+
+#endif /* CURL_DISABLE_LIBCURL_OPTION */
--- /dev/null
+#ifndef HEADER_CURL_SLIST_WC_H
+#define HEADER_CURL_SLIST_WC_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "tool_setup.h"
+#ifndef CURL_DISABLE_LIBCURL_OPTION
+
+/* linked-list structure with last node cache for easysrc */
+struct slist_wc {
+ struct curl_slist *first;
+ struct curl_slist *last;
+};
+
+/*
+ * NAME curl_slist_wc_append()
+ *
+ * DESCRIPTION
+ *
+ * Appends a string to a linked list. If no list exists, it will be created
+ * first. Returns the new list, after appending.
+ */
+struct slist_wc *slist_wc_append(struct slist_wc *, const char *);
+
+/*
+ * NAME curl_slist_free_all()
+ *
+ * DESCRIPTION
+ *
+ * free a previously built curl_slist_wc.
+ */
+void slist_wc_free_all(struct slist_wc *);
+
+#endif /* CURL_DISABLE_LIBCURL_OPTION */
+
+#endif /* HEADER_CURL_SLIST_WC_H */
+
***************************************************************************/
#include "tool_setup.h"
+#include "slist_wc.h"
+
#ifndef CURL_DISABLE_LIBCURL_OPTION
#define ENABLE_CURLX_PRINTF
/* global variable definitions, for easy-interface source code generation */
-struct curl_slist *easysrc_decl = NULL; /* Variable declarations */
-struct curl_slist *easysrc_data = NULL; /* Build slists, forms etc. */
-struct curl_slist *easysrc_code = NULL; /* Setopt calls */
-struct curl_slist *easysrc_toohard = NULL; /* Unconvertible setopt */
-struct curl_slist *easysrc_clean = NULL; /* Clean up allocated data */
+struct slist_wc *easysrc_decl = NULL; /* Variable declarations */
+struct slist_wc *easysrc_data = NULL; /* Build slists, forms etc. */
+struct slist_wc *easysrc_code = NULL; /* Setopt calls */
+struct slist_wc *easysrc_toohard = NULL; /* Unconvertible setopt */
+struct slist_wc *easysrc_clean = NULL; /* Clean up allocated data */
int easysrc_form_count = 0;
int easysrc_slist_count = 0;
/* Clean up all source code if we run out of memory */
static void easysrc_free(void)
{
- curl_slist_free_all(easysrc_decl);
+ slist_wc_free_all(easysrc_decl);
easysrc_decl = NULL;
- curl_slist_free_all(easysrc_data);
+ slist_wc_free_all(easysrc_data);
easysrc_data = NULL;
- curl_slist_free_all(easysrc_code);
+ slist_wc_free_all(easysrc_code);
easysrc_code = NULL;
- curl_slist_free_all(easysrc_toohard);
+ slist_wc_free_all(easysrc_toohard);
easysrc_toohard = NULL;
- curl_slist_free_all(easysrc_clean);
+ slist_wc_free_all(easysrc_clean);
easysrc_clean = NULL;
}
/* Add a source line to the main code or remarks */
-CURLcode easysrc_add(struct curl_slist **plist, const char *line)
+CURLcode easysrc_add(struct slist_wc **plist, const char *line)
{
CURLcode ret = CURLE_OK;
- struct curl_slist *list =
- curl_slist_append(*plist, line);
+ struct slist_wc *list = slist_wc_append(*plist, line);
if(!list) {
easysrc_free();
ret = CURLE_OUT_OF_MEMORY;
return ret;
}
-CURLcode easysrc_addf(struct curl_slist **plist, const char *fmt, ...)
+CURLcode easysrc_addf(struct slist_wc **plist, const char *fmt, ...)
{
CURLcode ret;
char *bufp;
for(i=0; ((c = srchard[i]) != NULL); i++)
CHKRET(easysrc_add(&easysrc_code, c));
/* Each unconverted option */
- for(ptr=easysrc_toohard; ptr; ptr = ptr->next)
- CHKRET(easysrc_add(&easysrc_code, ptr->data));
+ if(easysrc_toohard) {
+ for(ptr=easysrc_toohard->first; ptr; ptr = ptr->next)
+ CHKRET(easysrc_add(&easysrc_code, ptr->data));
+ }
CHKRET(easysrc_add(&easysrc_code, ""));
CHKRET(easysrc_add(&easysrc_code, "*/"));
- curl_slist_free_all(easysrc_toohard);
+ slist_wc_free_all(easysrc_toohard);
easysrc_toohard = NULL;
}
fprintf(out, "%s\n", c);
/* Declare variables used for complex setopt values */
- for(ptr=easysrc_decl; ptr; ptr = ptr->next)
- fprintf(out, " %s\n", ptr->data);
+ if(easysrc_decl) {
+ for(ptr=easysrc_decl->first; ptr; ptr = ptr->next)
+ fprintf(out, " %s\n", ptr->data);
+ }
/* Set up complex values for setopt calls */
if(easysrc_data) {
fprintf(out, "\n");
- for(ptr=easysrc_data; ptr; ptr = ptr->next)
+ for(ptr=easysrc_data->first; ptr; ptr = ptr->next)
fprintf(out, " %s\n", ptr->data);
}
fprintf(out, "\n");
- for(ptr=easysrc_code; ptr; ptr = ptr->next) {
- if(ptr->data[0]) {
- fprintf(out, " %s\n", ptr->data);
- }
- else {
- fprintf(out, "\n");
+ if(easysrc_code) {
+ for(ptr=easysrc_code->first; ptr; ptr = ptr->next) {
+ if(ptr->data[0]) {
+ fprintf(out, " %s\n", ptr->data);
+ }
+ else {
+ fprintf(out, "\n");
+ }
}
}
- for(ptr=easysrc_clean; ptr; ptr = ptr->next)
- fprintf(out, " %s\n", ptr->data);
+ if(easysrc_clean) {
+ for(ptr=easysrc_clean->first; ptr; ptr = ptr->next)
+ fprintf(out, " %s\n", ptr->data);
+ }
for(i=0; ((c = srcend[i]) != NULL); i++)
fprintf(out, "%s\n", c);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
/* global variable declarations, for easy-interface source code generation */
-extern struct curl_slist *easysrc_decl; /* Variable declarations */
-extern struct curl_slist *easysrc_data; /* Build slists, forms etc. */
-extern struct curl_slist *easysrc_code; /* Setopt calls etc. */
-extern struct curl_slist *easysrc_toohard; /* Unconvertible setopt */
-extern struct curl_slist *easysrc_clean; /* Clean up (reverse order) */
+extern struct slist_wc *easysrc_decl; /* Variable declarations */
+extern struct slist_wc *easysrc_data; /* Build slists, forms etc. */
+extern struct slist_wc *easysrc_code; /* Setopt calls etc. */
+extern struct slist_wc *easysrc_toohard; /* Unconvertible setopt */
+extern struct slist_wc *easysrc_clean; /* Clean up (reverse order) */
extern int easysrc_form_count; /* Number of curl_httppost variables */
extern int easysrc_slist_count; /* Number of curl_slist variables */
extern CURLcode easysrc_init(void);
-extern CURLcode easysrc_add(struct curl_slist **plist, const char *bupf);
-extern CURLcode easysrc_addf(struct curl_slist **plist, const char *fmt, ...);
+extern CURLcode easysrc_add(struct slist_wc **plist, const char *bupf);
+extern CURLcode easysrc_addf(struct slist_wc **plist,
+ const char *fmt, ...);
extern CURLcode easysrc_perform(void);
extern CURLcode easysrc_cleanup(void);