00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __C_CREATEREPOLIB_COMPRESSION_WRAPPER_H__
00021 #define __C_CREATEREPOLIB_COMPRESSION_WRAPPER_H__
00022
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026
00027 #include <glib.h>
00028 #include "checksum.h"
00029
00037 typedef enum {
00038 CR_CW_AUTO_DETECT_COMPRESSION,
00039 CR_CW_UNKNOWN_COMPRESSION,
00040 CR_CW_NO_COMPRESSION,
00041 CR_CW_GZ_COMPRESSION,
00042 CR_CW_BZ2_COMPRESSION,
00043 CR_CW_XZ_COMPRESSION,
00044 CR_CW_COMPRESSION_SENTINEL,
00045 } cr_CompressionType;
00046
00049 typedef enum {
00050 CR_CW_MODE_READ,
00051 CR_CW_MODE_WRITE,
00052 CR_CW_MODE_SENTINEL,
00053 } cr_OpenMode;
00054
00057 typedef struct {
00058 gint64 size;
00059 cr_ChecksumType checksum_type;
00060 char *checksum;
00061 } cr_ContentStat;
00062
00069 cr_ContentStat *cr_contentstat_new(cr_ChecksumType type, GError **err);
00070
00075 void cr_contentstat_free(cr_ContentStat *cstat, GError **err);
00076
00079 typedef struct {
00080 cr_CompressionType type;
00081 void *FILE;
00082 cr_OpenMode mode;
00083 cr_ContentStat *stat;
00084 cr_ChecksumCtx *checksum_ctx;
00085 } CR_FILE;
00086
00087 #define CR_CW_ERR -1
00093 const char *cr_compression_suffix(cr_CompressionType comtype);
00094
00100 cr_CompressionType cr_detect_compression(const char* filename, GError **err);
00101
00106 cr_CompressionType cr_compression_type(const char *name);
00107
00115 #define cr_open(FILENAME, MODE, COMTYPE, ERR) \
00116 cr_sopen(FILENAME, MODE, COMTYPE, NULL, ERR)
00117
00128 CR_FILE *cr_sopen(const char *filename,
00129 cr_OpenMode mode,
00130 cr_CompressionType comtype,
00131 cr_ContentStat *stat,
00132 GError **err);
00133
00141 int cr_read(CR_FILE *cr_file, void *buffer, unsigned int len, GError **err);
00142
00151 int cr_write(CR_FILE *cr_file,
00152 const void *buffer,
00153 unsigned int len,
00154 GError **err);
00155
00162 int cr_puts(CR_FILE *cr_file, const char *str, GError **err);
00163
00171 int cr_printf(GError **err, CR_FILE *cr_file, const char *format, ...);
00172
00178 int cr_close(CR_FILE *cr_file, GError **err);
00179
00182 #ifdef __cplusplus
00183 }
00184 #endif
00185
00186 #endif