- u64 timestamp = 0;
- xmlNode *child;
-
- if (!node)
- return 0;
- node_for_each_child(node, child) {
- if (node_is_element(child, "HIGHPART"))
- timestamp |= node_get_number(child, 16) << 32;
- else if (node_is_element(child, "LOWPART"))
- timestamp |= node_get_number(child, 16);
- }
- return timestamp;
-}
-
-static int
-tstr_get_utf8(const tchar *tstr, const xmlChar **utf8_ret)
-{
- if (wimlib_mbs_is_utf8) {
- *utf8_ret = (xmlChar *)tstr;
- return 0;
- }
- return tstr_to_utf8_simple(tstr, (char **)utf8_ret);
-}
-
-static void
-tstr_put_utf8(const xmlChar *utf8)
-{
- if (!wimlib_mbs_is_utf8)
- FREE((void *)utf8);
-}
-
-/* Retrieve the text contents of an XML element as a 'tchar' string. If not
- * found or if the text could not be translated, returns NULL. */
-static const tchar *
-node_get_ttext(struct wim_xml_info *info, xmlNode *node)
-{
- const xmlChar *text;
- tchar **ttext_p;
-
- text = node_get_text(node);
-
- if (!text || wimlib_mbs_is_utf8)
- return (const tchar *)text;
-
- ttext_p = &info->strings[info->next_string_idx];
- if (info->num_strings >= ARRAY_LEN(info->strings)) {
- FREE(*ttext_p);
- *ttext_p = NULL;
- }
- if (utf8_to_tstr_simple(text, ttext_p))
- return NULL;
- if (info->num_strings < ARRAY_LEN(info->strings))
- info->num_strings++;
- info->next_string_idx++;
- info->next_string_idx %= ARRAY_LEN(info->strings);
- return *ttext_p;
-}
-
-/* Unlink the specified node from its parent, then free it (recursively). */
-static void
-unlink_and_free_tree(xmlNode *node)
-{
- xmlUnlinkNode(node);
- xmlFreeNode(node);
-}
-
-/* Unlink and free (recursively) all children of the specified node. */
-static void
-unlink_and_free_children(xmlNode *node)
-{
- xmlNode *child;
-
- while ((child = node->last) != NULL)
- unlink_and_free_tree(child);
-}
-
-/* Add the new child element 'replacement' to 'parent', replacing any same-named
- * element that may already exist. */
-static void
-node_replace_child_element(xmlNode *parent, xmlNode *replacement)
-{
- xmlNode *child;
-
- node_for_each_child(parent, child) {
- if (node_is_element(child, replacement->name)) {
- xmlReplaceNode(child, replacement);
- xmlFreeNode(child);
- return;
- }
- }
-
- xmlAddChild(parent, replacement);