Text-messages checking of command-line arguments validity.
authorshort <>
Sat, 27 Sep 2003 06:50:48 +0000 (06:50 +0000)
committershort <>
Sat, 27 Sep 2003 06:50:48 +0000 (06:50 +0000)
 - Bugreport by the courtesy of Martin Drab.

src/client/cmdline/main.c

index 8ff0c23..a8addad 100644 (file)
@@ -248,18 +248,16 @@ struct captive_options options;
                        popt_table,     /* options */
                        POPT_CONTEXT_POSIXMEHARDER);    /* flags; && !POPT_CONTEXT_KEEP_FIRST */
        if (context==NULL) {
-               g_assert_not_reached(); /* argument recognization args_error */
+               g_error(_("Error parsing command-line arguments"));
                return EXIT_FAILURE;
                }
        errint=poptReadDefaultConfig(context,
                        TRUE);  /* useEnv */
-       if (errint!=0) {
-               g_assert_not_reached(); /* argument recognization args_error */
-               return EXIT_FAILURE;
-               }
+       if (errint!=0)
+               g_warning(_("Error reading default popt configuration"));
        errint=poptGetNextOpt(context);
        if (errint!=-1) {
-               g_assert_not_reached(); /* some non-callbacked argument reached */
+               g_error(_("Error parsing (dash-prefixed) command-line argument"));
                return EXIT_FAILURE;
                }
        cmd_argv=poptGetArgs(context);
@@ -269,20 +267,28 @@ struct captive_options options;
        captive_options=NULL;   /* already parsed by 'CAPTIVE_POPT_INCLUDE' */
 
        /* image_iochannel */
-       if (cmd_argc) {
-               g_assert(options.image_iochannel==NULL);
-               if (!(options.image_iochannel=g_io_channel_new_file(
-                               cmd_argv[0],    /* filename */
-                               (options.rwmode==CAPTIVE_OPTION_RWMODE_RW ? "r+" : "r"),        /* mode */
-                               NULL))) {       /* error */
-                       g_error(_("image_iochannel open failed"));
-                       return EXIT_FAILURE;
-                       }
+       if (cmd_argc<=0) {
+               g_error(_("File/device disk image pathname command-line argument required"));
+               return EXIT_FAILURE;
+               }
+       g_assert(options.image_iochannel==NULL);
+       if (!(options.image_iochannel=g_io_channel_new_file(
+                       cmd_argv[0],    /* filename */
+                       (options.rwmode==CAPTIVE_OPTION_RWMODE_RW ? "r+" : "r"),        /* mode */
+                       NULL))) {       /* error */
+               g_error(_("image_iochannel open failed"));
+               return EXIT_FAILURE;
                }
-       if (cmd_argc>0) {
-               /* image file */
-               cmd_argc--;
-               cmd_argv++;
+       cmd_argc--;
+       cmd_argv++;
+
+       if (options.filesystem.type==CAPTIVE_OPTIONS_MODULE_TYPE_EMPTY) {
+               g_error(_("'--filesystem' option required ('ntfs.sys' pathname suggested)"));
+               return EXIT_FAILURE;
+               }
+       if (!options.load_module) {
+               g_warning(_("'--load-module' option required ('ntoskrnl.exe' pathname suggested)"));
+               return EXIT_FAILURE;
                }
 
        if (GNOME_VFS_OK!=captive_vfs_new(&cmdline_captive_vfs_object,&options)) {