1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2015 Lennart Poettering
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "curl-util.h"
26 #include "import-compress.h"
29 typedef struct PullJob PullJob
;
31 typedef void (*PullJobFinished
)(PullJob
*job
);
32 typedef int (*PullJobOpenDisk
)(PullJob
*job
);
33 typedef int (*PullJobHeader
)(PullJob
*job
, const char *header
, size_t sz
);
34 typedef void (*PullJobProgress
)(PullJob
*job
);
36 typedef enum PullJobState
{
38 PULL_JOB_ANALYZING
, /* Still reading into ->payload, to figure out what we have */
39 PULL_JOB_RUNNING
, /* Writing to destination */
43 _PULL_JOB_STATE_INVALID
= -1,
46 typedef enum VerificationStyle
{
47 VERIFICATION_STYLE_UNSET
,
48 VERIFICATION_PER_FILE
, /* SuSE-style ".sha256" files with inline signature */
49 VERIFICATION_PER_DIRECTORY
, /* Ubuntu-style SHA256SUM files with detach SHA256SUM.gpg signatures */
52 #define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
61 PullJobFinished on_finished
;
62 PullJobOpenDisk on_open_disk
;
63 PullJobHeader on_header
;
64 PullJobProgress on_progress
;
68 struct curl_slist
*request_header
;
74 uint64_t content_length
;
75 uint64_t written_compressed
;
76 uint64_t written_uncompressed
;
78 uint64_t uncompressed_max
;
79 uint64_t compressed_max
;
83 size_t payload_allocated
;
89 ImportCompress compress
;
91 unsigned progress_percent
;
93 usec_t last_status_usec
;
98 gcry_md_hd_t checksum_context
;
102 bool grow_machine_directory
;
103 uint64_t written_since_last_grow
;
105 VerificationStyle style
;
108 int pull_job_new(PullJob
**job
, const char *url
, CurlGlue
*glue
, void *userdata
);
109 PullJob
* pull_job_unref(PullJob
*job
);
111 int pull_job_begin(PullJob
*j
);
113 void pull_job_curl_on_finished(CurlGlue
*g
, CURL
*curl
, CURLcode result
);
115 DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob
*, pull_job_unref
);