]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/import/pull-job.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / import / pull-job.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
56ebfaf1
LP
2#pragma once
3
85dbc41d 4#include <gcrypt.h>
56ebfaf1 5
56ebfaf1 6#include "curl-util.h"
3e2cda69 7#include "import-compress.h"
71d35b6b 8#include "macro.h"
56ebfaf1 9
dc2c282b
LP
10typedef struct PullJob PullJob;
11
12typedef void (*PullJobFinished)(PullJob *job);
13typedef int (*PullJobOpenDisk)(PullJob *job);
14typedef int (*PullJobHeader)(PullJob *job, const char *header, size_t sz);
15typedef void (*PullJobProgress)(PullJob *job);
16
17typedef enum PullJobState {
18 PULL_JOB_INIT,
19 PULL_JOB_ANALYZING, /* Still reading into ->payload, to figure out what we have */
20 PULL_JOB_RUNNING, /* Writing to destination */
21 PULL_JOB_DONE,
22 PULL_JOB_FAILED,
23 _PULL_JOB_STATE_MAX,
24 _PULL_JOB_STATE_INVALID = -1,
25} PullJobState;
26
697be0be
TB
27typedef 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 */
31} VerificationStyle;
32
9854730b 33#define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
dc2c282b 34
dc2c282b
LP
35struct PullJob {
36 PullJobState state;
56ebfaf1
LP
37 int error;
38
39 char *url;
40
41 void *userdata;
dc2c282b
LP
42 PullJobFinished on_finished;
43 PullJobOpenDisk on_open_disk;
44 PullJobHeader on_header;
45 PullJobProgress on_progress;
56ebfaf1
LP
46
47 CurlGlue *glue;
48 CURL *curl;
49 struct curl_slist *request_header;
50
51 char *etag;
52 char **old_etags;
85dbc41d 53 bool etag_exists;
56ebfaf1
LP
54
55 uint64_t content_length;
56 uint64_t written_compressed;
57 uint64_t written_uncompressed;
58
59 uint64_t uncompressed_max;
60 uint64_t compressed_max;
61
62 uint8_t *payload;
63 size_t payload_size;
64 size_t payload_allocated;
65
66 int disk_fd;
67
68 usec_t mtime;
69
3e2cda69 70 ImportCompress compress;
56ebfaf1
LP
71
72 unsigned progress_percent;
73 usec_t start_usec;
74 usec_t last_status_usec;
75
76 bool allow_sparse;
85dbc41d 77
98c38001
LP
78 bool calc_checksum;
79 gcry_md_hd_t checksum_context;
85dbc41d 80
98c38001 81 char *checksum;
26166c88 82
697be0be 83 VerificationStyle style;
56ebfaf1
LP
84};
85
dc2c282b
LP
86int pull_job_new(PullJob **job, const char *url, CurlGlue *glue, void *userdata);
87PullJob* pull_job_unref(PullJob *job);
56ebfaf1 88
dc2c282b 89int pull_job_begin(PullJob *j);
56ebfaf1 90
dc2c282b 91void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result);
98c38001 92
dc2c282b 93DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob*, pull_job_unref);