wineserver: Add support for long command line options.
This commit is contained in:
parent
284335229a
commit
67daa7f760
|
@ -28,6 +28,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef HAVE_GETOPT_H
|
||||||
|
# include <getopt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
@ -41,36 +44,48 @@ timeout_t master_socket_timeout = 3 * -TICKS_PER_SEC; /* master socket timeout,
|
||||||
const char *server_argv0;
|
const char *server_argv0;
|
||||||
|
|
||||||
/* parse-line args */
|
/* parse-line args */
|
||||||
/* FIXME: should probably use getopt, and add a (more complete?) help option */
|
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\nusage: %s [options]\n\n", server_argv0);
|
fprintf(stderr, "Usage: %s [options]\n\n", server_argv0);
|
||||||
fprintf(stderr, "options:\n");
|
fprintf(stderr, "Options:\n");
|
||||||
fprintf(stderr, " -d<n> set debug level to <n>\n");
|
fprintf(stderr, " -d[n], --debug[=n] set debug level to n or +1 if n not specified\n");
|
||||||
fprintf(stderr, " -f remain in the foreground for debugging\n");
|
fprintf(stderr, " -f, --foreground remain in the foreground for debugging\n");
|
||||||
fprintf(stderr, " -h display this help message\n");
|
fprintf(stderr, " -h, --help display this help message\n");
|
||||||
fprintf(stderr, " -k[n] kill the current wineserver, optionally with signal n\n");
|
fprintf(stderr, " -k[n], --kill[=n] kill the current wineserver, optionally with signal n\n");
|
||||||
fprintf(stderr, " -p[n] make server persistent, optionally for n seconds\n");
|
fprintf(stderr, " -p[n], --persistent[=n] make server persistent, optionally for n seconds\n");
|
||||||
fprintf(stderr, " -v display version information and exit\n");
|
fprintf(stderr, " -v, --version display version information and exit\n");
|
||||||
fprintf(stderr, " -w wait until the current wineserver terminates\n");
|
fprintf(stderr, " -w, --wait wait until the current wineserver terminates\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_args( int argc, char *argv[] )
|
static void parse_args( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int i, ret;
|
int ret, optc;
|
||||||
|
|
||||||
|
static struct option long_options[] =
|
||||||
|
{
|
||||||
|
{"debug", 2, 0, 'd'},
|
||||||
|
{"foreground", 0, 0, 'f'},
|
||||||
|
{"help", 0, 0, 'h'},
|
||||||
|
{"kill", 2, 0, 'k'},
|
||||||
|
{"persistent", 2, 0, 'p'},
|
||||||
|
{"version", 0, 0, 'v'},
|
||||||
|
{"wait", 0, 0, 'w'},
|
||||||
|
{ NULL, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
server_argv0 = argv[0];
|
server_argv0 = argv[0];
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
|
while ((optc = getopt_long( argc, argv, "d::fhk::p::vw", long_options, NULL )) != -1)
|
||||||
{
|
{
|
||||||
if (argv[i][0] == '-')
|
switch(optc)
|
||||||
{
|
{
|
||||||
switch(argv[i][1])
|
|
||||||
{
|
|
||||||
case 'd':
|
case 'd':
|
||||||
if (isdigit(argv[i][2])) debug_level = atoi( argv[i] + 2 );
|
if (optarg && isdigit(*optarg))
|
||||||
else debug_level++;
|
debug_level = atoi( optarg );
|
||||||
|
else
|
||||||
|
debug_level++;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
foreground = 1;
|
foreground = 1;
|
||||||
|
@ -80,12 +95,14 @@ static void parse_args( int argc, char *argv[] )
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
if (isdigit(argv[i][2])) ret = kill_lock_owner( atoi(argv[i] + 2) );
|
if (optarg && isdigit(*optarg))
|
||||||
else ret = kill_lock_owner(-1);
|
ret = kill_lock_owner( atoi( optarg ) );
|
||||||
|
else
|
||||||
|
ret = kill_lock_owner(-1);
|
||||||
exit( !ret );
|
exit( !ret );
|
||||||
case 'p':
|
case 'p':
|
||||||
if (isdigit(argv[i][2]))
|
if (optarg && isdigit(*optarg))
|
||||||
master_socket_timeout = (timeout_t)atoi( argv[i] + 2 ) * -TICKS_PER_SEC;
|
master_socket_timeout = (timeout_t)atoi( optarg ) * -TICKS_PER_SEC;
|
||||||
else
|
else
|
||||||
master_socket_timeout = TIMEOUT_INFINITE;
|
master_socket_timeout = TIMEOUT_INFINITE;
|
||||||
break;
|
break;
|
||||||
|
@ -96,16 +113,8 @@ static void parse_args( int argc, char *argv[] )
|
||||||
wait_for_lock();
|
wait_for_lock();
|
||||||
exit(0);
|
exit(0);
|
||||||
default:
|
default:
|
||||||
fprintf( stderr, "wineserver: unknown option '%s'\n", argv[i] );
|
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf( stderr, "wineserver: unknown argument '%s'.\n", argv[i] );
|
|
||||||
usage();
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ useful to start \fBwineserver\fR explicitly with different options, as
|
||||||
explained below.
|
explained below.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.BI \-d [n]
|
.BI \-d [n] ,\ --debug [=n]
|
||||||
Set the debug level to
|
Set the debug level to
|
||||||
.I n.
|
.I n.
|
||||||
0 means no debugging information, 1 is the normal level, and 2 is for
|
0 means no debugging information, 1 is the normal level, and 2 is for
|
||||||
|
@ -27,14 +27,14 @@ stderr. \fBwine(1)\fR will automatically set the debug level when
|
||||||
starting \fBwineserver\fR if the +server option is set in the
|
starting \fBwineserver\fR if the +server option is set in the
|
||||||
WINEDEBUG variable.
|
WINEDEBUG variable.
|
||||||
.TP
|
.TP
|
||||||
.B \-f
|
.B \-f, --foreground
|
||||||
Make the server remain in the foreground for easier debugging, for
|
Make the server remain in the foreground for easier debugging, for
|
||||||
instance when running it under a debugger.
|
instance when running it under a debugger.
|
||||||
.TP
|
.TP
|
||||||
.B \-h
|
.B \-h, --help
|
||||||
Display a help message.
|
Display a help message.
|
||||||
.TP
|
.TP
|
||||||
.BI \-k [n]
|
.BI \-k [n] ,\ --kill [=n]
|
||||||
Kill the currently running
|
Kill the currently running
|
||||||
.B wineserver,
|
.B wineserver,
|
||||||
optionally by sending signal \fIn\fR. If no signal is specified, sends
|
optionally by sending signal \fIn\fR. If no signal is specified, sends
|
||||||
|
@ -42,7 +42,7 @@ a SIGINT first and then a SIGKILL. The instance of \fBwineserver\fR
|
||||||
that is killed is selected based on the WINEPREFIX environment
|
that is killed is selected based on the WINEPREFIX environment
|
||||||
variable.
|
variable.
|
||||||
.TP
|
.TP
|
||||||
.BI \-p [n]
|
.BI \-p [n] ,\ --persistent [=n]
|
||||||
Specify the \fBwineserver\fR persistence delay, i.e. the amount of
|
Specify the \fBwineserver\fR persistence delay, i.e. the amount of
|
||||||
time that the server will keep running when all client processes have
|
time that the server will keep running when all client processes have
|
||||||
terminated. This avoids the cost of shutting down and starting again
|
terminated. This avoids the cost of shutting down and starting again
|
||||||
|
@ -50,10 +50,10 @@ when programs are launched in quick succession. The timeout \fIn\fR is
|
||||||
in seconds, the default value is 3 seconds. If \fIn\fR is not
|
in seconds, the default value is 3 seconds. If \fIn\fR is not
|
||||||
specified, the server stays around forever.
|
specified, the server stays around forever.
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v, --version
|
||||||
Display version information and exit.
|
Display version information and exit.
|
||||||
.TP
|
.TP
|
||||||
.B \-w
|
.B \-w, --wait
|
||||||
Wait until the currently running
|
Wait until the currently running
|
||||||
.B wineserver
|
.B wineserver
|
||||||
terminates.
|
terminates.
|
||||||
|
|
Loading…
Reference in New Issue