tool_metalink.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_TOOL_METALINK_H
00002 #define HEADER_CURL_TOOL_METALINK_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 #include "tool_setup.h"
00025 
00026 struct GlobalConfig;
00027 struct OperationConfig;
00028 
00029 /* returns 1 for success, 0 otherwise (we use OpenSSL *_Init fncs directly) */
00030 typedef int (* Curl_digest_init_func)(void *context);
00031 
00032 typedef void (* Curl_digest_update_func)(void *context,
00033                                          const unsigned char *data,
00034                                          unsigned int len);
00035 typedef void (* Curl_digest_final_func)(unsigned char *result, void *context);
00036 
00037 typedef struct {
00038   Curl_digest_init_func     digest_init;   /* Initialize context procedure */
00039   Curl_digest_update_func   digest_update; /* Update context with data */
00040   Curl_digest_final_func    digest_final;  /* Get final result procedure */
00041   unsigned int           digest_ctxtsize;  /* Context structure size */
00042   unsigned int           digest_resultlen; /* Result length (bytes) */
00043 } digest_params;
00044 
00045 typedef struct {
00046   const digest_params   *digest_hash;      /* Hash function definition */
00047   void                  *digest_hashctx;   /* Hash function context */
00048 } digest_context;
00049 
00050 digest_context * Curl_digest_init(const digest_params *dparams);
00051 int Curl_digest_update(digest_context *context,
00052                        const unsigned char *data,
00053                        unsigned int len);
00054 int Curl_digest_final(digest_context *context, unsigned char *result);
00055 
00056 typedef struct {
00057   const char *hash_name;
00058   const digest_params *dparams;
00059 } metalink_digest_def;
00060 
00061 typedef struct {
00062   const char *alias_name;
00063   const metalink_digest_def *digest_def;
00064 } metalink_digest_alias;
00065 
00066 typedef struct metalink_checksum {
00067   const metalink_digest_def *digest_def;
00068   /* raw digest value, not ascii hex digest */
00069   unsigned char *digest;
00070 } metalink_checksum;
00071 
00072 typedef struct metalink_resource {
00073   struct metalink_resource *next;
00074   char *url;
00075 } metalink_resource;
00076 
00077 typedef struct metalinkfile {
00078   struct metalinkfile *next;
00079   char *filename;
00080   metalink_checksum *checksum;
00081   metalink_resource *resource;
00082 } metalinkfile;
00083 
00084 #ifdef USE_METALINK
00085 
00086 /*
00087  * curl requires libmetalink 0.1.0 or newer
00088  */
00089 #define CURL_REQ_LIBMETALINK_MAJOR  0
00090 #define CURL_REQ_LIBMETALINK_MINOR  1
00091 #define CURL_REQ_LIBMETALINK_PATCH  0
00092 
00093 #define CURL_REQ_LIBMETALINK_VERS  ((CURL_REQ_LIBMETALINK_MAJOR * 10000) + \
00094                                     (CURL_REQ_LIBMETALINK_MINOR * 100) + \
00095                                      CURL_REQ_LIBMETALINK_PATCH)
00096 
00097 extern const digest_params MD5_DIGEST_PARAMS[1];
00098 extern const digest_params SHA1_DIGEST_PARAMS[1];
00099 extern const digest_params SHA256_DIGEST_PARAMS[1];
00100 
00101 #include <metalink/metalink.h>
00102 
00103 /*
00104  * Counts the resource in the metalinkfile.
00105  */
00106 int count_next_metalink_resource(metalinkfile *mlfile);
00107 void clean_metalink(struct OperationConfig *config);
00108 
00109 /*
00110  * Performs final parse operation and extracts information from
00111  * Metalink and creates metalinkfile structs.
00112  *
00113  * This function returns 0 if it succeeds without warnings, or one of
00114  * the following negative error codes:
00115  *
00116  * -1: Parsing failed; or no file is found
00117  * -2: Parsing succeeded with some warnings.
00118  */
00119 int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
00120                    const char *metalink_url);
00121 
00122 /*
00123  * Callback function for CURLOPT_WRITEFUNCTION
00124  */
00125 size_t metalink_write_cb(void *buffer, size_t sz, size_t nmemb,
00126                          void *userdata);
00127 
00128 /*
00129  * Returns nonzero if content_type includes "application/metalink+xml"
00130  * media-type. The check is done in case-insensitive manner.
00131  */
00132 int check_metalink_content_type(const char *content_type);
00133 
00134 /*
00135  * Check checksum of file denoted by filename.
00136  *
00137  * This function returns 1 if the checksum matches or one of the
00138  * following integers:
00139  *
00140  * 0:
00141  *   Checksum didn't match.
00142  * -1:
00143  *   Could not open file; or could not read data from file.
00144  * -2:
00145  *   No checksum in Metalink supported, hash algorithm not available, or
00146  *   Metalink does not contain checksum.
00147  */
00148 int metalink_check_hash(struct GlobalConfig *config,
00149                         metalinkfile *mlfile,
00150                         const char *filename);
00151 
00152 /*
00153  * Release resources allocated at global scope.
00154  */
00155 void metalink_cleanup(void);
00156 
00157 #else /* USE_METALINK */
00158 
00159 #define count_next_metalink_resource(x)  0
00160 #define clean_metalink(x)  (void)x
00161 
00162 /* metalink_cleanup() takes no arguments */
00163 #define metalink_cleanup() Curl_nop_stmt
00164 
00165 #endif /* USE_METALINK */
00166 
00167 #endif /* HEADER_CURL_TOOL_METALINK_H */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07