diff --git a/src/compat.h b/src/compat.h index fbd1073..56b414e 100644 --- a/src/compat.h +++ b/src/compat.h @@ -31,6 +31,8 @@ #define SYSKLOGD_COMPAT_H_ #include +#include +#include /* * The following macro is used to remove const cast-away warnings @@ -69,4 +71,33 @@ static inline char *getprogname(void) return __progname; } +static inline int strtobytes(char *arg) +{ + int mod = 0, bytes; + size_t pos; + + if (!arg) + return -1; + + pos = strspn(arg, "0123456789"); + if (arg[pos] != 0) { + if (arg[pos] == 'G') + mod = 3; + else if (arg[pos] == 'M') + mod = 2; + else if (arg[pos] == 'k') + mod = 1; + else + return -1; + + arg[pos] = 0; + } + + bytes = atoi(arg); + while (mod--) + bytes *= 1000; + + return bytes; +} + #endif /* SYSKLOGD_COMPAT_H_ */ diff --git a/src/syslogd.c b/src/syslogd.c index 2a2718c..d7ff37e 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -569,6 +569,7 @@ static char sccsid[] __attribute__((unused)) = #endif #include "config.h" #include +#include "compat.h" /* * Linux uses EIO instead of EBADFD (mrn 12 May 96) @@ -2713,35 +2714,6 @@ void init(void) logit("syslogd: restarted.\n"); } -static int strtobytes(char *arg) -{ - int mod = 0, bytes; - size_t pos; - - if (!arg) - return -1; - - pos = strspn(arg, "0123456789"); - if (arg[pos] != 0) { - if (arg[pos] == 'G') - mod = 3; - else if (arg[pos] == 'M') - mod = 2; - else if (arg[pos] == 'k') - mod = 1; - else - return -1; - - arg[pos] = 0; - } - - bytes = atoi(arg); - while (mod--) - bytes *= 1000; - - return bytes; -} - /* * Crack a configuration file line */