2011-09-16 15:44:45 -04:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2014-02-01 08:26:09 -05:00
|
|
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2011-09-16 15:44:45 -04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2012-04-06 17:35:15 -04:00
|
|
|
#include "tool_setup.h"
|
2011-09-16 15:44:45 -04:00
|
|
|
|
|
|
|
#include "tool_cfgable.h"
|
2014-02-01 08:36:48 -05:00
|
|
|
#include "tool_main.h"
|
2011-09-16 15:44:45 -04:00
|
|
|
|
2013-01-03 20:50:28 -05:00
|
|
|
#include "memdebug.h" /* keep this as LAST include */
|
2011-09-16 15:44:45 -04:00
|
|
|
|
2014-02-01 08:26:09 -05:00
|
|
|
void init_config(struct Configurable* config)
|
|
|
|
{
|
|
|
|
memset(config, 0, sizeof(struct Configurable));
|
|
|
|
|
|
|
|
config->errors = stderr; /* default errors to stderr */
|
2014-02-01 08:36:48 -05:00
|
|
|
config->postfieldsize = -1;
|
|
|
|
config->showerror = -1; /* will show errors */
|
|
|
|
config->use_httpget = FALSE;
|
|
|
|
config->create_dirs = FALSE;
|
|
|
|
config->maxredirs = DEFAULT_MAXREDIRS;
|
|
|
|
config->proto = CURLPROTO_ALL; /* FIXME: better to read from library */
|
|
|
|
config->proto_present = FALSE;
|
|
|
|
config->proto_redir =
|
|
|
|
CURLPROTO_ALL & ~(CURLPROTO_FILE|CURLPROTO_SCP); /* not FILE or SCP */
|
|
|
|
config->proto_redir_present = FALSE;
|
2014-02-01 08:26:09 -05:00
|
|
|
}
|
|
|
|
|
2014-02-07 14:29:46 -05:00
|
|
|
static void free_config_fields(struct Configurable *config)
|
2011-09-16 15:44:45 -04:00
|
|
|
{
|
2011-09-23 23:32:51 -04:00
|
|
|
struct getout *urlnode;
|
|
|
|
|
2011-09-17 08:09:36 -04:00
|
|
|
if(config->easy) {
|
|
|
|
curl_easy_cleanup(config->easy);
|
|
|
|
config->easy = NULL;
|
|
|
|
}
|
|
|
|
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->random_file);
|
|
|
|
Curl_safefree(config->egd_file);
|
2011-09-17 19:58:18 -04:00
|
|
|
Curl_safefree(config->useragent);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->cookie);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->cookiejar);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->cookiefile);
|
2011-09-17 08:09:36 -04:00
|
|
|
|
|
|
|
Curl_safefree(config->postfields);
|
|
|
|
Curl_safefree(config->referer);
|
|
|
|
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->headerfile);
|
|
|
|
Curl_safefree(config->ftpport);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->iface);
|
|
|
|
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->range);
|
|
|
|
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->userpwd);
|
|
|
|
Curl_safefree(config->tls_username);
|
|
|
|
Curl_safefree(config->tls_password);
|
|
|
|
Curl_safefree(config->tls_authtype);
|
|
|
|
Curl_safefree(config->proxyuserpwd);
|
|
|
|
Curl_safefree(config->proxy);
|
|
|
|
|
2013-02-09 16:18:02 -05:00
|
|
|
Curl_safefree(config->dns_ipv6_addr);
|
|
|
|
Curl_safefree(config->dns_ipv4_addr);
|
|
|
|
Curl_safefree(config->dns_interface);
|
|
|
|
Curl_safefree(config->dns_servers);
|
|
|
|
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->noproxy);
|
2012-02-16 07:19:47 -05:00
|
|
|
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->mail_from);
|
|
|
|
curl_slist_free_all(config->mail_rcpt);
|
2012-02-16 07:19:47 -05:00
|
|
|
Curl_safefree(config->mail_auth);
|
2011-09-16 15:44:45 -04:00
|
|
|
|
|
|
|
Curl_safefree(config->netrc_file);
|
2011-09-17 08:09:36 -04:00
|
|
|
|
2011-09-23 23:32:51 -04:00
|
|
|
urlnode = config->url_list;
|
|
|
|
while(urlnode) {
|
|
|
|
struct getout *next = urlnode->next;
|
|
|
|
Curl_safefree(urlnode->url);
|
|
|
|
Curl_safefree(urlnode->outfile);
|
|
|
|
Curl_safefree(urlnode->infile);
|
|
|
|
Curl_safefree(urlnode);
|
|
|
|
urlnode = next;
|
|
|
|
}
|
|
|
|
config->url_list = NULL;
|
|
|
|
config->url_last = NULL;
|
|
|
|
config->url_get = NULL;
|
|
|
|
config->url_out = NULL;
|
2011-09-17 08:09:36 -04:00
|
|
|
|
|
|
|
Curl_safefree(config->cipher_list);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->cert);
|
|
|
|
Curl_safefree(config->cert_type);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->cacert);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->capath);
|
|
|
|
Curl_safefree(config->crlfile);
|
|
|
|
Curl_safefree(config->key);
|
|
|
|
Curl_safefree(config->key_type);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->key_passwd);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->pubkey);
|
|
|
|
Curl_safefree(config->hostpubmd5);
|
2011-09-23 23:32:51 -04:00
|
|
|
Curl_safefree(config->engine);
|
2011-09-16 15:44:45 -04:00
|
|
|
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->customrequest);
|
|
|
|
Curl_safefree(config->krblevel);
|
|
|
|
Curl_safefree(config->trace_dump);
|
|
|
|
|
2013-08-25 13:18:59 -04:00
|
|
|
Curl_safefree(config->xoauth2_bearer);
|
|
|
|
|
2011-09-23 23:32:51 -04:00
|
|
|
config->trace_stream = NULL; /* closed elsewhere when appropriate */
|
2011-09-17 08:09:36 -04:00
|
|
|
|
|
|
|
Curl_safefree(config->writeout);
|
|
|
|
|
2011-09-23 23:32:51 -04:00
|
|
|
config->errors = NULL; /* closed elsewhere when appropriate */
|
2011-09-17 08:09:36 -04:00
|
|
|
|
|
|
|
curl_slist_free_all(config->quote);
|
2011-09-16 15:44:45 -04:00
|
|
|
curl_slist_free_all(config->postquote);
|
2011-09-17 08:09:36 -04:00
|
|
|
curl_slist_free_all(config->prequote);
|
|
|
|
|
2011-09-16 15:44:45 -04:00
|
|
|
curl_slist_free_all(config->headers);
|
2011-09-17 08:09:36 -04:00
|
|
|
|
|
|
|
if(config->httppost) {
|
|
|
|
curl_formfree(config->httppost);
|
|
|
|
config->httppost = NULL;
|
|
|
|
}
|
2011-11-03 18:21:01 -04:00
|
|
|
config->last_post = NULL;
|
2011-09-17 08:09:36 -04:00
|
|
|
|
2011-09-16 15:44:45 -04:00
|
|
|
curl_slist_free_all(config->telnet_options);
|
|
|
|
curl_slist_free_all(config->resolve);
|
|
|
|
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->socksproxy);
|
|
|
|
Curl_safefree(config->socks5_gssapi_service);
|
|
|
|
|
|
|
|
Curl_safefree(config->ftp_account);
|
|
|
|
Curl_safefree(config->ftp_alternative_to_user);
|
|
|
|
|
|
|
|
Curl_safefree(config->libcurl);
|
2011-09-16 15:44:45 -04:00
|
|
|
}
|
2014-02-07 14:29:46 -05:00
|
|
|
|
|
|
|
void config_free(struct Configurable *config)
|
|
|
|
{
|
|
|
|
free_config_fields(config);
|
|
|
|
free(config);
|
|
|
|
}
|