2011-09-16 15:44:45 -04:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2019-02-11 13:10:41 -05:00
|
|
|
* Copyright (C) 1998 - 2019, 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
|
2016-02-02 18:19:02 -05:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2011-09-16 15:44:45 -04:00
|
|
|
*
|
|
|
|
* 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-23 07:59:59 -05:00
|
|
|
void config_init(struct OperationConfig* config)
|
2014-02-01 08:26:09 -05:00
|
|
|
{
|
2014-02-23 07:59:59 -05:00
|
|
|
memset(config, 0, sizeof(struct OperationConfig));
|
2014-02-01 08:26:09 -05:00
|
|
|
|
2014-02-01 08:36:48 -05:00
|
|
|
config->postfieldsize = -1;
|
|
|
|
config->use_httpget = FALSE;
|
|
|
|
config->create_dirs = FALSE;
|
|
|
|
config->maxredirs = DEFAULT_MAXREDIRS;
|
2019-05-14 10:36:15 -04:00
|
|
|
config->proto = CURLPROTO_ALL;
|
2014-02-01 08:36:48 -05:00
|
|
|
config->proto_present = FALSE;
|
2014-11-30 16:28:22 -05:00
|
|
|
config->proto_redir = CURLPROTO_ALL & /* All except FILE, SCP and SMB */
|
2019-05-14 10:36:15 -04:00
|
|
|
~(CURLPROTO_FILE | CURLPROTO_SCP | CURLPROTO_SMB |
|
|
|
|
CURLPROTO_SMBS);
|
2014-02-01 08:36:48 -05:00
|
|
|
config->proto_redir_present = FALSE;
|
2015-08-22 21:49:26 -04:00
|
|
|
config->proto_default = NULL;
|
2016-06-30 08:56:02 -04:00
|
|
|
config->tcp_nodelay = TRUE; /* enabled by default */
|
2018-01-30 19:33:51 -05:00
|
|
|
config->happy_eyeballs_timeout_ms = CURL_HET_DEFAULT;
|
2019-08-05 03:45:23 -04:00
|
|
|
config->http09_allowed = FALSE;
|
2014-02-01 08:26:09 -05:00
|
|
|
}
|
|
|
|
|
2014-02-23 07:59:59 -05:00
|
|
|
static void free_config_fields(struct OperationConfig *config)
|
2011-09-16 15:44:45 -04:00
|
|
|
{
|
2011-09-23 23:32:51 -04:00
|
|
|
struct getout *urlnode;
|
|
|
|
|
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);
|
2019-03-03 05:17:52 -05:00
|
|
|
Curl_safefree(config->altsvc);
|
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);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_tls_username);
|
|
|
|
Curl_safefree(config->proxy_tls_password);
|
|
|
|
Curl_safefree(config->proxy_tls_authtype);
|
2011-09-17 08:09:36 -04:00
|
|
|
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
|
|
|
|
2018-09-06 03:16:02 -04:00
|
|
|
Curl_safefree(config->doh_url);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->cipher_list);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_cipher_list);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->cert);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_cert);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->cert_type);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_cert_type);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->cacert);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_cacert);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->capath);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_capath);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->crlfile);
|
2014-09-30 22:31:17 -04:00
|
|
|
Curl_safefree(config->pinnedpubkey);
|
2018-01-28 08:15:56 -05:00
|
|
|
Curl_safefree(config->proxy_pinnedpubkey);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_crlfile);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->key);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_key);
|
2011-09-16 15:44:45 -04:00
|
|
|
Curl_safefree(config->key_type);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_key_type);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->key_passwd);
|
2016-11-16 12:49:15 -05:00
|
|
|
Curl_safefree(config->proxy_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);
|
2017-06-21 17:35:08 -04:00
|
|
|
Curl_safefree(config->request_target);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->customrequest);
|
|
|
|
Curl_safefree(config->krblevel);
|
|
|
|
|
2015-09-04 02:11:09 -04:00
|
|
|
Curl_safefree(config->oauth_bearer);
|
2019-04-19 09:26:47 -04:00
|
|
|
Curl_safefree(config->sasl_authzid);
|
2013-08-25 13:18:59 -04:00
|
|
|
|
2014-11-27 17:59:26 -05:00
|
|
|
Curl_safefree(config->unix_socket_path);
|
2011-09-17 08:09:36 -04:00
|
|
|
Curl_safefree(config->writeout);
|
2015-08-23 14:57:17 -04:00
|
|
|
Curl_safefree(config->proto_default);
|
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);
|
2014-02-04 17:48:16 -05:00
|
|
|
curl_slist_free_all(config->proxyheaders);
|
2011-09-17 08:09:36 -04:00
|
|
|
|
2019-02-19 11:08:58 -05:00
|
|
|
curl_mime_free(config->mimepost);
|
|
|
|
config->mimepost = NULL;
|
|
|
|
tool_mime_free(config->mimeroot);
|
|
|
|
config->mimeroot = NULL;
|
2017-09-02 13:17:33 -04:00
|
|
|
config->mimecurrent = 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);
|
2016-01-25 08:37:24 -05:00
|
|
|
curl_slist_free_all(config->connect_to);
|
2011-09-16 15:44:45 -04:00
|
|
|
|
2016-12-16 10:02:08 -05:00
|
|
|
Curl_safefree(config->preproxy);
|
2015-03-29 08:52:31 -04:00
|
|
|
Curl_safefree(config->proxy_service_name);
|
|
|
|
Curl_safefree(config->service_name);
|
2011-09-17 08:09:36 -04:00
|
|
|
|
|
|
|
Curl_safefree(config->ftp_account);
|
|
|
|
Curl_safefree(config->ftp_alternative_to_user);
|
2011-09-16 15:44:45 -04:00
|
|
|
}
|
2014-02-07 14:29:46 -05:00
|
|
|
|
2014-02-23 07:59:59 -05:00
|
|
|
void config_free(struct OperationConfig *config)
|
2014-02-07 14:29:46 -05:00
|
|
|
{
|
2014-02-23 07:59:59 -05:00
|
|
|
struct OperationConfig *last = config;
|
2014-02-07 16:14:43 -05:00
|
|
|
|
|
|
|
/* Free each of the structures in reverse order */
|
2014-02-23 10:10:18 -05:00
|
|
|
while(last) {
|
2014-02-23 07:59:59 -05:00
|
|
|
struct OperationConfig *prev = last->prev;
|
2014-02-07 16:14:43 -05:00
|
|
|
|
|
|
|
free_config_fields(last);
|
|
|
|
free(last);
|
|
|
|
|
|
|
|
last = prev;
|
2014-02-23 10:10:18 -05:00
|
|
|
}
|
2014-02-07 14:29:46 -05:00
|
|
|
}
|