Suggest URLs for updated setup based on build architecture
[cygwin-setup.git] / compress_zstd.h
blobf8e6ca09eecdc2ea5f1bb31f967f8279238a3a8f
1 /*
2 * Copyright (c) 2018, Cygwin
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
14 #ifndef SETUP_COMPRESS_ZSTD_H
15 #define SETUP_COMPRESS_ZSTD_H
17 #include "compress.h"
18 #include <zstd.h>
19 #include <stdint.h>
21 class compress_zstd:public compress
23 public:
24 compress_zstd (io_stream *); /* decompress (read) only */
25 virtual ssize_t read (void *buffer, size_t len);
26 virtual ssize_t write (const void *buffer, size_t len); /* not implemented */
27 virtual ssize_t peek (void *buffer, size_t len);
28 virtual off_t tell (); /* not implemented */
29 virtual off_t seek (off_t where, io_stream_seek_t whence);
30 virtual int error ();
31 virtual const char *next_file_name () { return NULL; };
32 virtual int set_mtime (time_t);
33 virtual time_t get_mtime ();
34 virtual mode_t get_mode ();
35 virtual size_t get_size () {return 0;};
36 virtual ~compress_zstd ();
37 static bool is_zstd (void *buffer, size_t len);
38 virtual void release_original(); /* give up ownership of original io_stream */
40 private:
41 compress_zstd () {};
43 io_stream *original;
44 bool owns_original;
45 int lasterr;
46 void create ();
47 void destroy ();
49 struct private_data {
50 ZSTD_DStream *stream;
51 ZSTD_outBuffer out_block;
52 size_t out_bsz;
53 size_t out_pos;
54 uint64_t total_out;
55 char eof; /* True = found end of compressed data. */
56 ZSTD_inBuffer in_block;
57 size_t in_bsz;
58 size_t in_pos;
59 uint64_t total_in;
60 size_t in_processed;
61 size_t out_processed;
64 struct private_data *state;
67 #endif /* SETUP_COMPRESS_ZSTD_H */