(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.
This commit is contained in:
parent
3939741d65
commit
147cf97224
4 changed files with 47 additions and 51 deletions
|
@ -37,7 +37,7 @@
|
||||||
#define DEFAULT_SERVICE_NAME "Empire Server"
|
#define DEFAULT_SERVICE_NAME "Empire Server"
|
||||||
|
|
||||||
extern int install_service(char *program_name, char *service_name,
|
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 int remove_service(char *service_name);
|
||||||
extern void WINAPI service_main(DWORD argc, LPTSTR *argv);
|
extern void WINAPI service_main(DWORD argc, LPTSTR *argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,23 +5,16 @@ emp_server \- Empire server
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B emp_server
|
.B emp_server
|
||||||
[
|
[
|
||||||
.BI \-dhps
|
.BI \-dhpsv
|
||||||
]
|
|
||||||
[
|
|
||||||
.BI \-D " datadir"
|
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.BI \-e " configfile"
|
.BI \-e " configfile"
|
||||||
]
|
]
|
||||||
[
|
|
||||||
.IR name
|
|
||||||
]
|
|
||||||
.br
|
.br
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.I emp_server
|
.I emp_server
|
||||||
is a daemon which listens to the Empire port for players connecting to
|
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
|
the game. For more information on the game of Empire, see the info
|
||||||
.I info
|
|
||||||
pages within the game.
|
pages within the game.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
|
@ -32,8 +25,13 @@ error. You normally want to use this flag if you are running
|
||||||
.I emp_server
|
.I emp_server
|
||||||
from within a debugger.
|
from within a debugger.
|
||||||
.TP
|
.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
|
.B \-h
|
||||||
Help. Print a usage line showing the command line options.
|
Help. Print brief usage information and exit.
|
||||||
.TP
|
.TP
|
||||||
.B \-p
|
.B \-p
|
||||||
Threading debug mode. Implies -d.
|
Threading debug mode. Implies -d.
|
||||||
|
@ -41,18 +39,11 @@ Threading debug mode. Implies -d.
|
||||||
.B \-s
|
.B \-s
|
||||||
Enable thread stack checking.
|
Enable thread stack checking.
|
||||||
.TP
|
.TP
|
||||||
.BI \-D " datadir"
|
.B \-v
|
||||||
causes the server to use the data files in
|
Print version information and exit.
|
||||||
.I datadir
|
.SH OPERANDS
|
||||||
.TP
|
Operands are ignored for backward compatibility. Their use is
|
||||||
.BI \-e " configfile"
|
deprecated.
|
||||||
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.
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Please report all bugs to the Wolfpack <wolfpack@wolfpackempire.com>
|
Please report all bugs to the Wolfpack <wolfpack@wolfpackempire.com>
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
int
|
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];
|
char strDir[1024];
|
||||||
HANDLE schSCManager,schService;
|
HANDLE schSCManager,schService;
|
||||||
|
@ -53,10 +53,6 @@ install_service(char *program_name, char *service_name, int datadir_set, char *c
|
||||||
} else
|
} else
|
||||||
strcpy(strDir, program_name);
|
strcpy(strDir, program_name);
|
||||||
|
|
||||||
if (datadir_set) {
|
|
||||||
strcat(strDir, " -D ");
|
|
||||||
strcat(strDir, datadir);
|
|
||||||
}
|
|
||||||
if (config_file != NULL) {
|
if (config_file != NULL) {
|
||||||
strcat(strDir, " -e ");
|
strcat(strDir, " -e ");
|
||||||
strcat(strDir, config_file);
|
strcat(strDir, config_file);
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include "product.h"
|
#include "product.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
#include "version.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
|
||||||
static void nullify_objects(void);
|
static void nullify_objects(void);
|
||||||
|
@ -86,18 +87,27 @@ int daemonize = 1;
|
||||||
static void
|
static void
|
||||||
print_usage(char *program_name)
|
print_usage(char *program_name)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
printf("Usage: %s [OPTION]...\n"
|
||||||
printf("Usage: %s -i -I service_name -r -R service_name -D datadir -e config_file -d -p\n",
|
" -d debug mode\n"
|
||||||
program_name);
|
" -e CONFIG-FILE configuration file\n"
|
||||||
printf("-i install service with the default name %s\n", DEFAULT_SERVICE_NAME);
|
" (default %s)\n"
|
||||||
printf("-r remove service with the default name %s\n", DEFAULT_SERVICE_NAME);
|
" -h display this help and exit\n"
|
||||||
|
#ifdef _WIN32
|
||||||
#else
|
" -i install service `%s'\n"
|
||||||
printf("Usage: %s -D datadir -e config_file -d -p -s\n", program_name);
|
" -I NAME install service NAME\n"
|
||||||
printf("-s stack check flag (include print flag)\n");
|
|
||||||
#endif
|
#endif
|
||||||
printf("-p print flag\n");
|
" -p threading debug mode, implies -d\n"
|
||||||
printf("-d debug mode\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
|
int
|
||||||
|
@ -108,7 +118,6 @@ main(int argc, char **argv)
|
||||||
int install_service_set = 0;
|
int install_service_set = 0;
|
||||||
char *service_name = NULL;
|
char *service_name = NULL;
|
||||||
int remove_service_set = 0;
|
int remove_service_set = 0;
|
||||||
int datadir_set = 0;
|
|
||||||
#endif
|
#endif
|
||||||
char *config_file = NULL;
|
char *config_file = NULL;
|
||||||
int op;
|
int op;
|
||||||
|
@ -118,14 +127,8 @@ main(int argc, char **argv)
|
||||||
#else
|
#else
|
||||||
# define XOPTS
|
# define XOPTS
|
||||||
#endif
|
#endif
|
||||||
while ((op = getopt(argc, argv, "D:de:psh" XOPTS)) != EOF) {
|
while ((op = getopt(argc, argv, "de:hpsv" XOPTS)) != EOF) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 'D':
|
|
||||||
datadir = optarg;
|
|
||||||
#if defined(_WIN32)
|
|
||||||
datadir_set++;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case 'p':
|
case 'p':
|
||||||
flags |= EMPTH_PRINT;
|
flags |= EMPTH_PRINT;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
@ -157,17 +160,23 @@ main(int argc, char **argv)
|
||||||
case 's':
|
case 's':
|
||||||
flags |= EMPTH_STACKCHECK;
|
flags |= EMPTH_STACKCHECK;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
printf("Wolfpack Empire %d.%d.%d\n",
|
||||||
|
EMP_VERS_MAJOR, EMP_VERS_MINOR, EMP_VERS_PATCH);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Try -h for help.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if ((debug || flags || datadir_set || config_file != NULL) &&
|
if ((debug || flags || config_file != NULL) &&
|
||||||
remove_service_set) {
|
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");
|
"-r or -R options\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +207,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (install_service_set)
|
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 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
init_server();
|
init_server();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue