CR_XML_FILELISTS_NS"\" packages=\"%d\">\n"
#define XML_OTHER_HEADER XML_HEADER"<otherdata xmlns=\"" \
CR_XML_OTHER_NS"\" packages=\"%d\">\n"
+#define XML_PRESTODELTA_HEADER XML_HEADER"<prestodelta>\n"
#define XML_PRIMARY_FOOTER "</metadata>"
#define XML_FILELISTS_FOOTER "</filelists>"
#define XML_OTHER_FOOTER "</otherdata>"
+#define XML_PRESTODELTA_FOOTER "</prestodelta>"
cr_XmlFile *
cr_xmlfile_sopen(const char *filename,
cr_xmlfile_set_num_of_pkgs(cr_XmlFile *f, long num, GError **err)
{
assert(f);
- assert(f->header == 0);
- assert(num >= 0);
assert(!err || *err == NULL);
+ if (f->header != 0) {
+ g_set_error(err, CR_XML_FILE_ERROR, CRE_BADARG,
+ "Header was already written");
+ return CRE_BADARG;
+ }
+
+ if (num < 0) {
+ g_set_error(err, CR_XML_FILE_ERROR, CRE_BADARG,
+ "The number must be a positive integer number");
+ return CRE_BADARG;
+ }
+
f->pkgs = num;
return CRE_OK;
}
case CR_XMLFILE_OTHER:
xml_header = XML_OTHER_HEADER;
break;
+ case CR_XMLFILE_PRESTODELTA:
+ xml_header = XML_PRESTODELTA_HEADER;
+ break;
default:
g_critical("%s: Bad file type", __func__);
assert(0);
case CR_XMLFILE_OTHER:
xml_footer = XML_OTHER_FOOTER;
break;
+ case CR_XMLFILE_PRESTODELTA:
+ xml_footer = XML_PRESTODELTA_FOOTER;
+ break;
default:
g_critical("%s: Bad file type", __func__);
assert(0);
CR_XMLFILE_PRIMARY, /*!< primary.xml */
CR_XMLFILE_FILELISTS, /*!< filelists.xml */
CR_XMLFILE_OTHER, /*!< other.xml */
+ CR_XMLFILE_PRESTODELTA, /*!< prestodelta.xml */
CR_XMLFILE_SENTINEL, /*!< sentinel of the list */
} cr_XmlFileType;
#define cr_xmlfile_sopen_other(FILENAME, COMTYPE, STAT, ERR) \
cr_xmlfile_sopen(FILENAME, CR_XMLFILE_OTHER, COMTYPE, STAT, ERR)
+/** Open a new prestodelta XML file.
+ * @param FILENAME Filename.
+ * @param COMTYPE Type of used compression.
+ * @param ERR GError **
+ * @return Opened cr_XmlFile or NULL on error
+ */
+#define cr_xmlfile_open_prestodelta(FILENAME, COMTYPE, ERR) \
+ cr_xmlfile_open(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, ERR)
+
+/** Open a new prestodelta XML file.
+ * @param FILENAME Filename.
+ * @param COMTYPE Type of compression.
+ * @param STAT cr_ContentStat object or NULL.
+ * @param ERR GError **
+ * @return Opened cr_XmlFile or NULL on error
+ */
+#define cr_xmlfile_sopen_prestodelta(FILENAME, COMTYPE, STAT, ERR) \
+ cr_xmlfile_sopen(FILENAME, CR_XMLFILE_PRESTODELTA, COMTYPE, STAT, ERR)
+
+
/** Open a new XML file with stats.
* Note: Opened file must not exists! This function cannot
* open existing file!.