]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/tools.c
fix bug when ldap is compiled in but disabled in config
[irc/evilnet/x3.git] / src / tools.c
index 0ebae6392618dc59f8ccb9ec4b23848102100058..6815a3605a173752e5f6e5a00263b3d9f07b1cf2 100644 (file)
@@ -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;
+}