+/* A struct wim_info structure corresponds to the entire XML data for a WIM file. */
+struct wim_info {
+ u64 total_bytes;
+ int num_images;
+ /* Array of `struct image_info's, one for each image in the WIM that is
+ * mentioned in the XML data. */
+ struct image_info *images;
+};
+
+struct xml_string_spec {
+ const char *name;
+ size_t offset;
+};
+
+#define ELEM(STRING_NAME, MEMBER_NAME) \
+ {STRING_NAME, offsetof(struct image_info, MEMBER_NAME)}
+static const struct xml_string_spec
+image_info_xml_string_specs[] = {
+ ELEM("NAME", name),
+ ELEM("DESCRIPTION", description),
+ ELEM("DISPLAYNAME", display_name),
+ ELEM("DISPLAYDESCRIPTION", display_description),
+ ELEM("FLAGS", flags),
+};
+#undef ELEM
+
+#define ELEM(STRING_NAME, MEMBER_NAME) \
+ {STRING_NAME, offsetof(struct windows_info, MEMBER_NAME)}
+static const struct xml_string_spec
+windows_info_xml_string_specs[] = {
+ ELEM("PRODUCTNAME", product_name),
+ ELEM("EDITIONID", edition_id),
+ ELEM("INSTALLATIONTYPE", installation_type),
+ ELEM("HAL", hal),
+ ELEM("PRODUCTTYPE", product_type),
+ ELEM("PRODUCTSUITE", product_suite),
+};
+#undef ELEM
+
+u64
+wim_info_get_total_bytes(const struct wim_info *info)
+{
+ if (info)
+ return info->total_bytes;
+ else
+ return 0;
+}
+
+u64
+wim_info_get_image_hard_link_bytes(const struct wim_info *info, int image)
+{
+ 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)
+{
+ if (info)
+ return info->images[image - 1].total_bytes;
+ else
+ return 0;
+}
+
+unsigned
+wim_info_get_num_images(const struct wim_info *info)
+{
+ if (info)
+ return info->num_images;
+ else
+ return 0;
+}
+
+void
+wim_info_set_wimboot(struct wim_info *info, int image, bool value)
+{
+ info->images[image - 1].wimboot = value;
+}
+
+bool
+wim_info_get_wimboot(const struct wim_info *info, int image)
+{
+ return info->images[image - 1].wimboot;
+}
+
+u64
+wim_info_get_windows_build_number(const struct wim_info *info, int image)
+{
+ return info->images[image - 1].windows_info.windows_version.build;
+}
+
+/* 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