]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/import/pull-job.h
import: port importd from libgcrypt to openssl^gcrypt
[thirdparty/systemd.git] / src / import / pull-job.h
index c907e74060982a6d554d08d3c89b123f4e9b9f08..7a98b0f2f652e8ab97c01acccb28e3de74b9cb37 100644 (file)
@@ -1,11 +1,13 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <gcrypt.h>
+#include <sys/stat.h>
 
 #include "curl-util.h"
 #include "import-compress.h"
 #include "macro.h"
+#include "openssl-util.h"
+#include "pull-common.h"
 
 typedef struct PullJob PullJob;
 
@@ -13,23 +15,18 @@ typedef void (*PullJobFinished)(PullJob *job);
 typedef int (*PullJobOpenDisk)(PullJob *job);
 typedef int (*PullJobHeader)(PullJob *job, const char *header, size_t sz);
 typedef void (*PullJobProgress)(PullJob *job);
+typedef int (*PullJobNotFound)(PullJob *job, char **ret_new_url);
 
 typedef enum PullJobState {
         PULL_JOB_INIT,
         PULL_JOB_ANALYZING, /* Still reading into ->payload, to figure out what we have */
-        PULL_JOB_RUNNING,  /* Writing to destination */
+        PULL_JOB_RUNNING,   /* Writing to destination */
         PULL_JOB_DONE,
         PULL_JOB_FAILED,
         _PULL_JOB_STATE_MAX,
-        _PULL_JOB_STATE_INVALID = -1,
+        _PULL_JOB_STATE_INVALID = -EINVAL,
 } PullJobState;
 
-typedef enum VerificationStyle {
-        VERIFICATION_STYLE_UNSET,
-        VERIFICATION_PER_FILE,        /* SuSE-style ".sha256" files with inline signature */
-        VERIFICATION_PER_DIRECTORY,   /* Ubuntu-style SHA256SUM files with detach SHA256SUM.gpg signatures */
-} VerificationStyle;
-
 #define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
 
 struct PullJob {
@@ -43,6 +40,7 @@ struct PullJob {
         PullJobOpenDisk on_open_disk;
         PullJobHeader on_header;
         PullJobProgress on_progress;
+        PullJobNotFound on_not_found;
 
         CurlGlue *glue;
         CURL *curl;
@@ -55,15 +53,17 @@ struct PullJob {
         uint64_t content_length;
         uint64_t written_compressed;
         uint64_t written_uncompressed;
+        uint64_t offset;
 
         uint64_t uncompressed_max;
         uint64_t compressed_max;
 
         uint8_t *payload;
         size_t payload_size;
-        size_t payload_allocated;
 
         int disk_fd;
+        bool close_disk_fd;
+        struct stat disk_stat;
 
         usec_t mtime;
 
@@ -73,14 +73,12 @@ struct PullJob {
         usec_t start_usec;
         usec_t last_status_usec;
 
-        bool allow_sparse;
-
         bool calc_checksum;
-        gcry_md_hd_t checksum_context;
+        hash_context_t checksum_ctx;
 
         char *checksum;
-
-        VerificationStyle style;
+        bool sync;
+        bool force_memory;
 };
 
 int pull_job_new(PullJob **job, const char *url, CurlGlue *glue, void *userdata);
@@ -90,4 +88,6 @@ int pull_job_begin(PullJob *j);
 
 void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result);
 
+void pull_job_close_disk_fd(PullJob *j);
+
 DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob*, pull_job_unref);