createrepo_c library  0.9.1
C library for metadata manipulation
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)
 

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_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_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_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)
 

Detailed Description

Macro Definition Documentation

#define CR_CB_RET_ERR   1

Return value for callbacks signalizing error

Definition at line 38 of file xml_parser.h.

#define CR_CB_RET_OK   0

Return value for callbacks signalizing success

Definition at line 37 of file xml_parser.h.

Typedef Documentation

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

Callback for XML parser wich 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
pkgPackage that will be populated.
pkgIdpkgId (hash) of the new package (in case of filelists.xml or other.xml) or package type ("rpm" in case of primary.xml).
nameName of the new package.
archArch of the new package.
cbdataUser data.
errGError **
Returns
CR_CB_RET_OK (0) or CR_CB_RET_ERR (1) - stops the parsing

Definition at line 68 of file xml_parser.h.

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

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

Parameters
pkgCurrently parsed package.
cbdataUser data.
errGError **
Returns
CR_CB_RET_OK (0) or CR_CB_RET_ERR (1) - stops the parsing

Definition at line 81 of file xml_parser.h.

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
typeType of warning
msgWarning msg. The message is destroyed after the call. If you want touse the message later, you have to copy it.
cbdataUser data.
errGError **
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

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

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.xml. File could be compressed.

Parameters
pathPath to filelists.xml
newpkgcbCallback 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_dataUser data for the newpkgcb.
pkgcbPackage callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
pkgcb_dataUser data for the pkgcb.
warningcbCallback for warning messages.
warningcb_dataUser data for the warningcb.
errGError **
Returns
cr_Error code.
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
pathPath to other.xml
newpkgcbCallback 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_dataUser data for the newpkgcb.
pkgcbPackage callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
pkgcb_dataUser data for the pkgcb.
warningcbCallback for warning messages.
warningcb_dataUser data for the warningcb.
errGError **
Returns
cr_Error code.
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
pathPath to filelists.xml
newpkgcbCallback 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_dataUser data for the newpkgcb.
pkgcbPackage callback. (Called when complete package xml chunk is parsed.). Could be NULL if newpkgcb is not NULL.
pkgcb_dataUser data for the pkgcb.
warningcbCallback for warning messages.
warningcb_dataUser data for the warningcb.
do_files0 - Ignore file tags in primary.xml.
errGError **
Returns
cr_Error code.
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
pathPath to repomd.xml
repomdcr_Repomd object.
warningcbCallback for warning messages.
warningcb_dataUser data for the warningcb.
errGError **
Returns
cr_Error code.
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
pathPath to updateinfo.xml
updateinfocr_UpdateInfo object.
warningcbCallback for warning messages.
warningcb_dataUser data for the warningcb.
errGError **
Returns
cr_Error code.