config parse return values and error msgs

This commit is contained in:
Pasi Kallinen
2017-09-13 13:26:37 +03:00
parent 2c688a12d5
commit b6737fd1f6
+24 -24
View File
@@ -2262,7 +2262,7 @@ char *origbuf;
bufp = find_optparam(buf); bufp = find_optparam(buf);
if (!bufp) { if (!bufp) {
config_error_add("Not a config statement, missing '='"); config_error_add("Not a config statement, missing '='");
return 0; return FALSE;
} }
/* skip past '=', then space between it and value, if any */ /* skip past '=', then space between it and value, if any */
++bufp; ++bufp;
@@ -2439,8 +2439,8 @@ char *origbuf;
n = !!atoi(bufp); /* XXX this could be tighter */ n = !!atoi(bufp); /* XXX this could be tighter */
/* allow anyone to turn it off, but only sysconf to turn it on*/ /* allow anyone to turn it off, but only sysconf to turn it on*/
if (src != SET_IN_SYS && n != 0) { if (src != SET_IN_SYS && n != 0) {
raw_printf("Illegal value in SEDUCE"); config_error_add("Illegal value in SEDUCE");
return 0; return FALSE;
} }
sysopt.seduce = n; sysopt.seduce = n;
sysopt_seduce_set(sysopt.seduce); sysopt_seduce_set(sysopt.seduce);
@@ -2448,45 +2448,45 @@ char *origbuf;
n = atoi(bufp); n = atoi(bufp);
/* XXX to get more than 25, need to rewrite all lock code */ /* XXX to get more than 25, need to rewrite all lock code */
if (n < 0 || n > 25) { if (n < 0 || n > 25) {
raw_printf("Illegal value in MAXPLAYERS (maximum is 25)."); config_error_add("Illegal value in MAXPLAYERS (maximum is 25).");
return 0; return FALSE;
} }
sysopt.maxplayers = n; sysopt.maxplayers = n;
} else if (src == SET_IN_SYS && match_varname(buf, "PERSMAX", 7)) { } else if (src == SET_IN_SYS && match_varname(buf, "PERSMAX", 7)) {
n = atoi(bufp); n = atoi(bufp);
if (n < 1) { if (n < 1) {
raw_printf("Illegal value in PERSMAX (minimum is 1)."); config_error_add("Illegal value in PERSMAX (minimum is 1).");
return 0; return FALSE;
} }
sysopt.persmax = n; sysopt.persmax = n;
} else if (src == SET_IN_SYS && match_varname(buf, "PERS_IS_UID", 11)) { } else if (src == SET_IN_SYS && match_varname(buf, "PERS_IS_UID", 11)) {
n = atoi(bufp); n = atoi(bufp);
if (n != 0 && n != 1) { if (n != 0 && n != 1) {
raw_printf("Illegal value in PERS_IS_UID (must be 0 or 1)."); config_error_add("Illegal value in PERS_IS_UID (must be 0 or 1).");
return 0; return FALSE;
} }
sysopt.pers_is_uid = n; sysopt.pers_is_uid = n;
} else if (src == SET_IN_SYS && match_varname(buf, "ENTRYMAX", 8)) { } else if (src == SET_IN_SYS && match_varname(buf, "ENTRYMAX", 8)) {
n = atoi(bufp); n = atoi(bufp);
if (n < 10) { if (n < 10) {
raw_printf("Illegal value in ENTRYMAX (minimum is 10)."); config_error_add("Illegal value in ENTRYMAX (minimum is 10).");
return 0; return FALSE;
} }
sysopt.entrymax = n; sysopt.entrymax = n;
} else if ((src == SET_IN_SYS) && match_varname(buf, "POINTSMIN", 9)) { } else if ((src == SET_IN_SYS) && match_varname(buf, "POINTSMIN", 9)) {
n = atoi(bufp); n = atoi(bufp);
if (n < 1) { if (n < 1) {
raw_printf("Illegal value in POINTSMIN (minimum is 1)."); config_error_add("Illegal value in POINTSMIN (minimum is 1).");
return 0; return FALSE;
} }
sysopt.pointsmin = n; sysopt.pointsmin = n;
} else if (src == SET_IN_SYS } else if (src == SET_IN_SYS
&& match_varname(buf, "MAX_STATUENAME_RANK", 10)) { && match_varname(buf, "MAX_STATUENAME_RANK", 10)) {
n = atoi(bufp); n = atoi(bufp);
if (n < 1) { if (n < 1) {
raw_printf( config_error_add(
"Illegal value in MAX_STATUENAME_RANK (minimum is 1)."); "Illegal value in MAX_STATUENAME_RANK (minimum is 1).");
return 0; return FALSE;
} }
sysopt.tt_oname_maxrank = n; sysopt.tt_oname_maxrank = n;
@@ -2496,8 +2496,8 @@ char *origbuf;
n = atoi(bufp); n = atoi(bufp);
#if defined(PANICTRACE) && defined(PANICTRACE_LIBC) #if defined(PANICTRACE) && defined(PANICTRACE_LIBC)
if (n < 0 || n > 2) { if (n < 0 || n > 2) {
raw_printf("Illegal value in PANICTRACE_LIBC (not 0,1,2)."); config_error_add("Illegal value in PANICTRACE_LIBC (not 0,1,2).");
return 0; return FALSE;
} }
#endif #endif
sysopt.panictrace_libc = n; sysopt.panictrace_libc = n;
@@ -2506,16 +2506,16 @@ char *origbuf;
n = atoi(bufp); n = atoi(bufp);
#if defined(PANICTRACE) #if defined(PANICTRACE)
if (n < 0 || n > 2) { if (n < 0 || n > 2) {
raw_printf("Illegal value in PANICTRACE_GDB (not 0,1,2)."); config_error_add("Illegal value in PANICTRACE_GDB (not 0,1,2).");
return 0; return FALSE;
} }
#endif #endif
sysopt.panictrace_gdb = n; sysopt.panictrace_gdb = n;
} else if (src == SET_IN_SYS && match_varname(buf, "GDBPATH", 7)) { } else if (src == SET_IN_SYS && match_varname(buf, "GDBPATH", 7)) {
#if defined(PANICTRACE) && !defined(VMS) #if defined(PANICTRACE) && !defined(VMS)
if (!file_exists(bufp)) { if (!file_exists(bufp)) {
raw_printf("File specified in GDBPATH does not exist."); config_error_add("File specified in GDBPATH does not exist.");
return 0; return FALSE;
} }
#endif #endif
if (sysopt.gdbpath) if (sysopt.gdbpath)
@@ -2524,8 +2524,8 @@ char *origbuf;
} else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) { } else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) {
#if defined(PANICTRACE) && !defined(VMS) #if defined(PANICTRACE) && !defined(VMS)
if (!file_exists(bufp)) { if (!file_exists(bufp)) {
raw_printf("File specified in GREPPATH does not exist."); config_error_add("File specified in GREPPATH does not exist.");
return 0; return FALSE;
} }
#endif #endif
if (sysopt.greppath) if (sysopt.greppath)
@@ -2692,7 +2692,7 @@ char *origbuf;
#endif #endif
} else { } else {
config_error_add("Unknown config statement"); config_error_add("Unknown config statement");
return 0; return FALSE;
} }
return retval; return retval;
} }