captive_init(): 'image_iochannel' is now optional to just parse 'captive_args'
authorshort <>
Mon, 20 Jan 2003 23:24:11 +0000 (23:24 +0000)
committershort <>
Mon, 20 Jan 2003 23:24:11 +0000 (23:24 +0000)
src/client/cmdline/main.c
src/libcaptive/client/init.c

index b44f1e4..3b7f81e 100644 (file)
@@ -19,12 +19,18 @@ int main(int argc,char **argv)
                exit(EXIT_FAILURE);
                }
 
-       if (!captive_init(argv[1],
-                       (!argv[2] ? NULL : g_io_channel_new_file(       /* FIXME: g_io_channel_new_file() is NOT 64-bit compliant! */
-                                       argv[2],        /* filename */
-                                       "r",    /* mode */
-                                       NULL))))        /* error */
-               g_error(_("captive_init FAIL"));
+       if (FALSE!=captive_init(
+                       argv[1],        /* captive_args */
+                       NULL))  /* image_iochannel */
+               g_error(_("captive_init captive_args phase FAIL"));
+
+       if (TRUE!=captive_init(NULL,    /* captive_args */
+                       (               /* image_iochannel */
+                                       !argv[2] ? NULL : g_io_channel_new_file(        /* FIXME: g_io_channel_new_file() is NOT 64-bit compliant! */
+                                                       argv[2],        /* filename */
+                                                       (captive_option_rwmode==CAPTIVE_OPTION_RWMODE_RW ? "w+" : "r"), /* mode */
+                                                       NULL))))        /* error */
+               g_error(_("captive_init image_iochannel FAIL"));
 
        return EXIT_SUCCESS;
 }
index f3be024..13a6d8c 100644 (file)
@@ -261,13 +261,17 @@ GIOStatus erriostatus;
  * @captive_args: String with possible options to parse by popt.
  * %NULL value is permitted.
  * @image_iochannel: Host OS file of the disk image to mount.
- * %NULL value is forbidden.
+ * %NULL value is permitted (initialization would not apply in such case).
  *
  * Initializes %libcaptive and loads the specified filesystem.
+ * You can supply %NULL value for @image_iochannel - in such case no library
+ * initialization is done; only passed @captive_args are parsed. Function
+ * will return you %FALSE value as it is not yet initializied.
  *
- * You should supply
+ * You should supply only @captive_args with %NULL @image_iochannel if you
+ * need to parse+examine the arguments to properly initialize @image_iochannel.
  *
- * Returns: %TRUE if successfuly loaded.
+ * Returns: %TRUE if successfuly initialized.
  */
 gboolean captive_init(const gchar *captive_args,GIOChannel *image_iochannel)
 {
@@ -329,6 +333,10 @@ args_err:
                        }
                }
 
+       /* If we were just requested to parse the arguments. */
+       if (!image_iochannel)
+               return FALSE;
+
        g_return_val_if_fail(image_iochannel!=NULL,FALSE);
 
        captive_image_iochannel=image_iochannel;