diff options
Diffstat (limited to 'src/server_check.c')
-rw-r--r-- | src/server_check.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/server_check.c b/src/server_check.c new file mode 100644 index 0000000..94069cc --- /dev/null +++ b/src/server_check.c @@ -0,0 +1,61 @@ +/* + * active port forwarder - software for secure forwarding + * Copyright (C) 2003,2004,2005 jeremian <jeremian [at] poczta.fm> + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> + +#include "stats.h" + +void +check_value(int* where, char* what, char* info) +{ + char* znak; + long tmp; + if ((tmp = strtol(what, &znak, 10)) >= INT_MAX) { + aflog(0, "%s: %s\n", info, what); + exit(1); + } + if (((*what) == '\0') || (*znak != '\0')) { + aflog(0, "%s: %s\n", info, what); + exit(1); + } + if (tmp <= 0) { + aflog(0, "%s: %d\n", info, *where); + exit(1); + } + (*where) = tmp; +} + +int +check_long(char* text, long* number) +{ + char* tmp; + if (((*number = strtol(text, &tmp, 10)) == LONG_MAX) || (*number == LONG_MIN)) { + return 1; + } + if ((*text != '\0') && (*tmp == '\0')) { + return 0; + } + else { + return 2; + } +} + |