+++ /dev/null
-curl_SOURCES += tool_metalink.c tool_metalink.h
endif
include Makefile.inc
-if HAVE_LIBMETALINK
-include Makefile-metalink.inc
-endif # HAVE_LIBMETALINK
# This might hold -Werror
CFLAGS += @CURL_CFLAG_EXTRAS@ @LIBMETALINK_CFLAGS@
tool_vms.c \
tool_writeenv.c \
tool_writeout.c \
- tool_xattr.c
+ tool_xattr.c \
+ tool_metalink.c
CURL_HFILES = hugehelp.h \
tool_binmode.h \
tool_vms.h \
tool_writeenv.h \
tool_writeout.h \
- tool_xattr.h
+ tool_xattr.h \
+ tool_metalink.h
curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
#include "tool_sdecls.h"
-#ifdef HAVE_LIBMETALINK
#include "tool_metalink.h"
-#endif /* HAVE_LIBMETALINK */
struct Configurable {
CURL *easy; /* once we have one, we keep it here */
bool xattr; /* store metadata in extended attributes */
long gssapi_delegation;
bool ssl_allow_beast; /* allow this SSL vulnerability */
-#ifdef HAVE_LIBMETALINK
+
metalinkfile *metalinkfile_list; /* point to the first node */
metalinkfile *metalinkfile_last; /* point to the last/current node */
-#endif /* HAVE_LIBMETALINK */
}; /* struct Configurable */
void free_config_fields(struct Configurable *config);
#include "tool_paramhlp.h"
#include "tool_parsecfg.h"
#include "tool_version.h"
-
-#ifdef HAVE_LIBMETALINK
-# include "tool_metalink.h"
-#endif /* HAVE_LIBMETALINK */
+#include "tool_metalink.h"
#include "memdebug.h" /* keep this as LAST include */
# include <fcntl.h>
#endif
+#include <metalink/metalink_parser.h>
+
#include "rawstr.h"
#include "tool_metalink.h"
#endif /* METALINK_HASH_CHECK */
+#ifdef HAVE_LIBMETALINK
+
static metalink_checksum *new_metalink_checksum(const char *hash_name,
const char *hash_value)
{
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)
{
metalink_resource *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)
{
metalinkfile *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)
{
metalink_error_t r;
return 0;
}
+#endif /* HAVE_LIBMETALINK */
+
/*
* Returns nonzero if content_type includes mediatype.
*/
{
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;
+}
***************************************************************************/
#include "tool_setup.h"
-#include <metalink/metalink_parser.h>
-
struct Configurable;
#if defined(USE_OPENSSL) || defined(USE_GNUTLS)
struct OutStruct heads;
-#ifdef HAVE_LIBMETALINK
metalinkfile *mlfile_last = NULL;
-#endif /* HAVE_LIBMETALINK */
CURL *curl = NULL;
char *httpgetfields = NULL;
int infilenum;
URLGlob *inglob;
- int metalink = 0; /* nonzero for metalink download. Put outside of
- HAVE_LIBMETALINK to reduce #ifdef */
-#ifdef HAVE_LIBMETALINK
+ int metalink = 0; /* nonzero for metalink download. */
metalinkfile *mlfile;
metalink_resource *mlres;
-#endif /* HAVE_LIBMETALINK */
outfiles = NULL;
infilenum = 1;
inglob = NULL;
-#ifdef HAVE_LIBMETALINK
if(urlnode->flags & GETOUT_METALINK) {
metalink = 1;
if(mlfile_last == NULL) {
mlfile = NULL;
mlres = NULL;
}
-#endif /* HAVE_LIBMETALINK */
/* urlnode->url is the full URL (it might be NULL) */
break;
}
-#ifdef HAVE_LIBMETALINK
if(metalink) {
/* For Metalink download, we don't use glob. Instead we use
the number of resources as urlnum. */
urlnum = count_next_metalink_resource(mlfile);
}
else
-#endif /* HAVE_LIBMETALINK */
if(!config->globoff) {
/* Unless explicitly shut off, we expand '{...}' and '[...]'
expressions and return total number of URLs in pattern set */
long retry_sleep;
char *this_url;
HeaderData hdrdata;
-#ifdef HAVE_LIBMETALINK
int metalink_next_res = 0;
-#endif /* HAVE_LIBMETALINK */
outfile = NULL;
infdopen = FALSE;
outs.stream = stdout;
outs.config = config;
-#ifdef HAVE_LIBMETALINK
if(metalink) {
/* For Metalink download, use name in Metalink file as
filename. */
}
}
else {
-#endif /* HAVE_LIBMETALINK */
if(urls) {
res = glob_next_url(&this_url, urls);
if(res)
goto show_error;
}
}
-#ifdef HAVE_LIBMETALINK
}
-#endif /* HAVE_LIBMETALINK */
if((urlnode->flags&GETOUT_USEREMOTE) ||
(outfile && !curlx_strequal("-", outfile)) ) {
continue; /* curl_easy_perform loop */
}
} /* if retry_numretries */
-#ifdef HAVE_LIBMETALINK
else if(metalink) {
/* Metalink: Decide to try the next resource or
not. Basically, we want to try the next resource if
else
metalink_next_res = 1;
}
-#endif /* HAVE_LIBMETALINK */
/* In all ordinary cases, just break out of loop here */
break; /* curl_easy_perform loop */
infd = STDIN_FILENO;
}
-#ifdef HAVE_LIBMETALINK
if(metalink) {
/* Should exit if error is fatal. */
if(is_fatal_error(res)) {
break;
}
else
-#endif /* HAVE_LIBMETALINK */
if(urlnum > 1) {
/* when url globbing, exit loop upon critical error */
if(is_fatal_error(res))
if(config->errors_fopened && config->errors)
fclose(config->errors);
-#ifdef HAVE_LIBMETALINK
/* Release metalink related resources here */
clean_metalink(config);
-#endif /* HAVE_LIBMETALINK */
main_free(); /* cleanup */