60 |
#include "../plugins/plugins.h" |
#include "../plugins/plugins.h" |
61 |
|
|
62 |
|
|
63 |
int quit_weechat; /* = 1 if quit request from user... why ? :'( */ |
int quit_weechat; /* = 1 if quit request from user... why ? :'( */ |
64 |
char *weechat_home; /* WeeChat home dir. (example: /home/toto/.weechat) */ |
char *weechat_home = NULL; /* WeeChat home dir. (example: /home/toto/.weechat) */ |
65 |
FILE *weechat_log_file; /* WeeChat log file (~/.weechat/weechat.log) */ |
FILE *weechat_log_file = NULL; /* WeeChat log file (~/.weechat/weechat.log) */ |
66 |
|
|
67 |
char *local_charset = NULL; /* local charset, for example: ISO-8859-1 */ |
char *local_charset = NULL; /* local charset, for example: ISO-8859-1 */ |
68 |
|
|
264 |
|| (strcmp (argv[i], "--config") == 0)) |
|| (strcmp (argv[i], "--config") == 0)) |
265 |
{ |
{ |
266 |
wee_display_config_options (); |
wee_display_config_options (); |
267 |
exit (EXIT_SUCCESS); |
wee_shutdown (EXIT_SUCCESS); |
268 |
} |
} |
269 |
else if ((strcmp (argv[i], "-h") == 0) |
else if ((strcmp (argv[i], "-h") == 0) |
270 |
|| (strcmp (argv[i], "--help") == 0)) |
|| (strcmp (argv[i], "--help") == 0)) |
271 |
{ |
{ |
272 |
printf ("\n" WEE_USAGE1, argv[0], argv[0]); |
printf ("\n" WEE_USAGE1, argv[0], argv[0]); |
273 |
printf ("%s", WEE_USAGE2); |
printf ("%s", WEE_USAGE2); |
274 |
exit (EXIT_SUCCESS); |
wee_shutdown (EXIT_SUCCESS); |
275 |
} |
} |
276 |
else if ((strcmp (argv[i], "-l") == 0) |
else if ((strcmp (argv[i], "-l") == 0) |
277 |
|| (strcmp (argv[i], "--license") == 0)) |
|| (strcmp (argv[i], "--license") == 0)) |
278 |
{ |
{ |
279 |
printf ("\n%s%s", WEE_LICENSE); |
printf ("\n%s%s", WEE_LICENSE); |
280 |
exit (EXIT_SUCCESS); |
wee_shutdown (EXIT_SUCCESS); |
281 |
} |
} |
282 |
else if ((strcmp (argv[i], "-v") == 0) |
else if ((strcmp (argv[i], "-v") == 0) |
283 |
|| (strcmp (argv[i], "--version") == 0)) |
|| (strcmp (argv[i], "--version") == 0)) |
284 |
{ |
{ |
285 |
printf (PACKAGE_VERSION "\n"); |
printf (PACKAGE_VERSION "\n"); |
286 |
exit (EXIT_SUCCESS); |
wee_shutdown (EXIT_SUCCESS); |
287 |
} |
} |
288 |
else if ((strncasecmp (argv[i], "irc://", 6) == 0)) |
else if ((strncasecmp (argv[i], "irc://", 6) == 0)) |
289 |
{ |
{ |
358 |
{ |
{ |
359 |
fprintf (stderr, _("%s unable to get HOME directory\n"), |
fprintf (stderr, _("%s unable to get HOME directory\n"), |
360 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
361 |
exit (EXIT_FAILURE); |
wee_shutdown (EXIT_FAILURE); |
362 |
} |
} |
363 |
dir_length = strlen (ptr_home) + 10; |
dir_length = strlen (ptr_home) + 10; |
364 |
weechat_home = |
weechat_home = |
367 |
{ |
{ |
368 |
fprintf (stderr, _("%s not enough memory for home directory\n"), |
fprintf (stderr, _("%s not enough memory for home directory\n"), |
369 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
370 |
exit (EXIT_FAILURE); |
wee_shutdown (EXIT_FAILURE); |
371 |
} |
} |
372 |
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home, |
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home, |
373 |
DIR_SEPARATOR); |
DIR_SEPARATOR); |
377 |
{ |
{ |
378 |
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"), |
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"), |
379 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
380 |
exit (EXIT_FAILURE); |
wee_shutdown (EXIT_FAILURE); |
381 |
} |
} |
382 |
|
|
383 |
dir_length = strlen (weechat_home) + 64; |
dir_length = strlen (weechat_home) + 64; |
509 |
} |
} |
510 |
|
|
511 |
/* |
/* |
512 |
* wee_shutdown: shutdown WeeChat |
* wee_gui_shutdown: shutdown WeeChat GUI |
513 |
*/ |
*/ |
514 |
|
|
515 |
void |
void |
516 |
wee_shutdown () |
wee_gui_shutdown () |
517 |
{ |
{ |
518 |
dcc_end (); |
dcc_end (); |
519 |
server_free_all (); |
server_free_all (); |
520 |
gui_end (); |
gui_end (); |
521 |
|
} |
522 |
|
|
523 |
|
/* |
524 |
|
* wee_shutdown: shutdown WeeChat |
525 |
|
*/ |
526 |
|
|
527 |
|
void |
528 |
|
wee_shutdown (int return_code) |
529 |
|
{ |
530 |
|
if (weechat_home) |
531 |
|
free (weechat_home); |
532 |
if (weechat_log_file) |
if (weechat_log_file) |
533 |
fclose (weechat_log_file); |
fclose (weechat_log_file); |
534 |
exit (EXIT_SUCCESS); |
if (local_charset) |
535 |
|
free (local_charset); |
536 |
|
alias_free_all (); |
537 |
|
exit (return_code); |
538 |
} |
} |
539 |
|
|
540 |
/* |
/* |
586 |
plugin_end (); /* end plugin interface(s) */ |
plugin_end (); /* end plugin interface(s) */ |
587 |
server_disconnect_all (); /* disconnect from all servers */ |
server_disconnect_all (); /* disconnect from all servers */ |
588 |
(void) config_write (NULL); /* save config file */ |
(void) config_write (NULL); /* save config file */ |
589 |
wee_shutdown (); /* quit WeeChat (oh no, why?) */ |
command_index_free (); /* free commands index */ |
590 |
|
wee_gui_shutdown (); /* shut down WeeChat GUI */ |
591 |
|
wee_shutdown (EXIT_SUCCESS); /* quit WeeChat (oh no, why?) */ |
592 |
|
|
593 |
return EXIT_SUCCESS; /* make gcc happy (never executed) */ |
return EXIT_SUCCESS; /* make gcc happy (never executed) */ |
594 |
} |
} |