+Option '--debug-messages' (default off) - variable 'captive_debug_messages'
authorshort <>
Tue, 4 Feb 2003 00:10:32 +0000 (00:10 +0000)
committershort <>
Tue, 4 Feb 2003 00:10:32 +0000 (00:10 +0000)
 - turned on in the default captive.conf

src/client/libcaptive-gnomevfs/captive.conf
src/libcaptive/client/init.c
src/libcaptive/include/captive/client.h

index 3b87ba9..d7c2ab6 100644 (file)
@@ -1,2 +1,2 @@
-captive-fs.so:  libcaptive-gnomevfs.so --load-module=/home/lace/src/captive/w32/ntoskrnl.exe --filesystem=/home/lace/.captive-fs.so  --rw
-captive-fs.sys: libcaptive-gnomevfs.so --load-module=/home/lace/src/captive/w32/ntoskrnl.exe --filesystem=/home/lace/.captive-fs.sys --rw
+captive-fs.so:  libcaptive-gnomevfs.so --load-module=/home/lace/src/captive/w32/ntoskrnl.exe --filesystem=/home/lace/.captive-fs.so  --rw --debug-messages
+captive-fs.sys: libcaptive-gnomevfs.so --load-module=/home/lace/src/captive/w32/ntoskrnl.exe --filesystem=/home/lace/.captive-fs.sys --rw --debug-messages
index 202f38c..8600c7a 100644 (file)
@@ -62,6 +62,7 @@ static TOP_LEVEL_IRP TopLevelIrp;     /* TODO:thread */
 gchar *captive_option_filesystem;
 enum captive_option_rwmode captive_option_rwmode=CAPTIVE_OPTION_RWMODE_BLIND;
 enum captive_option_media captive_option_media=CAPTIVE_OPTION_MEDIA_DISK;
+gboolean captive_debug_messages=FALSE;
 GIOChannel *captive_image_iochannel;
 /* Non-blinded original GIOChannel for flushing during shutdown. */
 static GIOChannel *captive_image_iochannel_orig;
@@ -105,6 +106,11 @@ static void arg_disk(void)
        captive_option_media=CAPTIVE_OPTION_MEDIA_DISK;
 }
 
+static void arg_debug_messages(void)
+{
+       captive_debug_messages=TRUE;
+}
+
 
 static void captive_popt_callback
                (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data);
@@ -128,13 +134,14 @@ const struct poptOption captive_popt[]={
 #define CAPTIVE_POPT_NONE(longname,descripP) \
                CAPTIVE_POPT(longname,POPT_ARG_NONE  ,NULL                ,descripP,NULL       )
 
-               CAPTIVE_POPT_STRING("filesystem" ,N_("Path to .sys or .so filesystem module file"),N_("pathname")),
-               CAPTIVE_POPT_STRING("load-module",N_("Path to any W32 module to load w/o initialization"),N_("pathname")),
-               CAPTIVE_POPT_NONE(  "ro"         ,N_("Read/write mode: Any write access will be forbidden")),
-               CAPTIVE_POPT_NONE(  "blind"      ,N_("Read/write mode: All writes are just simulated in memory (default)")),
-               CAPTIVE_POPT_NONE(  "rw"         ,N_("Read/write mode: Write directly to the image file/device")),
-               CAPTIVE_POPT_NONE(  "cdrom"      ,N_("Media type: CD-ROM")),
-               CAPTIVE_POPT_NONE(  "disk"       ,N_("Media type: Disk (default)")),
+               CAPTIVE_POPT_STRING("filesystem"    ,N_("Path to .sys or .so filesystem module file"),N_("pathname")),
+               CAPTIVE_POPT_STRING("load-module"   ,N_("Path to any W32 module to load w/o initialization"),N_("pathname")),
+               CAPTIVE_POPT_NONE(  "ro"            ,N_("Read/write mode: Any write access will be forbidden")),
+               CAPTIVE_POPT_NONE(  "blind"         ,N_("Read/write mode: All writes are just simulated in memory (default)")),
+               CAPTIVE_POPT_NONE(  "rw"            ,N_("Read/write mode: Write directly to the image file/device")),
+               CAPTIVE_POPT_NONE(  "cdrom"         ,N_("Media type: CD-ROM")),
+               CAPTIVE_POPT_NONE(  "disk"          ,N_("Media type: Disk (default)")),
+               CAPTIVE_POPT_NONE(  "debug-messages",N_("Turn on debugging messages")),
 
 #undef CAPTIVE_POPT_NONE
 #undef CAPTIVE_POPT_STRING
@@ -157,6 +164,7 @@ static void (*const popt_func_table[])(void)={
                arg_rw,
                arg_cdrom,
                arg_disk,
+               arg_debug_messages,
                };
 
 
@@ -287,6 +295,12 @@ NTSTATUS err;
 static void captive_shutdown_atexit(void);
 
 
+static void    log_discard_func(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
+{
+       /* NOP */
+}
+
+
 /**
  * captive_init:
  * @captive_args: String with possible options to parse by popt.
@@ -368,7 +382,18 @@ args_err:
        if (!image_iochannel)
                return FALSE;
 
-       g_return_val_if_fail(image_iochannel!=NULL,FALSE);
+       if (!captive_debug_messages) {
+               g_log_set_handler(
+                               G_LOG_DOMAIN,   /* log_domain; "Captive" */
+                               0       /* log_levels */
+                                               | G_LOG_FLAG_RECURSION
+                                               | G_LOG_FLAG_FATAL
+                                               | G_LOG_LEVEL_MESSAGE
+                                               | G_LOG_LEVEL_INFO
+                                               | G_LOG_LEVEL_DEBUG,
+                               log_discard_func,       /* log_func */
+                               NULL);  /* user_data */
+               }
 
        if (captive_option_rwmode==CAPTIVE_OPTION_RWMODE_BLIND)
                captive_image_iochannel=(GIOChannel *)captive_giochannel_blind_new(image_iochannel);
index fa52ac8..70002b7 100644 (file)
@@ -45,6 +45,7 @@ enum captive_option_media {
                CAPTIVE_OPTION_MEDIA_DISK,
                };
 extern enum captive_option_media captive_option_media;
+extern gboolean captive_debug_messages;
 extern GIOChannel *captive_image_iochannel;
 /**
  * captive_image_size: