]> wimlib.net Git - wimlib/blobdiff - src/xml.c
xml.c: Fix writing <WINDOWS> element
[wimlib] / src / xml.c
index cd98a79584ce06d1a7ea7c1d276b17631dcb61e3..5258aaf4cfacb7275e1d8203195668b09680c20d 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -132,42 +132,68 @@ windows_info_xml_string_specs[] = {
 u64
 wim_info_get_total_bytes(const struct wim_info *info)
 {
-       if (!info)
+       if (info)
+               return info->total_bytes;
+       else
                return 0;
-       return info->total_bytes;
 }
 
 u64
 wim_info_get_image_hard_link_bytes(const struct wim_info *info, int image)
 {
-       return info->images[image - 1].hard_link_bytes;
+       if (info)
+               return info->images[image - 1].hard_link_bytes;
+       else
+               return 0;
 }
 
 u64
 wim_info_get_image_total_bytes(const struct wim_info *info, int image)
 {
-       return info->images[image - 1].total_bytes;
+       if (info)
+               return info->images[image - 1].total_bytes;
+       else
+               return 0;
 }
 
 unsigned
 wim_info_get_num_images(const struct wim_info *info)
 {
-       return info->num_images;
+       if (info)
+               return info->num_images;
+       else
+               return 0;
 }
 
+/* Architecture constants are from w64 mingw winnt.h  */
+#define PROCESSOR_ARCHITECTURE_INTEL 0
+#define PROCESSOR_ARCHITECTURE_MIPS 1
+#define PROCESSOR_ARCHITECTURE_ALPHA 2
+#define PROCESSOR_ARCHITECTURE_PPC 3
+#define PROCESSOR_ARCHITECTURE_SHX 4
+#define PROCESSOR_ARCHITECTURE_ARM 5
+#define PROCESSOR_ARCHITECTURE_IA64 6
+#define PROCESSOR_ARCHITECTURE_ALPHA64 7
+#define PROCESSOR_ARCHITECTURE_MSIL 8
+#define PROCESSOR_ARCHITECTURE_AMD64 9
+#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
+
 /* Returns a statically allocated string that is a string representation of the
  * architecture number. */
 static const tchar *
 get_arch(int arch)
 {
        switch (arch) {
-       case 0:
+       case PROCESSOR_ARCHITECTURE_INTEL:
                return T("x86");
-       case 6:
+       case PROCESSOR_ARCHITECTURE_MIPS:
+               return T("MIPS");
+       case PROCESSOR_ARCHITECTURE_ARM:
+               return T("ARM");
+       case PROCESSOR_ARCHITECTURE_IA64:
                return T("ia64");
-       case 9:
+       case PROCESSOR_ARCHITECTURE_AMD64:
                return T("x86_64");
-       /* XXX Are there other arch values? */
        default:
                return T("unknown");
        }
@@ -726,7 +752,11 @@ xml_write_windows_version(xmlTextWriter *writer,
        if (rc < 0)
                return rc;
 
-       return xmlTextWriterEndElement(writer); /* </VERSION> */
+       rc = xmlTextWriterEndElement(writer); /* </VERSION> */
+       if (rc < 0)
+               return rc;
+
+       return 0;
 }
 
 /* Writes the information contained in a `struct windows_info' to the XML
@@ -776,16 +806,19 @@ xml_write_windows_info(xmlTextWriter *writer,
 
        if (windows_info->windows_version_exists) {
                rc = xml_write_windows_version(writer, &windows_info->windows_version);
-               if (rc < 0)
+               if (rc)
                        return rc;
        }
 
-       rc = xml_write_string(writer, "SYSTEMROOT",
-                             windows_info->system_root);
+       rc = xml_write_string(writer, "SYSTEMROOT", windows_info->system_root);
        if (rc)
                return rc;
 
-       return xmlTextWriterEndElement(writer); /* </WINDOWS> */
+       rc = xmlTextWriterEndElement(writer); /* </WINDOWS> */
+       if (rc < 0)
+               return rc;
+
+       return 0;
 }
 
 /* Writes a time element to the XML document being constructed in memory. */
@@ -871,6 +904,7 @@ xml_write_image_info(xmlTextWriter *writer, const struct image_info *image_info)
        rc = xmlTextWriterEndElement(writer); /* </IMAGE> */
        if (rc < 0)
                return rc;
+
        return 0;
 }
 
@@ -1454,6 +1488,7 @@ out_output_buffer_close:
 out_buffer_free:
        xmlBufferFree(buf);
 out:
+       DEBUG("ret=%d", ret);
        return ret;
 
 out_write_error:
@@ -1489,8 +1524,10 @@ write_wim_xml_data(WIMStruct *wim, int image, u64 total_bytes,
                                             WIMLIB_COMPRESSION_TYPE_NONE,
                                             out_res_entry,
                                             NULL,
-                                            write_resource_flags);
+                                            write_resource_flags,
+                                            &wim->lzx_context);
        FREE(xml_data);
+       DEBUG("ret=%d");
        return ret;
 }