4 This file is part of systemd.
6 Copyright 2015 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "curl-util.h"
25 #include "import-compress.h"
28 typedef struct PullJob PullJob
;
30 typedef void (*PullJobFinished
)(PullJob
*job
);
31 typedef int (*PullJobOpenDisk
)(PullJob
*job
);
32 typedef int (*PullJobHeader
)(PullJob
*job
, const char *header
, size_t sz
);
33 typedef void (*PullJobProgress
)(PullJob
*job
);
35 typedef enum PullJobState
{
37 PULL_JOB_ANALYZING
, /* Still reading into ->payload, to figure out what we have */
38 PULL_JOB_RUNNING
, /* Writing to destination */
42 _PULL_JOB_STATE_INVALID
= -1,
45 #define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
54 PullJobFinished on_finished
;
55 PullJobOpenDisk on_open_disk
;
56 PullJobHeader on_header
;
57 PullJobProgress on_progress
;
61 struct curl_slist
*request_header
;
67 uint64_t content_length
;
68 uint64_t written_compressed
;
69 uint64_t written_uncompressed
;
71 uint64_t uncompressed_max
;
72 uint64_t compressed_max
;
76 size_t payload_allocated
;
82 ImportCompress compress
;
84 unsigned progress_percent
;
86 usec_t last_status_usec
;
91 gcry_md_hd_t checksum_context
;
95 bool grow_machine_directory
;
96 uint64_t written_since_last_grow
;
99 int pull_job_new(PullJob
**job
, const char *url
, CurlGlue
*glue
, void *userdata
);
100 PullJob
* pull_job_unref(PullJob
*job
);
102 int pull_job_begin(PullJob
*j
);
104 void pull_job_curl_on_finished(CurlGlue
*g
, CURL
*curl
, CURLcode result
);
106 DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob
*, pull_job_unref
);