updates.
[silc.git] / apps / irssi / src / silc / core / silc-core.c
index 4cfcd54dde5f3f1755130e273b096bf9e0928cf1..9936826d50f8ac12e3e1133e7cced32caac9335b 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_pkcs = NULL;
 static char *opt_keyfile = NULL;
 static int opt_bits = 0;
@@ -61,7 +66,7 @@ uint32 sims_count = 0;
 
 static int my_silc_scheduler(void)
 {
-  silc_schedule_one(0);
+  silc_schedule_one(silc_client->schedule, 0);
   return 1;
 }
 
@@ -180,19 +185,36 @@ void silc_core_init(void)
       "Set the length of the public key pair", "VALUE" },
     { "show-key", 'S', POPT_ARG_STRING, &opt_keyfile, 0, 
       "Show the contents of the public key", "FILE" },
+    { "list-ciphers", 'C', POPT_ARG_NONE, &opt_list_ciphers, 0,
+      "List supported ciphers", NULL },
+    { "list-hash-funcs", 'H', POPT_ARG_NONE, &opt_list_hash, 0,
+      "List supported hash functions", NULL },
+    { "list-hmacs", 'H', POPT_ARG_NONE, &opt_list_hmac, 0,
+      "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 },
+    { "version", 'V', POPT_ARG_NONE, &opt_version, 0,
+      "Show version", NULL },
     { NULL, '\0', 0, NULL }
   };
 
   args_register(options);
 }
 
+static void silc_nickname_format_parse(const char *nickname,
+                                      char **ret_nickname)
+{
+  silc_parse_userfqdn(nickname, ret_nickname, NULL);
+}
+
 /* Finalize init. Called from src/fe-text/silc.c */
 
 void silc_core_init_finish(void)
 {
   CHAT_PROTOCOL_REC *rec;
+  SilcClientParams params;
 
   if (opt_create_keypair == TRUE) {
     /* Create new key pair and exit */
@@ -215,6 +237,37 @@ void silc_core_init_finish(void)
     exit(0);
   }
 
+  if (opt_list_ciphers) {
+    silc_cipher_register_default();
+    silc_client_list_ciphers();
+    exit(0);
+  }
+
+  if (opt_list_hash) {
+    silc_hash_register_default();
+    silc_client_list_hash_funcs();
+    exit(0);
+  }
+
+  if (opt_list_hmac) {
+    silc_hmac_register_default();
+    silc_client_list_hmacs();
+    exit(0);
+  }
+
+  if (opt_list_pkcs) {
+    silc_pkcs_register_default();
+    silc_client_list_pkcs();
+    exit(0);
+  }
+
+  if (opt_version) {
+    printf("SILC Secure Internet Live Conferencing, version %s "
+          "(base: SILC Toolkit %s)\n", silc_dist_version, silc_version);
+    printf("(c) 1997 - 2001 Pekka Riikonen <priikone@silcnet.org>\n");
+    exit(0); 
+  }
+
   silc_debug = opt_debug;
   silc_log_set_callbacks(silc_log_info, silc_log_warning,
                         silc_log_error, NULL);
@@ -224,8 +277,13 @@ void silc_core_init_finish(void)
   settings_add_str("server", "alternate_nick", NULL);
   silc_init_userinfo();
 
+  /* Initialize client parameters */
+  memset(&params, 0, sizeof(params));
+  strcat(params.nickname_format, "%n@%h%a");
+  params.nickname_parse = silc_nickname_format_parse;
+
   /* Allocate SILC client */
-  silc_client = silc_client_alloc(&ops, NULL);
+  silc_client = silc_client_alloc(&ops, &params, NULL, silc_version_string);
 
   /* Load local config file */
   silc_config = silc_client_config_alloc(SILC_CLIENT_HOME_CONFIG_FILE);