createrepo_c library 1.2.1 C library for metadata manipulation

Data Structures | Macros | Enumerations | Functions
XML file API.

## Data Structures
struct | cr_XmlFile

## Macros
#define | cr_xmlfile_open_primary(FILENAME, COMTYPE, ERR) cr_xmlfile_open(FILENAME, CR_XMLFILE_PRIMARY, COMTYPE, ERR)
#define | cr_xmlfile_sopen_primary(FILENAME, COMTYPE, STAT, ERR) cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRIMARY, COMTYPE, STAT, ERR)
#define | cr_xmlfile_open_filelists(FILENAME, COMTYPE, ERR) cr_xmlfile_open(FILENAME, CR_XMLFILE_FILELISTS, COMTYPE, ERR)
#define | cr_xmlfile_open_filelists_ext(FILENAME, COMTYPE, ERR) cr_xmlfile_open(FILENAME, CR_XMLFILE_FILELISTS_EXT, COMTYPE, ERR)
#define | cr_xmlfile_sopen_filelists(FILENAME, COMTYPE, STAT, ERR) cr_xmlfile_sopen(FILENAME, CR_XMLFILE_FILELISTS, COMTYPE, STAT, ERR)
#define | cr_xmlfile_sopen_filelists_ext(FILENAME, COMTYPE, STAT, ERR) cr_xmlfile_sopen(FILENAME, CR_XMLFILE_FILELISTS_EXT, COMTYPE, STAT, ERR)
#define | cr_xmlfile_open_other(FILENAME, COMTYPE, ERR) cr_xmlfile_open(FILENAME, CR_XMLFILE_OTHER, COMTYPE, ERR)
#define | cr_xmlfile_sopen_other(FILENAME, COMTYPE, STAT, ERR) cr_xmlfile_sopen(FILENAME, CR_XMLFILE_OTHER, COMTYPE, STAT, ERR)
#define | cr_xmlfile_open_prestodelta(FILENAME, COMTYPE, ERR) cr_xmlfile_open(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, ERR)
#define | cr_xmlfile_sopen_prestodelta(FILENAME, COMTYPE, STAT, ERR) cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, STAT, ERR)
#define | cr_xmlfile_open_updateinfo(FILENAME, COMTYPE, ERR) cr_xmlfile_open(FILENAME, CR_XMLFILE_UPDATEINFO, COMTYPE, ERR)
#define | cr_xmlfile_sopen_updateinfo(FILENAME, COMTYPE, STAT, ERR) cr_xmlfile_sopen(FILENAME, CR_XMLFILE_UPDATEINFO, COMTYPE, STAT, ERR)
#define | cr_xmlfile_open(FILENAME, TYPE, COMTYPE, ERR) cr_xmlfile_sopen(FILENAME, TYPE, COMTYPE, NULL, ERR)

## Enumerations
enum | cr_XmlFileType { CR_XMLFILE_PRIMARY, CR_XMLFILE_FILELISTS, CR_XMLFILE_FILELISTS_EXT, CR_XMLFILE_OTHER, CR_XMLFILE_PRESTODELTA, CR_XMLFILE_UPDATEINFO, CR_XMLFILE_SENTINEL }

## Functions
cr_XmlFile * | cr_xmlfile_sopen (const char *filename, cr_XmlFileType type, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)
int | cr_xmlfile_set_num_of_pkgs (cr_XmlFile *f, long num, GError **err)
int | cr_xmlfile_add_pkg (cr_XmlFile *f, cr_Package *pkg, GError **err)
int | cr_xmlfile_add_chunk (cr_XmlFile *f, const char *chunk, GError **err)
int | cr_xmlfile_close (cr_XmlFile *f, GError **err)
void | cr_rewrite_header_package_count (gchar *original_filename, cr_CompressionType xml_compression, int package_count, int task_count, cr_ContentStat *file_stat, gchar *zck_dict_file, GError **err)

## Detailed Description

## Macro Definition Documentation

## ◆ cr_xmlfile_open

#define cr_xmlfile_open | ( |  | FILENAME,
|  |  | TYPE,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, TYPE, COMTYPE, NULL, ERR)

Open a new XML file with stats. Note: Opened file must not exists! This function cannot open existing file!.

Parameters

  FILENAME | Filename.
  TYPE | Type of XML file.
  COMTYPE | Type of used compression.
  ERR | **GError

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 186 of file xml_file.h.

## ◆ cr_xmlfile_open_filelists

#define cr_xmlfile_open_filelists | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_open(FILENAME, CR_XMLFILE_FILELISTS, COMTYPE, ERR)

Open a new filelists XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of used compression.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 88 of file xml_file.h.

## ◆ cr_xmlfile_open_filelists_ext

#define cr_xmlfile_open_filelists_ext | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_open(FILENAME, CR_XMLFILE_FILELISTS_EXT, COMTYPE, ERR)

Open a new filelists-ext XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of used compression.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 97 of file xml_file.h.

## ◆ cr_xmlfile_open_other

#define cr_xmlfile_open_other | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_open(FILENAME, CR_XMLFILE_OTHER, COMTYPE, ERR)

Open a new other XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of used compression.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 126 of file xml_file.h.

## ◆ cr_xmlfile_open_prestodelta

#define cr_xmlfile_open_prestodelta | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_open(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, ERR)

Open a new prestodelta XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of used compression.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 145 of file xml_file.h.

## ◆ cr_xmlfile_open_primary

#define cr_xmlfile_open_primary | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_open(FILENAME, CR_XMLFILE_PRIMARY, COMTYPE, ERR)

Open a new primary XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 69 of file xml_file.h.

## ◆ cr_xmlfile_open_updateinfo

#define cr_xmlfile_open_updateinfo | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | ERR
| ) |  | cr_xmlfile_open(FILENAME, CR_XMLFILE_UPDATEINFO, COMTYPE, ERR)

Open a new updateinfo XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of used compression.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 164 of file xml_file.h.

## ◆ cr_xmlfile_sopen_filelists

#define cr_xmlfile_sopen_filelists | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | STAT,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, CR_XMLFILE_FILELISTS, COMTYPE, STAT, ERR)

Open a new filelists XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  STAT | cr_ContentStat object or NULL.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 107 of file xml_file.h.

## ◆ cr_xmlfile_sopen_filelists_ext

#define cr_xmlfile_sopen_filelists_ext | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | STAT,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, CR_XMLFILE_FILELISTS_EXT, COMTYPE, STAT, ERR)

Open a new filelists-ext XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  STAT | cr_ContentStat object or NULL.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 117 of file xml_file.h.

## ◆ cr_xmlfile_sopen_other

#define cr_xmlfile_sopen_other | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | STAT,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, CR_XMLFILE_OTHER, COMTYPE, STAT, ERR)

Open a new other XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  STAT | cr_ContentStat object or NULL.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 136 of file xml_file.h.

## ◆ cr_xmlfile_sopen_prestodelta

#define cr_xmlfile_sopen_prestodelta | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | STAT,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, STAT, ERR)

Open a new prestodelta XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  STAT | cr_ContentStat object or NULL.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 155 of file xml_file.h.

## ◆ cr_xmlfile_sopen_primary

#define cr_xmlfile_sopen_primary | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | STAT,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRIMARY, COMTYPE, STAT, ERR)

Open a new primary XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  STAT | cr_ContentStat object or NULL.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 79 of file xml_file.h.

## ◆ cr_xmlfile_sopen_updateinfo

#define cr_xmlfile_sopen_updateinfo | ( |  | FILENAME,
|  |  | COMTYPE,
|  |  | STAT,
|  |  | ERR
| ) |  | cr_xmlfile_sopen(FILENAME, CR_XMLFILE_UPDATEINFO, COMTYPE, STAT, ERR)

Open a new updateinfo XML file.

Parameters

  FILENAME | Filename.
  COMTYPE | Type of compression.
  STAT | cr_ContentStat object or NULL.
  ERR | GError **

Returns
  Opened cr_XmlFile or NULL on error

Definition at line 174 of file xml_file.h.

## Enumeration Type Documentation

## ◆ cr_XmlFileType

enum cr_XmlFileType

Supported types of xml files

Enumerator
CR_XMLFILE_PRIMARY | primary.xml
CR_XMLFILE_FILELISTS | filelists.xml
CR_XMLFILE_FILELISTS_EXT | filelists-ext.xml
CR_XMLFILE_OTHER | other.xml
CR_XMLFILE_PRESTODELTA | prestodelta.xml
CR_XMLFILE_UPDATEINFO | updateinfo.xml
CR_XMLFILE_SENTINEL | sentinel of the list

Definition at line 38 of file xml_file.h.

## Function Documentation

## ◆ cr_rewrite_header_package_count()

void cr_rewrite_header_package_count | ( | gchar * | original_filename,
|  | cr_CompressionType | xml_compression,
|  | int | package_count,
|  | int | task_count,
|  | cr_ContentStat * | file_stat,
|  | gchar * | zck_dict_file,
|  | GError ** | err
| ) |  |

Rewrite package count field in repodata header in xml file. In order to do this we have to decompress and after the change compress the whole file again, so entirely new file is created.

Parameters

  original_filename | Current file with wrong value in header
  package_count | Actual package count (desired value in header)
  task_count | Task count (current value in header)
  file_stat | cr_ContentStat for stats of the new file, it will be modified
  zck_dict_file | Optional path to zck dictionary
  err | **GError

## ◆ cr_xmlfile_add_chunk()

int cr_xmlfile_add_chunk | ( | cr_XmlFile * | f,
|  | const char * | chunk,
|  | GError ** | err
| ) |  |

Add (write) string with XML chunk into the file. Note: Because of writing, in case of multithreaded program, should be guarded by locks, this function could be much more effective than cr_xml_file_add_pkg(). In case of _add_pkg() function, creating of string with xml chunk is done in a critical section. In _add_chunk() function, you could just dump XML whenever you want and in the critical section do only writting.

Parameters

  f | An opened cr_XmlFile
  chunk | String with XML chunk.
  err | **GError

Returns
  cr_Error code

## ◆ cr_xmlfile_add_pkg()

int cr_xmlfile_add_pkg | ( | cr_XmlFile * | f,
|  | cr_Package * | pkg,
|  | GError ** | err
| ) |  |

Add package to the xml file.

Parameters

  f | An opened cr_XmlFile
  pkg | Package object.
  err | **GError

Returns
  cr_Error code

## ◆ cr_xmlfile_close()

int cr_xmlfile_close | ( | cr_XmlFile * | f,
|  | GError ** | err
| ) |  |

Close an opened cr_XmlFile.

Parameters

  f | An opened cr_XmlFile
  err | **GError

Returns
  cr_Error code

## ◆ cr_xmlfile_set_num_of_pkgs()

int cr_xmlfile_set_num_of_pkgs | ( | cr_XmlFile * | f,
|  | long | num,
|  | GError ** | err
| ) |  |

Set total number of packages that will be in the file. This number must be set before any write operation (cr_xml_add_pkg, cr_xml_file_add_chunk, ..).

Parameters

  f | An opened cr_XmlFile
  num | Total number of packages in the file.
  err | **GError

Returns
  cr_Error code

## ◆ cr_xmlfile_sopen()

cr_XmlFile* cr_xmlfile_sopen | ( | const char * | filename,
|  | cr_XmlFileType | type,
|  | cr_CompressionType | comtype,
|  | cr_ContentStat * | stat,
|  | GError ** | err
| ) |  |

Open a new XML file. Note: Opened file must not exists! This function cannot open existing file!.

Parameters

  filename | Filename.
  type | Type of XML file.
  comtype | Type of used compression.
  stat | pointer to cr_ContentStat or NULL
  err | **GError

Returns
  Opened cr_XmlFile or NULL on error