updates.
[silc.git] / apps / irssi / src / silc / core / silc-core.c
index 767cb0b184797bfce1e76d1078da2897ba13bfe5..f5ea52a34107de8b04d65317fc37919442084ea1 100644 (file)
 
 /* 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;
@@ -57,7 +57,8 @@ static int idletag;
 SilcClient silc_client = NULL;
 SilcClientConfig silc_config = NULL;
 extern SilcClientOperations ops;
-extern int silc_debug;
+extern bool silc_debug;
+extern bool silc_debug_hexdump;
 #ifdef SILC_SIM
 /* SIM (SILC Module) table */
 SilcSimContext **sims = NULL;
@@ -66,7 +67,7 @@ uint32 sims_count = 0;
 
 static int my_silc_scheduler(void)
 {
-  silc_schedule_one(silc_client->schedule, 0);
+  silc_client_run_one(silc_client);
   return 1;
 }
 
@@ -119,13 +120,15 @@ static void silc_init_userinfo(void)
     
     user_name = settings_get_str("user_name");
   }
-         
+
   /* nick */
+  /* Actually take SILCUSER or IRCUSER since nickname cannot be set
+     beforehand in SILC (XXX auto-nicking support should be added to Irssi). */
   nick = settings_get_str("nick");
   if (nick == NULL || *nick == '\0') {
-    str = g_getenv("SILCNICK");
+    str = g_getenv("SILCUSER");
     if (!str)
-      str = g_getenv("IRCNICK");
+      str = g_getenv("IRCUSER");
     settings_set_str("nick", str != NULL ? str : user_name);
     
     nick = settings_get_str("nick");
@@ -193,8 +196,8 @@ 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,
-      "Enable debugging", NULL },
+    { "debug", 'd', POPT_ARG_STRING, &opt_debug, 0,
+      "Enable debugging", "STRING" },
     { "version", 'V', POPT_ARG_NONE, &opt_version, 0,
       "Show version", NULL },
     { NULL, '\0', 0, NULL }
@@ -268,9 +271,18 @@ 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_debug_hexdump = TRUE;
+    silc_log_set_debug_string(opt_debug);
+    silc_log_set_callbacks(silc_log_info, silc_log_warning,
+                          silc_log_error, NULL);
+#ifndef SILC_DEBUG
+    fprintf(stdout, 
+           "Run-time debugging is not enabled. To enable it recompile\n"
+           "the client with --enable-debug configuration option.\n");
+#endif
+  }
 
   /* Do some irssi initializing */
   settings_add_bool("server", "skip_motd", FALSE);