MCPcopy Create free account
hub / github.com/NetHack/NetHack / parse_args

Function parse_args

outdated/win/gnome/gnmain.c:465–524  ·  view source on GitHub ↗

parsing args */

Source from the content-addressed store, hash-verified

463
464/* parsing args */
465void
466parse_args(int argc, char *argv[])
467{
468 gint ch;
469
470 struct option options[] = { /* Default args */
471 { "help", no_argument, NULL, 'h' },
472 { "version", no_argument, NULL, 'v' },
473
474 { NULL, 0, NULL, 0 }
475 };
476
477 gchar *id = NULL;
478
479 /* initialize getopt */
480 optarg = NULL;
481 optind = 0;
482 optopt = 0;
483
484 while ((ch = getopt_long(argc, argv, "hv", options, NULL)) != EOF) {
485 switch (ch) {
486 case 'h':
487 g_print(
488 _("%s: A gnomified 'Hello World' program\n\n"
489 "Usage: %s [--help] [--version]\n\n"
490 "Options:\n"
491 " --help display this help and exit\n"
492 " --version output version information and exit\n"),
493 argv[0], argv[0]);
494 exit(0);
495 break;
496 case 'v':
497 g_print(_("NetHack %s.\n"), VERSION_STRING);
498 exit(0);
499 break;
500 case ':':
501 case '?':
502 g_print(_("Options error\n"));
503 exit(0);
504 break;
505 }
506 }
507
508 /* SM stuff */
509 session_id = gnome_client_new();
510#if 0
511 session_id = gnome_client_new (
512 /* callback to save the state and parameter for it */
513 save_state, argv[0],
514 /* callback to die and parameter for it */
515 NULL, NULL,
516 /* id from the previous session if restarted, NULL otherwise */
517 id);
518#endif
519 /* set the program name */
520 gnome_client_set_program(session_id, argv[0]);
521 g_free(id);
522

Callers 1

ghack_init_main_windowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected