aboutsummaryrefslogtreecommitdiff
path: root/src/tool_metalink.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-06-16 22:58:06 +0900
committerYang Tse <yangsita@gmail.com>2012-06-21 03:34:37 +0200
commit424bb3587748eb59c0d56613e88ef4511ad4dcbf (patch)
tree8e8c1d21f4c985a92fabd5ec92b293fadc55e20f /src/tool_metalink.h
parent08e0ad7b3974811127f7d61c016fee540f91d343 (diff)
curl: Refactored metalink_checksum
When creating metalink_checksum from metalink_checksum_t, first check hex digest is valid for the given hash function. We do this check in the order of digest_aliases so that first good match will be chosen (strongest hash function available). As a result, the metalinkfile now only contains at most one metalink_checksum because other entries are just redundant.
Diffstat (limited to 'src/tool_metalink.h')
-rw-r--r--src/tool_metalink.h77
1 files changed, 38 insertions, 39 deletions
diff --git a/src/tool_metalink.h b/src/tool_metalink.h
index 3ce1fe2f9..36b4b02c7 100644
--- a/src/tool_metalink.h
+++ b/src/tool_metalink.h
@@ -23,41 +23,6 @@
***************************************************************************/
#include "tool_setup.h"
-typedef struct metalink_checksum {
- struct metalink_checksum *next;
- char *hash_name;
- /* Hex-encoded hash value */
- char *hash_value;
-} metalink_checksum;
-
-typedef struct metalink_resource {
- struct metalink_resource *next;
- char *url;
-} metalink_resource;
-
-typedef struct metalinkfile {
- struct metalinkfile *next;
- char *filename;
- metalink_checksum *checksum;
- metalink_resource *resource;
-} metalinkfile;
-
-#ifdef USE_METALINK
-
-/*
- * Counts the resource in the metalinkfile.
- */
-int count_next_metalink_resource(metalinkfile *mlfile);
-void clean_metalink(struct Configurable *config);
-
-int parse_metalink(struct Configurable *config, const char *infile);
-
-/*
- * Returns nonzero if content_type includes "application/metalink+xml"
- * media-type. The check is done in case-insensitive manner.
- */
-int check_metalink_content_type(const char *content_type);
-
typedef void (* Curl_digest_init_func)(void *context);
typedef void (* Curl_digest_update_func)(void *context,
const unsigned char *data,
@@ -77,10 +42,6 @@ typedef struct {
void *digest_hashctx; /* Hash function context */
} digest_context;
-extern const digest_params MD5_DIGEST_PARAMS[1];
-extern const digest_params SHA1_DIGEST_PARAMS[1];
-extern const digest_params SHA256_DIGEST_PARAMS[1];
-
digest_context * Curl_digest_init(const digest_params *dparams);
int Curl_digest_update(digest_context *context,
const unsigned char *data,
@@ -97,6 +58,44 @@ typedef struct {
const metalink_digest_def *digest_def;
} metalink_digest_alias;
+typedef struct metalink_checksum {
+ const metalink_digest_def *digest_def;
+ /* raw digest value, not ascii hex digest */
+ unsigned char *digest;
+} metalink_checksum;
+
+typedef struct metalink_resource {
+ struct metalink_resource *next;
+ char *url;
+} metalink_resource;
+
+typedef struct metalinkfile {
+ struct metalinkfile *next;
+ char *filename;
+ metalink_checksum *checksum;
+ metalink_resource *resource;
+} metalinkfile;
+
+#ifdef USE_METALINK
+
+extern const digest_params MD5_DIGEST_PARAMS[1];
+extern const digest_params SHA1_DIGEST_PARAMS[1];
+extern const digest_params SHA256_DIGEST_PARAMS[1];
+
+/*
+ * Counts the resource in the metalinkfile.
+ */
+int count_next_metalink_resource(metalinkfile *mlfile);
+void clean_metalink(struct Configurable *config);
+
+int parse_metalink(struct Configurable *config, const char *infile);
+
+/*
+ * Returns nonzero if content_type includes "application/metalink+xml"
+ * media-type. The check is done in case-insensitive manner.
+ */
+int check_metalink_content_type(const char *content_type);
+
/*
* Check checksum of file denoted by filename.
*