ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/main_unix.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/main_unix.cpp (file contents):
Revision 1.47 by gbeauche, 2002-05-16T15:48:06Z vs.
Revision 1.48 by cebix, 2002-07-31T16:46:14Z

# Line 61 | Line 61 | struct sigstate {
61   # include <X11/extensions/xf86dga.h>
62   #endif
63  
64 + #include <string>
65 + using std::string;
66 +
67   #include "cpu_emulation.h"
68   #include "sys.h"
69   #include "rom_patches.h"
# Line 226 | Line 229 | static void sigsegv_dump_state(sigsegv_a
229  
230   static void usage(const char *prg_name)
231   {
232 <        printf("Usage: %s [OPTION...]\n", prg_name);
233 <        printf("\nUnix options:\n");
234 <        printf("  --display STRING\n    X display to use\n");
235 <        printf("  --break ADDRESS\n    set ROM breakpoint\n");
236 <        printf("  --rominfo\n    dump ROM information\n");
232 >        printf(
233 >                "Usage: %s [OPTION...]\n"
234 >                "\nUnix options:\n"
235 >                "  --config FILE\n    read/write configuration from/to FILE\n"
236 >                "  --display STRING\n    X display to use\n"
237 >                "  --break ADDRESS\n    set ROM breakpoint\n"
238 >                "  --rominfo\n    dump ROM information\n", prg_name
239 >        );
240 >        LoadPrefs(); // read the prefs file so PrefsPrintUsage() will print the correct default values
241          PrefsPrintUsage();
242          exit(0);
243   }
# Line 249 | Line 256 | int main(int argc, char **argv)
256          printf(GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR);
257          printf(" %s\n", GetString(STR_ABOUT_TEXT2));
258  
259 +        // Parse command line arguments
260 +        for (int i=1; i<argc; i++) {
261 +                if (strcmp(argv[i], "--help") == 0) {
262 +                        usage(argv[0]);
263 +                } else if (strcmp(argv[i], "--display") == 0) {
264 +                        i++; // don't remove the argument, gtk_init() needs it too
265 +                        if (i < argc)
266 +                                x_display_name = strdup(argv[i]);
267 +                } else if (strcmp(argv[i], "--break") == 0) {
268 +                        argv[i++] = NULL;
269 +                        if (i < argc) {
270 +                                ROMBreakpoint = strtol(argv[i], NULL, 0);
271 +                                argv[i] = NULL;
272 +                        }
273 +                } else if (strcmp(argv[i], "--config") == 0) {
274 +                        argv[i++] = NULL;
275 +                        if (i < argc) {
276 +                                extern string UserPrefsPath; // from prefs_unix.cpp
277 +                                UserPrefsPath = argv[i];
278 +                                argv[i] = NULL;
279 +                        }
280 +                } else if (strcmp(argv[i], "--rominfo") == 0) {
281 +                        argv[i] = NULL;
282 +                        PrintROMInfo = true;
283 +                }
284 +        }
285 +
286 +        // Remove processed arguments
287 +        for (int i=1; i<argc; i++) {
288 +                int k;
289 +                for (k=i; k<argc; k++)
290 +                        if (argv[k] != NULL)
291 +                                break;
292 +                if (k > i) {
293 +                        k -= i;
294 +                        for (int j=i+k; j<argc; j++)
295 +                                argv[j-k] = argv[j];
296 +                        argc -= k;
297 +                }
298 +        }
299 +
300   #ifdef ENABLE_GTK
301   #ifdef HAVE_GNOMEUI
302          // Init GNOME/GTK
# Line 260 | Line 308 | int main(int argc, char **argv)
308          gtk_set_locale();
309          gtk_init(&argc, &argv);
310   #endif
263        x_display_name = gdk_get_display(); // gtk_init() handles and removes the "--display" argument
311   #endif
312  
313          // Read preferences
314          PrefsInit(argc, argv);
315  
316 <        // Parse command line arguments
316 >        // Any command line arguments left?
317          for (int i=1; i<argc; i++) {
318 <                if (strcmp(argv[i], "--help") == 0) {
272 <                        usage(argv[0]);
273 <                } else if (strcmp(argv[i], "--display") == 0) {
274 <                        i++;
275 <                        if (i < argc)
276 <                                x_display_name = strdup(argv[i]);
277 <                } else if (strcmp(argv[i], "--break") == 0) {
278 <                        i++;
279 <                        if (i < argc)
280 <                                ROMBreakpoint = strtol(argv[i], NULL, 0);
281 <                } else if (strcmp(argv[i], "--rominfo") == 0) {
282 <                        PrintROMInfo = true;
283 <                } else if (argv[i][0] == '-') {
318 >                if (argv[i][0] == '-') {
319                          fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
320                          usage(argv[0]);
321                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines