1 Move extcmd code from hooks |
1 Move extcmd code from hooks |
2 |
2 |
3 diff -r 75d573fb8845 mcabber/mcabber/Makefile.am |
3 diff -r 75d573fb8845 mcabber/mcabber/Makefile.am |
4 --- a/mcabber/mcabber/Makefile.am Fri Jan 18 11:23:51 2013 +0200 |
4 --- a/mcabber/mcabber/Makefile.am Fri Jan 18 11:23:51 2013 +0200 |
5 +++ b/mcabber/mcabber/Makefile.am Fri Jan 18 11:30:51 2013 +0200 |
5 +++ b/mcabber/mcabber/Makefile.am Sun Jan 27 00:38:57 2013 +0200 |
6 @@ -7,7 +7,7 @@ |
6 @@ -7,7 +7,7 @@ |
7 xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \ |
7 xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \ |
8 xmpp_iq.c xmpp_iq.h xmpp_iqrequest.c xmpp_iqrequest.h \ |
8 xmpp_iq.c xmpp_iq.h xmpp_iqrequest.c xmpp_iqrequest.h \ |
9 xmpp_muc.c xmpp_muc.h xmpp_s10n.c xmpp_s10n.h \ |
9 xmpp_muc.c xmpp_muc.h xmpp_s10n.c xmpp_s10n.h \ |
10 - caps.c caps.h help.c help.h |
10 - caps.c caps.h help.c help.h |
176 +} |
176 +} |
177 + |
177 + |
178 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |
178 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |
179 diff -r 75d573fb8845 mcabber/mcabber/extcmd.h |
179 diff -r 75d573fb8845 mcabber/mcabber/extcmd.h |
180 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
180 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
181 +++ b/mcabber/mcabber/extcmd.h Fri Jan 18 11:30:51 2013 +0200 |
181 +++ b/mcabber/mcabber/extcmd.h Sun Jan 27 00:38:57 2013 +0200 |
182 @@ -0,0 +1,15 @@ |
182 @@ -0,0 +1,15 @@ |
183 +#ifndef __MCABBER_EXTCMD_H__ |
183 +#ifndef __MCABBER_EXTCMD_H__ |
184 +#define __MCABBER_EXTCMD_H__ 1 |
184 +#define __MCABBER_EXTCMD_H__ 1 |
185 + |
185 + |
186 +#define EXT_CMD_TYPE_MESSAGE "MSG" |
186 +#define EXT_CMD_TYPE_MESSAGE "MSG" |
464 -} |
464 -} |
465 - |
465 - |
466 /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */ |
466 /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */ |
467 diff -r 75d573fb8845 mcabber/mcabber/hooks.h |
467 diff -r 75d573fb8845 mcabber/mcabber/hooks.h |
468 --- a/mcabber/mcabber/hooks.h Fri Jan 18 11:23:51 2013 +0200 |
468 --- a/mcabber/mcabber/hooks.h Fri Jan 18 11:23:51 2013 +0200 |
469 +++ b/mcabber/mcabber/hooks.h Fri Jan 18 11:30:51 2013 +0200 |
469 +++ b/mcabber/mcabber/hooks.h Sun Jan 27 00:38:57 2013 +0200 |
470 @@ -66,9 +66,6 @@ |
470 @@ -66,9 +66,6 @@ |
471 guint hk_subscription(LmMessageSubType mstype, const gchar *bjid, |
471 guint hk_subscription(LmMessageSubType mstype, const gchar *bjid, |
472 const gchar *msg); |
472 const gchar *msg); |
473 |
473 |
474 -void hk_ext_cmd_init(const char *command); |
474 -void hk_ext_cmd_init(const char *command); |
490 -#include <string.h> |
490 -#include <string.h> |
491 -#include <signal.h> |
491 -#include <signal.h> |
492 -#include <termios.h> |
492 -#include <termios.h> |
493 -#include <sys/types.h> |
493 -#include <sys/types.h> |
494 -#include <sys/wait.h> |
494 -#include <sys/wait.h> |
495 +#include <stdio.h> // fprintf, fileno, fgets, puts |
495 +#include <stdio.h> // fprintf, fileno, fgets, puts |
496 +#include <stdlib.h> // exit, getenv |
496 +#include <stdlib.h> // exit, getenv |
497 +#include <unistd.h> // tcsetattr, tcgetattr, getopt |
497 +#include <unistd.h> // tcsetattr, tcgetattr, getopt |
498 +#include <string.h> // strchr, strlen, memset |
498 +#include <string.h> // strchr, strlen, memset |
499 +#include <signal.h> // signal |
499 +#include <signal.h> // signal |
500 +#include <termios.h> // tcsetattr, tcgetattr |
500 +#include <termios.h> // tcsetattr, tcgetattr |
|
501 +#include <sys/types.h> // waitpid |
|
502 +#include <sys/wait.h> // waitpid |
|
503 +#include <glib.h> |
|
504 +#include <config.h> |
|
505 +#include <poll.h> // POLLIN, POLLERR, POLLPRI |
|
506 + |
501 #include <glib.h> |
507 #include <glib.h> |
502 #include <config.h> |
508 #include <config.h> |
503 -#include <poll.h> |
509 #include <poll.h> |
504 +#include <poll.h> // POLLIN, POLLERR, POLLPRI |
510 @@ -44,6 +48,7 @@ |
505 |
|
506 #include "caps.h" |
|
507 #include "screen.h" |
|
508 @@ -44,6 +42,7 @@ |
|
509 #include "xmpp.h" |
511 #include "xmpp.h" |
510 #include "help.h" |
512 #include "help.h" |
511 #include "events.h" |
513 #include "events.h" |
512 +#include "extcmd.h" |
514 +#include "extcmd.h" |
513 |
515 |
514 #ifndef MODULES_ENABLE |
516 #ifndef MODULES_ENABLE |
515 # include "fifo.h" |
517 # include "fifo.h" |
516 @@ -58,10 +57,6 @@ |
518 @@ -348,10 +353,10 @@ |
517 # include "hgcset.h" |
519 case 'h': |
518 #endif |
520 case '?': |
519 |
521 printf("Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]); |
520 -#ifndef WAIT_ANY |
522 - return (c == 'h' ? 0 : -1); |
521 -# define WAIT_ANY -1 |
523 + return (c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE); |
522 -#endif |
524 case 'V': |
523 - |
525 compile_options(); |
524 static unsigned int terminate_ui; |
526 - return 0; |
525 GMainContext *main_context; |
527 + return EXIT_SUCCESS; |
526 |
528 case 'f': |
527 @@ -98,23 +93,7 @@ |
529 configFile = g_strdup(optarg); |
528 |
530 break; |
529 void sig_handler(int signum) |
531 @@ -360,7 +365,7 @@ |
530 { |
532 |
531 - if (signum == SIGCHLD) { |
533 if (optind < argc) { |
532 - int status; |
534 fprintf(stderr, "Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]); |
533 - pid_t pid; |
535 - return -1; |
534 - do { |
536 + return EXIT_FAILURE; |
535 - pid = waitpid (WAIT_ANY, &status, WNOHANG); |
537 } |
536 - // Check the exit status value if 'eventcmd_checkstatus' is set |
538 |
537 - if (settings_opt_get_int("eventcmd_checkstatus")) { |
539 /* Initialize command system, roster and default key bindings */ |
538 - if (pid > 0) { |
540 @@ -529,7 +534,7 @@ |
539 - // exit status 2 -> beep |
541 |
540 - if (WIFEXITED(status) && WEXITSTATUS(status) == 2) { |
542 printf("\n\nThanks for using mcabber!\n"); |
541 - scr_beep(); |
543 |
542 - } |
544 - return 0; |
543 - } |
545 + return EXIT_SUCCESS; |
544 - } |
546 } |
545 - } while (pid > 0); |
547 |
546 - signal(SIGCHLD, sig_handler); |
548 /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */ |
547 - } else if (signum == SIGTERM) { |
|
548 + if (signum == SIGTERM) { |
|
549 mcabber_terminate("Killed by SIGTERM"); |
|
550 } else if (signum == SIGINT) { |
|
551 mcabber_terminate("Killed by SIGINT"); |
|
552 @@ -332,7 +311,6 @@ |
|
553 |
|
554 signal(SIGTERM, sig_handler); |
|
555 signal(SIGINT, sig_handler); |
|
556 - signal(SIGCHLD, sig_handler); |
|
557 #ifdef USE_SIGWINCH |
|
558 signal(SIGWINCH, sig_handler); |
|
559 #endif |
|