mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
Reduced #ifdef HAVE_METALINK
This commit is contained in:
parent
7bdb9fba95
commit
1bfd750f3f
@ -1 +0,0 @@
|
|||||||
curl_SOURCES += tool_metalink.c tool_metalink.h
|
|
@ -50,9 +50,6 @@ AM_CPPFLAGS = -DCURL_STATICLIB
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
include Makefile.inc
|
include Makefile.inc
|
||||||
if HAVE_LIBMETALINK
|
|
||||||
include Makefile-metalink.inc
|
|
||||||
endif # HAVE_LIBMETALINK
|
|
||||||
|
|
||||||
# This might hold -Werror
|
# This might hold -Werror
|
||||||
CFLAGS += @CURL_CFLAG_EXTRAS@ @LIBMETALINK_CFLAGS@
|
CFLAGS += @CURL_CFLAG_EXTRAS@ @LIBMETALINK_CFLAGS@
|
||||||
|
@ -50,7 +50,8 @@ CURL_CFILES = hugehelp.c \
|
|||||||
tool_vms.c \
|
tool_vms.c \
|
||||||
tool_writeenv.c \
|
tool_writeenv.c \
|
||||||
tool_writeout.c \
|
tool_writeout.c \
|
||||||
tool_xattr.c
|
tool_xattr.c \
|
||||||
|
tool_metalink.c
|
||||||
|
|
||||||
CURL_HFILES = hugehelp.h \
|
CURL_HFILES = hugehelp.h \
|
||||||
tool_binmode.h \
|
tool_binmode.h \
|
||||||
@ -91,7 +92,8 @@ CURL_HFILES = hugehelp.h \
|
|||||||
tool_vms.h \
|
tool_vms.h \
|
||||||
tool_writeenv.h \
|
tool_writeenv.h \
|
||||||
tool_writeout.h \
|
tool_writeout.h \
|
||||||
tool_xattr.h
|
tool_xattr.h \
|
||||||
|
tool_metalink.h
|
||||||
|
|
||||||
curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
|
curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
|
||||||
|
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
|
|
||||||
#include "tool_sdecls.h"
|
#include "tool_sdecls.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
#include "tool_metalink.h"
|
#include "tool_metalink.h"
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
struct Configurable {
|
struct Configurable {
|
||||||
CURL *easy; /* once we have one, we keep it here */
|
CURL *easy; /* once we have one, we keep it here */
|
||||||
@ -202,10 +200,9 @@ struct Configurable {
|
|||||||
bool xattr; /* store metadata in extended attributes */
|
bool xattr; /* store metadata in extended attributes */
|
||||||
long gssapi_delegation;
|
long gssapi_delegation;
|
||||||
bool ssl_allow_beast; /* allow this SSL vulnerability */
|
bool ssl_allow_beast; /* allow this SSL vulnerability */
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
metalinkfile *metalinkfile_list; /* point to the first node */
|
metalinkfile *metalinkfile_list; /* point to the first node */
|
||||||
metalinkfile *metalinkfile_last; /* point to the last/current node */
|
metalinkfile *metalinkfile_last; /* point to the last/current node */
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
}; /* struct Configurable */
|
}; /* struct Configurable */
|
||||||
|
|
||||||
void free_config_fields(struct Configurable *config);
|
void free_config_fields(struct Configurable *config);
|
||||||
|
@ -43,10 +43,7 @@
|
|||||||
#include "tool_paramhlp.h"
|
#include "tool_paramhlp.h"
|
||||||
#include "tool_parsecfg.h"
|
#include "tool_parsecfg.h"
|
||||||
#include "tool_version.h"
|
#include "tool_version.h"
|
||||||
|
#include "tool_metalink.h"
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
# include "tool_metalink.h"
|
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
#include "memdebug.h" /* keep this as LAST include */
|
#include "memdebug.h" /* keep this as LAST include */
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <metalink/metalink_parser.h>
|
||||||
|
|
||||||
#include "rawstr.h"
|
#include "rawstr.h"
|
||||||
|
|
||||||
#include "tool_metalink.h"
|
#include "tool_metalink.h"
|
||||||
@ -412,6 +414,8 @@ int metalink_check_hash(struct Configurable *config,
|
|||||||
|
|
||||||
#endif /* METALINK_HASH_CHECK */
|
#endif /* METALINK_HASH_CHECK */
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBMETALINK
|
||||||
|
|
||||||
static metalink_checksum *new_metalink_checksum(const char *hash_name,
|
static metalink_checksum *new_metalink_checksum(const char *hash_name,
|
||||||
const char *hash_value)
|
const char *hash_value)
|
||||||
{
|
{
|
||||||
@ -423,16 +427,6 @@ static metalink_checksum *new_metalink_checksum(const char *hash_name,
|
|||||||
return chksum;
|
return chksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_metalink_checksum(metalink_checksum *chksum)
|
|
||||||
{
|
|
||||||
if(chksum == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Curl_safefree(chksum->hash_value);
|
|
||||||
Curl_safefree(chksum->hash_name);
|
|
||||||
Curl_safefree(chksum);
|
|
||||||
}
|
|
||||||
|
|
||||||
static metalink_resource *new_metalink_resource(const char *url)
|
static metalink_resource *new_metalink_resource(const char *url)
|
||||||
{
|
{
|
||||||
metalink_resource *res;
|
metalink_resource *res;
|
||||||
@ -442,15 +436,6 @@ static metalink_resource *new_metalink_resource(const char *url)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_metalink_resource(metalink_resource *res)
|
|
||||||
{
|
|
||||||
if(res == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Curl_safefree(res->url);
|
|
||||||
Curl_safefree(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
|
static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
|
||||||
{
|
{
|
||||||
metalinkfile *f;
|
metalinkfile *f;
|
||||||
@ -488,47 +473,6 @@ static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_metalinkfile(metalinkfile *mlfile)
|
|
||||||
{
|
|
||||||
metalink_checksum *mc;
|
|
||||||
metalink_resource *res;
|
|
||||||
if(mlfile == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Curl_safefree(mlfile->filename);
|
|
||||||
for(mc = mlfile->checksum; mc;) {
|
|
||||||
metalink_checksum *next;
|
|
||||||
next = mc->next;
|
|
||||||
delete_metalink_checksum(mc);
|
|
||||||
mc = next;
|
|
||||||
}
|
|
||||||
for(res = mlfile->resource; res;) {
|
|
||||||
metalink_resource *next;
|
|
||||||
next = res->next;
|
|
||||||
delete_metalink_resource(res);
|
|
||||||
res = next;
|
|
||||||
}
|
|
||||||
Curl_safefree(mlfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
int count_next_metalink_resource(metalinkfile *mlfile)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
metalink_resource *res;
|
|
||||||
for(res = mlfile->resource; res; res = res->next, ++count);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clean_metalink(struct Configurable *config)
|
|
||||||
{
|
|
||||||
while(config->metalinkfile_list) {
|
|
||||||
metalinkfile *mlfile = config->metalinkfile_list;
|
|
||||||
config->metalinkfile_list = config->metalinkfile_list->next;
|
|
||||||
delete_metalinkfile(mlfile);
|
|
||||||
}
|
|
||||||
config->metalinkfile_last = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_metalink(struct Configurable *config, const char *infile)
|
int parse_metalink(struct Configurable *config, const char *infile)
|
||||||
{
|
{
|
||||||
metalink_error_t r;
|
metalink_error_t r;
|
||||||
@ -592,6 +536,8 @@ int parse_metalink(struct Configurable *config, const char *infile)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBMETALINK */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns nonzero if content_type includes mediatype.
|
* Returns nonzero if content_type includes mediatype.
|
||||||
*/
|
*/
|
||||||
@ -612,3 +558,63 @@ int check_metalink_content_type(const char *content_type)
|
|||||||
{
|
{
|
||||||
return check_content_type(content_type, "application/metalink+xml");
|
return check_content_type(content_type, "application/metalink+xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int count_next_metalink_resource(metalinkfile *mlfile)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
metalink_resource *res;
|
||||||
|
for(res = mlfile->resource; res; res = res->next, ++count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void delete_metalink_checksum(metalink_checksum *chksum)
|
||||||
|
{
|
||||||
|
if(chksum == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Curl_safefree(chksum->hash_value);
|
||||||
|
Curl_safefree(chksum->hash_name);
|
||||||
|
Curl_safefree(chksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void delete_metalink_resource(metalink_resource *res)
|
||||||
|
{
|
||||||
|
if(res == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Curl_safefree(res->url);
|
||||||
|
Curl_safefree(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void delete_metalinkfile(metalinkfile *mlfile)
|
||||||
|
{
|
||||||
|
metalink_checksum *mc;
|
||||||
|
metalink_resource *res;
|
||||||
|
if(mlfile == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Curl_safefree(mlfile->filename);
|
||||||
|
for(mc = mlfile->checksum; mc;) {
|
||||||
|
metalink_checksum *next;
|
||||||
|
next = mc->next;
|
||||||
|
delete_metalink_checksum(mc);
|
||||||
|
mc = next;
|
||||||
|
}
|
||||||
|
for(res = mlfile->resource; res;) {
|
||||||
|
metalink_resource *next;
|
||||||
|
next = res->next;
|
||||||
|
delete_metalink_resource(res);
|
||||||
|
res = next;
|
||||||
|
}
|
||||||
|
Curl_safefree(mlfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clean_metalink(struct Configurable *config)
|
||||||
|
{
|
||||||
|
while(config->metalinkfile_list) {
|
||||||
|
metalinkfile *mlfile = config->metalinkfile_list;
|
||||||
|
config->metalinkfile_list = config->metalinkfile_list->next;
|
||||||
|
delete_metalinkfile(mlfile);
|
||||||
|
}
|
||||||
|
config->metalinkfile_last = 0;
|
||||||
|
}
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "tool_setup.h"
|
#include "tool_setup.h"
|
||||||
|
|
||||||
#include <metalink/metalink_parser.h>
|
|
||||||
|
|
||||||
struct Configurable;
|
struct Configurable;
|
||||||
|
|
||||||
#if defined(USE_OPENSSL) || defined(USE_GNUTLS)
|
#if defined(USE_OPENSSL) || defined(USE_GNUTLS)
|
||||||
|
@ -129,9 +129,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
|
|
||||||
struct OutStruct heads;
|
struct OutStruct heads;
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
metalinkfile *mlfile_last = NULL;
|
metalinkfile *mlfile_last = NULL;
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
CURL *curl = NULL;
|
CURL *curl = NULL;
|
||||||
char *httpgetfields = NULL;
|
char *httpgetfields = NULL;
|
||||||
@ -406,18 +404,14 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
int infilenum;
|
int infilenum;
|
||||||
URLGlob *inglob;
|
URLGlob *inglob;
|
||||||
|
|
||||||
int metalink = 0; /* nonzero for metalink download. Put outside of
|
int metalink = 0; /* nonzero for metalink download. */
|
||||||
HAVE_LIBMETALINK to reduce #ifdef */
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
metalinkfile *mlfile;
|
metalinkfile *mlfile;
|
||||||
metalink_resource *mlres;
|
metalink_resource *mlres;
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
outfiles = NULL;
|
outfiles = NULL;
|
||||||
infilenum = 1;
|
infilenum = 1;
|
||||||
inglob = NULL;
|
inglob = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
if(urlnode->flags & GETOUT_METALINK) {
|
if(urlnode->flags & GETOUT_METALINK) {
|
||||||
metalink = 1;
|
metalink = 1;
|
||||||
if(mlfile_last == NULL) {
|
if(mlfile_last == NULL) {
|
||||||
@ -431,7 +425,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
mlfile = NULL;
|
mlfile = NULL;
|
||||||
mlres = NULL;
|
mlres = NULL;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
/* urlnode->url is the full URL (it might be NULL) */
|
/* urlnode->url is the full URL (it might be NULL) */
|
||||||
|
|
||||||
@ -501,14 +494,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
if(metalink) {
|
if(metalink) {
|
||||||
/* For Metalink download, we don't use glob. Instead we use
|
/* For Metalink download, we don't use glob. Instead we use
|
||||||
the number of resources as urlnum. */
|
the number of resources as urlnum. */
|
||||||
urlnum = count_next_metalink_resource(mlfile);
|
urlnum = count_next_metalink_resource(mlfile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
if(!config->globoff) {
|
if(!config->globoff) {
|
||||||
/* Unless explicitly shut off, we expand '{...}' and '[...]'
|
/* Unless explicitly shut off, we expand '{...}' and '[...]'
|
||||||
expressions and return total number of URLs in pattern set */
|
expressions and return total number of URLs in pattern set */
|
||||||
@ -540,9 +531,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
long retry_sleep;
|
long retry_sleep;
|
||||||
char *this_url;
|
char *this_url;
|
||||||
HeaderData hdrdata;
|
HeaderData hdrdata;
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
int metalink_next_res = 0;
|
int metalink_next_res = 0;
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
outfile = NULL;
|
outfile = NULL;
|
||||||
infdopen = FALSE;
|
infdopen = FALSE;
|
||||||
@ -554,7 +543,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
outs.stream = stdout;
|
outs.stream = stdout;
|
||||||
outs.config = config;
|
outs.config = config;
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
if(metalink) {
|
if(metalink) {
|
||||||
/* For Metalink download, use name in Metalink file as
|
/* For Metalink download, use name in Metalink file as
|
||||||
filename. */
|
filename. */
|
||||||
@ -570,7 +558,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
if(urls) {
|
if(urls) {
|
||||||
res = glob_next_url(&this_url, urls);
|
res = glob_next_url(&this_url, urls);
|
||||||
if(res)
|
if(res)
|
||||||
@ -595,9 +582,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
goto show_error;
|
goto show_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
if((urlnode->flags&GETOUT_USEREMOTE) ||
|
if((urlnode->flags&GETOUT_USEREMOTE) ||
|
||||||
(outfile && !curlx_strequal("-", outfile)) ) {
|
(outfile && !curlx_strequal("-", outfile)) ) {
|
||||||
@ -1443,7 +1428,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
continue; /* curl_easy_perform loop */
|
continue; /* curl_easy_perform loop */
|
||||||
}
|
}
|
||||||
} /* if retry_numretries */
|
} /* if retry_numretries */
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
else if(metalink) {
|
else if(metalink) {
|
||||||
/* Metalink: Decide to try the next resource or
|
/* Metalink: Decide to try the next resource or
|
||||||
not. Basically, we want to try the next resource if
|
not. Basically, we want to try the next resource if
|
||||||
@ -1466,7 +1450,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
else
|
else
|
||||||
metalink_next_res = 1;
|
metalink_next_res = 1;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
/* In all ordinary cases, just break out of loop here */
|
/* In all ordinary cases, just break out of loop here */
|
||||||
break; /* curl_easy_perform loop */
|
break; /* curl_easy_perform loop */
|
||||||
@ -1620,7 +1603,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
infd = STDIN_FILENO;
|
infd = STDIN_FILENO;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
if(metalink) {
|
if(metalink) {
|
||||||
/* Should exit if error is fatal. */
|
/* Should exit if error is fatal. */
|
||||||
if(is_fatal_error(res)) {
|
if(is_fatal_error(res)) {
|
||||||
@ -1636,7 +1618,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
if(urlnum > 1) {
|
if(urlnum > 1) {
|
||||||
/* when url globbing, exit loop upon critical error */
|
/* when url globbing, exit loop upon critical error */
|
||||||
if(is_fatal_error(res))
|
if(is_fatal_error(res))
|
||||||
@ -1736,10 +1717,8 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
if(config->errors_fopened && config->errors)
|
if(config->errors_fopened && config->errors)
|
||||||
fclose(config->errors);
|
fclose(config->errors);
|
||||||
|
|
||||||
#ifdef HAVE_LIBMETALINK
|
|
||||||
/* Release metalink related resources here */
|
/* Release metalink related resources here */
|
||||||
clean_metalink(config);
|
clean_metalink(config);
|
||||||
#endif /* HAVE_LIBMETALINK */
|
|
||||||
|
|
||||||
main_free(); /* cleanup */
|
main_free(); /* cleanup */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user