diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-21 11:40:05 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-21 11:40:05 +0000 |
commit | e7f46d3292db21968d5e61dd6ce8e1649535e355 (patch) | |
tree | db3b90775b457ce36b6b8e022e0fbf648bd87cc2 | |
parent | 8a9bbfe513c4c3a01a779126c7eba529bd3c02d3 (diff) |
- conf.c:valid_tkline(): minor cleanups
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2312 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r-- | include/conf.h | 2 | ||||
-rw-r--r-- | src/conf.c | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/include/conf.h b/include/conf.h index ae9bc93..16a6766 100644 --- a/include/conf.h +++ b/include/conf.h @@ -386,7 +386,7 @@ extern int valid_comment(struct Client *, char *, int); #define TK_SECONDS 0 #define TK_MINUTES 1 -extern time_t valid_tkline(const char *, int); +extern time_t valid_tkline(const char *, const int); extern int match_conf_password(const char *, const struct MaskItem *); #define NOT_AUTHORIZED (-1) @@ -1719,17 +1719,19 @@ conf_error_report(const char *msg) * Originally written by Dianora (Diane, db@db.net) */ time_t -valid_tkline(const char *p, int minutes) +valid_tkline(const char *data, const int minutes) { + const unsigned char *p = (const unsigned char *)data; + unsigned char tmpch = '\0'; time_t result = 0; - for (; *p; ++p) + while ((tmpch = *p++)) { - if (!IsDigit(*p)) + if (!IsDigit(tmpch)) return 0; result *= 10; - result += (*p & 0xF); + result += (tmpch & 0xF); } /* @@ -1745,12 +1747,12 @@ valid_tkline(const char *p, int minutes) * of this calculation */ if (!minutes) - result = result / (time_t)60; + result = result / 60; if (result > MAX_TDKLINE_TIME) result = MAX_TDKLINE_TIME; - result = result * (time_t)60; /* turn it into seconds */ + result = result * 60; /* turn it into seconds */ return result; } |