createrepo_c library 1.2.1 C library for metadata manipulation

Data Structures | Macros | Enumerations | Functions
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_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_ContentStat * | cr_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_FILE * | cr_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
| ) |  | cr_sopen(FILENAME, MODE, COMTYPE, NULL, ERR)

Open/Create the specified file.

Parameters

  FILENAME | filename
  MODE | open mode
  COMTYPE | type of compression
  ERR | GError **

Returns
  pointer to a CR_FILE or NULL

Definition at line 121 of file compression_wrapper.h.

## Enumeration Type Documentation

## ◆ cr_CompressionType

enum 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

enum 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_file | CR_FILE pointer
  err | GError **

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

  comtype | compression type

Returns
  common file suffix

## ◆ cr_compression_type()

cr_CompressionType cr_compression_type | ( | const char * | name | ) |

Return compression type.

Parameters

  name | compression name

Returns
  compression type

## ◆ cr_contentstat_free()

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

Frees cr_ContentStat object.

Parameters

  cstat | cr_ContentStat object
  err | GError **

## ◆ cr_contentstat_new()

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

Creates new cr_ContentStat object

Parameters

  type | Type of checksum. (if CR_CHECKSUM_UNKNOWN is used, no checksum calculation will be done)
  err | GError **

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

  filename | filename
  err | GError **

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_file | CR_FILE pointer
  err | GError **

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_file | CR_FILE pointer
  zchunk_index | Index of wanted zchunk
  copy_buf | Output pointer, upon return contains wanted zchunk data
  err | GError **

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

  err | GError **
  cr_file | CR_FILE pointer
  format | format 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_file | CR_FILE pointer
  str | null terminated ('\0') string
  err | GError **

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_file | CR_FILE pointer
  buffer | target buffer
  len | number of bytes to read
  err | GError **

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_file | CR_FILE pointer
  auto_chunk | Whether auto-chunking should be enabled
  err | GError **

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_file | CR_FILE pointer
  dict | dictionary
  len | length of dictionary
  err | GError **

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

  filename | filename
  mode | open mode
  comtype | type of compression
  stat | pointer to cr_ContentStat or NULL
  err | GError **

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_file | CR_FILE pointer
  buffer | source buffer
  len | number of bytes to read
  err | GError **

Returns
  number of uncompressed bytes readed (0 = EOF) or CR_CW_ERR (-1)