1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 #include "import-compress.h"
10 typedef struct PullJob PullJob
;
12 typedef void (*PullJobFinished
)(PullJob
*job
);
13 typedef int (*PullJobOpenDisk
)(PullJob
*job
);
14 typedef int (*PullJobHeader
)(PullJob
*job
, const char *header
, size_t sz
);
15 typedef void (*PullJobProgress
)(PullJob
*job
);
17 typedef enum PullJobState
{
19 PULL_JOB_ANALYZING
, /* Still reading into ->payload, to figure out what we have */
20 PULL_JOB_RUNNING
, /* Writing to destination */
24 _PULL_JOB_STATE_INVALID
= -1,
27 typedef enum VerificationStyle
{
28 VERIFICATION_STYLE_UNSET
,
29 VERIFICATION_PER_FILE
, /* SuSE-style ".sha256" files with inline signature */
30 VERIFICATION_PER_DIRECTORY
, /* Ubuntu-style SHA256SUM files with detach SHA256SUM.gpg signatures */
33 #define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
42 PullJobFinished on_finished
;
43 PullJobOpenDisk on_open_disk
;
44 PullJobHeader on_header
;
45 PullJobProgress on_progress
;
49 struct curl_slist
*request_header
;
55 uint64_t content_length
;
56 uint64_t written_compressed
;
57 uint64_t written_uncompressed
;
59 uint64_t uncompressed_max
;
60 uint64_t compressed_max
;
64 size_t payload_allocated
;
70 ImportCompress compress
;
72 unsigned progress_percent
;
74 usec_t last_status_usec
;
79 gcry_md_hd_t checksum_context
;
83 VerificationStyle style
;
86 int pull_job_new(PullJob
**job
, const char *url
, CurlGlue
*glue
, void *userdata
);
87 PullJob
* pull_job_unref(PullJob
*job
);
89 int pull_job_begin(PullJob
*j
);
91 void pull_job_curl_on_finished(CurlGlue
*g
, CURL
*curl
, CURLcode result
);
93 DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob
*, pull_job_unref
);