X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/668dc38ee0a1fb3ab8e42b8d9d09580150973ac7..c99dcaf6a0f9c7798580fc9f315d7b368c9f972c:/src/tools.c diff --git a/src/tools.c b/src/tools.c index 0ebae63..6815a36 100644 --- a/src/tools.c +++ b/src/tools.c @@ -625,6 +625,15 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int flags) if (match_ircglob(hidden_host, glob)) return 1; } + + /* Match crypt hostname */ + if (match_ircglob(user->crypthost, glob)) + return 1; + + /* Match crypt IP */ + if (match_ircglob(user->cryptip, glob)) + return 1; + /* If only matching the visible hostnames, bail early. */ if ((flags & MATCH_VISIBLE) && IsHiddenHost(user) && (IsFakeHost(user) || (hidden_host_suffix && user->handle_info))) @@ -1102,6 +1111,23 @@ char *mysep(char **sepstr, char *delim) return(retstr); } +/* Mallocing snprintf * + * + * If it overruns size, it will simply be safely truncated. + */ +char * +x3_msnprintf(const int size, const char *format, ...) +{ + va_list ap; + char* buff = calloc(sizeof(char *), size+1); + + va_start(ap, format); + vsnprintf(buff, size, format, ap); + va_end(ap); + buff = realloc(buff, strlen(buff) + 1); + return buff; +} + char *time2str(time_t thetime) { char *buf, *tmp; @@ -1267,3 +1293,16 @@ char *pretty_mask(char *mask) } return make_nick_user_host(retmask, nick, user, host); } + +int str_is_number(const char *str) +{ + char *ptr; + int ret = false; + for(ptr = (char *)str;*ptr;ptr++) { + if((*ptr >= '0' && *ptr <= '9') || *ptr == '-') + ret = true; + else + return false; + } + return ret; +}