forked from github/server
indentation rules, strictly applied
This commit is contained in:
parent
763d134b9f
commit
27e435850e
1 changed files with 49 additions and 50 deletions
99
src/main.c
99
src/main.c
|
@ -32,14 +32,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
|
||||||
static const char * luafile = "setup.lua";
|
static const char *luafile = "setup.lua";
|
||||||
static const char * entry_point = NULL;
|
|
||||||
static const char * inifile = "eressea.ini";
|
static const char *entry_point = NULL;
|
||||||
|
|
||||||
|
static const char *inifile = "eressea.ini";
|
||||||
|
|
||||||
static int memdebug = 0;
|
static int memdebug = 0;
|
||||||
|
|
||||||
static void parse_config(const char * filename)
|
static void parse_config(const char *filename)
|
||||||
{
|
{
|
||||||
dictionary * d = iniparser_new(filename);
|
dictionary *d = iniparser_new(filename);
|
||||||
|
|
||||||
if (d) {
|
if (d) {
|
||||||
load_inifile(d);
|
load_inifile(d);
|
||||||
|
|
||||||
|
@ -53,8 +57,7 @@ static void parse_config(const char * filename)
|
||||||
global.inifile = d;
|
global.inifile = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int usage(const char *prog, const char *arg)
|
||||||
usage(const char * prog, const char * arg)
|
|
||||||
{
|
{
|
||||||
if (arg) {
|
if (arg) {
|
||||||
fprintf(stderr, "unknown argument: %s\n\n", arg);
|
fprintf(stderr, "unknown argument: %s\n\n", arg);
|
||||||
|
@ -65,62 +68,58 @@ usage(const char * prog, const char * arg)
|
||||||
"-v <level> : verbosity level\n"
|
"-v <level> : verbosity level\n"
|
||||||
"-C : run in interactive mode\n"
|
"-C : run in interactive mode\n"
|
||||||
"--color : force curses to use colors even when not detected\n"
|
"--color : force curses to use colors even when not detected\n"
|
||||||
"--tests : run test suite\n"
|
"--tests : run test suite\n" "--help : help\n", prog);
|
||||||
"--help : help\n", prog);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int parse_args(int argc, char **argv, int *exitcode)
|
||||||
parse_args(int argc, char **argv, int * exitcode)
|
|
||||||
{
|
{
|
||||||
int i, run_tests = 0;
|
int i, run_tests = 0;
|
||||||
|
|
||||||
for (i=1;i!=argc;++i) {
|
for (i = 1; i != argc; ++i) {
|
||||||
if (argv[i][0]!='-') {
|
if (argv[i][0] != '-') {
|
||||||
return usage(argv[0], argv[i]);
|
return usage(argv[0], argv[i]);
|
||||||
} else if (argv[i][1]=='-') { /* long format */
|
} else if (argv[i][1] == '-') { /* long format */
|
||||||
if (strcmp(argv[i]+2, "version")==0) {
|
if (strcmp(argv[i] + 2, "version") == 0) {
|
||||||
printf("\n%s PBEM host\n"
|
printf("\n%s PBEM host\n"
|
||||||
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
|
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
|
||||||
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
|
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n",
|
||||||
}
|
global.gamename, version());
|
||||||
else if (strcmp(argv[i]+2, "color")==0) {
|
} else if (strcmp(argv[i] + 2, "color") == 0) {
|
||||||
/* force the editor to have colors */
|
/* force the editor to have colors */
|
||||||
force_color = 1;
|
force_color = 1;
|
||||||
}
|
} else if (strcmp(argv[i] + 2, "help") == 0) {
|
||||||
else if (strcmp(argv[i]+2, "help")==0) {
|
|
||||||
return usage(argv[0], NULL);
|
return usage(argv[0], NULL);
|
||||||
}
|
} else if (strcmp(argv[i] + 2, "tests") == 0) {
|
||||||
else if (strcmp(argv[i]+2, "tests")==0) {
|
|
||||||
run_tests = 1;
|
run_tests = 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return usage(argv[0], argv[i]);
|
return usage(argv[0], argv[i]);
|
||||||
}
|
}
|
||||||
} else switch(argv[i][1]) {
|
} else
|
||||||
case 'C':
|
switch (argv[i][1]) {
|
||||||
entry_point = NULL;
|
case 'C':
|
||||||
break;
|
entry_point = NULL;
|
||||||
case 'e':
|
break;
|
||||||
entry_point = argv[++i];
|
case 'e':
|
||||||
break;
|
entry_point = argv[++i];
|
||||||
case 't':
|
break;
|
||||||
turn = atoi(argv[++i]);
|
case 't':
|
||||||
break;
|
turn = atoi(argv[++i]);
|
||||||
case 'q':
|
break;
|
||||||
verbosity = 0;
|
case 'q':
|
||||||
break;
|
verbosity = 0;
|
||||||
case 'v':
|
break;
|
||||||
verbosity = atoi(argv[++i]);
|
case 'v':
|
||||||
break;
|
verbosity = atoi(argv[++i]);
|
||||||
case 'h':
|
break;
|
||||||
usage(argv[0], NULL);
|
case 'h':
|
||||||
return 1;
|
usage(argv[0], NULL);
|
||||||
default:
|
return 1;
|
||||||
*exitcode = -1;
|
default:
|
||||||
usage(argv[0], argv[i]);
|
*exitcode = -1;
|
||||||
return 1;
|
usage(argv[0], argv[i]);
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_tests) {
|
if (run_tests) {
|
||||||
|
@ -136,10 +135,10 @@ void locale_init(void)
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
assert(towlower(0xC4)==0xE4); /* Ä => ä */
|
assert(towlower(0xC4) == 0xE4); /* Ä => ä */
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int err, result = 0;
|
int err, result = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue