get progname from argv[0]

This commit is contained in:
Gwenhael Le Moine 2024-09-26 08:01:14 +02:00
parent 23bde8adc6
commit aa06525ec8
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -133,22 +133,12 @@ config_t* config_init( int argc, char* argv[] )
const char* optstring = "h"; const char* optstring = "h";
struct option long_options[] = { struct option long_options[] = {
{"help", no_argument, NULL, 'h' }, {"help", no_argument, NULL, 'h' },
{"verbose", no_argument, &clopt_verbose, true },
{"48sx", no_argument, &clopt_model, MODEL_48SX }, {"48sx", no_argument, &clopt_model, MODEL_48SX },
{"48gx", no_argument, &clopt_model, MODEL_48GX }, {"48gx", no_argument, &clopt_model, MODEL_48GX },
{"40g", no_argument, &clopt_model, MODEL_40G }, {"40g", no_argument, &clopt_model, MODEL_40G },
{"49g", no_argument, &clopt_model, MODEL_49G }, {"49g", no_argument, &clopt_model, MODEL_49G },
{"verbose", no_argument, &clopt_verbose, true },
{"shiftless", no_argument, &clopt_shiftless, true },
{"gui", no_argument, &clopt_frontend, FRONTEND_SDL },
{"tui", no_argument, &clopt_frontend, FRONTEND_NCURSES},
{"tui-small", no_argument, NULL, 6110 },
{"tui-tiny", no_argument, NULL, 6120 },
{"mono", no_argument, &clopt_mono, true },
{"gray", no_argument, &clopt_gray, true },
{"chromeless", no_argument, &clopt_chromeless, true },
{"fullscreen", no_argument, &clopt_fullscreen, true },
{"scale", required_argument, NULL, 7110 },
{"reset", no_argument, &clopt_reset, true }, {"reset", no_argument, &clopt_reset, true },
{"monitor", no_argument, &clopt_monitor, true }, {"monitor", no_argument, &clopt_monitor, true },
@ -162,6 +152,20 @@ config_t* config_init( int argc, char* argv[] )
/* {"port1", required_argument, NULL, 8050 }, */ /* {"port1", required_argument, NULL, 8050 }, */
/* {"port2", required_argument, NULL, 8060 }, */ /* {"port2", required_argument, NULL, 8060 }, */
{"shiftless", no_argument, &clopt_shiftless, true },
{"gui", no_argument, &clopt_frontend, FRONTEND_SDL },
{"chromeless", no_argument, &clopt_chromeless, true },
{"fullscreen", no_argument, &clopt_fullscreen, true },
{"scale", required_argument, NULL, 7110 },
{"tui", no_argument, &clopt_frontend, FRONTEND_NCURSES},
{"tui-small", no_argument, NULL, 6110 },
{"tui-tiny", no_argument, NULL, 6120 },
{"mono", no_argument, &clopt_mono, true },
{"gray", no_argument, &clopt_gray, true },
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
@ -318,6 +322,8 @@ config_t* config_init( int argc, char* argv[] )
break; break;
} }
config.progname = strdup( argv[ 0 ] );
print_config(); print_config();
return &config; return &config;