Index: /trunk/include/sh_inotify.h
===================================================================
--- /trunk/include/sh_inotify.h	(revision 362)
+++ /trunk/include/sh_inotify.h	(revision 363)
@@ -6,10 +6,17 @@
 typedef struct 
 {
+  /*
+  void * list_of_watches;
+  */
+
   int    watch[SH_INOTIFY_MAX];
   int    flag[SH_INOTIFY_MAX];
   char * file[SH_INOTIFY_MAX];
-  int    count;
 
+  int     count;
+  int  max_count;
 } sh_watches;
+
+#define SH_INOTIFY_INITIALIZER { { 0 }, { 0 }, { NULL}, 0, 0 }
 
 int sh_inotify_wait_for_change(char * filename, sh_watches * watches, 
Index: /trunk/include/zAVLTree.h
===================================================================
--- /trunk/include/zAVLTree.h	(revision 362)
+++ /trunk/include/zAVLTree.h	(revision 363)
@@ -33,8 +33,11 @@
 
 /* typedef the keytype */
-typedef const char * zAVLKey;
+typedef const void * zAVLKey;
 
 /* Comparison function for strings is strcmp(). */
-#define zAVLKey_cmp(tree, a, b) (strcmp((a), (b)))
+/* #define zAVLKey_cmp(tree, a, b) (strcmp((a), (b))) */
+
+#define zAVL_KEY_STRING 0
+#define zAVL_KEY_INT    1
 
 
@@ -53,4 +56,5 @@
   long count;
   zAVLKey (*getkey)(const void *item);
+  int keytype;
 } zAVLTree;
 
@@ -62,5 +66,5 @@
 
 
-extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item));
+extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item), int keytype);
 extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item));
 extern int zAVLInsert (zAVLTree *avltree, void *item);
Index: /trunk/src/cutest_zAVLTree.c
===================================================================
--- /trunk/src/cutest_zAVLTree.c	(revision 362)
+++ /trunk/src/cutest_zAVLTree.c	(revision 363)
@@ -44,5 +44,5 @@
   CuAssertTrue(tc, NULL == ptr);
 
-  ztest_tree = zAVLAllocTree (ztest_key);
+  ztest_tree = zAVLAllocTree (ztest_key, zAVL_KEY_STRING);
   CuAssertPtrNotNull(tc, ztest_tree);
 
Index: /trunk/src/sh_files.c
===================================================================
--- /trunk/src/sh_files.c	(revision 362)
+++ /trunk/src/sh_files.c	(revision 363)
@@ -897,5 +897,5 @@
   if (zfileList == NULL)
     {
-      zfileList = zAVLAllocTree (zdirstack_key);
+      zfileList = zAVLAllocTree (zdirstack_key, zAVL_KEY_STRING);
       if (zfileList == NULL) 
 	{
@@ -975,5 +975,5 @@
 	  if (zglobList == NULL)
 	    {
-	      zglobList = zAVLAllocTree (zdirstack_key);
+	      zglobList = zAVLAllocTree (zdirstack_key, zAVL_KEY_STRING);
 	      if (zglobList == NULL) 
 		{
@@ -1456,5 +1456,5 @@
   if (tree == NULL)
     {
-      tree = zAVLAllocTree (zdirstack_key);
+      tree = zAVLAllocTree (zdirstack_key, zAVL_KEY_STRING);
       if (tree == NULL) 
 	{
Index: /trunk/src/sh_forward.c
===================================================================
--- /trunk/src/sh_forward.c	(revision 362)
+++ /trunk/src/sh_forward.c	(revision 363)
@@ -2088,5 +2088,5 @@
   if (all_clients == NULL)
     {
-      all_clients = zAVLAllocTree (sh_avl_key);
+      all_clients = zAVLAllocTree (sh_avl_key, zAVL_KEY_STRING);
       if (all_clients == NULL) 
 	{
Index: /trunk/src/sh_log_evalrule.c
===================================================================
--- /trunk/src/sh_log_evalrule.c	(revision 362)
+++ /trunk/src/sh_log_evalrule.c	(revision 363)
@@ -1122,5 +1122,5 @@
     {
       DEBUG("debug: allocate new counterlist AVL tree\n");
-      rule->counterlist = zAVLAllocTree(sh_eval_getkey);
+      rule->counterlist = zAVLAllocTree(sh_eval_getkey, zAVL_KEY_STRING);
     }
 
Index: /trunk/src/sh_log_mark.c
===================================================================
--- /trunk/src/sh_log_mark.c	(revision 362)
+++ /trunk/src/sh_log_mark.c	(revision 363)
@@ -77,5 +77,5 @@
   if (!(marklist))
     {
-      marklist = zAVLAllocTree(sh_log_mark_getkey);
+      marklist = zAVLAllocTree(sh_log_mark_getkey, zAVL_KEY_STRING);
     }
 
Index: /trunk/src/sh_nmail.c
===================================================================
--- /trunk/src/sh_nmail.c	(revision 362)
+++ /trunk/src/sh_nmail.c	(revision 363)
@@ -957,5 +957,5 @@
     }
 
-  mailkeys = zAVLAllocTree (sh_nmail_getkey);
+  mailkeys = zAVLAllocTree (sh_nmail_getkey, zAVL_KEY_STRING);
   goto start;
 }
Index: /trunk/src/sh_utmp.c
===================================================================
--- /trunk/src/sh_utmp.c	(revision 362)
+++ /trunk/src/sh_utmp.c	(revision 363)
@@ -558,5 +558,5 @@
 
 #if defined(HAVE_PTHREAD)
-static sh_watches inotify_watch;
+static sh_watches inotify_watch = SH_INOTIFY_INITIALIZER;
 #endif
 
Index: /trunk/src/zAVLTree.c
===================================================================
--- /trunk/src/zAVLTree.c	(revision 362)
+++ /trunk/src/zAVLTree.c	(revision 363)
@@ -53,4 +53,24 @@
 #define ZAVL_NO 0
 
+/* The comparison function. Was a macro, but this allows for more
+ * flexibility (non-string keys). The key is a (void *) now, and
+ * the type is stored in the zAVLTree struct. Oct 21, 2011, rw
+ */
+static int zAVLKey_cmp(const zAVLTree * tree, zAVLKey a, zAVLKey b)
+{
+  if (tree->keytype == zAVL_KEY_STRING)
+    {
+      return (strcmp((char*)a, (char *)b));
+    }
+  else /* zAVL_KEY_INT */
+    {
+      int x = *((int *)a);
+      int y = *((int *)b);
+
+      if      (x > y) return  1;
+      else if (x < y) return -1;
+      else return 0;
+    }
+}
 
 /*
@@ -62,5 +82,5 @@
  * was a malloc failure, then NULL is returned.
  */
-zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item))
+zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item), int keytype)
 {
   zAVLTree *rc;
@@ -73,4 +93,5 @@
   rc->count = 0;
   rc->getkey = getkey;
+  rc->keytype = keytype;
   return rc;
 }
