]> wimlib.net Git - wimlib/blobdiff - src/xml.c
Clean up file headers
[wimlib] / src / xml.c
index 03b0b7002f8274e7858f6fc105876a62bb955127..3969202981419befeb8866e294700db5d98e8b80 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -2,23 +2,25 @@
  * xml.c
  *
  * Deals with the XML information in WIM files.  Uses the C library libxml2.
- *
+ */
+
+/*
  * Copyright (C) 2012 Eric Biggers
  *
- * wimlib - Library for working with WIM files 
+ * This file is part of wimlib, a library for working with WIM files.
  *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option) any
- * later version.
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
  *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU Lesser General Public License along
- * with this library; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
 #include "wimlib_internal.h"
@@ -1040,7 +1042,6 @@ void print_image_info(const struct wim_info *wim_info, int image)
        time_t ctime;
        time_t mtime;
 
-       DEBUG("Printing the image info for image %d\n", image);
 
        if (image == WIM_ALL_IMAGES) {
                for (i = 1; i <= wim_info->num_images; i++)
@@ -1102,7 +1103,8 @@ int read_xml_data(FILE *fp, const struct resource_entry *res, u8 **xml_data_ret,
        xmlNode *root;
        int ret;
 
-       DEBUG("XML data is %"PRIu64" bytes long.\n", (u64)res->size);
+       DEBUG("XML data is %"PRIu64" bytes at offset %"PRIu64"\n", 
+                       (u64)res->size, res->offset);
 
        if (resource_is_compressed(res)) {
                ERROR("XML data is supposed to be uncompressed!\n");
@@ -1182,14 +1184,18 @@ err0:
 
 /* 
  * Writes XML data to a WIM file.
+ *
+ * If @total_bytes is non-zero, it specifies what to write to the TOTALBYTES
+ * element in the XML data.  If zero, TOTALBYTES is given the default value of
+ * the offset of the XML data.
  */
-int write_xml_data(const struct wim_info *wim_info, int image, FILE *out)
+int write_xml_data(const struct wim_info *wim_info, int image, FILE *out, 
+                  u64 total_bytes)
 {
        xmlBuffer     *buf;
        xmlTextWriter *writer;
        char          *utf16_str;
        int ret;
-       off_t total_bytes;
        int num_images;
        int i;
        const xmlChar *content;
@@ -1202,13 +1208,15 @@ int write_xml_data(const struct wim_info *wim_info, int image, FILE *out)
                         image <= wim_info->num_images));
 
        /* The contents of the <TOTALBYTES> element in the XML data, under the
-        * <WIM> element not the <IMAGE> element, is the size of the WIM file
-        * excluding the XML data and integrity table.  Which is the current
-        * offset, since the XML data goes at the end of the WIM file before the
-        * integrity table. */
-       total_bytes = ftello(out);
-       if (total_bytes == -1)
-               return WIMLIB_ERR_WRITE;
+        * <WIM> element not the <IMAGE> element, is (for non-spit WIMs) the
+        * size of the WIM file excluding the XML data and integrity table,
+        * which is the current offset, since the XML data goes at the end of
+        * the WIM file before the integrity table. */
+       if (total_bytes == 0) {
+               total_bytes = ftello(out);
+               if (total_bytes == (u64)-1)
+                       return WIMLIB_ERR_WRITE;
+       }
 
        DEBUG("Creating XML buffer and text writer\n");
        buf = xmlBufferCreate();