xml_parser: Add suport for warnings about weird stuff in xml
authorTomas Mlcoch <tmlcoch@redhat.com>
Wed, 11 Sep 2013 11:59:44 +0000 (13:59 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Wed, 11 Sep 2013 11:59:44 +0000 (13:59 +0200)
src/load_metadata.c

index 01a0269bf929f2b458c1ec130697971982df28b1..522863d11407649713c2647213d10789fbfc4fc4 100644 (file)
@@ -138,6 +138,18 @@ typedef struct {
     GHashTable      *pkglist_ht;
 } cr_CbData;
 
+static int
+warning_cb(cr_XmlParserWarningType type,
+           char *msg,
+           void *cbdata,
+           GError **err)
+{
+    CR_UNUSED(type);
+    CR_UNUSED(err);
+
+    g_warning("%s: %s", cbdata, msg);
+}
+
 static int
 primary_newpkgcb(cr_Package **pkg,
          const char *pkgId,
@@ -218,7 +230,7 @@ newpkgcb(cr_Package **pkg,
 
     *pkg = g_hash_table_lookup(cb_data->ht, pkgId);
 
-    if (cb_data->chunk) {
+    if (*pkg && cb_data->chunk) {
         assert(!(*pkg)->chunk);
         (*pkg)->chunk = cb_data->chunk;
     }
@@ -265,8 +277,8 @@ cr_load_xml_files(GHashTable *hashtable,
                          &cb_data,
                          primary_pkgcb,
                          &cb_data,
-                         NULL,
-                         NULL,
+                         warning_cb,
+                         "Primary XML parser",
                          (filelists_xml_path) ? 0 : 1,
                          &tmp_err);
     if (tmp_err) {
@@ -282,8 +294,8 @@ cr_load_xml_files(GHashTable *hashtable,
                                &cb_data,
                                pkgcb,
                                &cb_data,
-                               NULL,
-                               NULL,
+                               warning_cb,
+                               "Filelists XML parser",
                                &tmp_err);
         if (tmp_err) {
             int code = tmp_err->code;
@@ -299,8 +311,8 @@ cr_load_xml_files(GHashTable *hashtable,
                            &cb_data,
                            pkgcb,
                            &cb_data,
-                           NULL,
-                           NULL,
+                           warning_cb,
+                           "Other XML parser",
                            &tmp_err);
         if (tmp_err) {
             int code = tmp_err->code;