#include <glib.h>
#include <glib/gprintf.h>
#include <assert.h>
+#include <errno.h>
#include "error.h"
#include "xml_parser.h"
#include "xml_parser_internal.h"
return ret;
}
+gint64
+cr_xml_parser_strtoll(cr_ParserData *pd,
+ const char *nptr,
+ unsigned int base)
+{
+ gint64 val;
+ char *endptr;
+
+ assert(pd);
+ assert(base <= 36 && base != 1);
+
+ if (!nptr)
+ return 0;
+
+ val = g_ascii_strtoll(nptr, &endptr, base);
+
+ if ((val == G_MAXINT64 || val == G_MININT64) && errno == ERANGE)
+ cr_xml_parser_warning(pd, CR_XML_WARNING_BADATTRVAL,
+ "Correct integer value \"%s\" caused overflow", nptr);
+ else if (val == 0 && endptr)
+ cr_xml_parser_warning(pd, CR_XML_WARNING_BADATTRVAL,
+ "Conversion of \"%s\" to integer failed", nptr);
+
+ return val;
+}
+
int
cr_newpkgcb(cr_Package **pkg,
const char *pkgId,
cr_Package *pkg; /*!<
The package which is currently loaded. */
- /* Filelists related stuff */
+ /* Primary related stuff */
+
+ int do_files; /*!<
+ If == 0 then parser will ignore files elements in the primary.xml.
+ This is useful when you are inteding parse primary.xml as well as
+ filelists.xml. In this case files will be filled from filelists.xml.
+ If you are inteding parse only the primary.xml then it coud be useful
+ to parse files in primary.
+ If you parse files from both a primary.xml and a filelists.xml
+ then some files in package object will be duplicated! */
+
+ /* Filelists + Primary related stuff */
+
+ cr_FileType last_file_type;
+
+ /* Other related stuff */
+
+ cr_ChangelogEntry *changelog;
- int last_file_type;
} cr_ParserData;
/** Malloc and initialize common part of XML parser data.
const char *msg,
...);
+/** strtoll with ability to call warning cb if error during conversion.
+ */
+gint64 cr_xml_parser_strtoll(cr_ParserData *pd,
+ const char *nptr,
+ unsigned int base);
+
/** Default callback for the new package.
*/
int cr_newpkgcb(cr_Package **pkg,