New utility program empsched.
This commit is contained in:
parent
47be4f724c
commit
eeb9d3cb04
4 changed files with 159 additions and 2 deletions
|
@ -47,4 +47,5 @@ starting June 1st 2007, skipping July 4th:
|
||||||
skip 2007-07-04 20:00
|
skip 2007-07-04 20:00
|
||||||
|
|
||||||
The server reads the schedule file on startup, after an update, on the
|
The server reads the schedule file on startup, after an update, on the
|
||||||
reload command, and on catching SIGHUP.
|
reload command, and on catching SIGHUP. You can use the utility
|
||||||
|
program empsched to test a schedule before you install it.
|
||||||
|
|
|
@ -98,7 +98,8 @@ parameters, you must remove the service and reinstall the service.\}
|
||||||
.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 "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
\fIempire\fR(6), \fIfairland\fR(6), \fIfiles\fR(6), \fIpconfig\fR(6).
|
\fIempire\fR(6), \fIempsched\fR(6), \fIfairland\fR(6), \fIfiles\fR(6),
|
||||||
|
\fIpconfig\fR(6).
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
Dave Pare, Jeff Bailey, Thomas Ruschak, Ken Stevens and Steve McClure
|
Dave Pare, Jeff Bailey, Thomas Ruschak, Ken Stevens and Steve McClure
|
||||||
are principal authors. The full list of authors is too long to
|
are principal authors. The full list of authors is too long to
|
||||||
|
|
41
man/empsched.6
Normal file
41
man/empsched.6
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
.TH PRSCHED 1
|
||||||
|
.SH NAME
|
||||||
|
prsched \- Print Empire update schedule
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B prsched
|
||||||
|
[
|
||||||
|
.B \-hv
|
||||||
|
]
|
||||||
|
[
|
||||||
|
.BI \-e " configfile"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
.BI \-n " number"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
.I file
|
||||||
|
]
|
||||||
|
.br
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B prsched
|
||||||
|
prints the Empire update schedule.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.BI \-e " configfile"
|
||||||
|
Use game configuration in \fIconfigfile\fR.
|
||||||
|
.TP
|
||||||
|
.B \-h
|
||||||
|
Help. Print brief usage information and exit.
|
||||||
|
.TP
|
||||||
|
.BI \-n " number"
|
||||||
|
Print \fInumber\fR updates.
|
||||||
|
.TP
|
||||||
|
.B \-v
|
||||||
|
Print version information and exit.
|
||||||
|
.SH OPERANDS
|
||||||
|
If \fIfile\fR is given, \fBprsched\fR prints the schedule defined
|
||||||
|
there instead of the current schedule.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fIemp_server\fR(6).
|
||||||
|
.SH AUTHOR
|
||||||
|
Markus Armbruster <armbru@pond.sub.org>
|
114
src/util/empsched.c
Normal file
114
src/util/empsched.c
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* Empire - A multi-player, client/server Internet based war game.
|
||||||
|
* Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
|
||||||
|
* Ken Stevens, Steve McClure
|
||||||
|
*
|
||||||
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* ---
|
||||||
|
*
|
||||||
|
* See files README, COPYING and CREDITS in the root of the source
|
||||||
|
* tree for related information and legal notices. It is expected
|
||||||
|
* that future projects/authors will amend these files as needed.
|
||||||
|
*
|
||||||
|
* ---
|
||||||
|
*
|
||||||
|
* empsched.c: Show the update schedule
|
||||||
|
*
|
||||||
|
* Known contributors to this file:
|
||||||
|
* Markus Armbruster, 2007
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "../lib/gen/getopt.h"
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "optlist.h"
|
||||||
|
#include "prototypes.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
#define DFLT_N 16
|
||||||
|
#define MAX_N 1000
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_usage(char *program_name)
|
||||||
|
{
|
||||||
|
printf("Usage: %s [OPTION]... [FILE]\n"
|
||||||
|
"Print the Empire update schedule.\n\n"
|
||||||
|
" -e CONFIG-FILE configuration file\n"
|
||||||
|
" (default %s)\n"
|
||||||
|
" -n NUMBER print at most NUMBER updates (default %d)\n"
|
||||||
|
" -h display this help and exit\n"
|
||||||
|
" -v display version information and exit\n\n"
|
||||||
|
"If FILE is given, print the schedule defined there instead of\n"
|
||||||
|
"the current schedule.\n",
|
||||||
|
program_name, dflt_econfig, DFLT_N);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *config_file = NULL;
|
||||||
|
char *in_file;
|
||||||
|
unsigned long n = DFLT_N;
|
||||||
|
time_t sched[MAX_N + 1];
|
||||||
|
int opt, i;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "e:n:hv")) != EOF) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'e':
|
||||||
|
config_file = optarg;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
n = strtoul(optarg, NULL, 10);
|
||||||
|
if (n > MAX_N) {
|
||||||
|
fprintf(stderr, "%s: can't print more than %d updates",
|
||||||
|
argv[0], MAX_N);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
print_usage(argv[0]);
|
||||||
|
exit(0);
|
||||||
|
case 'v':
|
||||||
|
printf("%s\n\n%s", version, legal);
|
||||||
|
exit(0);
|
||||||
|
default:
|
||||||
|
print_usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emp_config(config_file) < 0)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
if (!argv[optind])
|
||||||
|
in_file = schedulefil;
|
||||||
|
else if (!strcmp(argv[optind], "-"))
|
||||||
|
in_file = NULL;
|
||||||
|
else
|
||||||
|
in_file = argv[optind];
|
||||||
|
|
||||||
|
read_schedule(in_file, sched, n + 1, 0, 0/* FIXME */);
|
||||||
|
|
||||||
|
for (i = 0; sched[i]; i++)
|
||||||
|
printf("%s", ctime(&sched[i]));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue