aboutsummaryrefslogtreecommitdiff
path: root/src/tool_metalink.c
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-05-26 22:51:03 +0900
committerDaniel Stenberg <daniel@haxx.se>2012-05-26 23:12:09 +0200
commit1bfd750f3f9e173ce5a6735756106cf6a1804960 (patch)
tree35251f9f29750ebef094ccf30b413eaa1a1ca918 /src/tool_metalink.c
parent7bdb9fba952ea24390b903478aedb5e1615ae2d4 (diff)
Reduced #ifdef HAVE_METALINK
Diffstat (limited to 'src/tool_metalink.c')
-rw-r--r--src/tool_metalink.c126
1 files changed, 66 insertions, 60 deletions
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index 461dbf148..6e18b4247 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -31,6 +31,8 @@
# include <fcntl.h>
#endif
+#include <metalink/metalink_parser.h>
+
#include "rawstr.h"
#include "tool_metalink.h"
@@ -412,6 +414,8 @@ int metalink_check_hash(struct Configurable *config,
#endif /* METALINK_HASH_CHECK */
+#ifdef HAVE_LIBMETALINK
+
static metalink_checksum *new_metalink_checksum(const char *hash_name,
const char *hash_value)
{
@@ -423,16 +427,6 @@ static metalink_checksum *new_metalink_checksum(const char *hash_name,
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;
@@ -442,15 +436,6 @@ static metalink_resource *new_metalink_resource(const char *url)
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;
@@ -488,47 +473,6 @@ static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
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;
@@ -592,6 +536,8 @@ int parse_metalink(struct Configurable *config, const char *infile)
return 0;
}
+#endif /* HAVE_LIBMETALINK */
+
/*
* 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");
}
+
+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;
+}