separate-extcmd.diff
changeset 64 d328b18462bd
parent 63 d268aa028975
child 87 78238d26911a
--- a/separate-extcmd.diff	Fri Jan 18 11:32:15 2013 +0200
+++ b/separate-extcmd.diff	Sun Feb 24 04:47:32 2013 +0200
@@ -2,7 +2,7 @@
 
 diff -r 75d573fb8845 mcabber/mcabber/Makefile.am
 --- a/mcabber/mcabber/Makefile.am	Fri Jan 18 11:23:51 2013 +0200
-+++ b/mcabber/mcabber/Makefile.am	Fri Jan 18 11:30:51 2013 +0200
++++ b/mcabber/mcabber/Makefile.am	Sun Jan 27 00:38:57 2013 +0200
 @@ -7,7 +7,7 @@
  		  xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \
  		  xmpp_iq.c xmpp_iq.h xmpp_iqrequest.c xmpp_iqrequest.h \
@@ -22,7 +22,7 @@
  if OTR
 diff -r 75d573fb8845 mcabber/mcabber/extcmd.c
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/mcabber/mcabber/extcmd.c	Fri Jan 18 11:30:51 2013 +0200
++++ b/mcabber/mcabber/extcmd.c	Sun Jan 27 00:38:57 2013 +0200
 @@ -0,0 +1,152 @@
 +/*
 + * extcmd.c      -- External event handler command
@@ -178,7 +178,7 @@
 +/* vim: set expandtab cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */
 diff -r 75d573fb8845 mcabber/mcabber/extcmd.h
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/mcabber/mcabber/extcmd.h	Fri Jan 18 11:30:51 2013 +0200
++++ b/mcabber/mcabber/extcmd.h	Sun Jan 27 00:38:57 2013 +0200
 @@ -0,0 +1,15 @@
 +#ifndef __MCABBER_EXTCMD_H__
 +#define __MCABBER_EXTCMD_H__ 1
@@ -197,7 +197,7 @@
 +#endif
 diff -r 75d573fb8845 mcabber/mcabber/hooks.c
 --- a/mcabber/mcabber/hooks.c	Fri Jan 18 11:23:51 2013 +0200
-+++ b/mcabber/mcabber/hooks.c	Fri Jan 18 11:30:51 2013 +0200
++++ b/mcabber/mcabber/hooks.c	Sun Jan 27 00:38:57 2013 +0200
 @@ -24,6 +24,7 @@
  #include <string.h>
  #include <sys/types.h>
@@ -466,7 +466,7 @@
  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
 diff -r 75d573fb8845 mcabber/mcabber/hooks.h
 --- a/mcabber/mcabber/hooks.h	Fri Jan 18 11:23:51 2013 +0200
-+++ b/mcabber/mcabber/hooks.h	Fri Jan 18 11:30:51 2013 +0200
++++ b/mcabber/mcabber/hooks.h	Sun Jan 27 00:38:57 2013 +0200
 @@ -66,9 +66,6 @@
  guint hk_subscription(LmMessageSubType mstype, const gchar *bjid,
                        const gchar *msg);
@@ -479,8 +479,8 @@
  /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
 diff -r 75d573fb8845 mcabber/mcabber/main.c
 --- a/mcabber/mcabber/main.c	Fri Jan 18 11:23:51 2013 +0200
-+++ b/mcabber/mcabber/main.c	Fri Jan 18 11:30:51 2013 +0200
-@@ -19,17 +19,15 @@
++++ b/mcabber/mcabber/main.c	Sun Jan 27 00:38:57 2013 +0200
+@@ -19,14 +19,18 @@
   * USA
   */
  
@@ -492,20 +492,22 @@
 -#include <termios.h>
 -#include <sys/types.h>
 -#include <sys/wait.h>
-+#include <stdio.h>   // fprintf, fileno, fgets, puts
-+#include <stdlib.h>  // exit, getenv
-+#include <unistd.h>  // tcsetattr, tcgetattr, getopt
-+#include <string.h>  // strchr, strlen, memset
-+#include <signal.h>  // signal
-+#include <termios.h> // tcsetattr, tcgetattr
++#include <stdio.h>     // fprintf, fileno, fgets, puts
++#include <stdlib.h>    // exit, getenv
++#include <unistd.h>    // tcsetattr, tcgetattr, getopt
++#include <string.h>    // strchr, strlen, memset
++#include <signal.h>    // signal
++#include <termios.h>   // tcsetattr, tcgetattr
++#include <sys/types.h> // waitpid
++#include <sys/wait.h>  // waitpid
++#include <glib.h>
++#include <config.h>
++#include <poll.h>      // POLLIN, POLLERR, POLLPRI
++
  #include <glib.h>
  #include <config.h>
--#include <poll.h>
-+#include <poll.h>    // POLLIN, POLLERR, POLLPRI
- 
- #include "caps.h"
- #include "screen.h"
-@@ -44,6 +42,7 @@
+ #include <poll.h>
+@@ -44,6 +48,7 @@
  #include "xmpp.h"
  #include "help.h"
  #include "events.h"
@@ -513,47 +515,34 @@
  
  #ifndef MODULES_ENABLE
  # include "fifo.h"
-@@ -58,10 +57,6 @@
- # include "hgcset.h"
- #endif
- 
--#ifndef WAIT_ANY
--# define WAIT_ANY -1
--#endif
--
- static unsigned int terminate_ui;
- GMainContext *main_context;
- 
-@@ -98,23 +93,7 @@
+@@ -348,10 +353,10 @@
+       case 'h':
+       case '?':
+         printf("Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
+-        return (c == 'h' ? 0 : -1);
++        return (c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE);
+       case 'V':
+         compile_options();
+-        return 0;
++        return EXIT_SUCCESS;
+       case 'f':
+         configFile = g_strdup(optarg);
+         break;
+@@ -360,7 +365,7 @@
  
- void sig_handler(int signum)
- {
--  if (signum == SIGCHLD) {
--    int status;
--    pid_t pid;
--    do {
--      pid = waitpid (WAIT_ANY, &status, WNOHANG);
--      // Check the exit status value if 'eventcmd_checkstatus' is set
--      if (settings_opt_get_int("eventcmd_checkstatus")) {
--        if (pid > 0) {
--          // exit status 2 -> beep
--          if (WIFEXITED(status) && WEXITSTATUS(status) == 2) {
--            scr_beep();
--          }
--        }
--      }
--    } while (pid > 0);
--    signal(SIGCHLD, sig_handler);
--  } else if (signum == SIGTERM) {
-+  if (signum == SIGTERM) {
-     mcabber_terminate("Killed by SIGTERM");
-   } else if (signum == SIGINT) {
-     mcabber_terminate("Killed by SIGINT");
-@@ -332,7 +311,6 @@
+   if (optind < argc) {
+     fprintf(stderr, "Usage: %s [-h|-V|-f mcabberrc_file]\n\n", argv[0]);
+-    return -1;
++    return EXIT_FAILURE;
+   }
  
-   signal(SIGTERM, sig_handler);
-   signal(SIGINT,  sig_handler);
--  signal(SIGCHLD, sig_handler);
- #ifdef USE_SIGWINCH
-   signal(SIGWINCH, sig_handler);
- #endif
+   /* Initialize command system, roster and default key bindings */
+@@ -529,7 +534,7 @@
+ 
+   printf("\n\nThanks for using mcabber!\n");
+ 
+-  return 0;
++  return EXIT_SUCCESS;
+ }
+ 
+ /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */