XML parser API.

Defines

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

Define Documentation

#define CR_CB_RET_ERR   1

Return value for callbacks signalizing error

Definition at line 36 of file xml_parser.h.

#define CR_CB_RET_OK   0

Return value for callbacks signalizing success

Definition at line 35 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:
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 65 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:
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 78 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:
type Type of warning
msg Warning msg. The message is destroyed after the call. If you want touse 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 92 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

Definition at line 40 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:
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.
err GError **
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:
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.
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.
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.

Generated on 22 Oct 2014 for createrepo_c library by  doxygen 1.6.1