]> git.pond.sub.org Git - empserver/commitdiff
(main): Rev. 1.43 broke option -D. Its meaning in presence of -e is
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 16 Mar 2005 20:53:27 +0000 (20:53 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 16 Mar 2005 20:53:27 +0000 (20:53 +0000)
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
man/emp_server.6
src/lib/gen/service.c
src/server/main.c

index 5070ebdb7f0573a6efb139a92153319303fb462b..dcc29993ddef8df3a50889b4e8f2923d46c8a0fe 100644 (file)
@@ -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
index 782a009bcff7b2b7d0171859aac5230d88aa60e5..7eb223617bba3b936290e3d63e9b8195782834f8 100644 (file)
@@ -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 <wolfpack@wolfpackempire.com>
 .SH AUTHORS
index a9652c820822a814962050b66a6659af744147d8..097adf6ed72cb1d0b16bc41dbc00bef98042650f 100644 (file)
@@ -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);
index 6d125c20420c6cf2c58d391c69004f3a7530a3bd..91d12bb69d0fe4b2d4aa946ab72b535646633301 100644 (file)
@@ -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();