this NEEDS TO BE tested on non-linux, so get moving.

>From 3f7af452dd46e69112172c2280e93cc0eac8119a Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 18 Mar 2010 04:09:07 +0100
Subject: [PATCH] Make inotify optional

Well, try to.

This needs to be tested on !linux.
---
 configure.ac   |    4 +++-
 src/event.c    |   12 ++++++++++--
 src/main.c     |   12 ++++++++++--
 src/shutdown.c |    6 ++++++
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7992179..a4be3a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,7 +128,9 @@ if test "x$HAVEDL" = xyes; then
     AC_CHECK_HEADERS(dlfcn.h)
 fi
 
-
+dnl Check for inotify
+dnl =================
+AC_CHECK_HEADERS(sys/inotify.h, AC_DEFINE(HAVE_INOTIFY, 1, Check for inotify))
 
 dnl Check CPP
 dnl =========
diff --git a/src/event.c b/src/event.c
index d29cafc..fe14b11 100644
--- a/src/event.c
+++ b/src/event.c
@@ -20,9 +20,12 @@
  *  USA.
  */
 
-#include <sys/inotify.h>
 #include "wconfig.h"
 
+#ifdef HAVE_INOTIFY
+#include <sys/inotify.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -282,6 +285,7 @@ void DispatchEvent(XEvent * event)
        }
 }
 
+#ifdef HAVE_INOTIFY
 /*
  *----------------------------------------------------------------------
  * inotifyHandleEvents-
@@ -342,6 +346,7 @@ void inotifyHandleEvents(int fd, int wd)
                i += sizeof(struct inotify_event) + pevent->len;
        }
 }
+#endif /* HAVE_INOTIFY */
 
 /*
  *----------------------------------------------------------------------
@@ -359,6 +364,7 @@ void inotifyHandleEvents(int fd, int wd)
 void EventLoop(void)
 {
        XEvent event;
+#ifdef HAVE_INOTIFY
        extern int inotifyFD;
        extern int inotifyWD;
        struct timeval time;
@@ -367,12 +373,13 @@ void EventLoop(void)
 
        if (inotifyFD < 0 || inotifyWD < 0)
                retVal = -1;
+#endif
 
        for (;;) {
 
                WMNextEvent(dpy, &event);       /* Blocks here */
                WMHandleEvent(&event);
-
+#ifdef HAVE_INOTIFY
                if (retVal != -1) {
                        time.tv_sec = 0;
                        time.tv_usec = 0;
@@ -392,6 +399,7 @@ void EventLoop(void)
                        if (FD_ISSET(inotifyFD, &rfds))
                                inotifyHandleEvents(inotifyFD, inotifyWD);
                }
+#endif
        }
 }
 
diff --git a/src/main.c b/src/main.c
index 225ce4b..b775d8d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -19,10 +19,12 @@
  *  USA.
  */
 
-#include <sys/inotify.h>
-
 #include "wconfig.h"
 
+#ifdef HAVE_INOTIFY
+#include <sys/inotify.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -67,8 +69,10 @@ char *ProgName;
 
 unsigned int ValidModMask = 0xff;
 
+#ifdef HAVE_INOTIFY
 int inotifyFD;
 int inotifyWD;
+#endif
 /* locale to use. NULL==POSIX or C */
 char *Locale = NULL;
 
@@ -460,6 +464,7 @@ void check_defaults()
        wfree(path);
 }
 
+#ifdef HAVE_INOTIFY
 /*
  * Add watch here, used to notify if configuration
  * files have changed, using linux kernel inotify mechanism
@@ -490,6 +495,7 @@ static void inotifyWatchConfig()
        }
        wfree(watchPath);
 }
+#endif /* HAVE_INOTIFY */
 
 static void execInitScript()
 {
@@ -762,7 +768,9 @@ static int real_main(int argc, char **argv)
                multiHead = False;
 
        execInitScript();
+#ifdef HAVE_INOTIFY
        inotifyWatchConfig();
+#endif
        EventLoop();
        return -1;
 }
diff --git a/src/shutdown.c b/src/shutdown.c
index f6f6c27..8b5e86b 100644
--- a/src/shutdown.c
+++ b/src/shutdown.c
@@ -56,7 +56,9 @@ static void wipeDesktop(WScreen * scr);
 void Shutdown(WShutdownMode mode)
 {
        int i;
+#ifdef HAVE_INOTIFY
        extern int inotifyFD;
+#endif
 
        switch (mode) {
        case WSLogoutMode:
@@ -64,7 +66,9 @@ void Shutdown(WShutdownMode mode)
        case WSExitMode:
                /* if there is no session manager, send SAVE_YOURSELF to
                 * the clients */
+#ifdef HAVE_INOTIFY
                close(inotifyFD);
+#endif
                for (i = 0; i < wScreenCount; i++) {
                        WScreen *scr;
 
@@ -92,7 +96,9 @@ void Shutdown(WShutdownMode mode)
                for (i = 0; i < wScreenCount; i++) {
                        WScreen *scr;
 
+#ifdef HAVE_INOTIFY
                        close(inotifyFD);
+#endif
                        scr = wScreenWithNumber(i);
                        if (scr) {
                                if (scr->helper_pid)
-- 
1.7.0


-- 
[-]

mkdir /nonexistent
From 3f7af452dd46e69112172c2280e93cc0eac8119a Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 18 Mar 2010 04:09:07 +0100
Subject: [PATCH] Make inotify optional

Well, try to.

This needs to be tested on !linux.
---
 configure.ac   |    4 +++-
 src/event.c    |   12 ++++++++++--
 src/main.c     |   12 ++++++++++--
 src/shutdown.c |    6 ++++++
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7992179..a4be3a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,7 +128,9 @@ if test "x$HAVEDL" = xyes; then
     AC_CHECK_HEADERS(dlfcn.h)
 fi
 
-
+dnl Check for inotify
+dnl =================
+AC_CHECK_HEADERS(sys/inotify.h, AC_DEFINE(HAVE_INOTIFY, 1, Check for inotify))
 
 dnl Check CPP
 dnl =========
diff --git a/src/event.c b/src/event.c
index d29cafc..fe14b11 100644
--- a/src/event.c
+++ b/src/event.c
@@ -20,9 +20,12 @@
  *  USA.
  */
 
-#include <sys/inotify.h>
 #include "wconfig.h"
 
+#ifdef HAVE_INOTIFY
+#include <sys/inotify.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -282,6 +285,7 @@ void DispatchEvent(XEvent * event)
 	}
 }
 
+#ifdef HAVE_INOTIFY
 /*
  *----------------------------------------------------------------------
  * inotifyHandleEvents-
@@ -342,6 +346,7 @@ void inotifyHandleEvents(int fd, int wd)
 		i += sizeof(struct inotify_event) + pevent->len;
 	}
 }
+#endif /* HAVE_INOTIFY */
 
 /*
  *----------------------------------------------------------------------
@@ -359,6 +364,7 @@ void inotifyHandleEvents(int fd, int wd)
 void EventLoop(void)
 {
 	XEvent event;
+#ifdef HAVE_INOTIFY
 	extern int inotifyFD;
 	extern int inotifyWD;
 	struct timeval time;
@@ -367,12 +373,13 @@ void EventLoop(void)
 
 	if (inotifyFD < 0 || inotifyWD < 0)
 		retVal = -1;
+#endif
 
 	for (;;) {
 
 		WMNextEvent(dpy, &event);	/* Blocks here */
 		WMHandleEvent(&event);
-
+#ifdef HAVE_INOTIFY
 		if (retVal != -1) {
 			time.tv_sec = 0;
 			time.tv_usec = 0;
@@ -392,6 +399,7 @@ void EventLoop(void)
 			if (FD_ISSET(inotifyFD, &rfds))
 				inotifyHandleEvents(inotifyFD, inotifyWD);
 		}
+#endif
 	}
 }
 
diff --git a/src/main.c b/src/main.c
index 225ce4b..b775d8d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -19,10 +19,12 @@
  *  USA.
  */
 
-#include <sys/inotify.h>
-
 #include "wconfig.h"
 
+#ifdef HAVE_INOTIFY
+#include <sys/inotify.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -67,8 +69,10 @@ char *ProgName;
 
 unsigned int ValidModMask = 0xff;
 
+#ifdef HAVE_INOTIFY
 int inotifyFD;
 int inotifyWD;
+#endif
 /* locale to use. NULL==POSIX or C */
 char *Locale = NULL;
 
@@ -460,6 +464,7 @@ void check_defaults()
 	wfree(path);
 }
 
+#ifdef HAVE_INOTIFY
 /*
  * Add watch here, used to notify if configuration
  * files have changed, using linux kernel inotify mechanism
@@ -490,6 +495,7 @@ static void inotifyWatchConfig()
 	}
 	wfree(watchPath);
 }
+#endif /* HAVE_INOTIFY */
 
 static void execInitScript()
 {
@@ -762,7 +768,9 @@ static int real_main(int argc, char **argv)
 		multiHead = False;
 
 	execInitScript();
+#ifdef HAVE_INOTIFY
 	inotifyWatchConfig();
+#endif
 	EventLoop();
 	return -1;
 }
diff --git a/src/shutdown.c b/src/shutdown.c
index f6f6c27..8b5e86b 100644
--- a/src/shutdown.c
+++ b/src/shutdown.c
@@ -56,7 +56,9 @@ static void wipeDesktop(WScreen * scr);
 void Shutdown(WShutdownMode mode)
 {
 	int i;
+#ifdef HAVE_INOTIFY
 	extern int inotifyFD;
+#endif
 
 	switch (mode) {
 	case WSLogoutMode:
@@ -64,7 +66,9 @@ void Shutdown(WShutdownMode mode)
 	case WSExitMode:
 		/* if there is no session manager, send SAVE_YOURSELF to
 		 * the clients */
+#ifdef HAVE_INOTIFY
 		close(inotifyFD);
+#endif
 		for (i = 0; i < wScreenCount; i++) {
 			WScreen *scr;
 
@@ -92,7 +96,9 @@ void Shutdown(WShutdownMode mode)
 		for (i = 0; i < wScreenCount; i++) {
 			WScreen *scr;
 
+#ifdef HAVE_INOTIFY
 			close(inotifyFD);
+#endif
 			scr = wScreenWithNumber(i);
 			if (scr) {
 				if (scr->helper_pid)
-- 
1.7.0

Reply via email to