updates.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 7 Nov 2001 15:13:21 +0000 (15:13 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 7 Nov 2001 15:13:21 +0000 (15:13 +0000)
CHANGES
README.CVS
apps/irssi/src/silc/core/silc-core.c
apps/silcd/silcd.c
lib/silcutil/silclog.c
lib/silcutil/silclog.h
lib/silcutil/unix/silcunixutil.c

diff --git a/CHANGES b/CHANGES
index fe6c148167a237102afd52482f6bc882c27f6085..7ecfb7a101d3d26ff42a98b4bff1b9146a9057ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,20 @@
+Wed Nov  7 17:15:07 EET 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * Added silc_log_set_debug_string function to set a regex
+         string to match for debug output.  Only the function names,
+         or filenames matching the given debug string is actually
+         printed.  This way it is possible to filter out those debug
+         strings that user is not interested in.
+
+         Fixed a bug in silc_string_regexify.
+
+         Affected files lib/silcutil/silclog.[ch], and
+         lib/silcutil/unix/silcunixutil.c.
+
+       * Changed the -d options in both server and Irssi SILC client
+         to take the debug string as argument.  Affected files
+         silcd/silcd.c and irssi/src/silc/core/silc-core.c.
+
 Tue Nov  6 21:31:54 EET 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Added silc_hash_babbleprint to create a Bubble Babble
 Tue Nov  6 21:31:54 EET 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Added silc_hash_babbleprint to create a Bubble Babble
index 1835d121424be173238d16866046a36e535df610..fc950df7c38022104e44d31695350ca5d66a459f 100644 (file)
@@ -179,8 +179,7 @@ is a string that is used to match the output debug.  The example "*" will
 match for everything, and all debugs will be printed.  If you want to
 limit the debugs you want to printout you can give for example a string
 like "*server*,*rng*" to match all functions, and filenames that has
 match for everything, and all debugs will be printed.  If you want to
 limit the debugs you want to printout you can give for example a string
 like "*server*,*rng*" to match all functions, and filenames that has
-"server" or "rng" string in them.  Others will not be printed out.  You   
-can freely define regural expressions as debug string.
+"server" or "rng" string in them.  Others will not be printed out.
 
 
 Howto Clean SILC Source Tree
 
 
 Howto Clean SILC Source Tree
index 767cb0b184797bfce1e76d1078da2897ba13bfe5..ffc5e2a7f77368fb651e2f7b1df8392e8851d7f6 100644 (file)
 
 /* Command line option variables */
 static bool opt_create_keypair = FALSE;
 
 /* Command line option variables */
 static bool opt_create_keypair = FALSE;
-static bool opt_debug = FALSE;
 static bool opt_list_ciphers = FALSE;
 static bool opt_list_hash = FALSE;
 static bool opt_list_hmac = FALSE;
 static bool opt_list_pkcs = FALSE;
 static bool opt_version = FALSE;
 static bool opt_list_ciphers = FALSE;
 static bool opt_list_hash = FALSE;
 static bool opt_list_hmac = FALSE;
 static bool opt_list_pkcs = FALSE;
 static bool opt_version = FALSE;
+static char *opt_debug = FALSE;
 static char *opt_pkcs = NULL;
 static char *opt_keyfile = NULL;
 static int opt_bits = 0;
 static char *opt_pkcs = NULL;
 static char *opt_keyfile = NULL;
 static int opt_bits = 0;
@@ -193,7 +193,7 @@ void silc_core_init(void)
       "List supported HMACs", NULL },
     { "list-pkcs", 'P', POPT_ARG_NONE, &opt_list_pkcs, 0,
       "List supported PKCSs", NULL },
       "List supported HMACs", NULL },
     { "list-pkcs", 'P', POPT_ARG_NONE, &opt_list_pkcs, 0,
       "List supported PKCSs", NULL },
-    { "debug", 'd', POPT_ARG_NONE, &opt_debug, 0,
+    { "debug", 'd', POPT_ARG_STRING, &opt_debug, 0,
       "Enable debugging", NULL },
     { "version", 'V', POPT_ARG_NONE, &opt_version, 0,
       "Show version", NULL },
       "Enable debugging", NULL },
     { "version", 'V', POPT_ARG_NONE, &opt_version, 0,
       "Show version", NULL },
@@ -268,9 +268,12 @@ void silc_core_init_finish(void)
     exit(0); 
   }
 
     exit(0); 
   }
 
-  silc_debug = opt_debug;
-  silc_log_set_callbacks(silc_log_info, silc_log_warning,
-                        silc_log_error, NULL);
+  if (opt_debug) {
+    silc_debug = TRUE;
+    silc_log_set_debug_string(opt_debug);
+    silc_log_set_callbacks(silc_log_info, silc_log_warning,
+                          silc_log_error, NULL);
+  }
 
   /* Do some irssi initializing */
   settings_add_bool("server", "skip_motd", FALSE);
 
   /* Do some irssi initializing */
   settings_add_bool("server", "skip_motd", FALSE);
index 8dfa1e490c7255e9bd2fa52d1f58e2962ce13055..7b0122c448ffc6f276d05ed7ddb7aa0b4125cc70 100644 (file)
@@ -70,7 +70,7 @@ Usage: silcd [options]\n\
 \n\
   Generic Options:\n\
   -f  --config-file=FILE        Alternate configuration file\n\
 \n\
   Generic Options:\n\
   -f  --config-file=FILE        Alternate configuration file\n\
-  -d  --debug=string            Enable debugging (no daemon)\n\
+  -d  --debug                   Enable debugging (no daemon)\n\
   -h  --help                    Display this message\n\
   -V  --version                 Display version\n\
 \n\
   -h  --help                    Display this message\n\
   -V  --version                 Display version\n\
 \n\
index 15c64884fec45277afd572fdf4fc32909f6f6070..f75a735adb955c424c5b2adaf39d27070a3fd01d 100644 (file)
@@ -23,6 +23,7 @@
 
 /* Set TRUE/FALSE to enable/disable debugging */
 int silc_debug = FALSE;
 
 /* Set TRUE/FALSE to enable/disable debugging */
 int silc_debug = FALSE;
+char *silc_debug_string = NULL;
 
 /* SILC Log name strings. These strings are printed to the log file. */
 const SilcLogTypeName silc_log_types[] =
 
 /* SILC Log name strings. These strings are printed to the log file. */
 const SilcLogTypeName silc_log_types[] =
@@ -148,6 +149,13 @@ void silc_log_output_debug(char *file, char *function,
     return;
   }
 
     return;
   }
 
+  if (silc_debug_string && 
+      (!silc_string_regex_match(silc_debug_string, file) &&
+       !silc_string_regex_match(silc_debug_string, function))) {
+    silc_free(string);
+    return;
+  }
+
   if (debug_cb)
     {
       (*debug_cb)(file, function, line, string);
   if (debug_cb)
     {
       (*debug_cb)(file, function, line, string);
@@ -175,6 +183,13 @@ void silc_log_output_hexdump(char *file, char *function,
     return;
   }
 
     return;
   }
 
+  if (silc_debug_string && 
+      (!silc_string_regex_match(silc_debug_string, file) &&
+       !silc_string_regex_match(silc_debug_string, function))) {
+    silc_free(string);
+    return;
+  }
+
   if (debug_hexdump_cb)
     {
       (*debug_hexdump_cb)(file, function, line, data_in, len, string);
   if (debug_hexdump_cb)
     {
       (*debug_hexdump_cb)(file, function, line, data_in, len, string);
@@ -294,3 +309,15 @@ void silc_log_reset_debug_callbacks()
   debug_cb = NULL;
   debug_hexdump_cb = NULL;
 }
   debug_cb = NULL;
   debug_hexdump_cb = NULL;
 }
+
+/* Set current debug string */
+
+void silc_log_set_debug_string(const char *debug_string)
+{
+  silc_free(silc_debug_string);
+  if (strchr(debug_string, '(') &&
+      strchr(debug_string, ')'))
+    silc_debug_string = strdup(debug_string);
+  else
+    silc_debug_string = silc_string_regexify(debug_string);
+}
index 05ed479ba8a176af980228fb6882b62efd0facc2..97a870a3055b2501d78159b117f8e2432385fd8e 100644 (file)
@@ -23,6 +23,7 @@
 
 /* Set TRUE/FALSE to enable/disable debugging */
 extern int silc_debug;
 
 /* Set TRUE/FALSE to enable/disable debugging */
 extern int silc_debug;
+extern char *silc_debug_string;
 
 /* SILC Log types */
 typedef enum {
 
 /* SILC Log types */
 typedef enum {
@@ -124,5 +125,6 @@ void silc_log_reset_callbacks();
 void silc_log_set_debug_callbacks(SilcDebugCb debug, 
                                  SilcDebugHexdumpCb debug_hexdump);
 void silc_log_reset_debug_callbacks();
 void silc_log_set_debug_callbacks(SilcDebugCb debug, 
                                  SilcDebugHexdumpCb debug_hexdump);
 void silc_log_reset_debug_callbacks();
+void silc_log_set_debug_string(const char *debug_string);
 
 #endif
 
 #endif
index 696adb3f77bba0d77c38b92e9b6abfb1fe15e11e..79e1185cb4505df0dbe0ee652c649858c6d2756a 100644 (file)
@@ -62,7 +62,7 @@ char *silc_string_regexify(const char *string)
     count++;
   }
 
     count++;
   }
 
-  regex[count - 1] = ')';
+  regex[count++] = ')';
   regex[count] = '$';
 
   return regex;
   regex[count] = '$';
 
   return regex;