comparison mupdf-source/thirdparty/curl/src/tool_metalink.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 #ifndef HEADER_CURL_TOOL_METALINK_H
2 #define HEADER_CURL_TOOL_METALINK_H
3 /***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2014, 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.haxx.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ***************************************************************************/
24 #include "tool_setup.h"
25 #include "tool_sdecls.h"
26
27 struct GlobalConfig;
28 struct OperationConfig;
29
30 /* returns 1 for success, 0 otherwise (we use OpenSSL *_Init fncs directly) */
31 typedef int (* Curl_digest_init_func)(void *context);
32
33 typedef void (* Curl_digest_update_func)(void *context,
34 const unsigned char *data,
35 unsigned int len);
36 typedef void (* Curl_digest_final_func)(unsigned char *result, void *context);
37
38 typedef struct {
39 Curl_digest_init_func digest_init; /* Initialize context procedure */
40 Curl_digest_update_func digest_update; /* Update context with data */
41 Curl_digest_final_func digest_final; /* Get final result procedure */
42 unsigned int digest_ctxtsize; /* Context structure size */
43 unsigned int digest_resultlen; /* Result length (bytes) */
44 } digest_params;
45
46 typedef struct {
47 const digest_params *digest_hash; /* Hash function definition */
48 void *digest_hashctx; /* Hash function context */
49 } digest_context;
50
51 digest_context * Curl_digest_init(const digest_params *dparams);
52 int Curl_digest_update(digest_context *context,
53 const unsigned char *data,
54 unsigned int len);
55 int Curl_digest_final(digest_context *context, unsigned char *result);
56
57 typedef struct {
58 const char *hash_name;
59 const digest_params *dparams;
60 } metalink_digest_def;
61
62 typedef struct {
63 const char *alias_name;
64 const metalink_digest_def *digest_def;
65 } metalink_digest_alias;
66
67 typedef struct metalink_checksum {
68 const metalink_digest_def *digest_def;
69 /* raw digest value, not ascii hex digest */
70 unsigned char *digest;
71 } metalink_checksum;
72
73 typedef struct metalink_resource {
74 struct metalink_resource *next;
75 char *url;
76 } metalink_resource;
77
78 typedef struct metalinkfile {
79 struct metalinkfile *next;
80 char *filename;
81 metalink_checksum *checksum;
82 metalink_resource *resource;
83 } metalinkfile;
84
85 #ifdef USE_METALINK
86
87 /*
88 * curl requires libmetalink 0.1.0 or newer
89 */
90 #define CURL_REQ_LIBMETALINK_MAJOR 0
91 #define CURL_REQ_LIBMETALINK_MINOR 1
92 #define CURL_REQ_LIBMETALINK_PATCH 0
93
94 #define CURL_REQ_LIBMETALINK_VERS ((CURL_REQ_LIBMETALINK_MAJOR * 10000) + \
95 (CURL_REQ_LIBMETALINK_MINOR * 100) + \
96 CURL_REQ_LIBMETALINK_PATCH)
97
98 extern const digest_params MD5_DIGEST_PARAMS[1];
99 extern const digest_params SHA1_DIGEST_PARAMS[1];
100 extern const digest_params SHA256_DIGEST_PARAMS[1];
101
102 #include <metalink/metalink.h>
103
104 /*
105 * Counts the resource in the metalinkfile.
106 */
107 int count_next_metalink_resource(metalinkfile *mlfile);
108 void clean_metalink(struct OperationConfig *config);
109
110 /*
111 * Performs final parse operation and extracts information from
112 * Metalink and creates metalinkfile structs.
113 *
114 * This function returns 0 if it succeeds without warnings, or one of
115 * the following negative error codes:
116 *
117 * -1: Parsing failed; or no file is found
118 * -2: Parsing succeeded with some warnings.
119 */
120 int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
121 const char *metalink_url);
122
123 /*
124 * Callback function for CURLOPT_WRITEFUNCTION
125 */
126 size_t metalink_write_cb(void *buffer, size_t sz, size_t nmemb,
127 void *userdata);
128
129 /*
130 * Returns nonzero if content_type includes "application/metalink+xml"
131 * media-type. The check is done in case-insensitive manner.
132 */
133 int check_metalink_content_type(const char *content_type);
134
135 /*
136 * Check checksum of file denoted by filename.
137 *
138 * This function returns 1 if the checksum matches or one of the
139 * following integers:
140 *
141 * 0:
142 * Checksum didn't match.
143 * -1:
144 * Could not open file; or could not read data from file.
145 * -2:
146 * No checksum in Metalink supported, hash algorithm not available, or
147 * Metalink does not contain checksum.
148 */
149 int metalink_check_hash(struct GlobalConfig *config,
150 metalinkfile *mlfile,
151 const char *filename);
152
153 /*
154 * Release resources allocated at global scope.
155 */
156 void metalink_cleanup(void);
157
158 #else /* USE_METALINK */
159
160 #define count_next_metalink_resource(x) 0
161 #define clean_metalink(x) (void)x
162
163 /* metalink_cleanup() takes no arguments */
164 #define metalink_cleanup() Curl_nop_stmt
165
166 #endif /* USE_METALINK */
167
168 #endif /* HEADER_CURL_TOOL_METALINK_H */