/[weechat]/weechat/src/common/weechat.c
ViewVC logotype

Diff of /weechat/src/common/weechat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.52 by flashcode, Sat Jul 9 17:08:26 2005 UTC revision 1.53 by flashcode, Thu Jul 14 07:04:46 2005 UTC
# Line 373  wee_parse_args (int argc, char *argv[]) Line 373  wee_parse_args (int argc, char *argv[])
373              || (strcmp (argv[i], "--config") == 0))              || (strcmp (argv[i], "--config") == 0))
374          {          {
375              wee_display_config_options ();              wee_display_config_options ();
376              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
377          }          }
378          else if ((strcmp (argv[i], "-f") == 0)          else if ((strcmp (argv[i], "-f") == 0)
379              || (strcmp (argv[i], "--key-functions") == 0))              || (strcmp (argv[i], "--key-functions") == 0))
380          {          {
381              wee_display_key_functions ();              wee_display_key_functions ();
382              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
383          }          }
384          else if ((strcmp (argv[i], "-h") == 0)          else if ((strcmp (argv[i], "-h") == 0)
385                  || (strcmp (argv[i], "--help") == 0))                  || (strcmp (argv[i], "--help") == 0))
386          {          {
387              printf ("\n" WEE_USAGE1, argv[0], argv[0]);              printf ("\n" WEE_USAGE1, argv[0], argv[0]);
388              printf ("%s", WEE_USAGE2);              printf ("%s", WEE_USAGE2);
389              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
390          }          }
391          else if ((strcmp (argv[i], "-i") == 0)          else if ((strcmp (argv[i], "-i") == 0)
392              || (strcmp (argv[i], "--irc-commands") == 0))              || (strcmp (argv[i], "--irc-commands") == 0))
393          {          {
394              wee_display_commands (0, 1);              wee_display_commands (0, 1);
395              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
396          }          }
397          else if ((strcmp (argv[i], "-k") == 0)          else if ((strcmp (argv[i], "-k") == 0)
398              || (strcmp (argv[i], "--keys") == 0))              || (strcmp (argv[i], "--keys") == 0))
399          {          {
400              wee_display_keys ();              wee_display_keys ();
401              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
402          }          }
403          else if ((strcmp (argv[i], "-l") == 0)          else if ((strcmp (argv[i], "-l") == 0)
404                   || (strcmp (argv[i], "--license") == 0))                   || (strcmp (argv[i], "--license") == 0))
405          {          {
406              printf ("\n%s%s", WEE_LICENSE);              printf ("\n%s%s", WEE_LICENSE);
407              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
408          }          }
409          else if ((strcmp (argv[i], "-v") == 0)          else if ((strcmp (argv[i], "-v") == 0)
410                   || (strcmp (argv[i], "--version") == 0))                   || (strcmp (argv[i], "--version") == 0))
411          {          {
412              printf (PACKAGE_VERSION "\n");              printf (PACKAGE_VERSION "\n");
413              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
414          }          }
415          else if ((strcmp (argv[i], "-w") == 0)          else if ((strcmp (argv[i], "-w") == 0)
416              || (strcmp (argv[i], "--weechat-commands") == 0))              || (strcmp (argv[i], "--weechat-commands") == 0))
417          {          {
418              wee_display_commands (1, 0);              wee_display_commands (1, 0);
419              wee_shutdown (EXIT_SUCCESS);              wee_shutdown (EXIT_SUCCESS, 0);
420          }          }
421          else if ((strncasecmp (argv[i], "irc", 3) == 0))          else if ((strncasecmp (argv[i], "irc", 3) == 0))
422          {          {
# Line 492  wee_create_home_dirs () Line 492  wee_create_home_dirs ()
492      {      {
493          fprintf (stderr, _("%s unable to get HOME directory\n"),          fprintf (stderr, _("%s unable to get HOME directory\n"),
494                   WEECHAT_ERROR);                   WEECHAT_ERROR);
495          wee_shutdown (EXIT_FAILURE);          wee_shutdown (EXIT_FAILURE, 0);
496      }      }
497      dir_length = strlen (ptr_home) + 10;      dir_length = strlen (ptr_home) + 10;
498      weechat_home =      weechat_home =
# Line 501  wee_create_home_dirs () Line 501  wee_create_home_dirs ()
501      {      {
502          fprintf (stderr, _("%s not enough memory for home directory\n"),          fprintf (stderr, _("%s not enough memory for home directory\n"),
503                   WEECHAT_ERROR);                   WEECHAT_ERROR);
504          wee_shutdown (EXIT_FAILURE);          wee_shutdown (EXIT_FAILURE, 0);
505      }      }
506      snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,      snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
507                DIR_SEPARATOR);                DIR_SEPARATOR);
# Line 511  wee_create_home_dirs () Line 511  wee_create_home_dirs ()
511      {      {
512          fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),          fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),
513                   WEECHAT_ERROR);                   WEECHAT_ERROR);
514          wee_shutdown (EXIT_FAILURE);          wee_shutdown (EXIT_FAILURE, 0);
515      }      }
516            
517      dir_length = strlen (weechat_home) + 64;      dir_length = strlen (weechat_home) + 64;
# Line 581  wee_init_vars () Line 581  wee_init_vars ()
581      msgq_last_msg = NULL;      msgq_last_msg = NULL;
582            
583      /* init gnutls */      /* init gnutls */
584      #ifdef HAVE_GNUTLS  #ifdef HAVE_GNUTLS
585      gnutls_global_init ();      gnutls_global_init ();
586      gnutls_certificate_allocate_credentials (&gnutls_xcred);      gnutls_certificate_allocate_credentials (&gnutls_xcred);
587      gnutls_certificate_set_x509_trust_file (gnutls_xcred, "ca.pem", GNUTLS_X509_FMT_PEM);      gnutls_certificate_set_x509_trust_file (gnutls_xcred, "ca.pem", GNUTLS_X509_FMT_PEM);
588      #endif  #endif
589  }  }
590    
591  /*  /*
# Line 669  wee_gui_shutdown () Line 669  wee_gui_shutdown ()
669   */   */
670    
671  void  void
672  wee_shutdown (int return_code)  wee_shutdown (int return_code, int crash)
673  {  {
674      fifo_remove ();      fifo_remove ();
675      if (weechat_home)      if (weechat_home)
# Line 680  wee_shutdown (int return_code) Line 680  wee_shutdown (int return_code)
680          free (local_charset);          free (local_charset);
681      alias_free_all ();      alias_free_all ();
682            
683      #ifdef HAVE_GNUTLS  #ifdef HAVE_GNUTLS
684      gnutls_certificate_free_credentials (gnutls_xcred);      gnutls_certificate_free_credentials (gnutls_xcred);
685      gnutls_global_deinit();      gnutls_global_deinit();
686      #endif  #endif
687            
688      exit (return_code);      if (crash)
689            abort();
690        else
691            exit (return_code);
692  }  }
693    
694  /*  /*
# Line 776  wee_dump (int crash) Line 779  wee_dump (int crash)
779  }  }
780    
781  /*  /*
  * my_sigint: SIGINT handler, do nothing (just ignore this signal)  
  *            Prevents user for exiting with Ctrl-C  
  */  
   
 void  
 my_sigint ()  
 {  
     /* do nothing */  
 }  
   
 /*  
782   * my_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit   * my_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit
783   */   */
784    
# Line 801  my_sigsegv () Line 793  my_sigsegv ()
793      fprintf (stderr, "*** Please send this file to WeeChat developers.\n");      fprintf (stderr, "*** Please send this file to WeeChat developers.\n");
794      fprintf (stderr, "*** (be careful, private info may be in this file since\n");      fprintf (stderr, "*** (be careful, private info may be in this file since\n");
795      fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");      fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
796      wee_shutdown (EXIT_FAILURE);      wee_shutdown (EXIT_FAILURE, 1);
797  }  }
798    
799  /*  /*
# Line 821  main (int argc, char *argv[]) Line 813  main (int argc, char *argv[])
813      local_charset = strdup (nl_langinfo (CODESET));      local_charset = strdup (nl_langinfo (CODESET));
814      #endif      #endif
815            
816      signal (SIGINT, my_sigint);     /* ignore SIGINT signal                 */      signal (SIGINT, SIG_IGN);       /* ignore SIGINT signal                 */
817      signal (SIGSEGV, my_sigsegv);   /* crash dump when SIGSEGV is received  */      signal (SIGSEGV, my_sigsegv);   /* crash dump when SIGSEGV is received  */
818      gui_pre_init (&argc, &argv);    /* pre-initiliaze interface             */      gui_pre_init (&argc, &argv);    /* pre-initiliaze interface             */
819      wee_init_vars ();               /* initialize some variables            */      wee_init_vars ();               /* initialize some variables            */
# Line 860  main (int argc, char *argv[]) Line 852  main (int argc, char *argv[])
852      (void) config_write (NULL);     /* save config file                     */      (void) config_write (NULL);     /* save config file                     */
853      command_index_free ();          /* free commands index                  */      command_index_free ();          /* free commands index                  */
854      wee_gui_shutdown ();            /* shut down WeeChat GUI                */      wee_gui_shutdown ();            /* shut down WeeChat GUI                */
855      wee_shutdown (EXIT_SUCCESS);    /* quit WeeChat (oh no, why?)           */      wee_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?)           */
856            
857      return EXIT_SUCCESS;            /* make gcc happy (never executed)      */      return EXIT_SUCCESS;            /* make gcc happy (never executed)      */
858  }  }

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26