#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>
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);
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;
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;
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,
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:
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;
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: {
}
}
}
- 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);
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;
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; \
})
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);
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() */
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"));
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"),
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);
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")));
}
/* 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"),
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"),
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;
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;
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);
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);
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);
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"),