From 147cf97224b77fb9e607eeca92b4ad0c0bcc747d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 16 Mar 2005 20:53:27 +0000 Subject: [PATCH] (main): Rev. 1.43 broke option -D. Its meaning in presence of -e is unclear. Other programs only support -e. Remove -D. (install_service): Remove argument datadir_set. (main): New option -v. (main): Exit successfully after -h. (main): Don't print usage on unknown options, just point to -h. (print_usage): Rewrite. Deprecate use of non-option arguments. --- include/service.h | 2 +- man/emp_server.6 | 35 ++++++++++----------------- src/lib/gen/service.c | 6 +---- src/server/main.c | 55 +++++++++++++++++++++++++------------------ 4 files changed, 47 insertions(+), 51 deletions(-) diff --git a/include/service.h b/include/service.h index 5070ebdb7..dcc29993d 100644 --- a/include/service.h +++ b/include/service.h @@ -37,7 +37,7 @@ #define DEFAULT_SERVICE_NAME "Empire Server" extern int install_service(char *program_name, char *service_name, - int datadir_set, char *config_file); + char *config_file); extern int remove_service(char *service_name); extern void WINAPI service_main(DWORD argc, LPTSTR *argv); #endif diff --git a/man/emp_server.6 b/man/emp_server.6 index 782a009bc..7eb223617 100644 --- a/man/emp_server.6 +++ b/man/emp_server.6 @@ -5,23 +5,16 @@ emp_server \- Empire server .SH SYNOPSIS .B emp_server [ -.BI \-dhps -] -[ -.BI \-D " datadir" +.BI \-dhpsv ] [ .BI \-e " configfile" ] -[ -.IR name -] .br .SH DESCRIPTION .I emp_server is a daemon which listens to the Empire port for players connecting to -the game. For more information on the game of Empire, see the -.I info +the game. For more information on the game of Empire, see the info pages within the game. .SH OPTIONS .TP @@ -32,8 +25,13 @@ error. You normally want to use this flag if you are running .I emp_server from within a debugger. .TP +.BI \-e " configfile" +Use game configuration specification in +.I configfile +\&. By default, the file "econfig" in the data directory is used. +.TP .B \-h -Help. Print a usage line showing the command line options. +Help. Print brief usage information and exit. .TP .B \-p Threading debug mode. Implies -d. @@ -41,18 +39,11 @@ Threading debug mode. Implies -d. .B \-s Enable thread stack checking. .TP -.BI \-D " datadir" -causes the server to use the data files in -.I datadir -.TP -.BI \-e " configfile" -causes the server to use the game configuration specification in -.I configfile -(by default, the file "econfig" in the data directory is used) -.TP -.IR name -This argument does nothing. It is used by scripts to locate the -server to kill it. +.B \-v +Print version information and exit. +.SH OPERANDS +Operands are ignored for backward compatibility. Their use is +deprecated. .SH BUGS Please report all bugs to the Wolfpack .SH AUTHORS diff --git a/src/lib/gen/service.c b/src/lib/gen/service.c index a9652c820..097adf6ed 100644 --- a/src/lib/gen/service.c +++ b/src/lib/gen/service.c @@ -39,7 +39,7 @@ #include "optlist.h" int -install_service(char *program_name, char *service_name, int datadir_set, char *config_file) +install_service(char *program_name, char *service_name, char *config_file) { char strDir[1024]; HANDLE schSCManager,schService; @@ -53,10 +53,6 @@ install_service(char *program_name, char *service_name, int datadir_set, char *c } else strcpy(strDir, program_name); - if (datadir_set) { - strcat(strDir, " -D "); - strcat(strDir, datadir); - } if (config_file != NULL) { strcat(strDir, " -e "); strcat(strDir, config_file); diff --git a/src/server/main.c b/src/server/main.c index 6d125c204..91d12bb69 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -64,6 +64,7 @@ #include "product.h" #include "optlist.h" #include "server.h" +#include "version.h" #include "prototypes.h" static void nullify_objects(void); @@ -86,18 +87,27 @@ int daemonize = 1; static void print_usage(char *program_name) { -#if defined(_WIN32) - printf("Usage: %s -i -I service_name -r -R service_name -D datadir -e config_file -d -p\n", - program_name); - printf("-i install service with the default name %s\n", DEFAULT_SERVICE_NAME); - printf("-r remove service with the default name %s\n", DEFAULT_SERVICE_NAME); - -#else - printf("Usage: %s -D datadir -e config_file -d -p -s\n", program_name); - printf("-s stack check flag (include print flag)\n"); + printf("Usage: %s [OPTION]...\n" + " -d debug mode\n" + " -e CONFIG-FILE configuration file\n" + " (default %s)\n" + " -h display this help and exit\n" +#ifdef _WIN32 + " -i install service `%s'\n" + " -I NAME install service NAME\n" #endif - printf("-p print flag\n"); - printf("-d debug mode\n"); + " -p threading debug mode, implies -d\n" +#ifdef _WIN32 + " -r remove service `%s'\n" + " -R NAME remove service NAME\n" +#endif + " -s enable stack checking\n" + " -v display version information and exit\n" + program_name, dflt_econfig +#ifdef _WIN32 + , DEFAULT_SERVICE_NAME, DEFAULT_SERVICE_NAME +#endif + ); } int @@ -108,7 +118,6 @@ main(int argc, char **argv) int install_service_set = 0; char *service_name = NULL; int remove_service_set = 0; - int datadir_set = 0; #endif char *config_file = NULL; int op; @@ -118,14 +127,8 @@ main(int argc, char **argv) #else # define XOPTS #endif - while ((op = getopt(argc, argv, "D:de:psh" XOPTS)) != EOF) { + while ((op = getopt(argc, argv, "de:hpsv" XOPTS)) != EOF) { switch (op) { - case 'D': - datadir = optarg; -#if defined(_WIN32) - datadir_set++; -#endif - break; case 'p': flags |= EMPTH_PRINT; /* fall through */ @@ -157,17 +160,23 @@ main(int argc, char **argv) case 's': flags |= EMPTH_STACKCHECK; break; + case 'v': + printf("Wolfpack Empire %d.%d.%d\n", + EMP_VERS_MAJOR, EMP_VERS_MINOR, EMP_VERS_PATCH); + return EXIT_SUCCESS; case 'h': - default: print_usage(argv[0]); + return EXIT_SUCCESS; + default: + fprintf(stderr, "Try -h for help.\n"); return EXIT_FAILURE; } } #if defined(_WIN32) - if ((debug || flags || datadir_set || config_file != NULL) && + if ((debug || flags || config_file != NULL) && remove_service_set) { - fprintf(stderr, "Can't use -p, -s, -d, -D or -e with either " + fprintf(stderr, "Can't use -p, -s, -d or -e with either " "-r or -R options\n"); exit(EXIT_FAILURE); } @@ -198,7 +207,7 @@ main(int argc, char **argv) #if defined(_WIN32) if (install_service_set) - return install_service(argv[0], service_name, datadir_set, config_file); + return install_service(argv[0], service_name, config_file); #endif /* _WIN32 */ init_server(); -- 2.43.0