createrepo_c library 1.1.4
C library for metadata manipulation
Loading...
Searching...
No Matches
Wrapper for compressed file.

Data Structures

struct  cr_ContentStat
 
struct  CR_FILE
 

Macros

#define CR_CW_ERR   -1
 
#define cr_open(FILENAME, MODE, COMTYPE, ERR)
 

Enumerations

enum  cr_CompressionType {
  CR_CW_AUTO_DETECT_COMPRESSION , CR_CW_UNKNOWN_COMPRESSION , CR_CW_NO_COMPRESSION , CR_CW_GZ_COMPRESSION ,
  CR_CW_BZ2_COMPRESSION , CR_CW_XZ_COMPRESSION , CR_CW_ZCK_COMPRESSION , CR_CW_ZSTD_COMPRESSION ,
  CR_CW_COMPRESSION_SENTINEL
}
 
enum  cr_OpenMode { CR_CW_MODE_READ , CR_CW_MODE_WRITE , CR_CW_MODE_SENTINEL }
 

Functions

cr_ContentStatcr_contentstat_new (cr_ChecksumType type, GError **err)
 
void cr_contentstat_free (cr_ContentStat *cstat, GError **err)
 
const char * cr_compression_suffix (cr_CompressionType comtype)
 
cr_CompressionType cr_detect_compression (const char *filename, GError **err)
 
cr_CompressionType cr_compression_type (const char *name)
 
CR_FILEcr_sopen (const char *filename, cr_OpenMode mode, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)
 
int cr_set_dict (CR_FILE *cr_file, const void *dict, unsigned int len, GError **err)
 
int cr_read (CR_FILE *cr_file, void *buffer, unsigned int len, GError **err)
 
int cr_write (CR_FILE *cr_file, const void *buffer, unsigned int len, GError **err)
 
int cr_puts (CR_FILE *cr_file, const char *str, GError **err)
 
int cr_end_chunk (CR_FILE *cr_file, GError **err)
 
int cr_set_autochunk (CR_FILE *cr_file, gboolean auto_chunk, GError **err)
 
ssize_t cr_get_zchunk_with_index (CR_FILE *f, ssize_t zchunk_index, char **copy_buf, GError **err)
 
int cr_printf (GError **err, CR_FILE *cr_file, const char *format,...)
 
int cr_close (CR_FILE *cr_file, GError **err)
 

Detailed Description

Macro Definition Documentation

◆ CR_CW_ERR

#define CR_CW_ERR   -1

Return value - Error

Definition at line 93 of file compression_wrapper.h.

◆ cr_open

#define cr_open ( FILENAME,
MODE,
COMTYPE,
ERR )
Value:
cr_sopen(FILENAME, MODE, COMTYPE, NULL, ERR)
CR_FILE * cr_sopen(const char *filename, cr_OpenMode mode, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)

Open/Create the specified file.

Parameters
FILENAMEfilename
MODEopen mode
COMTYPEtype of compression
ERRGError **
Returns
pointer to a CR_FILE or NULL

Definition at line 121 of file compression_wrapper.h.

Enumeration Type Documentation

◆ cr_CompressionType

Compression type.

Enumerator
CR_CW_AUTO_DETECT_COMPRESSION 

Autodetection

CR_CW_UNKNOWN_COMPRESSION 

Unknown compression

CR_CW_NO_COMPRESSION 

No compression

CR_CW_GZ_COMPRESSION 

Gzip compression

CR_CW_BZ2_COMPRESSION 

BZip2 compression

CR_CW_XZ_COMPRESSION 

XZ compression

CR_CW_ZCK_COMPRESSION 

ZCK compression

CR_CW_ZSTD_COMPRESSION 

ZSTD compression

CR_CW_COMPRESSION_SENTINEL 

Sentinel of the list

Definition at line 37 of file compression_wrapper.h.

◆ cr_OpenMode

Open modes.

Enumerator
CR_CW_MODE_READ 

Read mode

CR_CW_MODE_WRITE 

Write mode

CR_CW_MODE_SENTINEL 

Sentinel of the list

Definition at line 51 of file compression_wrapper.h.

Function Documentation

◆ cr_close()

int cr_close ( CR_FILE * cr_file,
GError ** err )

Closes the CR_FILE.

Parameters
cr_fileCR_FILE pointer
errGError **
Returns
cr_Error code

◆ cr_compression_suffix()

const char * cr_compression_suffix ( cr_CompressionType comtype)

Returns a common suffix for the specified cr_CompressionType.

Parameters
comtypecompression type
Returns
common file suffix

◆ cr_compression_type()

cr_CompressionType cr_compression_type ( const char * name)

Return compression type.

Parameters
namecompression name
Returns
compression type

◆ cr_contentstat_free()

void cr_contentstat_free ( cr_ContentStat * cstat,
GError ** err )

Frees cr_ContentStat object.

Parameters
cstatcr_ContentStat object
errGError **

◆ cr_contentstat_new()

cr_ContentStat * cr_contentstat_new ( cr_ChecksumType type,
GError ** err )

Creates new cr_ContentStat object

Parameters
typeType of checksum. (if CR_CHECKSUM_UNKNOWN is used, no checksum calculation will be done)
errGError **
Returns
cr_ContentStat object

◆ cr_detect_compression()

cr_CompressionType cr_detect_compression ( const char * filename,
GError ** err )

Detect a compression type of the specified file.

Parameters
filenamefilename
errGError **
Returns
detected type of compression

◆ cr_end_chunk()

int cr_end_chunk ( CR_FILE * cr_file,
GError ** err )

If compression format allows ending of chunks, tell it to end chunk

Parameters
cr_fileCR_FILE pointer
errGError **
Returns
CRE_OK or CR_CW_ERR

◆ cr_get_zchunk_with_index()

ssize_t cr_get_zchunk_with_index ( CR_FILE * f,
ssize_t zchunk_index,
char ** copy_buf,
GError ** err )

Get specific zchunks data indentified by index

Parameters
cr_fileCR_FILE pointer
zchunk_indexIndex of wanted zchunk
copy_bufOutput pointer, upon return contains wanted zchunk data
errGError **
Returns
Size of data from zchunk indexed by zchunk_index

◆ cr_printf()

int cr_printf ( GError ** err,
CR_FILE * cr_file,
const char * format,
... )

Writes a formatted string into the cr_file.

Parameters
errGError **
cr_fileCR_FILE pointer
formatformat string
...list of additional arguments as specified in format
Returns
Number of bytes written or CR_CW_ERR (-1)

◆ cr_puts()

int cr_puts ( CR_FILE * cr_file,
const char * str,
GError ** err )

Writes the string pointed by str into the cr_file.

Parameters
cr_fileCR_FILE pointer
strnull terminated ('\0') string
errGError **
Returns
number of uncompressed bytes writed or CR_CW_ERR

◆ cr_read()

int cr_read ( CR_FILE * cr_file,
void * buffer,
unsigned int len,
GError ** err )

Reads an array of len bytes from the CR_FILE.

Parameters
cr_fileCR_FILE pointer
buffertarget buffer
lennumber of bytes to read
errGError **
Returns
number of readed bytes or CR_CW_ERR (-1)

◆ cr_set_autochunk()

int cr_set_autochunk ( CR_FILE * cr_file,
gboolean auto_chunk,
GError ** err )

Set zchunk auto-chunk algorithm. Must be done before first byte is written

Parameters
cr_fileCR_FILE pointer
auto_chunkWhether auto-chunking should be enabled
errGError **
Returns
CRE_OK or CR_CW_ERR

◆ cr_set_dict()

int cr_set_dict ( CR_FILE * cr_file,
const void * dict,
unsigned int len,
GError ** err )

Sets the compression dictionary for a file

Parameters
cr_fileCR_FILE pointer
dictdictionary
lenlength of dictionary
errGError **
Returns
CRE_OK or CR_CW_ERR (-1)

◆ cr_sopen()

CR_FILE * cr_sopen ( const char * filename,
cr_OpenMode mode,
cr_CompressionType comtype,
cr_ContentStat * stat,
GError ** err )

Open/Create the specified file. If opened for writting, you can pass a cr_ContentStat object and after cr_close() get stats of an open content (stats of uncompressed content).

Parameters
filenamefilename
modeopen mode
comtypetype of compression
statpointer to cr_ContentStat or NULL
errGError **
Returns
pointer to a CR_FILE or NULL

◆ cr_write()

int cr_write ( CR_FILE * cr_file,
const void * buffer,
unsigned int len,
GError ** err )

Writes the array of len bytes from buffer to the cr_file.

Parameters
cr_fileCR_FILE pointer
buffersource buffer
lennumber of bytes to read
errGError **
Returns
number of uncompressed bytes readed (0 = EOF) or CR_CW_ERR (-1)