]> granicus.if.org Git - curl/commitdiff
curl: Added runtime version check for libmetalink
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Sat, 30 Jun 2012 12:17:44 +0000 (21:17 +0900)
committerYang Tse <yangsita@gmail.com>
Mon, 2 Jul 2012 14:28:01 +0000 (16:28 +0200)
src/tool_getparam.c
src/tool_metalink.h

index 4bdf0a59d2e14765625ca53a5743b664c7aca8d8..c9c6198ff1eab4ef704de9a1e49c56630b27fdb0 100644 (file)
@@ -824,7 +824,21 @@ ParameterError getparameter(char *flag,    /* f or -long-flag */
       case 'J': /* --metalink */
         {
 #ifdef USE_METALINK
-          config->use_metalink = toggle;
+          int major, minor, patch;
+          metalink_get_version(&major, &minor, &patch);
+          if((major*10000)+(minor*100)+patch < CURL_REQ_LIBMETALINK_VERS) {
+            warnf(config,
+                  "--metalink option cannot be used because the version of "
+                  "the linked libmetalink library is too old. "
+                  "Required: %d.%d.%d, found %d.%d.%d\n",
+                  CURL_REQ_LIBMETALINK_MAJOR,
+                  CURL_REQ_LIBMETALINK_MINOR,
+                  CURL_REQ_LIBMETALINK_PATCH,
+                  major, minor, patch);
+            return PARAM_BAD_USE;
+          }
+          else
+            config->use_metalink = toggle;
 #else
           warnf(config, "--metalink option is ignored because the binary is "
                 "built without the Metalink support.\n");
index 42ad28a4b06e849b1e16a240459ab8c12ebfabba..49a6e64b7ee1b9520459435f871b5063e4ac015a 100644 (file)
@@ -78,6 +78,17 @@ typedef struct metalinkfile {
 
 #ifdef USE_METALINK
 
+/*
+ * curl requires libmetalink 0.1.0 or newer
+ */
+#define CURL_REQ_LIBMETALINK_MAJOR  0
+#define CURL_REQ_LIBMETALINK_MINOR  1
+#define CURL_REQ_LIBMETALINK_PATCH  0
+
+#define CURL_REQ_LIBMETALINK_VERS  ((CURL_REQ_LIBMETALINK_MAJOR * 10000) + \
+                                    (CURL_REQ_LIBMETALINK_MINOR * 100) + \
+                                     CURL_REQ_LIBMETALINK_PATCH)
+
 extern const digest_params MD5_DIGEST_PARAMS[1];
 extern const digest_params SHA1_DIGEST_PARAMS[1];
 extern const digest_params SHA256_DIGEST_PARAMS[1];