createrepo_c library 1.2.1 C library for metadata manipulation

Macros | Typedefs | Enumerations | Functions
XML parser API.

## Macros
#define | CR_CB_RET_OK 0
#define | CR_CB_RET_ERR 1

## Typedefs
typedef int(* | cr_XmlParserNewPkgCb) (cr_Package **pkg, const char *pkgId, const char *name, const char *arch, void *cbdata, GError **err)
typedef int(* | cr_XmlParserPkgCb) (cr_Package *pkg, void *cbdata, GError **err)
typedef int(* | cr_XmlParserWarningCb) (cr_XmlParserWarningType type, char *msg, void *cbdata, GError **err)
typedef struct _cr_PkgIterator | cr_PkgIterator

## Enumerations
enum | cr_XmlParserWarningType { CR_XML_WARNING_UNKNOWNTAG, CR_XML_WARNING_MISSINGATTR, CR_XML_WARNING_UNKNOWNVAL, CR_XML_WARNING_BADATTRVAL, CR_XML_WARNING_MISSINGVAL, CR_XML_WARNING_BADMDTYPE, CR_XML_WARNING_SENTINEL }

## Functions
int | cr_xml_parse_primary (const char *path, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserPkgCb pkgcb, void *pkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, int do_files, GError **err)
int | cr_xml_parse_primary_snippet (const char *xml_string, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserPkgCb pkgcb, void *pkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, int do_files, GError **err)
int | cr_xml_parse_filelists (const char *path, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserPkgCb pkgcb, void *pkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
int | cr_xml_parse_filelists_snippet (const char *xml_string, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserPkgCb pkgcb, void *pkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
int | cr_xml_parse_other (const char *path, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserPkgCb pkgcb, void *pkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
int | cr_xml_parse_other_snippet (const char *xml_string, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserPkgCb pkgcb, void *pkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
int | cr_xml_parse_repomd (const char *path, cr_Repomd *repomd, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
int | cr_xml_parse_updateinfo (const char *path, cr_UpdateInfo *updateinfo, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
cr_PkgIterator * | cr_PkgIterator_new (const char *primary_path, const char *filelists_path, const char *other_path, cr_XmlParserNewPkgCb newpkgcb, void *newpkgcb_data, cr_XmlParserWarningCb warningcb, void *warningcb_data, GError **err)
cr_Package * | cr_PkgIterator_parse_next (cr_PkgIterator *iter, GError **err)
void | cr_PkgIterator_free (cr_PkgIterator *iter, GError **err)
gboolean | cr_PkgIterator_is_finished (cr_PkgIterator *iter)

## Detailed Description

## Macro Definition Documentation

## ◆ CR_CB_RET_ERR

#define CR_CB_RET_ERR 1

Return value for callbacks signalizing error

Definition at line 38 of file xml_parser.h.

## ◆ CR_CB_RET_OK

#define CR_CB_RET_OK 0

Return value for callbacks signalizing success

Definition at line 37 of file xml_parser.h.

## Typedef Documentation

## ◆ cr_XmlParserNewPkgCb

typedef int(* cr_XmlParserNewPkgCb) (cr_Package **pkg, const char *pkgId, const char *name, const char *arch, void *cbdata, GError **err)

Callback for XML parser which is called when a new package object parsing is started. This function has to set *pkg to package object which will be populated by parser. The object could be empty, or already partially filled (by other XML parsers) package object. If the pointer is set to NULL, current package will be skiped. Note: For the primary.xml file pkgId, name and arch are NULL!

Parameters

  pkg | Package that will be populated.
  pkgId | pkgId (hash) of the new package (in case of filelists.xml or other.xml) or package type ("rpm" in case of primary.xml).
  name | Name of the new package.
  arch | Arch of the new package.
  cbdata | User data.
  err | GError **

Returns
  CR_CB_RET_OK (0) or CR_CB_RET_ERR (1) - stops the parsing

Definition at line 68 of file xml_parser.h.

## ◆ cr_XmlParserPkgCb

typedef int(* cr_XmlParserPkgCb) (cr_Package *pkg, void *cbdata, GError **err)

Callback for XML parser which is called when a package element is parsed.

Parameters

  pkg | Currently parsed package.
  cbdata | User data.
  err | GError **

Returns
  CR_CB_RET_OK (0) or CR_CB_RET_ERR (1) - stops the parsing

Definition at line 81 of file xml_parser.h.

## ◆ cr_XmlParserWarningCb

typedef int(* cr_XmlParserWarningCb) (cr_XmlParserWarningType type, char *msg, void *cbdata, GError **err)

Callback for XML parser warnings. All reported warnings are non-fatal, and ignored by default. But if callback return CR_CB_RET_ERR instead of CR_CB_RET_OK then parsing is immediately interrupted.

Parameters

  type | Type of warning
  msg | Warning msg. The message is destroyed after the call. If you want to use the message later, you have to copy it.
  cbdata | User data.
  err | GError **

Returns
  CR_CB_RET_OK (0) or CR_CB_RET_ERR (1) - stops the parsing

Definition at line 95 of file xml_parser.h.

## Enumeration Type Documentation

## ◆ cr_XmlParserWarningType

enum cr_XmlParserWarningType

Type of warnings reported by parsers by the warning callback.

Enumerator
CR_XML_WARNING_UNKNOWNTAG | Unknown tag
CR_XML_WARNING_MISSINGATTR | Missing attribute
CR_XML_WARNING_UNKNOWNVAL | Unknown tag or attribute value
CR_XML_WARNING_BADATTRVAL | Bad attribute value
CR_XML_WARNING_MISSINGVAL | Missing tag value
CR_XML_WARNING_BADMDTYPE | Bad metadata type (expected mandatory tag was not found)

Definition at line 42 of file xml_parser.h.

## Function Documentation

## ◆ cr_xml_parse_filelists()

int cr_xml_parse_filelists | ( | const char * | path,
|  | cr_XmlParserNewPkgCb | newpkgcb,
|  | void * | newpkgcb_data,
|  | cr_XmlParserPkgCb | pkgcb,
|  | void * | pkgcb_data,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | GError ** | err
| ) |  |

Parse filelists[_ext].xml. File could be compressed.

Parameters

  path | Path to filelists[_ext].xml
  newpkgcb | Callback for new package (Called when new package xml chunk is found and package object to store the data is needed). If NULL cr_newpkgcb is used.
  newpkgcb_data | User data for the newpkgcb.
  pkgcb | Package callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
  pkgcb_data | User data for the pkgcb.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_filelists_snippet()

int cr_xml_parse_filelists_snippet | ( | const char * | xml_string,
|  | cr_XmlParserNewPkgCb | newpkgcb,
|  | void * | newpkgcb_data,
|  | cr_XmlParserPkgCb | pkgcb,
|  | void * | pkgcb_data,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | GError ** | err
| ) |  |

Parse string snippet of filelists[_ext] xml repodata. Snippet cannot contain root xml element <filelists[_ext]>. It contains only <package> elemetns.

Parameters

  xml_string | String containg filelists[_ext] xml data
  newpkgcb | Callback for new package (Called when new package xml chunk is found and package object to store the data is needed). If NULL cr_newpkgcb is used.
  newpkgcb_data | User data for the newpkgcb.
  pkgcb | Package callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
  pkgcb_data | User data for the pkgcb.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_other()

int cr_xml_parse_other | ( | const char * | path,
|  | cr_XmlParserNewPkgCb | newpkgcb,
|  | void * | newpkgcb_data,
|  | cr_XmlParserPkgCb | pkgcb,
|  | void * | pkgcb_data,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | GError ** | err
| ) |  |

Parse other.xml. File could be compressed.

Parameters

  path | Path to other.xml
  newpkgcb | Callback for new package (Called when new package xml chunk is found and package object to store the data is needed). If NULL cr_newpkgcb is used.
  newpkgcb_data | User data for the newpkgcb.
  pkgcb | Package callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
  pkgcb_data | User data for the pkgcb.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_other_snippet()

int cr_xml_parse_other_snippet | ( | const char * | xml_string,
|  | cr_XmlParserNewPkgCb | newpkgcb,
|  | void * | newpkgcb_data,
|  | cr_XmlParserPkgCb | pkgcb,
|  | void * | pkgcb_data,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | GError ** | err
| ) |  |

Parse string snippet of other xml repodata. Snippet cannot contain root xml element <otherdata>. It contains only <package> elemetns.

Parameters

  xml_string | String containg other xml data
  newpkgcb | Callback for new package (Called when new package xml chunk is found and package object to store the data is needed). If NULL cr_newpkgcb is used.
  newpkgcb_data | User data for the newpkgcb.
  pkgcb | Package callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
  pkgcb_data | User data for the pkgcb.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_primary()

int cr_xml_parse_primary | ( | const char * | path,
|  | cr_XmlParserNewPkgCb | newpkgcb,
|  | void * | newpkgcb_data,
|  | cr_XmlParserPkgCb | pkgcb,
|  | void * | pkgcb_data,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | int | do_files,
|  | GError ** | err
| ) |  |

Parse primary.xml. File could be compressed.

Parameters

  path | Path to filelists.xml
  newpkgcb | Callback for new package (Called when new package xml chunk is found and package object to store the data is needed). If NULL cr_newpkgcb is used.
  newpkgcb_data | User data for the newpkgcb.
  pkgcb | Package callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
  pkgcb_data | User data for the pkgcb.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  do_files | 0 - Ignore file tags in primary.xml.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_primary_snippet()

int cr_xml_parse_primary_snippet | ( | const char * | xml_string,
|  | cr_XmlParserNewPkgCb | newpkgcb,
|  | void * | newpkgcb_data,
|  | cr_XmlParserPkgCb | pkgcb,
|  | void * | pkgcb_data,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | int | do_files,
|  | GError ** | err
| ) |  |

Parse string snippet of primary xml repodata. Snippet cannot contain root xml element <metadata>. It contains only <package> elemetns.

Parameters

  xml_string | String containg primary xml data
  newpkgcb | Callback for new package (Called when new package xml chunk is found and package object to store the data is needed). If NULL cr_newpkgcb is used.
  newpkgcb_data | User data for the newpkgcb.
  pkgcb | Package callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
  pkgcb_data | User data for the pkgcb.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  do_files | 0 - Ignore file tags in primary.xml.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_repomd()

int cr_xml_parse_repomd | ( | const char * | path,
|  | cr_Repomd * | repomd,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | GError ** | err
| ) |  |

Parse repomd.xml. File could be compressed.

Parameters

  path | Path to repomd.xml
  repomd | cr_Repomd object.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  err | GError **

Returns
  cr_Error code.

## ◆ cr_xml_parse_updateinfo()

int cr_xml_parse_updateinfo | ( | const char * | path,
|  | cr_UpdateInfo * | updateinfo,
|  | cr_XmlParserWarningCb | warningcb,
|  | void * | warningcb_data,
|  | GError ** | err
| ) |  |

Parse updateinfo.xml. File could be compressed.

Parameters

  path | Path to updateinfo.xml
  updateinfo | cr_UpdateInfo object.
  warningcb | Callback for warning messages.
  warningcb_data | User data for the warningcb.
  err | GError **

Returns
  cr_Error code.