CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2003-01-12 23:54:46 UTC

Modified files:
     ChangeLog include/class.h include/ircd_string.h ircd/class.c
     ircd/gline.c ircd/ircd_string.c

Log message:

Author: Thomas Helvey <[EMAIL PROTECTED]> Message: Add hasher, fix bugster

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.373 ircu2.10/ChangeLog:1.374
--- ircu2.10/ChangeLog:1.373    Sat Jan 11 04:49:22 2003
+++ ircu2.10/ChangeLog  Sun Jan 12 15:54:35 2003
@@ -1,3 +1,8 @@
+2003-01-12  Thomas Helvey <[EMAIL PROTECTED]>
+       * include/class.h, include/ircd_string.h, ircd/class.c,
+       ircd/gline.c, ircd_string.c: Fix undefined order
+       of evaluation bug in gline.c, add general purpose hasher for
+       conf entries. 
 2003-01-11  Thomas Helvey <[EMAIL PROTECTED]>
        * include/channel.h, include/ircd_alloc.h, ircd/channel.c,
        ircd/client.c, ircd/gline.c, ircd/ircd_alloc.c,
Index: ircu2.10/include/class.h
diff -u ircu2.10/include/class.h:1.13 ircu2.10/include/class.h:1.14
--- ircu2.10/include/class.h:1.13       Tue Jan  7 02:06:44 2003
+++ ircu2.10/include/class.h    Sun Jan 12 15:54:36 2003
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: class.h,v 1.13 2003/01/07 10:06:44 a1kmm Exp $
+ * $Id: class.h,v 1.14 2003/01/12 23:54:36 bleepster Exp $
  */
 #ifndef INCLUDED_class_h
 #define INCLUDED_class_h
@@ -80,7 +80,8 @@
 extern int get_conf_ping(const struct ConfItem *aconf);
 extern char *get_client_class(struct Client *acptr);
 extern void add_class(char *name, unsigned int ping,
-                      unsigned int confreq, unsigned int maxli, unsigned int sendq);
+                      unsigned int confreq, unsigned int maxli,
+                      unsigned int sendq);
 extern void check_class(void);
 extern void report_classes(struct Client *sptr, struct StatDesc *sd, int stat,
                            char *param);
Index: ircu2.10/include/ircd_string.h
diff -u ircu2.10/include/ircd_string.h:1.5 ircu2.10/include/ircd_string.h:1.6
--- ircu2.10/include/ircd_string.h:1.5  Fri Jun 29 08:51:00 2001
+++ ircu2.10/include/ircd_string.h      Sun Jan 12 15:54:36 2003
@@ -1,7 +1,7 @@
 /*
  * ircd_string.h
  *
- * $Id: ircd_string.h,v 1.5 2001/06/29 15:51:00 kev Exp $
+ * $Id: ircd_string.h,v 1.6 2003/01/12 23:54:36 bleepster Exp $
  */
 #ifndef INCLUDED_ircd_string_h
 #define INCLUDED_ircd_string_h
@@ -23,11 +23,15 @@
 extern int string_is_address(const char* str);
 extern int string_has_wildcards(const char* str);
 
+/*! Return hash for string using PJW algorithm */
+extern unsigned hash_pjw(const char* str);
 extern char*       ircd_strncpy(char* dest, const char* src, size_t len);
 extern int         ircd_strcmp(const char *a, const char *b);
 extern int         ircd_strncmp(const char *a, const char *b, size_t n);
-extern int         unique_name_vector(char* names, char token, char** vector, int 
size);
-extern int         token_vector(char* names, char token, char** vector, int size);
+extern int         unique_name_vector(char* names, char token,
+                                      char** vector, int size);
+extern int         token_vector(char* names, char token,
+                                char** vector, int size);
 extern const char* ircd_ntoa(const char* addr);
 extern const char* ircd_ntoa_r(char* buf, const char* addr);
 extern char*       host_from_uh(char* buf, const char* userhost, size_t len);
Index: ircu2.10/ircd/class.c
diff -u ircu2.10/ircd/class.c:1.24 ircu2.10/ircd/class.c:1.25
--- ircu2.10/ircd/class.c:1.24  Tue Jan  7 02:06:42 2003
+++ ircu2.10/ircd/class.c       Sun Jan 12 15:54:36 2003
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: class.c,v 1.24 2003/01/07 10:06:42 a1kmm Exp $
+ * $Id: class.c,v 1.25 2003/01/12 23:54:36 bleepster Exp $
  */
 #include "config.h"
 
@@ -119,7 +119,8 @@
 
   for (prev = cl = connClassList; cl; cl = prev->next) {
     Debug((DEBUG_DEBUG, "Class %s : CF: %d PF: %d ML: %d LI: %d SQ: %d",
-           ConClass(cl), ConFreq(cl), PingFreq(cl), MaxLinks(cl), Links(cl), 
MaxSendq(cl)));
+           ConClass(cl), ConFreq(cl), PingFreq(cl), MaxLinks(cl),
+           Links(cl), MaxSendq(cl)));
     /*
      * unlink marked classes, delete unreferenced ones
      */
@@ -270,7 +271,8 @@
 void class_send_meminfo(struct Client* cptr)
 {
   send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Classes: inuse: %d(%d)",
-             connClassAllocCount, connClassAllocCount * sizeof(struct 
ConnectionClass));
+             connClassAllocCount,
+             connClassAllocCount * sizeof(struct ConnectionClass));
 }
 
 
Index: ircu2.10/ircd/gline.c
diff -u ircu2.10/ircd/gline.c:1.42 ircu2.10/ircd/gline.c:1.43
--- ircu2.10/ircd/gline.c:1.42  Sat Jan 11 04:49:26 2003
+++ ircu2.10/ircd/gline.c       Sun Jan 12 15:54:36 2003
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: gline.c,v 1.42 2003/01/11 12:49:26 bleepster Exp $
+ * $Id: gline.c,v 1.43 2003/01/12 23:54:36 bleepster Exp $
  */
 #include "config.h"
 
@@ -242,7 +242,8 @@
     } else if (*mask == '*' || *mask == '?')
       flags |= MASK_WILD_0 | MASK_WILDS; /* found a wildcard */
     else if (*mask == '/') { /* n.n.n.n/n notation; parse bit specifier */
-      ipmask = strtoul(++mask, &mask, 10);
+      ++mask;
+      ipmask = strtoul(mask, &mask, 10);
 
       if (*mask || dots != 3 || ipmask > 32 || /* sanity-check to date */
          (flags & (MASK_WILDS | MASK_IP)) != MASK_IP)
Index: ircu2.10/ircd/ircd_string.c
diff -u ircu2.10/ircd/ircd_string.c:1.11 ircu2.10/ircd/ircd_string.c:1.12
--- ircu2.10/ircd/ircd_string.c:1.11    Sun Sep 23 17:04:16 2001
+++ ircu2.10/ircd/ircd_string.c Sun Jan 12 15:54:36 2003
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: ircd_string.c,v 1.11 2001/09/24 00:04:16 isomer Exp $
+ * $Id: ircd_string.c,v 1.12 2003/01/12 23:54:36 bleepster Exp $
  */
 #include "config.h"
 
@@ -45,7 +45,8 @@
 static regex_t hostRegex;
 
 static const char* addrExpr =
-    
"^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){1,3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$";
+    "^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){1,3}"
+    "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$";
 static regex_t addrRegex;
 
 int init_string(void)
@@ -89,6 +90,22 @@
       return 1;
   }
   return 0;
+}
+
+unsigned int hash_pjw(const char* str)
+{
+  unsigned h = 0;
+  unsigned g;
+  assert(str);
+
+  for ( ; *str; ++str) {
+    h = (h << 4) + *str;
+    if ((g = h & 0xf0000000)) {
+      h ^= g >> 24;  /* fold top four bits onto ------X- */
+      h ^= g;        /* clear top four bits */
+    }
+  }
+  return h;
 }
 
 /*
----------------------- End of diff -----------------------

Reply via email to