createrepo_c library  0.9.1
C library for metadata manipulation
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)   cr_sopen(FILENAME, MODE, COMTYPE, NULL, 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_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_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_printf (GError **err, CR_FILE *cr_file, const char *format,...)
 
int cr_close (CR_FILE *cr_file, GError **err)
 

Detailed Description

Macro Definition Documentation

#define CR_CW_ERR   -1

Return value - Error

Definition at line 87 of file compression_wrapper.h.

#define cr_open (   FILENAME,
  MODE,
  COMTYPE,
  ERR 
)    cr_sopen(FILENAME, MODE, COMTYPE, NULL, 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 115 of file compression_wrapper.h.

Enumeration Type Documentation

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_COMPRESSION_SENTINEL 

Sentinel of the list

Definition at line 37 of file compression_wrapper.h.

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 49 of file compression_wrapper.h.

Function Documentation

int cr_close ( CR_FILE cr_file,
GError **  err 
)

Closes the CR_FILE.

Parameters
cr_fileCR_FILE pointer
errGError **
Returns
cr_Error code
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_CompressionType cr_compression_type ( const char *  name)

Return compression type.

Parameters
namecompression name
Returns
compression type
void cr_contentstat_free ( cr_ContentStat cstat,
GError **  err 
)

Frees cr_ContentStat object.

Parameters
cstatcr_ContentStat object
errGError **
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_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
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)
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
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_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
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)