.. _program_listing_file_server_main.c: Program Listing for File main.c =============================== |exhale_lsh| :ref:`Return to documentation for file ` (``server/main.c``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include #include #include #include #include "utils/common_macros.h" #include "server.h" #include "server_args_parser.h" const char SERVER_USAGE[] = { "Usage: ./server [OPTIONS]\n" "Options:\n" " -h, --help Show this help message and exit\n" " -p, --port Set the port number\n" " -x, --width Set the width of the map\n" " -y, --height Set the height of the map\n" " -n, --names ... Set team names\n" " -c, --client-number Set the number of clients per team\n" " -f, --freq reciprocal of time unit (default: 100)\n" }; static constexpr const int EXIT_TEK_FAILURE = 84; static const char *RESERVED_TEAM_NAMES[] = { "-SERVER", "-UNASSIGNED", "GRAPHIC" }; [[gnu::weak]] int main(int argc, char *argv[]) { char *teams[TEAM_COUNT_LIMIT] = { }; params_t params = { .teams = teams, .registered_team_count = LENGTH_OF(RESERVED_TEAM_NAMES) }; memcpy(params.teams, RESERVED_TEAM_NAMES, LENGTH_OF(RESERVED_TEAM_NAMES) * sizeof *params.teams); if (!parse_args(¶ms, argc, argv)) return EXIT_TEK_FAILURE; if (params.help) return printf("%s\n", SERVER_USAGE), EXIT_SUCCESS; if (!server_run(¶ms, get_timestamp())) return EXIT_TEK_FAILURE; return EXIT_SUCCESS; }