Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / client / bug-replay / main.c
index 59615ed..2c4b5cf 100644 (file)
@@ -29,6 +29,7 @@
 #include <glib-object.h>       /* for g_type_init() */
 #include <glib/ghash.h>
 
+#include <captive/client.h>
 #include <captive/libxml.h>
 #include <captive/options.h>
 #include <captive/macros.h>
@@ -95,14 +96,9 @@ CaptiveDirectoryObject *captive_directory_object;
 CaptiveFileObject *captive_file_object;
 GnomeVFSResult errgnomevfsresult;
 struct captive_libxml_string_drop_stack *drop_stack=NULL;
-const xmlChar *xml_object;
+const gchar *xml_object;
 
-       /* Prevent output block buffering if redirecting stdout to file. */
-       setvbuf(stdout,(char *)NULL,_IONBF,0);
-       setvbuf(stderr,(char *)NULL,_IONBF,0);
-
-       /* Initialize GObject subsystem of GLib. */
-       g_type_init();
+       captive_standalone_init();
 
        captive_options_init(&options);
 
@@ -150,6 +146,9 @@ const xmlChar *xml_object;
                        case CAPTIVE_XML_TEXT_READER_NODE_TYPE_COMMENT:
                                break;
 
+                       case CAPTIVE_XML_TEXT_READER_NODE_TYPE_SIGNIFICANT_WHITESPACE:
+                               break;
+
                        case CAPTIVE_XML_TEXT_READER_NODE_TYPE_TEXT:    /* Even empty nodes have some '#text'. */
                                break;
 
@@ -160,23 +159,23 @@ const xmlChar *xml_object;
 const xmlChar *xml_name;
 
                                xml_name=xmlTextReaderName(xml_reader);
-                               /**/ if (!xmlStrcmp(xml_name,"bug")) {  /* root tag */
+                               /**/ if (!xmlStrcmp(xml_name,BAD_CAST "bug")) { /* root tag */
                                        }
-                               else if (!xmlStrcmp(xml_name,"captive")) {
-const xmlChar *xml_captive_version;
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "captive")) {
+const gchar *xml_captive_version;
 
-                                       xml_captive_version=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,"version"));
+                                       xml_captive_version=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,BAD_CAST "version"));
                                        g_assert(xml_captive_version!=NULL);
-                                       g_assert(!xmlStrcmp(xml_captive_version,VERSION));
+                                       g_assert(!strcmp(xml_captive_version,VERSION));
                                        }
-                               else if (!xmlStrcmp(xml_name,"filesystem")) {   /* contains <module/> */
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "filesystem")) {  /* contains <module/> */
                                        module_is_filesystem=TRUE;
                                        }
-                               else if (!xmlStrcmp(xml_name,"load_module")) {  /* contains <module/> */
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "load_module")) { /* contains <module/> */
                                        module_is_filesystem=FALSE;
                                        }
-                               else if (!xmlStrcmp(xml_name,"module")) {
-const xmlChar *xml_module_basename;
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "module")) {
+const gchar *xml_module_basename;
 struct captive_options_module *options_module;
 gboolean errbool;
 
@@ -186,7 +185,7 @@ gboolean errbool;
                                                captive_new(options_module);
                                                options.load_module=g_list_append(options.load_module,options_module);
                                                }
-                                       xml_module_basename=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,"basename"));
+                                       xml_module_basename=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,BAD_CAST "basename"));
                                        g_assert(xml_module_basename!=NULL);
                                        g_assert(strchr(xml_module_basename,'/')==NULL);        /* a bit of security */
                                        errbool=captive_options_module_load(options_module,
@@ -195,13 +194,13 @@ gboolean errbool;
                                        g_assert(errbool==TRUE);
                                        switch (options_module->type) {
                                                case CAPTIVE_OPTIONS_MODULE_TYPE_PE32: {
-const xmlChar *xml_module_md5,*xml_module_length;
+const gchar *xml_module_md5,*xml_module_length;
 
                                                        if (options_module->u.pe32.md5
-                                                                       && (xml_module_md5=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,"version"))))
-                                                               g_assert(!xmlStrcmp(xml_module_md5,options_module->u.pe32.md5));
-                                                       if ((xml_module_length=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,"length"))))
-                                                               g_assert(!xmlStrcmp(xml_module_length,
+                                                                       && (xml_module_md5=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,BAD_CAST "version"))))
+                                                               g_assert(!strcmp(xml_module_md5,options_module->u.pe32.md5));
+                                                       if ((xml_module_length=captive_libxml_string_drop(&drop_stack,xmlTextReaderGetAttribute(xml_reader,BAD_CAST "length"))))
+                                                               g_assert(!strcmp(xml_module_length,
                                                                                captive_printf_alloca("%lu",(unsigned long)options_module->u.pe32.length)));
                                                        } break;
                                                case CAPTIVE_OPTIONS_MODULE_TYPE_GMODULE:
@@ -210,7 +209,7 @@ const xmlChar *xml_module_md5,*xml_module_length;
                                                default: g_assert_not_reached();
                                                }
                                        }
-                               else if (!xmlStrcmp(xml_name,"action")) {
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "action")) {
 int xml_action_depth;
 gboolean action_done,action_preread;
 
@@ -228,14 +227,16 @@ gboolean action_done,action_preread;
                                                switch (xmlTextReaderNodeType(xml_reader)) {
                                                        case CAPTIVE_XML_TEXT_READER_NODE_TYPE_COMMENT:
                                                                break;
+                                                       case CAPTIVE_XML_TEXT_READER_NODE_TYPE_SIGNIFICANT_WHITESPACE:
+                                                               break;
                                                        case CAPTIVE_XML_TEXT_READER_NODE_TYPE_TEXT:    /* Even empty nodes have some '#text'. */
                                                                break;
                                                        case CAPTIVE_XML_TEXT_READER_NODE_TYPE_END: {   /* We do not track tag ends. */
                                                                if ((action_done=(xml_action_depth==xmlTextReaderDepth(xml_reader)))) {
-const xmlChar *xml_name_end;
+const gchar *xml_name_end;
 
                                                                        xml_name_end=captive_libxml_string_drop(&drop_stack,xmlTextReaderName(xml_reader));
-                                                                       g_assert(!xmlStrcmp(xml_name_end,"action"));
+                                                                       g_assert(!strcmp(xml_name_end,"action"));
                                                                        }
                                                                } break;
                                                        case CAPTIVE_XML_TEXT_READER_NODE_TYPE_START: {
@@ -254,7 +255,7 @@ xmlNode *xml_node;
                                                        }
                                                }
                                        }
-                               else if (!xmlStrcmp(xml_name,"media")) {
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "media")) {
 const xmlChar *xml_media_end_name,*xml_media_type;
 
                                        g_assert(options.image_iochannel==NULL);
@@ -262,18 +263,18 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                                        g_assert(CAPTIVE_XML_TEXT_READER_NODE_TYPE_END==xmlTextReaderNodeType(xml_reader));
                                        xml_media_end_name=xmlTextReaderName(xml_reader);
                                        g_assert(xml_media_end_name!=NULL);
-                                       g_assert(!xmlStrcmp(xml_media_end_name,"media"));
+                                       g_assert(!xmlStrcmp(xml_media_end_name,BAD_CAST "media"));
                                        xmlFree((xmlChar *)xml_media_end_name);
-                                       xml_media_type=xmlTextReaderGetAttribute(xml_reader,"type");
+                                       xml_media_type=xmlTextReaderGetAttribute(xml_reader,BAD_CAST "type");
                                        g_assert(xml_media_type!=NULL);
-                                       /**/ if (!xmlStrcmp(xml_media_type,"cdrom"))
+                                       /**/ if (!xmlStrcmp(xml_media_type,BAD_CAST "cdrom"))
                                                options.media=CAPTIVE_OPTION_MEDIA_CDROM;
-                                       else if (!xmlStrcmp(xml_media_type,"disk"))
+                                       else if (!xmlStrcmp(xml_media_type,BAD_CAST "disk"))
                                                options.media=CAPTIVE_OPTION_MEDIA_DISK;
                                        else g_assert_not_reached();
                                        xmlFree((xmlChar *)xml_media_type);
                                        }
-                               else if (!xmlStrcmp(xml_name,"log")) {
+                               else if (!xmlStrcmp(xml_name,BAD_CAST "log")) {
                                        errint=xmlTextReaderNext(xml_reader);
                                        g_assert(errint==1);
                                        preread=TRUE;
@@ -315,7 +316,7 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                captive_libxml_string_drop_flush(&drop_stack);
 
 #define GET_PROP_STRING(prop_name) ({ \
-               const xmlChar *_get_prop_string_r=captive_libxml_string_drop(&drop_stack,xmlGetProp(xml_node,(prop_name))); \
+               const gchar *_get_prop_string_r=captive_libxml_string_drop(&drop_stack,xmlGetProp(xml_node,BAD_CAST (prop_name))); \
                g_assert(_get_prop_string_r!=NULL); \
                _get_prop_string_r; \
                })
@@ -329,14 +330,14 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                object=g_hash_table_lookup(object_hash,xml_object);
                g_assert(object==NULL || G_IS_OBJECT(object));
 
-               if (!xmlStrcmp(xml_node->name,"vfs_new")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "vfs_new")) {
                        g_assert(action_is_first==TRUE);
                        g_assert(captive_vfs_object!=NULL);
                        g_assert(object==NULL);
                        g_hash_table_insert(object_hash,g_strdup(xml_object),captive_vfs_object);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"vfs_commit")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "vfs_commit")) {
                        g_assert(action_is_first==TRUE);
                        g_assert(captive_vfs_object!=NULL);
                        g_assert(object==NULL);
@@ -344,7 +345,7 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                        continue;
                        }
                g_assert(action_is_first==FALSE);
-               if (!xmlStrcmp(xml_node->name,"vfs_close")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "vfs_close")) {
                        g_assert(captive_vfs_object!=NULL);
                        g_assert(CAPTIVE_VFS_OBJECT(object)==captive_vfs_object);
                        errbool=g_hash_table_remove(object_hash,xml_object);    /* g_object_unref() by object_hash_value_destroy_func() */
@@ -352,9 +353,16 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                        continue;
                        }
                g_assert(captive_vfs_object!=NULL);
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "vfs_volume_info_get")) {
+CaptiveVfsVolumeInfo volume_info;
+
+                       errgnomevfsresult=captive_vfs_volume_info_get(captive_vfs_object,&volume_info);
+                       g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
+                       continue;
+                       }
 
                /* DIRECTORY */
-               if (!xmlStrcmp(xml_node->name,"directory_new_open")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "directory_new_open")) {
                        g_assert(object==NULL);
                        errgnomevfsresult=captive_directory_new_open(&captive_directory_object,captive_vfs_object,
                                        GET_PROP_STRING("pathname"));
@@ -363,7 +371,7 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                                g_hash_table_insert(object_hash,g_strdup(xml_object),captive_directory_object);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"directory_new_make")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "directory_new_make")) {
                        g_assert(object==NULL);
                        errgnomevfsresult=captive_directory_new_make(&captive_directory_object,captive_vfs_object,
                                        GET_PROP_STRING("pathname"),
@@ -373,13 +381,13 @@ const xmlChar *xml_media_end_name,*xml_media_type;
                                g_hash_table_insert(object_hash,g_strdup(xml_object),captive_directory_object);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"directory_close")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "directory_close")) {
                        captive_directory_object=CAPTIVE_DIRECTORY_OBJECT(object);
                        errbool=g_hash_table_remove(object_hash,xml_object);    /* g_object_unref() by object_hash_value_destroy_func() */
                        g_assert(errbool==TRUE);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"directory_read")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "directory_read")) {
 GnomeVFSFileInfo file_info;
 
                        captive_directory_object=CAPTIVE_DIRECTORY_OBJECT(object);
@@ -387,7 +395,7 @@ GnomeVFSFileInfo file_info;
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"directory_remove")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "directory_remove")) {
                        captive_directory_object=CAPTIVE_DIRECTORY_OBJECT(object);
                        errgnomevfsresult=captive_directory_remove(captive_directory_object);
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
@@ -395,7 +403,7 @@ GnomeVFSFileInfo file_info;
                        }
 
                /* FILE */
-               if (!xmlStrcmp(xml_node->name,"file_new_open")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_new_open")) {
                        g_assert(object==NULL);
                        errgnomevfsresult=captive_file_new_open(&captive_file_object,captive_vfs_object,
                                        GET_PROP_STRING("pathname"),
@@ -405,7 +413,7 @@ GnomeVFSFileInfo file_info;
                                g_hash_table_insert(object_hash,g_strdup(xml_object),captive_file_object);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_new_create")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_new_create")) {
                        g_assert(object==NULL);
                        errgnomevfsresult=captive_file_new_create(&captive_file_object,captive_vfs_object,
                                        GET_PROP_STRING("pathname"),
@@ -417,13 +425,13 @@ GnomeVFSFileInfo file_info;
                                g_hash_table_insert(object_hash,g_strdup(xml_object),captive_file_object);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_close")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_close")) {
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
                        errbool=g_hash_table_remove(object_hash,xml_object);    /* g_object_unref() by object_hash_value_destroy_func() */
                        g_assert(errbool==TRUE);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_read")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_read")) {
 gpointer buffer;
 GnomeVFSFileSize num_bytes,bytes_read;
 
@@ -437,7 +445,7 @@ GnomeVFSFileSize num_bytes,bytes_read;
                        g_free(buffer);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_write")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_write")) {
 gpointer buffer;
 GnomeVFSFileSize num_bytes,bytes_written;
 
@@ -452,22 +460,22 @@ GnomeVFSFileSize num_bytes,bytes_written;
                        g_free(buffer);
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_seek")) {
-GnomeVFSSeekPosition whence;
-const xmlChar *whence_string;
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_seek")) {
+GnomeVFSSeekPosition whence=GNOME_VFS_SEEK_START;      /* Prevent: ... might be used uninitialized in this function */
+const gchar *whence_string;
 
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
                        whence_string=GET_PROP_STRING("whence");
-                       /**/ if (!xmlStrcmp(whence_string,"start"  )) whence=GNOME_VFS_SEEK_START;
-                       else if (!xmlStrcmp(whence_string,"current")) whence=GNOME_VFS_SEEK_CURRENT;
-                       else if (!xmlStrcmp(whence_string,"end"    )) whence=GNOME_VFS_SEEK_END;
+                       /**/ if (!strcmp(whence_string,"start"  )) whence=GNOME_VFS_SEEK_START;
+                       else if (!strcmp(whence_string,"current")) whence=GNOME_VFS_SEEK_CURRENT;
+                       else if (!strcmp(whence_string,"end"    )) whence=GNOME_VFS_SEEK_END;
                        else g_assert_not_reached();
                        errgnomevfsresult=captive_file_seek(captive_file_object,whence,
                                        GET_PROP_GINT64("offset"));
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_tell")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_tell")) {
 GnomeVFSFileOffset offset;
 
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
@@ -477,13 +485,13 @@ GnomeVFSFileOffset offset;
                                g_assert((gint64)offset==GET_PROP_GINT64("offset"));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_remove")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_remove")) {
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
                        errgnomevfsresult=captive_file_remove(captive_file_object);
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_file_info_get")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_file_info_get")) {
 GnomeVFSFileInfo file_info;
 
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
@@ -491,7 +499,7 @@ GnomeVFSFileInfo file_info;
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_file_info_set")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_file_info_set")) {
 GnomeVFSFileInfo file_info;
 
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
@@ -503,14 +511,14 @@ GnomeVFSFileInfo file_info;
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_truncate")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_truncate")) {
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
                        errgnomevfsresult=captive_file_truncate(captive_file_object,
                                        GET_PROP_GINT64("file_size"));
                        g_assert(!strcmp(gnome_vfs_result_to_string(errgnomevfsresult),GET_PROP_STRING("result")));
                        continue;
                        }
-               if (!xmlStrcmp(xml_node->name,"file_move")) {
+               if (!xmlStrcmp(xml_node->name,BAD_CAST "file_move")) {
                        captive_file_object=CAPTIVE_FILE_OBJECT(object);
                        errgnomevfsresult=captive_file_move(captive_file_object,
                                        GET_PROP_STRING("pathname_new"),