From a822fca4344037f17da731b4cebb2c0d4a67ba60 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 7 Nov 2001 15:13:21 +0000 Subject: [PATCH] updates. --- CHANGES | 17 +++++++++++++++++ README.CVS | 3 +-- apps/irssi/src/silc/core/silc-core.c | 13 ++++++++----- apps/silcd/silcd.c | 2 +- lib/silcutil/silclog.c | 27 +++++++++++++++++++++++++++ lib/silcutil/silclog.h | 2 ++ lib/silcutil/unix/silcunixutil.c | 2 +- 7 files changed, 57 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index fe6c1481..7ecfb7a1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,20 @@ +Wed Nov 7 17:15:07 EET 2001 Pekka Riikonen + + * 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 * Added silc_hash_babbleprint to create a Bubble Babble diff --git a/README.CVS b/README.CVS index 1835d121..fc950df7 100644 --- a/README.CVS +++ b/README.CVS @@ -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 -"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 diff --git a/apps/irssi/src/silc/core/silc-core.c b/apps/irssi/src/silc/core/silc-core.c index 767cb0b1..ffc5e2a7 100644 --- a/apps/irssi/src/silc/core/silc-core.c +++ b/apps/irssi/src/silc/core/silc-core.c @@ -42,12 +42,12 @@ /* 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 char *opt_debug = FALSE; 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 }, - { "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 }, @@ -268,9 +268,12 @@ void silc_core_init_finish(void) 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); diff --git a/apps/silcd/silcd.c b/apps/silcd/silcd.c index 8dfa1e49..7b0122c4 100644 --- a/apps/silcd/silcd.c +++ b/apps/silcd/silcd.c @@ -70,7 +70,7 @@ Usage: silcd [options]\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\ diff --git a/lib/silcutil/silclog.c b/lib/silcutil/silclog.c index 15c64884..f75a735a 100644 --- a/lib/silcutil/silclog.c +++ b/lib/silcutil/silclog.c @@ -23,6 +23,7 @@ /* 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[] = @@ -148,6 +149,13 @@ void silc_log_output_debug(char *file, char *function, 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); @@ -175,6 +183,13 @@ void silc_log_output_hexdump(char *file, char *function, 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); @@ -294,3 +309,15 @@ void silc_log_reset_debug_callbacks() 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); +} diff --git a/lib/silcutil/silclog.h b/lib/silcutil/silclog.h index 05ed479b..97a870a3 100644 --- a/lib/silcutil/silclog.h +++ b/lib/silcutil/silclog.h @@ -23,6 +23,7 @@ /* Set TRUE/FALSE to enable/disable debugging */ extern int silc_debug; +extern char *silc_debug_string; /* 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_string(const char *debug_string); #endif diff --git a/lib/silcutil/unix/silcunixutil.c b/lib/silcutil/unix/silcunixutil.c index 696adb3f..79e1185c 100644 --- a/lib/silcutil/unix/silcunixutil.c +++ b/lib/silcutil/unix/silcunixutil.c @@ -62,7 +62,7 @@ char *silc_string_regexify(const char *string) count++; } - regex[count - 1] = ')'; + regex[count++] = ')'; regex[count] = '$'; return regex; -- 2.24.0