65 |
#include "command.h" |
#include "command.h" |
66 |
#include "fifo.h" |
#include "fifo.h" |
67 |
#include "utf8.h" |
#include "utf8.h" |
68 |
|
#include "session.h" |
69 |
#include "../irc/irc.h" |
#include "../irc/irc.h" |
70 |
#include "../gui/gui.h" |
#include "../gui/gui.h" |
71 |
|
|
74 |
#endif |
#endif |
75 |
|
|
76 |
|
|
77 |
|
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0]) */ |
78 |
|
char *weechat_session = NULL; /* WeeChat session file (for /upgrade command) */ |
79 |
time_t weechat_start_time; /* WeeChat start time (used by /uptime command) */ |
time_t weechat_start_time; /* WeeChat start time (used by /uptime command) */ |
80 |
int quit_weechat; /* = 1 if quit request from user... why ? :'( */ |
int quit_weechat; /* = 1 if quit request from user... why ? :'( */ |
81 |
int sigsegv = 0; /* SIGSEGV received? */ |
int sigsegv = 0; /* SIGSEGV received? */ |
166 |
} |
} |
167 |
|
|
168 |
/* |
/* |
169 |
* wee_log_printf: displays a message in WeeChat log (~/.weechat/weechat.log) |
* weechat_log_printf: displays a message in WeeChat log (~/.weechat/weechat.log) |
170 |
*/ |
*/ |
171 |
|
|
172 |
void |
void |
173 |
wee_log_printf (char *message, ...) |
weechat_log_printf (char *message, ...) |
174 |
{ |
{ |
175 |
static char buffer[4096]; |
static char buffer[4096]; |
176 |
char *ptr_buffer; |
char *ptr_buffer; |
217 |
{ |
{ |
218 |
char *outbuf; |
char *outbuf; |
219 |
|
|
220 |
#ifdef HAVE_ICONV |
#ifdef HAVE_ICONV |
221 |
iconv_t cd; |
iconv_t cd; |
222 |
char *inbuf; |
char *inbuf; |
223 |
ICONV_CONST char *ptr_inbuf; |
ICONV_CONST char *ptr_inbuf; |
252 |
} |
} |
253 |
else |
else |
254 |
outbuf = strdup (string); |
outbuf = strdup (string); |
255 |
#else |
#else |
256 |
/* make gcc happy */ |
/* make gcc happy */ |
257 |
(void) from_code; |
(void) from_code; |
258 |
(void) to_code; |
(void) to_code; |
259 |
outbuf = strdup (string); |
outbuf = strdup (string); |
260 |
#endif /* HAVE_ICONV */ |
#endif /* HAVE_ICONV */ |
261 |
|
|
262 |
return outbuf; |
return outbuf; |
263 |
} |
} |
266 |
* get_timeval_diff: calculates difference between two times (return in milliseconds) |
* get_timeval_diff: calculates difference between two times (return in milliseconds) |
267 |
*/ |
*/ |
268 |
|
|
269 |
long get_timeval_diff(struct timeval *tv1, struct timeval *tv2) |
long |
270 |
|
get_timeval_diff (struct timeval *tv1, struct timeval *tv2) |
271 |
{ |
{ |
272 |
long diff_sec, diff_usec; |
long diff_sec, diff_usec; |
273 |
|
|
283 |
} |
} |
284 |
|
|
285 |
/* |
/* |
286 |
* wee_display_config_options: display config options |
* weechat_display_usage: display WeeChat usage |
287 |
*/ |
*/ |
288 |
|
|
289 |
void wee_display_config_options () |
void |
290 |
|
weechat_display_usage (char *exec_name) |
291 |
|
{ |
292 |
|
printf ("\n"); |
293 |
|
printf (_("%s (c) Copyright 2003-2005, compiled on %s %s\n" |
294 |
|
"Developed by FlashCode <flashcode@flashtux.org> - %s"), |
295 |
|
PACKAGE_STRING, __DATE__, __TIME__, WEECHAT_WEBSITE); |
296 |
|
printf ("\n\n"); |
297 |
|
printf (_("Usage: %s [options ...]\n" \ |
298 |
|
" or: %s [irc[6][s]://[nickname[:password]@]irc.example.org[:port][/channel][,channel[...]]"), |
299 |
|
exec_name, exec_name); |
300 |
|
printf ("\n\n"); |
301 |
|
printf (_(" -a, --no-connect disable auto-connect to servers at startup\n" |
302 |
|
" -c, --config display config file options\n" |
303 |
|
" -f, --key-functions display WeeChat internal functions for keys\n" |
304 |
|
" -h, --help this help\n" |
305 |
|
" -i, --irc-commands display IRC commands\n" |
306 |
|
" -k, --keys display WeeChat default keys\n" |
307 |
|
" -l, --license display WeeChat license\n" |
308 |
|
" -p, --no-plugin don't load any plugin at startup\n" |
309 |
|
" -v, --version display WeeChat version\n" |
310 |
|
" -w, --weechat-commands display WeeChat commands\n")); |
311 |
|
printf("\n"); |
312 |
|
} |
313 |
|
|
314 |
|
/* |
315 |
|
* weechat_display_config_options: display config options |
316 |
|
*/ |
317 |
|
|
318 |
|
void |
319 |
|
weechat_display_config_options () |
320 |
{ |
{ |
321 |
int i, j, k; |
int i, j, k; |
322 |
|
|
387 |
} |
} |
388 |
|
|
389 |
/* |
/* |
390 |
* wee_display_commands: display WeeChat and/or IRC commands |
* weechat_display_commands: display WeeChat and/or IRC commands |
391 |
*/ |
*/ |
392 |
|
|
393 |
void wee_display_commands (int weechat_cmd, int irc_cmd) |
void |
394 |
|
weechat_display_commands (int weechat_cmd, int irc_cmd) |
395 |
{ |
{ |
396 |
int i; |
int i; |
397 |
|
|
441 |
} |
} |
442 |
|
|
443 |
/* |
/* |
444 |
* wee_display_key_functions: display WeeChat key functions |
* weechat_display_key_functions: display WeeChat key functions |
445 |
*/ |
*/ |
446 |
|
|
447 |
void wee_display_key_functions () |
void |
448 |
|
weechat_display_key_functions () |
449 |
{ |
{ |
450 |
int i; |
int i; |
451 |
|
|
462 |
} |
} |
463 |
|
|
464 |
/* |
/* |
465 |
* wee_display_keys: display WeeChat default keys |
* weechat_display_keys: display WeeChat default keys |
466 |
*/ |
*/ |
467 |
|
|
468 |
void |
void |
469 |
wee_display_keys () |
weechat_display_keys () |
470 |
{ |
{ |
471 |
t_gui_key *ptr_key; |
t_gui_key *ptr_key; |
472 |
char *expanded_name; |
char *expanded_name; |
485 |
} |
} |
486 |
|
|
487 |
/* |
/* |
488 |
* wee_parse_args: parse command line args |
* weechat_parse_args: parse command line args |
489 |
*/ |
*/ |
490 |
|
|
491 |
void |
void |
492 |
wee_parse_args (int argc, char *argv[]) |
weechat_parse_args (int argc, char *argv[]) |
493 |
{ |
{ |
494 |
int i; |
int i; |
495 |
t_irc_server server_tmp; |
t_irc_server server_tmp; |
496 |
|
|
497 |
|
weechat_argv0 = strdup (argv[0]); |
498 |
|
weechat_session = NULL; |
499 |
server_cmd_line = 0; |
server_cmd_line = 0; |
500 |
auto_connect = 1; |
auto_connect = 1; |
501 |
auto_load_plugins = 1; |
auto_load_plugins = 1; |
508 |
else if ((strcmp (argv[i], "-c") == 0) |
else if ((strcmp (argv[i], "-c") == 0) |
509 |
|| (strcmp (argv[i], "--config") == 0)) |
|| (strcmp (argv[i], "--config") == 0)) |
510 |
{ |
{ |
511 |
wee_display_config_options (); |
weechat_display_config_options (); |
512 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
513 |
} |
} |
514 |
else if ((strcmp (argv[i], "-f") == 0) |
else if ((strcmp (argv[i], "-f") == 0) |
515 |
|| (strcmp (argv[i], "--key-functions") == 0)) |
|| (strcmp (argv[i], "--key-functions") == 0)) |
516 |
{ |
{ |
517 |
wee_display_key_functions (); |
weechat_display_key_functions (); |
518 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
519 |
} |
} |
520 |
else if ((strcmp (argv[i], "-h") == 0) |
else if ((strcmp (argv[i], "-h") == 0) |
521 |
|| (strcmp (argv[i], "--help") == 0)) |
|| (strcmp (argv[i], "--help") == 0)) |
522 |
{ |
{ |
523 |
printf ("\n" WEE_USAGE1, argv[0], argv[0]); |
weechat_display_usage (argv[0]); |
524 |
printf ("%s", WEE_USAGE2); |
weechat_shutdown (EXIT_SUCCESS, 0); |
|
wee_shutdown (EXIT_SUCCESS, 0); |
|
525 |
} |
} |
526 |
else if ((strcmp (argv[i], "-i") == 0) |
else if ((strcmp (argv[i], "-i") == 0) |
527 |
|| (strcmp (argv[i], "--irc-commands") == 0)) |
|| (strcmp (argv[i], "--irc-commands") == 0)) |
528 |
{ |
{ |
529 |
wee_display_commands (0, 1); |
weechat_display_commands (0, 1); |
530 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
531 |
} |
} |
532 |
else if ((strcmp (argv[i], "-k") == 0) |
else if ((strcmp (argv[i], "-k") == 0) |
533 |
|| (strcmp (argv[i], "--keys") == 0)) |
|| (strcmp (argv[i], "--keys") == 0)) |
534 |
{ |
{ |
535 |
wee_display_keys (); |
weechat_display_keys (); |
536 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
537 |
} |
} |
538 |
else if ((strcmp (argv[i], "-l") == 0) |
else if ((strcmp (argv[i], "-l") == 0) |
539 |
|| (strcmp (argv[i], "--license") == 0)) |
|| (strcmp (argv[i], "--license") == 0)) |
540 |
{ |
{ |
541 |
printf ("\n%s%s", WEE_LICENSE); |
printf ("\n%s%s", WEE_LICENSE); |
542 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
543 |
} |
} |
544 |
else if ((strcmp (argv[i], "-p") == 0) |
else if ((strcmp (argv[i], "-p") == 0) |
545 |
|| (strcmp (argv[i], "--no-plugin") == 0)) |
|| (strcmp (argv[i], "--no-plugin") == 0)) |
546 |
auto_load_plugins = 0; |
auto_load_plugins = 0; |
547 |
|
else if (strcmp (argv[i], "--session") == 0) |
548 |
|
{ |
549 |
|
if (i + 1 < argc) |
550 |
|
weechat_session = strdup (argv[++i]); |
551 |
|
else |
552 |
|
{ |
553 |
|
fprintf (stderr, |
554 |
|
_("%s missing argument for --session option\n"), |
555 |
|
WEECHAT_ERROR); |
556 |
|
weechat_shutdown (EXIT_FAILURE, 0); |
557 |
|
} |
558 |
|
} |
559 |
else if ((strcmp (argv[i], "-v") == 0) |
else if ((strcmp (argv[i], "-v") == 0) |
560 |
|| (strcmp (argv[i], "--version") == 0)) |
|| (strcmp (argv[i], "--version") == 0)) |
561 |
{ |
{ |
562 |
printf (PACKAGE_VERSION "\n"); |
printf (PACKAGE_VERSION "\n"); |
563 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
564 |
} |
} |
565 |
else if ((strcmp (argv[i], "-w") == 0) |
else if ((strcmp (argv[i], "-w") == 0) |
566 |
|| (strcmp (argv[i], "--weechat-commands") == 0)) |
|| (strcmp (argv[i], "--weechat-commands") == 0)) |
567 |
{ |
{ |
568 |
wee_display_commands (1, 0); |
weechat_display_commands (1, 0); |
569 |
wee_shutdown (EXIT_SUCCESS, 0); |
weechat_shutdown (EXIT_SUCCESS, 0); |
570 |
} |
} |
571 |
else if ((ascii_strncasecmp (argv[i], "irc", 3) == 0)) |
else if ((ascii_strncasecmp (argv[i], "irc", 3) == 0)) |
572 |
{ |
{ |
601 |
} |
} |
602 |
|
|
603 |
/* |
/* |
604 |
* wee_create_dir: create a directory |
* weechat_create_dir: create a directory |
605 |
* return: 1 if ok (or directory already exists) |
* return: 1 if ok (or directory already exists) |
606 |
* 0 if error |
* 0 if error |
607 |
*/ |
*/ |
608 |
|
|
609 |
int |
int |
610 |
wee_create_dir (char *directory) |
weechat_create_dir (char *directory) |
611 |
{ |
{ |
612 |
if (mkdir (directory, 0755) < 0) |
if (mkdir (directory, 0755) < 0) |
613 |
{ |
{ |
623 |
} |
} |
624 |
|
|
625 |
/* |
/* |
626 |
* wee_create_home_dirs: create (if not found): |
* weechat_create_home_dirs: create WeeChat directories (if not found) |
|
* - WeeChat home directory ("~/.weechat") |
|
|
* - "perl" directory (and "autoload") |
|
|
* - "ruby" directory (and "autoload") |
|
|
* - "python" directory (and "autoload") |
|
627 |
*/ |
*/ |
628 |
|
|
629 |
void |
void |
630 |
wee_create_home_dirs () |
weechat_create_home_dirs () |
631 |
{ |
{ |
632 |
char *ptr_home, *dir_name; |
char *ptr_home, *dir_name; |
633 |
int dir_length; |
int dir_length; |
634 |
|
|
|
/* TODO: rewrite this code for Windows version */ |
|
635 |
ptr_home = getenv ("HOME"); |
ptr_home = getenv ("HOME"); |
636 |
if (!ptr_home) |
if (!ptr_home) |
637 |
{ |
{ |
638 |
fprintf (stderr, _("%s unable to get HOME directory\n"), |
fprintf (stderr, _("%s unable to get HOME directory\n"), |
639 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
640 |
wee_shutdown (EXIT_FAILURE, 0); |
weechat_shutdown (EXIT_FAILURE, 0); |
641 |
} |
} |
642 |
dir_length = strlen (ptr_home) + 10; |
dir_length = strlen (ptr_home) + 10; |
643 |
weechat_home = |
weechat_home = |
646 |
{ |
{ |
647 |
fprintf (stderr, _("%s not enough memory for home directory\n"), |
fprintf (stderr, _("%s not enough memory for home directory\n"), |
648 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
649 |
wee_shutdown (EXIT_FAILURE, 0); |
weechat_shutdown (EXIT_FAILURE, 0); |
650 |
} |
} |
651 |
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home, |
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home, |
652 |
DIR_SEPARATOR); |
DIR_SEPARATOR); |
653 |
|
|
654 |
/* create home directory "~/.weechat" ; error is fatal */ |
/* create home directory "~/.weechat" ; error is fatal */ |
655 |
if (!wee_create_dir (weechat_home)) |
if (!weechat_create_dir (weechat_home)) |
656 |
{ |
{ |
657 |
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"), |
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"), |
658 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
659 |
wee_shutdown (EXIT_FAILURE, 0); |
weechat_shutdown (EXIT_FAILURE, 0); |
660 |
} |
} |
661 |
|
|
662 |
dir_length = strlen (weechat_home) + 64; |
dir_length = strlen (weechat_home) + 64; |
665 |
/* create "~/.weechat/logs" */ |
/* create "~/.weechat/logs" */ |
666 |
snprintf (dir_name, dir_length, "%s%s%s", weechat_home, DIR_SEPARATOR, |
snprintf (dir_name, dir_length, "%s%s%s", weechat_home, DIR_SEPARATOR, |
667 |
"logs"); |
"logs"); |
668 |
if (!wee_create_dir (dir_name)) |
if (!weechat_create_dir (dir_name)) |
669 |
{ |
{ |
670 |
fprintf (stderr, _("%s unable to create ~/.weechat/logs directory\n"), |
fprintf (stderr, _("%s unable to create ~/.weechat/logs directory\n"), |
671 |
WEECHAT_WARNING); |
WEECHAT_WARNING); |
676 |
} |
} |
677 |
|
|
678 |
/* |
/* |
679 |
* wee_init_vars: initialize some variables |
* weechat_init_vars: initialize some variables |
680 |
*/ |
*/ |
681 |
|
|
682 |
void |
void |
683 |
wee_init_vars () |
weechat_init_vars () |
684 |
{ |
{ |
685 |
/* start time, used by /uptime command */ |
/* start time, used by /uptime command */ |
686 |
weechat_start_time = time (NULL); |
weechat_start_time = time (NULL); |
698 |
} |
} |
699 |
|
|
700 |
/* |
/* |
701 |
* wee_init_log: initialize log file |
* weechat_init_log: initialize log file |
702 |
*/ |
*/ |
703 |
|
|
704 |
void |
void |
705 |
wee_init_log () |
weechat_init_log () |
706 |
{ |
{ |
707 |
int filename_length; |
int filename_length; |
708 |
char *filename; |
char *filename; |
719 |
} |
} |
720 |
|
|
721 |
/* |
/* |
722 |
|
* weechat_config_read: read WeeChat config file |
723 |
|
*/ |
724 |
|
|
725 |
|
void |
726 |
|
weechat_config_read () |
727 |
|
{ |
728 |
|
switch (config_read ()) |
729 |
|
{ |
730 |
|
case 0: /* read ok */ |
731 |
|
break; |
732 |
|
case -1: /* config file not found */ |
733 |
|
if (config_create_default () < 0) |
734 |
|
exit (EXIT_FAILURE); |
735 |
|
if (config_read () != 0) |
736 |
|
exit (EXIT_FAILURE); |
737 |
|
break; |
738 |
|
default: /* other error (fatal) */ |
739 |
|
server_free_all (); |
740 |
|
exit (EXIT_FAILURE); |
741 |
|
} |
742 |
|
} |
743 |
|
|
744 |
|
/* |
745 |
* weechat_welcome_message: display WeeChat welcome message - yeah! |
* weechat_welcome_message: display WeeChat welcome message - yeah! |
746 |
*/ |
*/ |
747 |
|
|
787 |
"%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n", |
"%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n", |
788 |
GUI_COLOR(COLOR_WIN_CHAT_NICK)); |
GUI_COLOR(COLOR_WIN_CHAT_NICK)); |
789 |
|
|
790 |
wee_log_printf ("%s (%s %s %s)\n", |
weechat_log_printf ("%s (%s %s %s)\n", |
791 |
PACKAGE_STRING, _("compiled on"), __DATE__, __TIME__); |
PACKAGE_STRING, _("compiled on"), __DATE__, __TIME__); |
792 |
} |
} |
793 |
|
|
794 |
/* |
/* |
795 |
* wee_gui_shutdown: shutdown WeeChat GUI |
* weechat_shutdown: shutdown WeeChat |
796 |
*/ |
*/ |
797 |
|
|
798 |
void |
void |
799 |
wee_gui_shutdown () |
weechat_shutdown (int return_code, int crash) |
|
{ |
|
|
dcc_end (); |
|
|
server_free_all (); |
|
|
gui_end (); |
|
|
} |
|
|
|
|
|
/* |
|
|
* wee_shutdown: shutdown WeeChat |
|
|
*/ |
|
|
|
|
|
void |
|
|
wee_shutdown (int return_code, int crash) |
|
800 |
{ |
{ |
801 |
|
if (weechat_argv0) |
802 |
|
free (weechat_argv0); |
803 |
fifo_remove (); |
fifo_remove (); |
804 |
if (weechat_home) |
if (weechat_home) |
805 |
free (weechat_home); |
free (weechat_home); |
821 |
} |
} |
822 |
|
|
823 |
/* |
/* |
824 |
* wee_dump writes dump to WeeChat log file |
* weechat_dump writes dump to WeeChat log file |
825 |
*/ |
*/ |
826 |
|
|
827 |
void |
void |
828 |
wee_dump (int crash) |
weechat_dump (int crash) |
829 |
{ |
{ |
830 |
t_irc_server *ptr_server; |
t_irc_server *ptr_server; |
831 |
t_irc_channel *ptr_channel; |
t_irc_channel *ptr_channel; |
832 |
t_irc_nick *ptr_nick; |
t_irc_nick *ptr_nick; |
833 |
|
t_irc_dcc *ptr_dcc; |
834 |
t_gui_window *ptr_window; |
t_gui_window *ptr_window; |
835 |
t_gui_buffer *ptr_buffer; |
t_gui_buffer *ptr_buffer; |
836 |
|
|
841 |
if (crash) |
if (crash) |
842 |
{ |
{ |
843 |
sigsegv = 1; |
sigsegv = 1; |
844 |
wee_log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...\n"); |
weechat_log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...\n"); |
845 |
} |
} |
846 |
|
|
847 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
848 |
if (crash) |
if (crash) |
849 |
{ |
{ |
850 |
wee_log_printf ("****** WeeChat CRASH DUMP ******\n"); |
weechat_log_printf ("****** WeeChat CRASH DUMP ******\n"); |
851 |
wee_log_printf ("****** Please send this file to WeeChat developers ******\n"); |
weechat_log_printf ("****** Please send this file to WeeChat developers ******\n"); |
852 |
wee_log_printf ("****** and explain when this crash happened ******\n"); |
weechat_log_printf ("****** and explain when this crash happened ******\n"); |
853 |
} |
} |
854 |
else |
else |
855 |
{ |
{ |
856 |
wee_log_printf ("****** WeeChat dump request ******\n"); |
weechat_log_printf ("****** WeeChat dump request ******\n"); |
857 |
} |
} |
858 |
|
|
859 |
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) |
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) |
860 |
{ |
{ |
861 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
862 |
server_print_log (ptr_server); |
server_print_log (ptr_server); |
863 |
|
|
864 |
for (ptr_channel = ptr_server->channels; ptr_channel; |
for (ptr_channel = ptr_server->channels; ptr_channel; |
865 |
ptr_channel = ptr_channel->next_channel) |
ptr_channel = ptr_channel->next_channel) |
866 |
{ |
{ |
867 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
868 |
channel_print_log (ptr_channel); |
channel_print_log (ptr_channel); |
869 |
|
|
870 |
for (ptr_nick = ptr_channel->nicks; ptr_nick; |
for (ptr_nick = ptr_channel->nicks; ptr_nick; |
871 |
ptr_nick = ptr_nick->next_nick) |
ptr_nick = ptr_nick->next_nick) |
872 |
{ |
{ |
873 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
874 |
nick_print_log (ptr_nick); |
nick_print_log (ptr_nick); |
875 |
} |
} |
876 |
|
|
877 |
} |
} |
878 |
} |
} |
879 |
|
|
880 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
881 |
wee_log_printf ("[windows/buffers]\n"); |
for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc) |
882 |
wee_log_printf (" => windows:\n"); |
{ |
883 |
|
dcc_print_log (ptr_dcc); |
884 |
|
} |
885 |
|
|
886 |
|
weechat_log_printf ("\n"); |
887 |
|
weechat_log_printf ("[windows/buffers]\n"); |
888 |
|
weechat_log_printf (" => windows:\n"); |
889 |
for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window) |
for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window) |
890 |
{ |
{ |
891 |
wee_log_printf (" 0x%X\n", ptr_window); |
weechat_log_printf (" 0x%X\n", ptr_window); |
892 |
} |
} |
893 |
wee_log_printf (" => buffers:\n"); |
weechat_log_printf (" => buffers:\n"); |
894 |
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) |
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) |
895 |
{ |
{ |
896 |
wee_log_printf (" 0x%X\n", ptr_buffer); |
weechat_log_printf (" 0x%X\n", ptr_buffer); |
897 |
} |
} |
898 |
wee_log_printf (" => current window = 0x%X\n", gui_current_window); |
weechat_log_printf (" => current window = 0x%X\n", gui_current_window); |
899 |
|
|
900 |
for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window) |
for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window) |
901 |
{ |
{ |
902 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
903 |
gui_window_print_log (ptr_window); |
gui_window_print_log (ptr_window); |
904 |
} |
} |
905 |
|
|
906 |
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) |
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) |
907 |
{ |
{ |
908 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
909 |
gui_buffer_print_log (ptr_buffer); |
gui_buffer_print_log (ptr_buffer); |
910 |
} |
} |
911 |
|
|
912 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
913 |
ignore_print_log (); |
ignore_print_log (); |
914 |
|
|
915 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
916 |
wee_log_printf ("****** End of dump ******\n"); |
weechat_log_printf ("****** End of dump ******\n"); |
917 |
wee_log_printf ("\n"); |
weechat_log_printf ("\n"); |
918 |
} |
} |
919 |
|
|
920 |
/* |
/* |
921 |
* my_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit |
* weechat_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit |
922 |
*/ |
*/ |
923 |
|
|
924 |
void |
void |
925 |
my_sigsegv () |
weechat_sigsegv () |
926 |
{ |
{ |
927 |
wee_dump (1); |
weechat_dump (1); |
928 |
wee_gui_shutdown (); |
dcc_end (); |
929 |
|
server_free_all (); |
930 |
|
gui_end (); |
931 |
fprintf (stderr, "\n"); |
fprintf (stderr, "\n"); |
932 |
fprintf (stderr, "*** Very bad! WeeChat has crashed (SIGSEGV received)\n"); |
fprintf (stderr, "*** Very bad! WeeChat has crashed (SIGSEGV received)\n"); |
933 |
fprintf (stderr, "*** Full crash dump was saved to ~/.weechat/weechat.log file\n"); |
fprintf (stderr, "*** Full crash dump was saved to ~/.weechat/weechat.log file\n"); |
934 |
fprintf (stderr, "*** Please send this file to WeeChat developers.\n"); |
fprintf (stderr, "*** Please send this file to WeeChat developers.\n"); |
935 |
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"); |
936 |
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"); |
937 |
wee_shutdown (EXIT_FAILURE, 1); |
weechat_shutdown (EXIT_FAILURE, 1); |
938 |
} |
} |
939 |
|
|
940 |
/* |
/* |
944 |
int |
int |
945 |
main (int argc, char *argv[]) |
main (int argc, char *argv[]) |
946 |
{ |
{ |
947 |
#ifdef ENABLE_NLS |
#ifdef ENABLE_NLS |
948 |
setlocale (LC_ALL, ""); /* initialize gettext */ |
setlocale (LC_ALL, ""); /* initialize gettext */ |
949 |
bindtextdomain (PACKAGE, LOCALEDIR); |
bindtextdomain (PACKAGE, LOCALEDIR); |
950 |
textdomain (PACKAGE); |
textdomain (PACKAGE); |
951 |
#endif |
#endif |
952 |
|
|
953 |
#ifdef HAVE_LANGINFO_CODESET |
#ifdef HAVE_LANGINFO_CODESET |
954 |
local_charset = strdup (nl_langinfo (CODESET)); |
local_charset = strdup (nl_langinfo (CODESET)); |
955 |
#endif |
#endif |
|
|
|
|
signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */ |
|
|
signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */ |
|
|
signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */ |
|
|
signal (SIGSEGV, my_sigsegv); /* crash dump when SIGSEGV is received */ |
|
|
gui_pre_init (&argc, &argv); /* pre-initiliaze interface */ |
|
|
wee_init_vars (); /* initialize some variables */ |
|
|
gui_key_init (); /* init keyboard (default key bindings) */ |
|
|
wee_parse_args (argc, argv); /* parse command line args */ |
|
|
wee_create_home_dirs (); /* create WeeChat directories */ |
|
|
wee_init_log (); /* init log file */ |
|
|
command_index_build (); /* build commands index for completion */ |
|
|
|
|
|
switch (config_read ()) /* read configuration */ |
|
|
{ |
|
|
case 0: /* config file OK */ |
|
|
break; |
|
|
case -1: /* config file not found */ |
|
|
if (config_create_default () < 0) |
|
|
return EXIT_FAILURE; |
|
|
if (config_read () != 0) |
|
|
return EXIT_FAILURE; |
|
|
break; |
|
|
default: /* other error (fatal) */ |
|
|
server_free_all (); |
|
|
return EXIT_FAILURE; |
|
|
} |
|
956 |
|
|
957 |
utf8_init (); /* init UTF-8 in WeeChat */ |
signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */ |
958 |
gui_init (); /* init WeeChat interface */ |
signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */ |
959 |
weechat_welcome_message (); /* display WeeChat welcome message */ |
signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */ |
960 |
|
signal (SIGSEGV, weechat_sigsegv); /* crash dump when SIGSEGV received */ |
961 |
|
gui_pre_init (&argc, &argv); /* pre-initiliaze interface */ |
962 |
|
weechat_init_vars (); /* initialize some variables */ |
963 |
|
gui_key_init (); /* init keyb. (default key bindings)*/ |
964 |
|
weechat_parse_args (argc, argv); /* parse command line args */ |
965 |
|
weechat_create_home_dirs (); /* create WeeChat directories */ |
966 |
|
weechat_init_log (); /* init log file */ |
967 |
|
command_index_build (); /* build cmd index for completion */ |
968 |
|
weechat_config_read (); /* read configuration */ |
969 |
|
utf8_init (); /* init UTF-8 in WeeChat */ |
970 |
|
gui_init (); /* init WeeChat interface */ |
971 |
|
weechat_welcome_message (); /* display WeeChat welcome message */ |
972 |
#ifdef PLUGINS |
#ifdef PLUGINS |
973 |
plugin_init (auto_load_plugins);/* init plugin interface(s) */ |
plugin_init (auto_load_plugins); /* init plugin interface(s) */ |
974 |
#endif |
#endif |
|
/* auto-connect to servers */ |
|
|
server_auto_connect (auto_connect, server_cmd_line); |
|
|
fifo_create (); /* create FIFO pipe for remote control */ |
|
975 |
|
|
976 |
gui_main_loop (); /* WeeChat main loop */ |
server_auto_connect (auto_connect, /* auto-connect to servers */ |
977 |
|
server_cmd_line); |
978 |
|
fifo_create (); /* FIFO pipe for remote control */ |
979 |
|
|
980 |
|
if (weechat_session) |
981 |
|
session_load (weechat_session); /* load previous session if asked */ |
982 |
|
|
983 |
|
gui_main_loop (); /* WeeChat main loop */ |
984 |
|
|
985 |
#ifdef PLUGINS |
#ifdef PLUGINS |
986 |
plugin_end (); /* end plugin interface(s) */ |
plugin_end (); /* end plugin interface(s) */ |
987 |
#endif |
#endif |
988 |
server_disconnect_all (); /* disconnect from all servers */ |
server_disconnect_all (); /* disconnect from all servers */ |
989 |
(void) config_write (NULL); /* save config file */ |
(void) config_write (NULL); /* save config file */ |
990 |
command_index_free (); /* free commands index */ |
command_index_free (); /* free commands index */ |
991 |
wee_gui_shutdown (); /* shut down WeeChat GUI */ |
dcc_end (); /* remove all DCC */ |
992 |
wee_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */ |
server_free_all (); /* free all servers */ |
993 |
|
gui_end (); /* shut down WeeChat GUI */ |
994 |
|
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */ |
995 |
|
|
996 |
return EXIT_SUCCESS; /* make gcc happy (never executed) */ |
return EXIT_SUCCESS; /* make gcc happy (never executed) */ |
997 |
} |
} |