/* $Id: parser.c,v 5.17 2001/11/30 11:47:19 bertg Exp $ * * XPilot, a multiplayer gravity war game. Copyright (C) 1991-2001 by * * Bjørn Stabell * Ken Ronny Schouten * Bert Gijsbers * Dick Balaska * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Original options parsing code contributed by Ted Lemon */ #include #include #include #include #ifdef _WINDOWS # include "NT/winServer.h" #endif #define SERVER #include "version.h" #include "config.h" #include "serverconst.h" #include "global.h" #include "proto.h" #include "defaults.h" #include "error.h" #include "portability.h" #include "checknames.h" #include "commonproto.h" char parser_version[] = VERSION; /* * Print the option list in "-help" format. * NT uses this to generate the ServerOpts.txt file */ static void Parse_help(char *progname) { int j; int flags, all_flags; const char *str; option_desc *options; int option_count; char msg[MSG_LEN]; options = Get_option_descs(&option_count); printf("Usage: %s [ options ]\n" "\n", progname); printf("Option flags specify where an option can be used and whether it\n" "is visible or not. Default flags are \"any\" if not otherwise\n" "specified by one or more of these keywords:\n" "\n"); printf("command May be specified on the command-line.\n" "passwordfile May be specified in the password file.\n" "defaults May be specified in the defaults file.\n" "any May be specified in the map file, defaults file,\n" " or on the command line.\n" "invisible Is not displayed when a list of options is\n" " requested from the server by an operator.\n" "\n"); printf("The possible options include:\n" "\n"); for (j = 0; j < option_count; j++) { printf(" %s%s", options[j].type == valBool ? "-/+" : "-", options[j].name); if (strcasecmp(options[j].commandLineOption, options[j].name)) xpprintf(" or %s", options[j].commandLineOption); printf(" %s\n", options[j].type == valInt ? "" : options[j].type == valReal ? "" : options[j].type == valString ? "" : options[j].type == valIPos ? "" : options[j].type == valSec ? "" : options[j].type == valPerSec ? "" : options[j].type == valList ? "" : ""); for (str = options[j].helpLine; *str; str++) { if (str == options[j].helpLine || str[-1] == '\n') { putchar('\t'); } putchar(*str); } if (str > options[j].helpLine && str[-1] != '\n') { putchar('\n'); } flags = options[j].flags; all_flags = (OPT_ORIGIN_ANY | OPT_VISIBLE); if ((flags & all_flags) != all_flags && flags != 0) { strlcpy(msg, "[ Flags: command, ", sizeof(msg)); if ((flags & OPT_PASSWORD) != 0) { strlcat(msg, "passwordfile, ", sizeof(msg)); } if ((flags & (OPT_DEFAULTS | OPT_MAP)) == OPT_DEFAULTS) { strlcat(msg, "defaults, ", sizeof(msg)); } if ((flags & OPT_MAP) != 0) { strlcat(msg, "any, ", sizeof(msg)); } if ((flags & OPT_VISIBLE) == 0) { strlcat(msg, "invisible, ", sizeof(msg)); } msg[strlen(msg) - 2] = '\0'; strlcat(msg, " ]", sizeof(msg)); printf("\t%s\n", msg); } putchar('\n'); } printf( " \n" " The probabilities are in the range [0.0-1.0] and they refer to the\n" " probability that an event will occur in a block per second.\n" " Boolean options are turned off by using +