X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/19fe6b99408a97e6a79b2a79b405bf7923c08e80..51db18e02060ffaee80af608346df7bf66007e8e:/src/tools.c diff --git a/src/tools.c b/src/tools.c index ecfdc1e..172765f 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1,7 +1,7 @@ /* tools.c - miscellaneous utility functions * Copyright 2000-2004 srvx Development Team * - * This file is part of srvx. + * This file is part of x3. * * srvx is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -418,24 +418,24 @@ user_matches_glob_broken(struct userNode *user, const char *orig_glob, int inclu if (!match_ircglob(user->ident, glob) && (IsSetHost(user) && !match_ircglob(setident, glob))) return 0; glob = marker + 1; - /* Now check the host part */ - if (isdigit(*glob) && !glob[strspn(glob, "0123456789./*?")]) { - /* Looks like an IP-based mask */ - return match_ircglob(inet_ntoa(user->ip), glob); - } else { - /* The host part of the mask isn't IP-based */ - if (IsSetHost(user) && match_ircglob(sethostname, glob)) - return 1; - if (IsFakeHost(user) && match_ircglob(user->fakehost, glob)) + /* If it might be an IP glob, test that. */ + if (!glob[strspn(glob, "0123456789./*?")] + && match_ircglob(inet_ntoa(user->ip), glob)) + return 1; + /* Check for a fakehost match. */ + if (IsFakeHost(user) && match_ircglob(user->fakehost, glob)) + return 1; + if (IsSetHost(user) && match_ircglob(sethostname, glob)) + return 1; + /* Check for an account match. */ + if (hidden_host_suffix && user->handle_info) { + char hidden_host[HOSTLEN+1]; + snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix); + if (match_ircglob(hidden_host, glob)) return 1; - if (hidden_host_suffix && user->handle_info) { - char hidden_host[HOSTLEN+1]; - snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix); - if (match_ircglob(hidden_host, glob)) - return 1; - } - return match_ircglob(user->hostname, glob); } + /* None of the above; could only be a hostname match. */ + return match_ircglob(user->hostname, glob); } int @@ -464,7 +464,7 @@ is_gline(const char *text) return 0; if (!*text) return 0; - while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) + while (*text && (isalnum((char)*text) || strchr(".-?*:", *text))) text++; return !*text; } @@ -493,7 +493,7 @@ split_ircmask(char *text, char **nick, char **ident, char **host) *ident = start; start = ++text; - while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) + while (*text && (isalnum((char)*text) || strchr(".-?*:", *text))) text++; if (host) *host = start; @@ -952,3 +952,13 @@ char *mysep(char **sepstr, char *delim) return(retstr); } +char *time2str(time_t thetime) +{ + char *buf, *tmp; + + buf = ctime(&thetime); + tmp = (char *)strchr(buf, '\n'); + *tmp = '\0'; + return(buf); +} +