tool_cfgable.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, 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 #include "tool_setup.h"
00023 
00024 #include "tool_cfgable.h"
00025 #include "tool_main.h"
00026 
00027 #include "memdebug.h" /* keep this as LAST include */
00028 
00029 void config_init(struct OperationConfig* config)
00030 {
00031   memset(config, 0, sizeof(struct OperationConfig));
00032 
00033   config->postfieldsize = -1;
00034   config->use_httpget = FALSE;
00035   config->create_dirs = FALSE;
00036   config->maxredirs = DEFAULT_MAXREDIRS;
00037   config->proto = CURLPROTO_ALL; /* FIXME: better to read from library */
00038   config->proto_present = FALSE;
00039   config->proto_redir = CURLPROTO_ALL & /* All except FILE, SCP and SMB */
00040                         ~(CURLPROTO_FILE | CURLPROTO_SCP | CURLPROTO_SMB |
00041                           CURLPROTO_SMBS);
00042   config->proto_redir_present = FALSE;
00043   config->proto_default = NULL;
00044   config->tcp_nodelay = TRUE; /* enabled by default */
00045 }
00046 
00047 static void free_config_fields(struct OperationConfig *config)
00048 {
00049   struct getout *urlnode;
00050 
00051   Curl_safefree(config->random_file);
00052   Curl_safefree(config->egd_file);
00053   Curl_safefree(config->useragent);
00054   Curl_safefree(config->cookie);
00055   Curl_safefree(config->cookiejar);
00056   Curl_safefree(config->cookiefile);
00057 
00058   Curl_safefree(config->postfields);
00059   Curl_safefree(config->referer);
00060 
00061   Curl_safefree(config->headerfile);
00062   Curl_safefree(config->ftpport);
00063   Curl_safefree(config->iface);
00064 
00065   Curl_safefree(config->range);
00066 
00067   Curl_safefree(config->userpwd);
00068   Curl_safefree(config->tls_username);
00069   Curl_safefree(config->tls_password);
00070   Curl_safefree(config->tls_authtype);
00071   Curl_safefree(config->proxy_tls_username);
00072   Curl_safefree(config->proxy_tls_password);
00073   Curl_safefree(config->proxy_tls_authtype);
00074   Curl_safefree(config->proxyuserpwd);
00075   Curl_safefree(config->proxy);
00076 
00077   Curl_safefree(config->dns_ipv6_addr);
00078   Curl_safefree(config->dns_ipv4_addr);
00079   Curl_safefree(config->dns_interface);
00080   Curl_safefree(config->dns_servers);
00081 
00082   Curl_safefree(config->noproxy);
00083 
00084   Curl_safefree(config->mail_from);
00085   curl_slist_free_all(config->mail_rcpt);
00086   Curl_safefree(config->mail_auth);
00087 
00088   Curl_safefree(config->netrc_file);
00089 
00090   urlnode = config->url_list;
00091   while(urlnode) {
00092     struct getout *next = urlnode->next;
00093     Curl_safefree(urlnode->url);
00094     Curl_safefree(urlnode->outfile);
00095     Curl_safefree(urlnode->infile);
00096     Curl_safefree(urlnode);
00097     urlnode = next;
00098   }
00099   config->url_list = NULL;
00100   config->url_last = NULL;
00101   config->url_get = NULL;
00102   config->url_out = NULL;
00103 
00104   Curl_safefree(config->cipher_list);
00105   Curl_safefree(config->proxy_cipher_list);
00106   Curl_safefree(config->cert);
00107   Curl_safefree(config->proxy_cert);
00108   Curl_safefree(config->cert_type);
00109   Curl_safefree(config->proxy_cert_type);
00110   Curl_safefree(config->cacert);
00111   Curl_safefree(config->proxy_cacert);
00112   Curl_safefree(config->capath);
00113   Curl_safefree(config->proxy_capath);
00114   Curl_safefree(config->crlfile);
00115   Curl_safefree(config->pinnedpubkey);
00116   Curl_safefree(config->proxy_crlfile);
00117   Curl_safefree(config->key);
00118   Curl_safefree(config->proxy_key);
00119   Curl_safefree(config->key_type);
00120   Curl_safefree(config->proxy_key_type);
00121   Curl_safefree(config->key_passwd);
00122   Curl_safefree(config->proxy_key_passwd);
00123   Curl_safefree(config->pubkey);
00124   Curl_safefree(config->hostpubmd5);
00125   Curl_safefree(config->engine);
00126 
00127   Curl_safefree(config->customrequest);
00128   Curl_safefree(config->krblevel);
00129 
00130   Curl_safefree(config->oauth_bearer);
00131 
00132   Curl_safefree(config->unix_socket_path);
00133   Curl_safefree(config->writeout);
00134   Curl_safefree(config->proto_default);
00135 
00136   curl_slist_free_all(config->quote);
00137   curl_slist_free_all(config->postquote);
00138   curl_slist_free_all(config->prequote);
00139 
00140   curl_slist_free_all(config->headers);
00141   curl_slist_free_all(config->proxyheaders);
00142 
00143   if(config->httppost) {
00144     curl_formfree(config->httppost);
00145     config->httppost = NULL;
00146   }
00147   config->last_post = NULL;
00148 
00149   curl_slist_free_all(config->telnet_options);
00150   curl_slist_free_all(config->resolve);
00151   curl_slist_free_all(config->connect_to);
00152 
00153   Curl_safefree(config->preproxy);
00154   Curl_safefree(config->proxy_service_name);
00155   Curl_safefree(config->service_name);
00156 
00157   Curl_safefree(config->ftp_account);
00158   Curl_safefree(config->ftp_alternative_to_user);
00159 }
00160 
00161 void config_free(struct OperationConfig *config)
00162 {
00163   struct OperationConfig *last = config;
00164 
00165   /* Free each of the structures in reverse order */
00166   while(last) {
00167     struct OperationConfig *prev = last->prev;
00168 
00169     free_config_fields(last);
00170     free(last);
00171 
00172     last = prev;
00173   }
00174 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06