createrepo_c library  1.2.6
C library for metadata manipulation
compression_wrapper.h
1 /* createrepo_c - Library of routines for manipulation with repodata
2  * Copyright (C) 2012 Tomas Mlcoch
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17  * USA.
18  */
19 
20 #ifndef __C_CREATEREPOLIB_COMPRESSION_WRAPPER_H__
21 #define __C_CREATEREPOLIB_COMPRESSION_WRAPPER_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <glib.h>
28 #include "checksum.h"
29 
37 typedef enum {
48 
49 /* Default compression method (configurable at build time) */
50 #ifndef CR_DEFAULT_COMPRESSION
51 #define CR_DEFAULT_COMPRESSION CR_CW_ZSTD_COMPRESSION
52 #endif
53 
56 typedef enum {
60 } cr_OpenMode;
61 
64 typedef struct {
65  gint64 size;
67  char *checksum;
68  gint64 hdr_size;
70  char *hdr_checksum;
72 
80 
85 void cr_contentstat_free(cr_ContentStat *cstat, GError **err);
86 
89 typedef struct {
91  void *FILE;
92  void *INNERFILE;
96 } CR_FILE;
97 
98 #define CR_CW_ERR -1
104 const char *cr_compression_suffix(cr_CompressionType comtype);
105 
111 cr_CompressionType cr_detect_compression(const char* filename, GError **err);
112 
117 cr_CompressionType cr_compression_type(const char *name);
118 
126 #define cr_open(FILENAME, MODE, COMTYPE, ERR) \
127  cr_sopen(FILENAME, MODE, COMTYPE, NULL, ERR)
128 
139 CR_FILE *cr_sopen(const char *filename,
140  cr_OpenMode mode,
141  cr_CompressionType comtype,
142  cr_ContentStat *stat,
143  GError **err);
144 
152 int cr_set_dict(CR_FILE *cr_file, const void *dict, unsigned int len, GError **err);
153 
161 int cr_read(CR_FILE *cr_file, void *buffer, unsigned int len, GError **err);
162 
171 int cr_write(CR_FILE *cr_file,
172  const void *buffer,
173  unsigned int len,
174  GError **err);
175 
182 int cr_puts(CR_FILE *cr_file, const char *str, GError **err);
183 
189 int cr_end_chunk(CR_FILE *cr_file, GError **err);
190 
197 int cr_set_autochunk(CR_FILE *cr_file, gboolean auto_chunk, GError **err);
198 
206 ssize_t cr_get_zchunk_with_index(CR_FILE *f, ssize_t zchunk_index, char **copy_buf, GError **err);
207 
215 int cr_printf(GError **err, CR_FILE *cr_file, const char *format, ...);
216 
222 int cr_close(CR_FILE *cr_file, GError **err);
223 
226 #ifdef __cplusplus
227 }
228 #endif
229 
230 #endif /* __C_CREATEREPOLIB_COMPRESSION_WRAPPER_H__ */
cr_ChecksumType checksum_type
int cr_set_dict(CR_FILE *cr_file, const void *dict, unsigned int len, GError **err)
cr_ChecksumType
Definition: checksum.h:43
cr_CompressionType
cr_ContentStat * stat
int cr_end_chunk(CR_FILE *cr_file, GError **err)
int cr_printf(GError **err, CR_FILE *cr_file, const char *format,...)
void * INNERFILE
int cr_close(CR_FILE *cr_file, GError **err)
cr_ContentStat * cr_contentstat_new(cr_ChecksumType type, GError **err)
int cr_set_autochunk(CR_FILE *cr_file, gboolean auto_chunk, GError **err)
cr_OpenMode mode
void cr_contentstat_free(cr_ContentStat *cstat, GError **err)
CR_FILE * cr_sopen(const char *filename, cr_OpenMode mode, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)
cr_ChecksumType hdr_checksum_type
int cr_read(CR_FILE *cr_file, void *buffer, unsigned int len, GError **err)
ssize_t cr_get_zchunk_with_index(CR_FILE *f, ssize_t zchunk_index, char **copy_buf, GError **err)
struct _cr_ChecksumCtx cr_ChecksumCtx
Definition: checksum.h:36
int cr_puts(CR_FILE *cr_file, const char *str, GError **err)
cr_CompressionType cr_detect_compression(const char *filename, GError **err)
int cr_write(CR_FILE *cr_file, const void *buffer, unsigned int len, GError **err)
cr_CompressionType type
cr_CompressionType cr_compression_type(const char *name)
cr_ChecksumCtx * checksum_ctx