/************************************************************************** Print extra usage information, including one line help on each option, to stderr. **************************************************************************/ static void print_usage(const char *argv0) { /* add client-specific usage information here */ fc_fprintf(stderr, _("This client has no special command line options\n\n")); /* TRANS: No full stop after the URL, could cause confusion. */ fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL); }
/************************************************************************** Print extra usage information, including one line help on each option, to stderr. **************************************************************************/ static void print_usage(const char *argv0) { /* add client-specific usage information here */ fc_fprintf(stderr, _(" -f, --fullscreen\tStart Client in Fullscreen mode\n")); fc_fprintf(stderr, _(" -e, --eventthread\tInit Event Subsystem in " "other thread (only Linux and BeOS)\n")); fc_fprintf(stderr, _(" -t, --theme THEME\tUse GUI theme THEME\n")); /* TRANS: No full stop after the URL, could cause confusion. */ fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL); }
/************************************************************************** The main loop for the UI. This is called from main(), and when it exits the client will exit. **************************************************************************/ void ui_main(int argc, char *argv[]) { parse_options(argc, argv); /* PORTME */ fc_fprintf(stderr, "Freeciv rules!\n"); }
/**************************************************************************** Connect to the GGZ client. ****************************************************************************/ void ggz_begin(void) { int ggz_socket; /* We're in GGZ mode */ ggzmod = ggzmod_new(GGZMOD_GAME); ggzmod_set_handler(ggzmod, GGZMOD_EVENT_SERVER, &handle_ggzmod_server); ggzmod_set_handler(ggzmod, GGZMOD_EVENT_STATS, &handle_ggzmod_stats); if (ggzmod_connect(ggzmod) < 0) { exit(EXIT_FAILURE); } ggz_socket = ggzmod_get_fd(ggzmod); if (ggz_socket < 0) { fc_fprintf(stderr, _("Only the GGZ client must call freeciv-client" " in ggz mode!\n")); exit(EXIT_FAILURE); } add_ggz_input(ggz_socket); }
/************************************************************************** Parse freeciv-ruledit commandline. **************************************************************************/ static int re_parse_cmdline(int argc, char *argv[]) { int i = 1; bool ui_separator = FALSE; int ui_options = 0; const char *option = NULL; while (i < argc) { if (ui_separator) { argv[1 + ui_options] = argv[i]; ui_options++; } else if (is_option("--help", argv[i])) { struct cmdhelp *help = cmdhelp_new(argv[0]); cmdhelp_add(help, "h", "help", R__("Print a summary of the options")); cmdhelp_add(help, "s", /* TRANS: "source" is exactly what user must type, do not translate. */ R__("source RULESET"), R__("Load given ruleset")); cmdhelp_add(help, "v", "version", R__("Print the version number")); /* The function below prints a header and footer for the options. * Furthermore, the options are sorted. */ cmdhelp_display(help, TRUE, TRUE, TRUE); cmdhelp_destroy(help); exit(EXIT_SUCCESS); } else if ((option = get_option_malloc("--source", argv, &i, argc))) { source_rs = option; } else if (is_option("--version", argv[i])) { fc_fprintf(stderr, "%s \n", freeciv_name_version()); exit(EXIT_SUCCESS); } else if (is_option("--", argv[i])) { ui_separator = TRUE; } i++; } return ui_options; }
/************************************************************************** Parse commandline parameters. Modified argv[] so it contains only ui-specific options afterwards. Number of those ui-specific options is returned. Currently this is implemented in a way that it never fails. Either it returns with success or exit()s. Implementation can be changhed so that this returns with value -1 in case program should be shut down instead of exiting itself. Callers are prepared for such implementation. **************************************************************************/ int fcmp_parse_cmdline(int argc, char *argv[]) { int i = 1; bool ui_separator = FALSE; int ui_options = 0; const char *option = NULL; while (i < argc) { if (ui_separator) { argv[1 + ui_options] = argv[i]; ui_options++; } else if (is_option("--help", argv[i])) { struct cmdhelp *help = cmdhelp_new(argv[0]); cmdhelp_add(help, "h", "help", _("Print a summary of the options")); cmdhelp_add(help, "L", /* TRANS: "List" is exactly what user must type, do not translate. */ _("List URL"), _("Load modpack list from given URL")); cmdhelp_add(help, "p", /* TRANS: "prefix" is exactly what user must type, do not translate. */ _("prefix DIR"), _("Install modpacks to given directory hierarchy")); cmdhelp_add(help, "v", "version", _("Print the version number")); /* The function below prints a header and footer for the options. * Furthermore, the options are sorted. */ cmdhelp_display(help, TRUE, TRUE, TRUE); cmdhelp_destroy(help); exit(EXIT_SUCCESS); } else if ((option = get_option_malloc("--List", argv, &i, argc))) { fcmp.list_url = option; } else if ((option = get_option_malloc("--prefix", argv, &i, argc))) { fcmp.inst_prefix = option; } else if (is_option("--version", argv[i])) { fc_fprintf(stderr, "%s \n", freeciv_name_version()); exit(EXIT_SUCCESS); } else if (is_option("--", argv[i])) { ui_separator = TRUE; } i++; } if (fcmp.inst_prefix == NULL) { const char *home = user_home_dir(); if (home == NULL) { log_error("Cannot determine user home directory"); } else { static char pfx_buf[500]; snprintf(pfx_buf, sizeof(pfx_buf), "%s/.freeciv", home); fcmp.inst_prefix = pfx_buf; } } return ui_options; }
/************************************************************************** The main loop for the UI. This is called from main(), and when it exits the client will exit. **************************************************************************/ void ui_main(int argc, char *argv[]) { /* PORTME */ fc_fprintf(stderr, "Freeciv rules!\n"); }