diff -ruN streamdev-0.3.4/Makefile streamdev-0.3.4-darwin/Makefile
--- streamdev-0.3.4/Makefile	2008-03-31 13:38:01.000000000 +0300
+++ streamdev-0.3.4-darwin/Makefile	2010-04-18 13:48:49.000000000 +0300
@@ -9,6 +9,8 @@
 #
 PLUGIN = streamdev
 
+APPLE_DARWIN = $(shell gcc -dumpmachine | grep -q 'apple-darwin' && echo "1" || echo "0")
+
 ### The version number of this plugin (taken from the main source file):
 
 VERSION = $(shell grep 'const char \*VERSION *=' common.c | awk '{ print $$5 }' | sed -e 's/[";]//g')
@@ -16,7 +18,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
-CXXFLAGS ?= -fPIC -Wall -Woverloaded-virtual
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress -arch i386
+else
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -40,7 +46,7 @@
 
 ### Includes and Defines (add further entries here):
 
-INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include -I.
+INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include -I. -I/sw/include
 
 DEFINES += -D_GNU_SOURCE
 
@@ -123,7 +129,11 @@
 libvdr-$(PLUGIN)-server.so: $(SERVEROBJS) $(COMMONOBJS) libdvbmpeg/libdvbmpegtools.a
 
 %.so: 
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) -dynamic $^ -o $@
+else
 	$(CXX) $(CXXFLAGS) -shared $^ -o $@
+endif
 	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
 
 dist: clean
diff -ruN streamdev-0.3.4/client/filter.c streamdev-0.3.4-darwin/client/filter.c
--- streamdev-0.3.4/client/filter.c	2008-03-31 13:38:01.000000000 +0300
+++ streamdev-0.3.4-darwin/client/filter.c	2010-04-18 11:37:10.000000000 +0300
@@ -49,12 +49,14 @@
 	m_Mask = Mask;
 	m_Pipe[0] = m_Pipe[1] = -1;
 
+#ifndef __APPLE__
 #ifdef SOCK_SEQPACKET  
 	// SOCK_SEQPACKET (since kernel 2.6.4)
 	if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, m_Pipe) != 0) {
 		esyslog("streamdev-client: socketpair(SOCK_SEQPACKET) failed: %m, trying SOCK_DGRAM");
 	}
 #endif
+#endif
 	if (m_Pipe[0] < 0 && socketpair(AF_UNIX, SOCK_DGRAM, 0, m_Pipe) != 0) {
 		esyslog("streamdev-client: couldn't open section filter socket: %m");
 	} 
@@ -247,6 +249,9 @@
 
 					if (errno != ECONNREFUSED && 
 							errno != ECONNRESET &&
+#ifdef __APPLE
+                            errno != ENOBUFS &&
+#endif
 							errno != EPIPE) {
 						Dprintf("FATAL ERROR: %m\n");
 						esyslog("streamdev-client: couldn't send section packet: %m");
diff -ruN streamdev-0.3.4/client/remote.c streamdev-0.3.4-darwin/client/remote.c
--- streamdev-0.3.4/client/remote.c	2008-03-31 13:38:01.000000000 +0300
+++ streamdev-0.3.4-darwin/client/remote.c	2010-04-18 11:37:10.000000000 +0300
@@ -161,7 +161,11 @@
 	while (*ptr != '\0' && *ptr != ':') ++ptr;
 	if (*ptr == '\0') return;
 	*(ptr++)= '\0';
+#ifdef __APPLE__
+	if (isnumber_darwin(tmpbuf))
+#else
 	if (isnumber(tmpbuf))
+#endif
 		m_Channel = Channels.GetByNumber(strtoul(tmpbuf, NULL, 10));
 	else
 		m_Channel = Channels.GetByChannelID(tChannelID::FromString(tmpbuf));
diff -ruN streamdev-0.3.4/common.c streamdev-0.3.4-darwin/common.c
--- streamdev-0.3.4/common.c	2008-03-31 13:43:21.000000000 +0300
+++ streamdev-0.3.4-darwin/common.c	2010-04-18 11:37:10.000000000 +0300
@@ -60,7 +60,11 @@
 		Dprintf("found apididx: %d\n", apididx);
 	}
 
+#ifdef __APPLE__
+	if (isnumber_darwin(string)) {
+#else
 	if (isnumber(string)) {
+#endif
 		int temp = strtol(String, NULL, 10);
 		if (temp >= 1 && temp <= Channels.MaxNumber())
 			channel = Channels.GetByNumber(temp);
diff -ruN streamdev-0.3.4/libdvbmpeg/ctools.c streamdev-0.3.4-darwin/libdvbmpeg/ctools.c
--- streamdev-0.3.4/libdvbmpeg/ctools.c	2008-03-31 13:38:02.000000000 +0300
+++ streamdev-0.3.4-darwin/libdvbmpeg/ctools.c	2010-04-18 11:37:10.000000000 +0300
@@ -2060,7 +2060,7 @@
 	if (break_up_filename(name,base_name,path,ext) < 0) exit(1);
 
 
-#ifdef __FreeBSD__
+#ifdef __APPLE__
 	if ( (fdin = open(name, O_RDONLY)) < 0){
 #else
 	if ( (fdin = open(name, O_RDONLY|O_LARGEFILE)) < 0){
@@ -2105,7 +2105,7 @@
 		sprintf(new_name,"%s-%03d.%s",base_name,i,ext);
 		printf("writing %s\n",new_name);
 
-#ifdef __FreeBSD__
+#ifdef __APPLE__
 		if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
 #else
 		if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
@@ -2122,7 +2122,7 @@
 	sprintf(new_name,"%s-%03d.%s",base_name,i,ext);
 	printf("writing %s\n",new_name);
 
-#ifdef __FreeBSD__
+#ifdef __APPLE__
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
 #else
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
@@ -2156,7 +2156,7 @@
 	if (break_up_filename(name,base_name,path,ext) < 0) exit(1);
 
 
-#ifdef __FreeBSD__
+#ifdef __APPLE__
 	if ( (fdin = open(name, O_RDONLY)) < 0){
 #else
 	if ( (fdin = open(name, O_RDONLY|O_LARGEFILE)) < 0){
@@ -2198,7 +2198,7 @@
 	sprintf(new_name,"%s-1.%s",base_name,ext);
 	printf("writing %s\n",new_name);
 
-#ifdef __FreeBSD__
+#ifdef __APPLE__
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
 #else
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
@@ -2215,7 +2215,7 @@
 	sprintf(new_name,"%s-2.%s",base_name,ext);
 	printf("writing %s\n",new_name);
 
-#ifdef __FreeBSD__
+#ifdef __APPLE__
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
 #else
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
diff -ruN streamdev-0.3.4/server/connectionVTP.c streamdev-0.3.4-darwin/server/connectionVTP.c
--- streamdev-0.3.4/server/connectionVTP.c	2008-03-31 13:38:03.000000000 +0300
+++ streamdev-0.3.4-darwin/server/connectionVTP.c	2010-04-18 11:37:10.000000000 +0300
@@ -78,7 +78,11 @@
 			else if (strcasecmp(p, "AT") == 0) {
 				dumpmode = dmAtTime;
 				if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
+#ifdef __APPLE__
+					if (isnumber_darwin(p))
+#else
 					if (isnumber(p))
+#endif
 						attime = strtol(p, NULL, 10);
 					else {
 						m_Errno = 501;
@@ -92,7 +96,11 @@
 				}
 			} else if (!m_Schedule) {
 				cChannel* Channel = NULL;
+#ifdef __APPLE__
+				if (isnumber_darwin(p))
+#else
 				if (isnumber(p))
+#endif
 					Channel = Channels.GetByNumber(strtol(Option, NULL, 10));
 				else
 					Channel = Channels.GetByChannelID(tChannelID::FromString(
@@ -302,7 +310,11 @@
 		m_Errno = 451;
 		m_Error = strdup("Channels are being modified - try again");
 	} else if (*Option) {
+#ifdef __APPLE__
+		if (isnumber_darwin(Option)) {
+#else
 		if (isnumber(Option)) {
+#endif
 			m_Channel = Channels.GetByNumber(strtol(Option, NULL, 10));
 			if (m_Channel == NULL) {
 				m_Errno = 501;
@@ -410,7 +422,11 @@
 		m_Traverse(false)
 {
 	if (*Option) {
+#ifdef __APPLE__
+		if (isnumber_darwin(Option)) {
+#else
 		if (isnumber(Option)) {
+#endif
 			m_Timer = Timers.Get(strtol(Option, NULL, 10) - 1);
 			if (m_Timer == NULL) {
 				m_Errno = 501;
@@ -992,7 +1008,11 @@
 {
 	INIT_WRAPPER();
 	if (*Option) {
+#ifdef __APPLE__
+		if (isnumber_darwin(Option)) {
+#else
 		if (isnumber(Option)) {
+#endif
 			cTimer *timer = Timers.Get(strtol(Option, NULL, 10) - 1);
 			if (timer) {
 				if (!timer->Recording()) {
diff -ruN streamdev-0.3.4/tools/select.h streamdev-0.3.4-darwin/tools/select.h
--- streamdev-0.3.4/tools/select.h	2008-03-31 13:38:04.000000000 +0300
+++ streamdev-0.3.4-darwin/tools/select.h	2010-04-18 11:37:10.000000000 +0300
@@ -64,12 +64,14 @@
 
 inline bool cTBSelect::CanRead(int FileNo) const {
 	if (FileNo < 0) return false;
-	return FD_ISSET(FileNo, &m_FdsResult[0]);
+        fd_set temp = m_FdsResult[0];
+	return FD_ISSET(FileNo, &temp);
 }
 
 inline bool cTBSelect::CanWrite(int FileNo) const {
 	if (FileNo < 0) return false;
-	return FD_ISSET(FileNo, &m_FdsResult[1]);
+        fd_set temp = m_FdsResult[1];
+	return FD_ISSET(FileNo, &temp);
 }
 
 #endif // TOOLBOX_SELECT_H
