Index: /trunk/src/sh_database.c
===================================================================
--- /trunk/src/sh_database.c	(revision 11)
+++ /trunk/src/sh_database.c	(revision 12)
@@ -53,4 +53,5 @@
   int    val;
   int    size;
+  int    alen;
   size_t off;
 } my_attr;
@@ -124,84 +125,87 @@
 } dbins;
 
+static my_attr * attr_tab_srch = NULL;
+static int       attr_tab_srch_siz = 0;
+
 static my_attr attr_tab[] = {
-  { NULL, N_("sev"),         0,   1,    8, offsetof(struct dbins_, sev) },
-  { NULL, N_("tstamp"),      0,   2,   16, offsetof(struct dbins_, time) },
-  { NULL, N_("remote_host"), 0,   3,   64, offsetof(struct dbins_, host) },
-  { NULL, N_("msg"),         0,   4, 1024, offsetof(struct dbins_, msg) },
-
-  { NULL, N_("path"),        0,   5,12288, offsetof(struct dbins_, path)  },
+  { NULL, N_("sev"),         0,   1,    8, 0, offsetof(struct dbins_, sev) },
+  { NULL, N_("tstamp"),      0,   2,   16, 0, offsetof(struct dbins_, time) },
+  { NULL, N_("remote_host"), 0,   3,   64, 0, offsetof(struct dbins_, host) },
+  { NULL, N_("msg"),         0,   4, 1024, 0, offsetof(struct dbins_, msg) },
+
+  { NULL, N_("path"),        0,   5,12288, 0, offsetof(struct dbins_, path)  },
   /* username -> userid; replace (long) 'userid' - below - by 'dummy' */ 
-  { NULL, N_("userid"),      0,   6,    9, offsetof(struct dbins_, user)  },
-  { NULL, N_("group"),       0,   7,    9, offsetof(struct dbins_, group)  },
-  { NULL, N_("program"),     0,   8,    8, offsetof(struct dbins_, program)  },
-  { NULL, N_("subroutine"),  0,   9,   16, offsetof(struct dbins_, subroutine)},
-  { NULL, N_("status"),      0,  10,   12, offsetof(struct dbins_, status)  },
-  { NULL, N_("hash"),        0,  11,   50, offsetof(struct dbins_, hash)  },
-  { NULL, N_("path_data"),   0,  12, 1024, offsetof(struct dbins_, path_data)  },
-  { NULL, N_("hash_data"),   0,  13,   50, offsetof(struct dbins_, hash_data)  },
-  { NULL, N_("key_uid"),     0,  14,   64, offsetof(struct dbins_, key_uid)  },
-  { NULL, N_("key_uid_data"),0,  15,   64, offsetof(struct dbins_, key_uid_data)},
-  { NULL, N_("key_id"),      0,  16,   16, offsetof(struct dbins_, key_id)  },
-  { NULL, N_("module"),      0,  17,    8, offsetof(struct dbins_, module)  },
-  { NULL, N_("syscall"),     0,  19,   16, offsetof(struct dbins_, syscall)  },
-  { NULL, N_("ip"),          0,  20,   16, offsetof(struct dbins_, ip)  },
-  { NULL, N_("tty"),         0,  21,   16, offsetof(struct dbins_, tty)  },
-  { NULL, N_("peer"),        0,  22,   64, offsetof(struct dbins_, peer)  },
-  { NULL, N_("obj"),         0,  23, 1024, offsetof(struct dbins_, obj)  },
-  { NULL, N_("interface"),   0,  24,   64, offsetof(struct dbins_, interface)},
-  { NULL, N_("time"),        0,  25,   64, offsetof(struct dbins_, ltime)  },
-  { NULL, N_("dir"),         0,  26, 1024, offsetof(struct dbins_, dir)  },
-  { NULL, N_("linked_path"), 0,  27, 1024, offsetof(struct dbins_, linked_path)},
-  { NULL, N_("service"),     0,  29,   64, offsetof(struct dbins_, service)},
-  { NULL, N_("facility"),    0,  30,   32, offsetof(struct dbins_, facility) },
-  { NULL, N_("priority"),    0,  31,   32, offsetof(struct dbins_, priority) },
-  { NULL, N_("syslog_msg"),  0,  32, 1024, offsetof(struct dbins_, syslog_msg)  },
-
-  { NULL, N_("mode_old"),    0,  33,   16, offsetof(struct dbins_, mode_old) },
-  { NULL, N_("mode_new"),    0,  34,   16, offsetof(struct dbins_, mode_new) },
-  { NULL, N_("device_old"),  0,  35,   16, offsetof(struct dbins_, device_old)}, 
-  { NULL, N_("device_new"),  0,  36,   16, offsetof(struct dbins_, device_new)},
-  { NULL, N_("owner_old"),   0,  37,    9, offsetof(struct dbins_, owner_old)},
-  { NULL, N_("owner_new"),   0,  38,    9, offsetof(struct dbins_, owner_new)},
-  { NULL, N_("group_old"),   0,  39,    9, offsetof(struct dbins_, group_old)},
-  { NULL, N_("group_new"),   0,  40,    9, offsetof(struct dbins_, group_new)},
-  { NULL, N_("ctime_old"),   0,  41,   20, offsetof(struct dbins_, ctime_old)},
-  { NULL, N_("ctime_new"),   0,  42,   20, offsetof(struct dbins_, ctime_new)},
-  { NULL, N_("atime_old"),   0,  43,   20, offsetof(struct dbins_, atime_old)},
-  { NULL, N_("atime_new"),   0,  44,   20, offsetof(struct dbins_, atime_new)},
-  { NULL, N_("mtime_old"),   0,  45,   20, offsetof(struct dbins_, mtime_old)},
-  { NULL, N_("mtime_new"),   0,  46,   20, offsetof(struct dbins_, mtime_new)},
-  { NULL, N_("chksum_old"),  0,  47,   50, offsetof(struct dbins_, chksum_old)},
-  { NULL, N_("chksum_new"),  0,  48,   50, offsetof(struct dbins_, chksum_new)},
-  { NULL, N_("link_old"),    0,  49, 1024, offsetof(struct dbins_, link_old)},
-  { NULL, N_("link_new"),    0,  50, 1024, offsetof(struct dbins_, link_new)},
-               
-  { NULL, N_("size_old"),     0,  51,    0, 0  },
-  { NULL, N_("size_new"),     0,  52,    0, 0  },
-  { NULL, N_("hardlinks_old"),0,  53,    0, 0  },
-  { NULL, N_("hardlinks_new"),0,  54,    0, 0  },
-  { NULL, N_("inode_old"),    0,  55,    0, 0  }, 
-  { NULL, N_("inode_new"),    0,  56,    0, 0  }, 
-
-  { NULL, N_("imode_old"),    0,  57,    0, 0  },
-  { NULL, N_("imode_new"),    0,  58,    0, 0  },
-  { NULL, N_("iattr_old"),    0,  59,    0, 0  },
-  { NULL, N_("iattr_new"),    0,  60,    0, 0  },
-  { NULL, N_("idevice_old"),  0,  61,    0, 0  }, 
-  { NULL, N_("idevice_new"),  0,  62,    0, 0  }, 
-  { NULL, N_("iowner_old"),   0,  63,    0, 0  },
-  { NULL, N_("iowner_new"),   0,  64,    0, 0  },
-  { NULL, N_("igroup_old"),   0,  65,    0, 0  },
-  { NULL, N_("igroup_new"),   0,  66,    0, 0  },
-
-  { NULL, N_("port"),         0,  67,    0, 0  },
-  { NULL, N_("return_code"),  0,  68,    0, 0  },
+  { NULL, N_("userid"),      0,   6,    9, 0, offsetof(struct dbins_, user)  },
+  { NULL, N_("group"),       0,   7,    9, 0, offsetof(struct dbins_, group)  },
+  { NULL, N_("program"),     0,   8,    8, 0, offsetof(struct dbins_, program)  },
+  { NULL, N_("subroutine"),  0,   9,   16, 0, offsetof(struct dbins_, subroutine)},
+  { NULL, N_("status"),      0,  10,   12, 0, offsetof(struct dbins_, status)  },
+  { NULL, N_("hash"),        0,  11,   50, 0, offsetof(struct dbins_, hash)  },
+  { NULL, N_("path_data"),   0,  12, 1024, 0, offsetof(struct dbins_, path_data)  },
+  { NULL, N_("hash_data"),   0,  13,   50, 0, offsetof(struct dbins_, hash_data)  },
+  { NULL, N_("key_uid"),     0,  14,   64, 0, offsetof(struct dbins_, key_uid)  },
+  { NULL, N_("key_uid_data"),0,  15,   64, 0, offsetof(struct dbins_, key_uid_data)},
+  { NULL, N_("key_id"),      0,  16,   16, 0, offsetof(struct dbins_, key_id)  },
+  { NULL, N_("module"),      0,  17,    8, 0, offsetof(struct dbins_, module)  },
+  { NULL, N_("syscall"),     0,  19,   16, 0, offsetof(struct dbins_, syscall)  },
+  { NULL, N_("ip"),          0,  20,   16, 0, offsetof(struct dbins_, ip)  },
+  { NULL, N_("tty"),         0,  21,   16, 0, offsetof(struct dbins_, tty)  },
+  { NULL, N_("peer"),        0,  22,   64, 0, offsetof(struct dbins_, peer)  },
+  { NULL, N_("obj"),         0,  23, 1024, 0, offsetof(struct dbins_, obj)  },
+  { NULL, N_("interface"),   0,  24,   64, 0, offsetof(struct dbins_, interface)},
+  { NULL, N_("time"),        0,  25,   64, 0, offsetof(struct dbins_, ltime)  },
+  { NULL, N_("dir"),         0,  26, 1024, 0, offsetof(struct dbins_, dir)  },
+  { NULL, N_("linked_path"), 0,  27, 1024, 0, offsetof(struct dbins_, linked_path)},
+  { NULL, N_("service"),     0,  29,   64, 0, offsetof(struct dbins_, service)},
+  { NULL, N_("facility"),    0,  30,   32, 0, offsetof(struct dbins_, facility) },
+  { NULL, N_("priority"),    0,  31,   32, 0, offsetof(struct dbins_, priority) },
+  { NULL, N_("syslog_msg"),  0,  32, 1024, 0, offsetof(struct dbins_, syslog_msg)  },
+
+  { NULL, N_("mode_old"),    0,  33,   16, 0, offsetof(struct dbins_, mode_old) },
+  { NULL, N_("mode_new"),    0,  34,   16, 0, offsetof(struct dbins_, mode_new) },
+  { NULL, N_("device_old"),  0,  35,   16, 0, offsetof(struct dbins_, device_old)}, 
+  { NULL, N_("device_new"),  0,  36,   16, 0, offsetof(struct dbins_, device_new)},
+  { NULL, N_("owner_old"),   0,  37,    9, 0, offsetof(struct dbins_, owner_old)},
+  { NULL, N_("owner_new"),   0,  38,    9, 0, offsetof(struct dbins_, owner_new)},
+  { NULL, N_("group_old"),   0,  39,    9, 0, offsetof(struct dbins_, group_old)},
+  { NULL, N_("group_new"),   0,  40,    9, 0, offsetof(struct dbins_, group_new)},
+  { NULL, N_("ctime_old"),   0,  41,   20, 0, offsetof(struct dbins_, ctime_old)},
+  { NULL, N_("ctime_new"),   0,  42,   20, 0, offsetof(struct dbins_, ctime_new)},
+  { NULL, N_("atime_old"),   0,  43,   20, 0, offsetof(struct dbins_, atime_old)},
+  { NULL, N_("atime_new"),   0,  44,   20, 0, offsetof(struct dbins_, atime_new)},
+  { NULL, N_("mtime_old"),   0,  45,   20, 0, offsetof(struct dbins_, mtime_old)},
+  { NULL, N_("mtime_new"),   0,  46,   20, 0, offsetof(struct dbins_, mtime_new)},
+  { NULL, N_("chksum_old"),  0,  47,   50, 0, offsetof(struct dbins_, chksum_old)},
+  { NULL, N_("chksum_new"),  0,  48,   50, 0, offsetof(struct dbins_, chksum_new)},
+  { NULL, N_("link_old"),    0,  49, 1024, 0, offsetof(struct dbins_, link_old)},
+  { NULL, N_("link_new"),    0,  50, 1024, 0, offsetof(struct dbins_, link_new)},
+               				    
+  { NULL, N_("size_old"),     0,  51,    0, 0, 0  },
+  { NULL, N_("size_new"),     0,  52,    0, 0, 0  },
+  { NULL, N_("hardlinks_old"),0,  53,    0, 0, 0  },
+  { NULL, N_("hardlinks_new"),0,  54,    0, 0, 0  },
+  { NULL, N_("inode_old"),    0,  55,    0, 0, 0  }, 
+  { NULL, N_("inode_new"),    0,  56,    0, 0, 0  }, 
+					    
+  { NULL, N_("imode_old"),    0,  57,    0, 0, 0  },
+  { NULL, N_("imode_new"),    0,  58,    0, 0, 0  },
+  { NULL, N_("iattr_old"),    0,  59,    0, 0, 0  },
+  { NULL, N_("iattr_new"),    0,  60,    0, 0, 0  },
+  { NULL, N_("idevice_old"),  0,  61,    0, 0, 0  }, 
+  { NULL, N_("idevice_new"),  0,  62,    0, 0, 0  }, 
+  { NULL, N_("iowner_old"),   0,  63,    0, 0, 0  },
+  { NULL, N_("iowner_new"),   0,  64,    0, 0, 0  },
+  { NULL, N_("igroup_old"),   0,  65,    0, 0, 0  },
+  { NULL, N_("igroup_new"),   0,  66,    0, 0, 0  },
+
+  { NULL, N_("port"),         0,  67,    0, 0, 0  },
+  { NULL, N_("return_code"),  0,  68,    0, 0, 0  },
   /* { NULL, N_("userid"),        0,  69,    0, 0  }, old 'userid', 1.8.1 */
 
-  { NULL, N_("host"),         0,  70,   64, offsetof(struct dbins_, fromhost)},
-  { NULL, N_("attr_old"),     0,  71,   16, offsetof(struct dbins_, attr_old)},
-  { NULL, N_("attr_new"),     0,  72,   16, offsetof(struct dbins_, attr_new)},
-
-  { NULL, NULL,      0,  0, 0, 0 }
+  { NULL, N_("host"),         0,  70,   64, 0, offsetof(struct dbins_, fromhost)},
+  { NULL, N_("attr_old"),     0,  71,   16, 0, offsetof(struct dbins_, attr_old)},
+  { NULL, N_("attr_new"),     0,  72,   16, 0, offsetof(struct dbins_, attr_new)},
+
+  { NULL, NULL,      0,  0, 0, 0, 0 }
 };
 
@@ -1179,4 +1183,38 @@
 	}
     }
+#if 0
+  /* apparently slower, see gyule.7 */
+  len = (long) strlen(val);
+
+  if ((val[0] != '\0') && (*size > 2))
+    {
+      if (flag == 1) 
+	{
+	  *end = ',';  ++end;
+	  *end = '\''; ++end; (*size) -= 2; 
+	  *end = '\0';
+	
+	  if ((long) *size > (len+2))
+	    {
+	      (void) sl_strlcat(end, val, (size_t) *size);
+	      end   += len; (*size) -= len;
+	      *end = '\''; ++end;  (*size) -= 1; 
+	    }
+	  *end = '\0'; 
+	}
+      else
+	{
+	  *end = ',';  ++end; (*size) -= 1;
+	  *end = '\0';
+	
+	  if ((long) *size > (len+1))
+	    {
+	      (void) sl_strlcat(end, val, (size_t) *size);
+	      end   += len; (*size) -= len;
+	    }
+	  *end = '\0';
+	}
+    }
+#endif
   return end;
 }
@@ -1375,41 +1413,59 @@
 }
  
+static int sh_database_comp_attr (const void *m1, const void *m2) 
+{
+  my_attr *mi1 = (my_attr *) m1;
+  my_attr *mi2 = (my_attr *) m2;
+  return strcmp(mi1->attr, mi2->attr);
+}
+
 
 static void init_attr_table()
 {
   static  int first = S_TRUE;
-  int         i;
+  int         i, j;
 
 #ifdef SH_STEALTH
   int     j, k;
 
-  if (first == S_TRUE)
-    {
-      i = 0;
-      while (attr_tab[i].attr_o != NULL)
-	{
-	  j = strlen(attr_tab[i].attr_o);
-	  attr_tab[i].attr = malloc (j+1); /* only once */
-	  if (NULL == attr_tab[i].attr)
-	    SL_RETURN (NULL, _("sh_database_parse"));
-	  for (k = 0; k < j; ++k)
-	    attr_tab[i].attr[k] = attr_tab[i].attr_o[k] ^ XOR_CODE;
-	  attr_tab[i].attr[j] = '\0';
-	  ++i;
-	}
-      first = S_FALSE;
-    }
+  if (first == S_FALSE)
+    return;
+
+  i = 0;
+  while (attr_tab[i].attr_o != NULL)
+    {
+      j = strlen(attr_tab[i].attr_o);
+      attr_tab[i].attr = malloc (j+1); /* only once */
+      if (NULL == attr_tab[i].attr)
+	SL_RETURN (NULL, _("sh_database_parse"));
+      for (k = 0; k < j; ++k)
+	attr_tab[i].attr[k] = attr_tab[i].attr_o[k] ^ XOR_CODE;
+      attr_tab[i].attr[j] = '\0';
+      attr_tab[i].alen = strlen(attr_tab[i].attr_o);
+      ++i;
+    }
+  first = S_FALSE;
+
 #else
-  if (first == S_TRUE)
-    {
-      i = 0;
-      while (attr_tab[i].attr_o != NULL)
-	{
-	  attr_tab[i].attr = attr_tab[i].attr_o;
-	  ++i;
-	}
-      first = S_FALSE;
-    }
+
+  i = 0;
+  while (attr_tab[i].attr_o != NULL)
+    {
+      attr_tab[i].attr = attr_tab[i].attr_o;
+      attr_tab[i].alen = strlen(attr_tab[i].attr_o);
+      ++i;
+    }
+  first = S_FALSE;
+
 #endif
+
+  /* create a sorted table for binary search
+   */
+  attr_tab_srch = SH_ALLOC(i * sizeof(my_attr));
+  for (j=0; j<i; ++j)
+    memcpy(&attr_tab_srch[j], &attr_tab[j], sizeof(my_attr));
+  qsort(attr_tab_srch, i, sizeof(my_attr), sh_database_comp_attr);
+  attr_tab_srch_siz = i;
+
   return;
 }
@@ -1479,4 +1535,7 @@
   int     i;
   size_t  j;
+  my_attr * res;
+  my_attr key;
+  char    key_str[64];
 
   SL_ENTER(_("sh_database_parse"));
@@ -1497,15 +1556,15 @@
   while ((p != NULL) && (*p != '\0') && (*p != '>'))
     {
-      if (p[0] == '/' && p[1] == '>')
+      if (p[0] == 'l' && p[1] == 'o' && p[2] == 'g' &&
+	  (p[3] == ' ' || p[3] == '>'))
+	{
+	  p = &p[4];
+	  goto parse;
+	}
+      else if (p[0] == '/' && p[1] == '>')
 	SL_RETURN (&p[2], _("sh_database_parse"));
-      if (p[0] == '/' && p[1] == 'l' && p[2] == 'o' && 
+      else if (p[0] == '/' && p[1] == 'l' && p[2] == 'o' && 
 	  p[3] == 'g' && p[4] == '>')
 	SL_RETURN (&p[5], _("sh_database_parse"));
-      if (p[0] == 'l' && p[1] == 'o' && p[2] == 'g' &&
-	  (p[3] == ' ' || p[3] == '>'))
-	{
-	  p = &p[4];
-	  goto parse;
-	}
       ++p;
     }
@@ -1519,4 +1578,7 @@
   if (!p || *p == '\0')
     SL_RETURN(NULL, _("sh_database_parse"));
+
+  if (*p != '<' && *p != '/')
+    goto par2;
 
   if (p[0] == '<' && p[1] == 'l' &&
@@ -1536,13 +1598,28 @@
     SL_RETURN (&p[5], _("sh_database_parse"));
 
+ par2:
 
   /* non-whitespace 
    */
   i = 0;
-  while (attr_tab[i].attr != NULL)
-    {
-      j = strlen(attr_tab[i].attr);
-      if (0 == strncmp(p, attr_tab[i].attr, j) && 
-	  p[j] == '=' && p[j+1] == '"')
+  for (i=0; i < 64; ++i)
+    {
+      key_str[i] = p[i];
+      if (p[i] == '=')
+	{
+	  key_str[i] = '\0';
+	  break;
+	}
+    }
+  key_str[63] = '\0';
+  key.attr = &key_str[0];
+
+  res = bsearch(&key, attr_tab_srch, attr_tab_srch_siz,
+		sizeof(my_attr), sh_database_comp_attr);
+
+  if (res != NULL)
+    {
+      j = res->alen; /* strlen(attr_tab[i].attr); */
+      if (p[j] == '=' && p[j+1] == '"')
 	{
 	  q = strchr(&p[j+2], '"');
@@ -1562,8 +1639,8 @@
 	      }
 
-	      if      (attr_tab[i].val == 1)
+	      if      (res->val == 1)
 		(void) sl_strlcpy(db_entry->sev, &p[j+2], 
-				  (size_t)attr_tab[i].size);
-	      else if (attr_tab[i].val == 2)
+				  (size_t)res->size);
+	      else if (res->val == 2)
 		{
 		  z = strchr(&p[j+2], 'T');
@@ -1571,19 +1648,19 @@
 		  (void) sl_strlcpy(db_entry->time, &p[j+2],  20);
 		}
-	      else if (attr_tab[i].val == 3)
+	      else if (res->val == 3)
 		(void) sl_strlcpy(db_entry->host, &p[j+2], 
-				  (size_t) attr_tab[i].size);
-	      else if (attr_tab[i].val == 4)
+				  (size_t) res->size);
+	      else if (res->val == 4)
 		(void) sl_strlcpy(db_entry->msg,  &p[j+2], 
-				  (size_t) attr_tab[i].size);
-	      else if (attr_tab[i].size != 0)
+				  (size_t) res->size);
+	      else if (res->size != 0)
 		{
-		  (void) sl_strlcpy( (((char *)(db_entry))+ attr_tab[i].off),
+		  (void) sl_strlcpy( (((char *)(db_entry))+ res->off),
 				     &p[j+2], 
-				     (size_t) attr_tab[i].size);
+				     (size_t) res->size);
 		}
-	      else if (attr_tab[i].val >= START_SEC_LONGS)
+	      else if (res->val >= START_SEC_LONGS)
 		{
-		  db_entry->long_data[attr_tab[i].val-START_SEC_LONGS]
+		  db_entry->long_data[res->val-START_SEC_LONGS]
 		    = atol(&p[j+2]);
 		}
Index: /trunk/src/sh_forward.c
===================================================================
--- /trunk/src/sh_forward.c	(revision 11)
+++ /trunk/src/sh_forward.c	(revision 12)
@@ -177,4 +177,7 @@
 
 int     clt_class = (-1);
+
+extern int flag_err_debug;
+extern int flag_err_info;
 
 #ifndef SH_STANDALONE
@@ -1225,5 +1228,6 @@
       else
 	{
-	  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_AUTH);
+	  if (flag_err_info == SL_TRUE)
+	    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_AUTH);
 	}
     }
@@ -1450,6 +1454,7 @@
 			  /* --- SERVER CMD END --- */
 #endif
-			  sh_error_handle((-1), FIL__, __LINE__, 0,
-					  MSG_TCP_CONF);
+			  if (flag_err_debug == SL_TRUE)
+			    sh_error_handle((-1), FIL__, __LINE__, 0,
+					    MSG_TCP_CONF);
 			}
 		    }
@@ -1648,5 +1653,6 @@
 		  (void) rewind_tmp (sfd);
 		  (void) sl_sync(sfd);
-		  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FOK);
+		  if (flag_err_info == SL_TRUE)
+		    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FOK);
 		}
 	      else
@@ -2812,6 +2818,7 @@
 		  conn->head[5]  = 'L';
 		  conn->head[6]  = 'T';
-		  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH,
-				  &(conn->buf[KEY_LEN]));
+		  if (flag_err_info == SL_TRUE)
+		    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH,
+				    &(conn->buf[KEY_LEN]));
 		  strcpy(conn->buf,                      /* known to fit  */
 			 &(conn->buf[KEY_LEN])); 
@@ -3172,6 +3179,7 @@
 		    _("msg=<File transfer - EOTE (7).>\n")));
 
-	      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKFILE,
-			      conn->peer);
+	      if (flag_err_info == SL_TRUE)
+		sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKFILE,
+				conn->peer);
 
 	      if ((conn->client_entry->status_now != CLT_SUSPEND) &&
@@ -3267,6 +3275,7 @@
 		  conn->head[5]  = 'L';
 		  conn->head[6]  = 'T';
-		  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH,
-				  &(conn->buf[KEY_LEN]));
+		  if (flag_err_info == SL_TRUE)
+		    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH,
+				    &(conn->buf[KEY_LEN]));
 		  strcpy(conn->buf,                      /* known to fit  */
 			 &(conn->buf[KEY_LEN]));
@@ -3591,6 +3600,7 @@
 	  if (0 != (conn->head[0] & SH_PROTO_END))
 	    {
-	      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKMSG,
-			      sh_strip_domain (conn->peer));
+	      if (flag_err_debug == SL_TRUE)
+		sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_OKMSG,
+				sh_strip_domain (conn->peer));
 	      sh_forward_do_free (conn);
 	      SL_RET0(_("check_protocol"));
@@ -4568,5 +4578,6 @@
       newconn->timer        = (unsigned long) time (NULL);
 
-      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_CNEW, newconn->fd);
+      if (flag_err_info == SL_TRUE)
+	sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_CNEW, newconn->fd);
 
       SL_RETURN( (0), _("sh_forward_accept"));
Index: /trunk/src/sh_tools.c
===================================================================
--- /trunk/src/sh_tools.c	(revision 11)
+++ /trunk/src/sh_tools.c	(revision 12)
@@ -121,9 +121,11 @@
  *     remaining unprintable chars                                 ---
  */
+#define SH_PUT_4(p, a, b, c) (p)[0] = (a); (p)[1] = (b); (p)[2] = (c);
+  
 char * sh_tools_safe_name (const char * instr, int flag)
 {
-  static   char ctest = ~('\\'|'&'|'='|'\'');
   unsigned char c;
   const  char * p;
+  char   *q;
   char   tmp[4];
   char * outstr;
@@ -143,4 +145,5 @@
 
   p = instr;
+  q = outstr;
 
 #if !defined(SH_USE_XML)
@@ -166,20 +169,24 @@
 	  if ((*p) == '"')
 	    { 
-	      sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '2', '2');
+	      i+=3; ++p;
 	      continue;
 	    } 
 	  else if ((*p) == '&')
 	    { 
-	      sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '2', '6');
+	      i+=3; ++p;
 	      continue;
 	    } 
 	  else if ((*p) == '<') 
 	    {     /* left angle       */
-	      sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '3', 'c');
+	      i+=3; ++p;
 	      continue;
 	    } 
 	  else if ((*p) == '>') 
 	    {     /* right angle      */
-	      sprintf(&outstr[i], "=%02x", c);i+=3; ++p; /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '3', 'e');
+	      i+=3; ++p;
 	      continue;
 	    }
@@ -187,6 +194,5 @@
 #endif
 
-      /* if ( (*p) != '\\' && (*p) != '&' && (*p) != '='  && (*p) != '\'') */
-      if (((*p) & ctest) != 0)
+      if ( (*p) != '\\' && (*p) != '&' && (*p) != '='  && (*p) != '\'') 
         {
 	  outstr[i] = *p; ++i;
@@ -203,5 +209,6 @@
       else if ((*p) == '\'')
 	{
-	  sprintf(&outstr[i], "=%02x", c);   i+=3; ++p;  /* known to fit  */
+	  SH_PUT_4(&outstr[i], '=', '2', '7');
+	  i+=3; ++p;
 	}
       else if (*p == '=')
@@ -209,5 +216,6 @@
 	  if (p[1] != '"' && p[1] != '<')
 	    { 
-	      sprintf(&outstr[i], "=%02x", c); i+=3; ++p;/* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '3', 'd');
+	      i+=3; ++p;
 	    }
 	  else
@@ -226,40 +234,41 @@
 	  switch (*p) {
 	  case '\\':
-	    sprintf(&outstr[i], "=%02x", c);  i+=3; ++p; /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '5', 'c');
+	    i+=3; ++p;
 	    break;
 	  case 'n':
-	    sprintf(&outstr[i], "=%02x", '\n');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '0', 'a');
 	    i+=3; ++p;
 	    break;
 	  case 'b':
-	    sprintf(&outstr[i], "=%02x", '\b');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '0', '8');
 	    i+=3; ++p;
 	    break;		       
 	  case 'r':		       
-	    sprintf(&outstr[i], "=%02x", '\r');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '0', 'd');
 	    i+=3; ++p;
 	    break;		       
 	  case 't':		       
-	    sprintf(&outstr[i], "=%02x", '\t');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '0', '9');
 	    i+=3; ++p;
 	    break;		       
 	  case 'v':		       
-	    sprintf(&outstr[i], "=%02x", '\v');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '0', 'b');
 	    i+=3; ++p;
 	    break;		       
 	  case 'f':		       
-	    sprintf(&outstr[i], "=%02x", '\f');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '0', 'c');
 	    i+=3; ++p;
 	    break;		       
 	  case '\'':		       
-	    sprintf(&outstr[i], "=%02x", '\'');          /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '2', '7');
 	    i+=3; ++p;
 	    break;		       
-	  case '\"':	/* also encode quoted '"' */ 	       
-	    sprintf(&outstr[i], "=%02x", '\"');          /* known to fit  */
+	  case '"':	/* also encode quoted '"' */ 	       
+	    SH_PUT_4(&outstr[i], '=', '2', '2');
 	    i+=3; ++p;
 	    break;		       
 	  case ' ':		       
-	    sprintf(&outstr[i], "=%02x", ' ');           /* known to fit  */
+	    SH_PUT_4(&outstr[i], '=', '2', '0');
 	    i+=3; ++p;
 	    break;
@@ -290,5 +299,5 @@
 	  if (p[0] == 'a' && p[1] == 'm' && p[2] == 'p' && p[3] == ';')
 	    {
-	      sprintf(&outstr[i], "=%02x", '&');         /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '2', '6');
 	      i+=3; p += 4;
 	    }
@@ -296,15 +305,15 @@
 		   p[4] == ';')
 	    {
-	      sprintf(&outstr[i], "=%02x", '"');         /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '2', '2');
 	      i+=3; p += 5;
 	    }
 	  else if (p[0] == 'l' && p[1] == 't' && p[2] == ';')
 	    {
-	      sprintf(&outstr[i], "=%02x", '<');         /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '3', 'c');
 	      i+=3; p += 3;
 	    }
 	  else if (p[0] == 'g' && p[1] == 't' && p[2] == ';')
 	    {
-	      sprintf(&outstr[i], "=%02x", '>');         /* known to fit  */
+	      SH_PUT_4(&outstr[i], '=', '3', 'e');
 	      i+=3; p += 3;
 	    }
Index: /trunk/src/sh_utils.c
===================================================================
--- /trunk/src/sh_utils.c	(revision 11)
+++ /trunk/src/sh_utils.c	(revision 12)
@@ -456,5 +456,5 @@
 /* can't inline (AIX)
  */
-int sh_util_hexchar( char c )
+int sh_util_hexchar( const char c )
 {
   /*@+charint@*/
@@ -471,5 +471,5 @@
 /* read a hexadecimal key, convert to binary
  */
-int sh_util_hextobinary (char * binary, char * hex, int bytes)
+int sh_util_hextobinary (char * binary, const char * hex, int bytes)
 {
   int i = 0, j, k, l = 0;
Index: /trunk/src/slib.c
===================================================================
--- /trunk/src/slib.c	(revision 11)
+++ /trunk/src/slib.c	(revision 12)
@@ -864,5 +864,5 @@
   if (dst == NULL)
     return SL_ENONE;
-  if (src == NULL || src == "") 
+  if (src == NULL || *src == '\0') 
     return SL_ENONE;
 
