2011-09-16 15:44:45 -04:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2015-01-16 16:33:49 -05:00
|
|
|
* Copyright (C) 1998 - 2015, 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;
|
|
|
|
config->proto = CURLPROTO_ALL; /* FIXME: better to read from library */
|
|
|
|
config->proto_present = FALSE;
|
2014-11-30 16:28:22 -05:00
|
|
|
config->proto_redir = CURLPROTO_ALL & /* All except FILE, SCP and SMB */
|
|
|
|
~(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;
|
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);
|
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);
|
2014-09-30 22:31:17 -04:00
|
|
|
Curl_safefree(config->pinnedpubkey);
|
2011-09-16 15:44:45 -04:00
|
|
|
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);
|
|
|
|
|
2015-09-04 02:11:09 -04:00
|
|
|
Curl_safefree(config->oauth_bearer);
|
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
|
|
|
|
|
|
|
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);
|
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
|
|
|
}
|