diff -ruN vdr-1.6.0-orig/CONTRIBUTORS vdr-1.6.0-2-darwin-2/CONTRIBUTORS
--- vdr-1.6.0-orig/CONTRIBUTORS	2008-03-18 19:34:00.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/CONTRIBUTORS	2009-02-11 21:43:09.000000000 +0200
@@ -595,6 +595,8 @@
  not two hex digits after the '#'
  for suggesting to suppress the automatic shutdown if the remote control is
  currently disabled
+ for suggesting to improve logging system time changes to avoid problems on slow
+ systems under heavy load
 
 Jeremy Hall <jhall@UU.NET>
  for fixing an incomplete initialization of the filter parameters in eit.c
@@ -958,6 +960,7 @@
  for making the SVDRP command LSTC list the channels with group separators if the
  option ':groups' is given
  for fixing handling 3 and 4 byte UTF-8 symbols in Utf8CharGet()
+ for fixing initializing the timer's flags in the cTimer copy constructor
 
 Olivier Jacques <jacquesolivier@hotmail.com>)
  for translating OSD texts to the French language
@@ -1050,6 +1053,7 @@
  language
  for fixing displaying the free disk space when entering the recordings menu where
  the last replayed recording was in a subdirectory, and pressing Back
+ for replacing the Finnish language code "smi" with "suo"
 
 Ralf Klueber <ralf.klueber@vodafone.com>
  for reporting a bug in cutting a recording if there is only a single editing mark
@@ -1174,6 +1178,7 @@
  for reporting an invalid access in the section handler when ending VDR
  for pointing out that cDevice::Transferring() doesn't return the right value in the
  early stage of channel switching
+ for fixing handling the counter in detection of pre 1.3.19 PS data
 
 Richard Robson <richard_robson@beeb.net>
  for reporting freezing replay if a timer starts while in Transfer Mode from the
@@ -1506,6 +1511,7 @@
  for translating OSD texts to the Estonian language
  for fixing a missing ',' in the Greek OSD texts
  for fixing a missing ',' in the Swedish OSD texts
+ for reporting problems with CAMs when checking the CAM status too frequently
 
 Milos Kapoun <m.kapoun@cra.cz>
  for suggesting to skip code table info in SI data
@@ -1574,6 +1580,7 @@
  for making housekeeping wait for a while after a replay has ended
  for fixing error handling in cCuttingThread::Action()
  for suppressing the automatic shutdown if the remote control is currently disabled
+ for fixing a problem with calling isyslog() from within the SignalHandler()
 
 Sven Kreiensen <svenk@kammer.uni-hannover.de>
  for his help in keeping 'channels.conf.terr' up to date
@@ -1890,6 +1897,7 @@
  for fixing cTimer::operator=() in case a cTimer variable is assigned to itself
  for making the list of tracks given in cStatus::SetAudioTrack() NULL terminated
  for fixing handling kLeft in the calls to cStatus::MsgOsdTextItem()
+ for fixing a possible integer overflow in GetAbsTime()
 
 Philip Prindeville <philipp_subx@redfish-solutions.com>
  for updates to 'sources.conf'
@@ -2111,6 +2119,7 @@
  for making the non-breaking space symbol be rendered as a blank
  for fixing a signed character used as index in cBase64Encoder::NextLine()
  for fixing formatting the name section in the VDR man pages
+ for reporting unneeded include files <linux/dvb/dmx.h> und <time.h> in remux.h
 
 Helge Lenz <h.lenz@gmx.de>
  for reporting a bug in setting the 'Delta' parameter when calling the shutdown
@@ -2347,3 +2356,10 @@
 
 Nan Feng <nfgx@21cn.com>
  for translating OSD texts to the Chinese language
+
+Edgar Toernig <froese@gmx.de>
+ for suggesting to not call FcFini() to avoid problems with older (broken) versions
+ of fontconfig
+
+Winfried Köhler <w_koehl@gmx.de>
+ for fixing wrong value for TableIdBAT in libsi/si.h
diff -ruN vdr-1.6.0-orig/HISTORY vdr-1.6.0-2-darwin-2/HISTORY
--- vdr-1.6.0-orig/HISTORY	2008-03-23 12:26:08.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/HISTORY	2009-02-11 21:43:09.000000000 +0200
@@ -5729,3 +5729,32 @@
 - Added Chinese language texts (thanks to Nan Feng).
 - Updated the Portuguese language texts.
 - Added a note about VDR_CHARSET_OVERRIDE to the INSTALL file.
+
+2008-04-13: Version 1.6.0-1
+
+- Fixed handling the counter in detection of pre 1.3.19 PS data (thanks to Reinhard
+  Nissl).
+- Improved logging system time changes to avoid problems on slow systems under
+  heavy load (suggested by Helmut Auer).
+- Fixed initializing the timer's flags in the cTimer copy constructor (thanks to
+  Andreas Mair).
+- Increased the time between checking the CAM status to 500ms to avoid problems
+  with some CAMs (reported by Arthur Konovalov).
+
+2008-09-06: Version 1.6.0-2
+
+- Updated the Italian OSD texts (thanks to Diego Pierotto).
+- The SVDRP signon message now indicates the character encoding in use, as in
+  "220 video SVDRP VideoDiskRecorder 1.7.1; Fri May  2 16:17:10 2008; ISO-8859-1".
+  This may be useful for instance for external tools that provide EPG data, so that
+  they can correctly encode the strings.
+- No longer calling FcFini() to avoid problems with older (broken) versions of
+  fontconfig (suggested by Edgar Toernig).
+- Updated the sources.conf file (thanks to Oleg Roitburd).
+- Fixed a possible integer overflow in GetAbsTime() (thanks to Alexander Rieger).
+- Fixed a problem with calling isyslog() from within the SignalHandler() (thanks
+  to Udo Richter).
+- Replaced the Finnish language code "smi" with "suo" (thanks to Rolf Ahrenberg).
+- Fixed wrong value for TableIdBAT in libsi/si.h (thanks to Winfried Köhler).
+- Removed unneeded include files <linux/dvb/dmx.h> und <time.h> from remux.h
+  (reported by Tobias Grimm).
diff -ruN vdr-1.6.0-orig/Makefile vdr-1.6.0-2-darwin-2/Makefile
--- vdr-1.6.0-orig/Makefile	2008-02-29 23:43:03.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -8,6 +8,8 @@
 
 .DELETE_ON_ERROR:
 
+APPLE_DARWIN = $(shell gcc -dumpmachine | grep -q 'apple-darwin' && echo "1" || echo "0")
+
 CC       ?= gcc
 CFLAGS   ?= -g -O2 -Wall
 
@@ -20,9 +22,15 @@
 MANDIR   = $(PREFIX)/share/man
 BINDIR   = $(PREFIX)/bin
 LOCDIR   = ./locale
+
+ifeq ($(APPLE_DARWIN), 1)
+LIBS     = -ljpeg -lpthread -ldl -lfreetype -lfontconfig -liconv -lintl
+INCLUDES = -I/usr/include/freetype2 -I/sw/include -I/opt/local/include  -I/usr/X11R6/include -I/usr/X11R6/include/freetype2
+LIBDIRS  = -L/sw/lib -L/opt/local/lib -L/usr/X11R6/lib
+else
 LIBS     = -ljpeg -lpthread -ldl -lcap -lrt -lfreetype -lfontconfig
 INCLUDES = -I/usr/include/freetype2
-
+endif
 PLUGINDIR= ./PLUGINS
 PLUGINLIBDIR= $(PLUGINDIR)/lib
 
@@ -36,12 +44,21 @@
 
 SILIB    = $(LSIDIR)/libsi.a
 
+ifeq ($(APPLE_DARWIN), 1)
+OBJS = audio.o channels.o ci.o config.o cutter.o darwinutils.o device.o diseqc.o dvbdevice.o dvbci.o dvbosd.o\
+       dvbplayer.o dvbspu.o dvbsubtitle.o eit.o eitscan.o epg.o filter.o font.o i18n.o interface.o keys.o\
+       lirc.o menu.o menuitems.o nit.o osdbase.o osd.o pat.o player.o plugin.o rcu.o\
+       receiver.o recorder.o recording.o remote.o remux.o ringbuffer.o sdt.o sections.o shutdown.o\
+       skinclassic.o skins.o skinsttng.o sources.o spu.o status.o svdrp.o themes.o thread.o\
+       timers.o tools.o transfer.o vdr.o videodir.o
+else
 OBJS = audio.o channels.o ci.o config.o cutter.o device.o diseqc.o dvbdevice.o dvbci.o dvbosd.o\
        dvbplayer.o dvbspu.o dvbsubtitle.o eit.o eitscan.o epg.o filter.o font.o i18n.o interface.o keys.o\
        lirc.o menu.o menuitems.o nit.o osdbase.o osd.o pat.o player.o plugin.o rcu.o\
        receiver.o recorder.o recording.o remote.o remux.o ringbuffer.o sdt.o sections.o shutdown.o\
        skinclassic.o skins.o skinsttng.o sources.o spu.o status.o svdrp.o themes.o thread.o\
        timers.o tools.o transfer.o vdr.o videodir.o
+endif
 
 ifndef NO_KBD
 DEFINES += -DREMOTE_KBD
@@ -94,7 +111,11 @@
 # The main program:
 
 vdr: $(OBJS) $(SILIB)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) -dynamic $(OBJS) $(NCURSESLIB) $(LIBS) $(LIBDIRS) $(SILIB) -o vdr
+else
 	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(NCURSESLIB) $(LIBS) $(LIBDIRS) $(SILIB) -o vdr
+endif
 
 # The libsi library:
 
diff -ruN vdr-1.6.0-orig/PLUGINS/src/hello/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/hello/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/hello/Makefile	2008-01-13 14:59:58.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/hello/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -11,6 +11,8 @@
 #
 PLUGIN = hello
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -18,7 +20,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -95,8 +101,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/osddemo/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/osddemo/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/osddemo/Makefile	2008-01-13 15:00:01.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/osddemo/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -9,6 +9,8 @@
 #
 PLUGIN = osddemo
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -16,7 +18,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -68,8 +74,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/pictures/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/pictures/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/pictures/Makefile	2008-01-13 15:00:04.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/pictures/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -11,6 +11,8 @@
 #
 PLUGIN = pictures
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -18,7 +20,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -95,8 +101,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/servicedemo/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/servicedemo/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/servicedemo/Makefile	2008-01-13 15:00:07.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/servicedemo/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -11,6 +11,8 @@
 PLUGIN1 = svccli
 PLUGIN2 = svcsvr
 
+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 'static const char \*VERSION *=' $(PLUGIN1).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -18,7 +20,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -70,12 +76,22 @@
 ### Targets:
 
 libvdr-$(PLUGIN1).so: $(PLUGIN1).o
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(PLUGIN1).o -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(PLUGIN1).o -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 libvdr-$(PLUGIN2).so: $(PLUGIN2).o
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(PLUGIN2).o -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(PLUGIN2).o -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/skincurses/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/skincurses/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/skincurses/Makefile	2008-01-19 13:40:33.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/skincurses/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -11,6 +11,8 @@
 #
 PLUGIN = skincurses
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -18,7 +20,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -95,8 +101,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
-	$(CXX) $(CXXFLAGS) -shared $(OBJS) -lncursesw -o $@
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/sky/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/sky/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/sky/Makefile	2008-01-13 15:00:16.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/sky/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -9,6 +9,8 @@
 #
 PLUGIN = sky
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -16,7 +18,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -68,8 +74,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/sky/sky.c vdr-1.6.0-2-darwin-2/PLUGINS/src/sky/sky.c
--- vdr-1.6.0-orig/PLUGINS/src/sky/sky.c	2008-03-22 12:19:32.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/sky/sky.c	2009-02-11 21:43:09.000000000 +0200
@@ -14,6 +14,9 @@
 #include <vdr/device.h>
 #include <vdr/plugin.h>
 #include <vdr/sources.h>
+#ifdef __APPLE__
+#include <vdr/darwinutils.h>
+#endif
 
 static const char *VERSION        = "0.3.7";
 static const char *DESCRIPTION    = "Sky Digibox interface";
@@ -33,7 +36,11 @@
 bool cSkyChannel::Parse(const char *s)
 {
   char *id = NULL;
+#ifdef __APPLE__
+  if (2 == sscanf_darwin(s, "%a[^:]:%d", &id, &digiboxChannelNumber))
+#else
   if (2 == sscanf(s, "%a[^:]:%d", &id, &digiboxChannelNumber))
+#endif
      channelID = tChannelID::FromString(id);
   free(id);
   return digiboxChannelNumber && channelID.Valid();
diff -ruN vdr-1.6.0-orig/PLUGINS/src/status/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/status/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/status/Makefile	2008-01-13 15:00:18.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/status/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -9,6 +9,8 @@
 #
 PLUGIN = status
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -16,7 +18,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -68,8 +74,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/PLUGINS/src/svdrpdemo/Makefile vdr-1.6.0-2-darwin-2/PLUGINS/src/svdrpdemo/Makefile
--- vdr-1.6.0-orig/PLUGINS/src/svdrpdemo/Makefile	2008-01-13 15:00:20.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/PLUGINS/src/svdrpdemo/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -9,6 +9,8 @@
 #
 PLUGIN = svdrpdemo
 
+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 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -16,7 +18,11 @@
 ### The C++ compiler and options:
 
 CXX      ?= g++
+ifeq ($(APPLE_DARWIN), 1)
+CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses -fno-common -bundle -flat_namespace -undefined suppress
+else
 CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+endif
 
 ### The directory environment:
 
@@ -68,8 +74,13 @@
 ### Targets:
 
 libvdr-$(PLUGIN).so: $(OBJS)
+ifeq ($(APPLE_DARWIN), 1)
+	$(CXX) $(CXXFLAGS) $(OBJS) -o $@
+	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
+else
 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
 	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
 
 dist: clean
 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff -ruN vdr-1.6.0-orig/channels.c vdr-1.6.0-2-darwin-2/channels.c
--- vdr-1.6.0-orig/channels.c	2008-03-05 18:42:50.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/channels.c	2009-02-11 21:43:09.000000000 +0200
@@ -13,6 +13,9 @@
 #include "device.h"
 #include "epg.h"
 #include "timers.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d'
 // format characters in order to allow any number of blanks after a numeric
@@ -134,7 +137,11 @@
   int tid;
   int sid;
   int rid = 0;
+#ifdef __APPLE__
+  int fields = sscanf_darwin(s, "%a[^-]-%d-%d-%d-%d", &sourcebuf, &nid, &tid, &sid, &rid);
+#else
   int fields = sscanf(s, "%a[^-]-%d-%d-%d-%d", &sourcebuf, &nid, &tid, &sid, &rid);
+#endif
   if (fields == 4 || fields == 5) {
      int source = cSource::FromString(sourcebuf);
      free(sourcebuf);
@@ -720,7 +727,11 @@
      char *vpidbuf = NULL;
      char *apidbuf = NULL;
      char *caidbuf = NULL;
+#ifdef __APPLE__
+     int fields = sscanf_darwin(s, "%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%d :%a[^:]:%d :%d :%d :%d ", &namebuf, &frequency, &parambuf, &sourcebuf, &srate, &vpidbuf, &apidbuf, &tpid, &caidbuf, &sid, &nid, &tid, &rid);
+#else
      int fields = sscanf(s, "%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%d :%a[^:]:%d :%d :%d :%d ", &namebuf, &frequency, &parambuf, &sourcebuf, &srate, &vpidbuf, &apidbuf, &tpid, &caidbuf, &sid, &nid, &tid, &rid);
+#endif
      if (fields >= 9) {
         if (fields == 9) {
            // allow reading of old format
diff -ruN vdr-1.6.0-orig/ci.c vdr-1.6.0-2-darwin-2/ci.c
--- vdr-1.6.0-orig/ci.c	2007-04-30 16:02:49.000000000 +0300
+++ vdr-1.6.0-2-darwin-2/ci.c	2009-02-11 21:43:09.000000000 +0200
@@ -4,13 +4,18 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: ci.c 1.48 2007/04/30 13:02:49 kls Exp $
+ * $Id: ci.c 1.48.1.1 2008/04/13 13:33:32 kls Exp $
  */
 
 #include "ci.h"
 #include <ctype.h>
-#include <linux/dvb/ca.h>
+#ifdef __APPLE__
+#include <sys/malloc.h>
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
+#include <linux/dvb/ca.h>
 #include <netinet/in.h>
 #include <poll.h>
 #include <string.h>
@@ -1525,7 +1530,7 @@
 
 cCamSlots CamSlots;
 
-#define MODULE_CHECK_INTERVAL 100 // ms
+#define MODULE_CHECK_INTERVAL 500 // ms
 #define MODULE_RESET_TIMEOUT    2 // s
 
 cCamSlot::cCamSlot(cCiAdapter *CiAdapter)
diff -ruN vdr-1.6.0-orig/config.h vdr-1.6.0-2-darwin-2/config.h
--- vdr-1.6.0-orig/config.h	2008-03-23 12:26:10.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/config.h	2009-02-11 21:43:09.000000000 +0200
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: config.h 1.310 2008/03/23 10:26:10 kls Exp $
+ * $Id: config.h 1.310.1.2 2008/09/07 09:33:03 kls Exp $
  */
 
 #ifndef __CONFIG_H
@@ -22,7 +22,7 @@
 
 // VDR's own version number:
 
-#define VDRVERSION  "1.6.0"
+#define VDRVERSION  "1.6.0-2"
 #define VDRVERSNUM   10600  // Version * 10000 + Major * 100 + Minor
 
 // The plugin API's version number:
diff -ruN vdr-1.6.0-orig/darwinutils.c vdr-1.6.0-2-darwin-2/darwinutils.c
--- vdr-1.6.0-orig/darwinutils.c	1970-01-01 02:00:00.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/darwinutils.c	2009-02-11 21:43:09.000000000 +0200
@@ -0,0 +1,597 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <machine/limits.h>
+#include <errno.h>
+#include <unistd.h>
+#include "darwinutils.h"
+#include "tools.h"
+#include <sys/param.h>
+
+# define __canonicalize_file_name_darwin canonicalize_file_name_darwin
+#  define __getcwd getcwd
+# define __readlink readlink
+
+char *strchrnul_darwin(const char *s, int c_in)
+{
+  char c = c_in;
+  while(*s && (*s != c))
+    s++;
+
+  return (char *) s;
+}
+
+char *strndup_darwin(const char *str, size_t len)
+{
+  size_t t;
+  char *dest;
+  
+  t = strlen(str);
+  if(len < t)
+  {
+    t = len;
+  }
+  
+  dest = (char *)calloc(t + 1, 1);
+  
+  if (NULL != dest)
+  {
+    memcpy(dest, str, t);
+    dest[t] = '\0';
+  }
+
+  return dest;
+}
+
+ssize_t getdelim_darwin(char **lineptr, size_t *n, int delimiter, FILE *fp)
+{
+  ssize_t result = 0;
+  size_t cur_len = 0;
+
+  if(lineptr == NULL || n == NULL || fp == NULL)
+  {
+    errno = EINVAL;
+    return -1;
+  }
+
+  flockfile (fp);
+
+  if(*lineptr == NULL || *n == 0)
+  {
+    *n = 120;
+    *lineptr = (char *) malloc (*n);
+    if (*lineptr == NULL)
+    {
+      result = -1;
+      goto unlock_return;
+	}
+  }
+
+  for(;;)
+  {
+    int i;
+    i = getc (fp);
+    if (i == EOF)
+    {
+      result = -1;
+      break;
+    }
+
+    if(cur_len + 1 >= *n)
+	{
+      size_t needed_max =
+      SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+      size_t needed = 2 * *n + 1;
+      char *new_lineptr;
+
+      if(needed_max < needed)
+        needed = needed_max;
+      if(cur_len + 1 >= needed)
+	  {
+	    result = -1;
+	    goto unlock_return;
+	  }
+
+	  new_lineptr = (char *)realloc(*lineptr, needed);
+      if(new_lineptr == NULL)
+      {
+        result = -1;
+        goto unlock_return;
+      }
+
+      *lineptr = new_lineptr;
+      *n = needed;
+    }
+
+    (*lineptr)[cur_len] = i;
+    cur_len++;
+
+    if (i == delimiter)
+      break;
+  }
+  (*lineptr)[cur_len] = '\0';
+  result = cur_len ? cur_len : result;
+
+  unlock_return:
+  funlockfile (fp);
+  return result;
+}
+
+ssize_t getline_darwin(char **lineptr, size_t *n, FILE *stream)
+{
+  return getdelim_darwin(lineptr, n, '\n', stream);
+}
+
+char * __realpath_darwin(const char *name, char *resolved)
+{
+  char *rpath, *dest, *extra_buf = NULL;
+  const char *start, *end, *rpath_limit;
+  long int path_max;
+  int num_links = 0;
+
+  if(name == NULL)
+  {
+    __set_errno (EINVAL);
+    return NULL;
+  }
+
+  if(name[0] == '\0')
+  {
+    __set_errno (ENOENT);
+    return NULL;
+  }
+
+  path_max = PATH_MAX;
+
+  if(resolved == NULL)
+  {
+    rpath = (char*)malloc (path_max);
+    if (rpath == NULL)
+      return NULL;
+  }
+  else
+    rpath = resolved;
+  rpath_limit = rpath + path_max;
+
+  if(name[0] != '/')
+  {
+    if(!__getcwd (rpath, path_max))
+    {
+      rpath[0] = '\0';
+      goto error;
+    }
+    dest = strchr (rpath, '\0');
+  }
+  else
+  {
+    rpath[0] = '/';
+    dest = rpath + 1;
+  }
+
+  for (start = end = name; *start; start = end)
+  {
+    struct stat st;
+    int n;
+
+    while(*start == '/')
+      ++start;
+
+    for(end = start; *end && *end != '/'; ++end)
+      ;
+
+    if(end - start == 0)
+      break;
+    else if(end - start == 1 && start[0] == '.')
+      ;
+    else if(end - start == 2 && start[0] == '.' && start[1] == '.')
+    {
+      if (dest > rpath + 1)
+        while ((--dest)[-1] != '/')
+          ;
+    }
+    else
+    {
+      size_t new_size;
+
+      if(dest[-1] != '/')
+        *dest++ = '/';
+
+      if(dest + (end - start) >= rpath_limit)
+      {
+        ptrdiff_t dest_offset = dest - rpath;
+        char *new_rpath;
+
+        if(resolved)
+        {
+          __set_errno(ENAMETOOLONG);
+          if(dest > rpath + 1)
+            dest--;
+          *dest = '\0';
+          goto error;
+        }
+        new_size = rpath_limit - rpath;
+        if(end - start + 1 > path_max)
+          new_size += end - start + 1;
+        else
+          new_size += path_max;
+        new_rpath = (char *) realloc (rpath, new_size);
+        if(new_rpath == NULL)
+          goto error;
+        rpath = new_rpath;
+        rpath_limit = rpath + new_size;
+
+        dest = rpath + dest_offset;
+      }
+
+      memcpy (dest, start, end - start);
+      dest += end - start;
+      *dest = '\0';
+
+      if(lstat (rpath, &st) < 0)
+        goto error;
+
+      if(S_ISLNK(st.st_mode))
+      {
+        char *buf = (char*)__alloca (path_max);
+        size_t len;
+        
+        if(++num_links > MAXSYMLINKS)
+        {
+          __set_errno(ELOOP);
+          goto error;
+        }
+
+        n = __readlink(rpath, buf, path_max);
+        if (n < 0)
+          goto error;
+        buf[n] = '\0';
+
+        if(!extra_buf)
+          extra_buf = (char*)__alloca(path_max);
+
+        len = strlen (end);
+        if((long int) (n + len) >= path_max)
+        {
+          __set_errno (ENAMETOOLONG);
+          goto error;
+        }
+
+        memmove(&extra_buf[n], end, len + 1);
+        name = end = (char*)memcpy(extra_buf, buf, n);
+
+        if(buf[0] == '/')
+          dest = rpath + 1;
+        else if (dest > rpath + 1)
+          while ((--dest)[-1] != '/');
+      }
+    }
+  }
+  if(dest > rpath + 1 && dest[-1] == '/')
+    --dest;
+  *dest = '\0';
+
+  return resolved ? (char*)memcpy (resolved, rpath, dest - rpath + 1) : rpath;
+
+  error:
+  if(resolved)
+    strcpy (resolved, rpath);
+  else
+    free (rpath);
+  return NULL;
+}
+
+
+char *__canonicalize_file_name_darwin(const char *name)
+{
+  return __realpath_darwin(name, NULL);
+}
+
+int sscanf_darwin(const char *str, const char *format, ...)
+{
+  va_list list;
+  const char *p;
+  char *s, *c;
+  char **a;
+  int **d;
+  unsigned int **x, **u;
+  int pos = 0, width = 0, count = 0;
+  char temp[1];
+  
+  va_start( list, format );
+  
+  for( p = format ; *p ; ++p )
+  {
+    width=0;
+    if( str[pos]==' ')
+    {
+      pos++;
+    }
+
+    if( *p != '%' )
+    {
+    }
+    else
+    {
+      switch( *++p )
+      {
+
+        case '0':
+          if(str[pos]=='0')
+            pos++;
+            p++;
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+        {
+          temp[0]=*p;
+          width = atoi(temp);
+          switch( *++p )
+          {
+            case 'X':
+            {
+              x = va_arg(list, unsigned int**);
+              read_x_w(str, x, width, &pos);
+              count++;
+              p++;
+              break;
+            }
+
+            case 's':
+            {
+              //string
+              s = va_arg(list, char *);
+              read_s_w(str, s, width, &pos);
+              count++;
+              pos++;
+              p++;
+              break;
+            }
+            default:
+            ;
+          }
+          break;
+          // length
+        }
+        case 's':
+        {
+          //string
+          p++;
+          break;
+        }
+
+        case 'c':
+        {
+          //char
+          c = va_arg(list, char*);
+          read_c(str, c, *++p, &pos);
+          pos++;
+          count++;
+          break;
+        }
+
+
+        case 'a':
+        {
+          //string with alloc
+          if(*(p+=2)=='^')
+          {
+            if(*(p+1)!='\n')
+            {
+              a = va_arg(list, char**);
+              read_a(str, a, *++p, &pos);
+              p++;
+              count++;
+              pos++;
+            }
+            else
+            {
+              a = va_arg(list, char**);
+              read_a(str, a, *++p, &pos);
+              p++;
+              count++;
+              pos++;
+            }
+          }
+          break;
+        }
+
+        case 'd':
+        {
+          //int
+          d = va_arg(list, int**);
+          if(*(p+1)==' ')
+            read_d(str, d, *(p+=2), &pos);
+          else
+            read_d(str, d, *++p, &pos);
+          pos++;
+          count++;
+          p--;
+          break;
+        }
+
+        case 'u':
+        {
+          //int
+          u = va_arg(list, unsigned int**);
+          if(*(p+1)==' ')
+            read_u(str, u, *(p+=2), &pos);
+          else
+            read_u(str, u, *++p, &pos);
+          count++;
+          pos++;
+          p--;
+          break;
+        }
+
+        case 'X':
+        {
+          //hex
+          x = va_arg(list, unsigned int**);
+          read_x(str, x, *++p, &pos);
+          count++;
+          pos++;
+          break;
+        }
+        
+        default:
+          break;
+      }
+    }
+  }
+  va_end( list );
+  return count;
+  
+}
+
+void read_a(const char *str, char **ptr, const char delimiter, int *position)
+{
+  int i=0, j=0;
+  int start = *position;
+  char *temp;
+  
+  while(str[*position]!=delimiter&&str[*position]!='\0')
+  {
+    (*position)++;
+    i++;
+  }
+  temp = (char*)calloc(i+1, sizeof(char) );
+  for( j=0;j<i;j++)
+  {
+    temp[j]=str[start];
+    start++;
+  }
+  temp[j]='\0';
+  *ptr = temp;
+}
+
+
+void read_d(const char *str, int **ptr, const char delimiter, int *position)
+{
+
+  int i=0, j=0;
+  int start = *position;
+  char *temp;
+
+  while(str[*position]!=delimiter&&str[*position]!='\0'&&str[*position]!=' ')
+  {
+    (*position)++;
+    i++;
+  }
+  temp = (char*)calloc(i+1, sizeof(char) );
+  for( j=0;j<i;j++)
+  {
+    temp[j]=str[start];
+    start++;
+  }
+  temp[j]='\0';
+  *ptr = (int*)atoi(temp);
+}
+
+
+void read_x(const char *str, unsigned int **ptr, const char delimiter, int 
+*position)
+{
+
+  int i=0, j=0;
+  int start = *position;
+  char *temp;
+  unsigned int *pointer;
+  pointer = (unsigned int*)ptr;
+
+  while(str[*position]!=delimiter&&str[*position]!='\0'&&str[*position]!=' ')
+  {
+    (*position)++;
+    i++;
+  }
+  temp = (char*)calloc(i+1, sizeof(char) );
+  for( j=0;j<i;j++)
+  {
+    temp[j]=str[start];
+    start++;
+  }
+  temp[j]='\0';
+  sscanf(temp, "%X", pointer);
+  free(temp);
+}
+
+void read_x_w(const char *str, unsigned int **ptr, int width, int *position)
+{
+  int j=0;
+  char *temp;
+  unsigned int *pointer;
+  pointer = (unsigned int*)ptr;
+
+  temp = (char*)calloc(width, sizeof(char) );
+  for( j=0;j<width;j++)
+  {
+    temp[j]=str[(*position)];
+    (*position)++;
+  }
+  temp[j]='\0';
+  sscanf(temp, "%X", pointer);
+  free(temp);
+}
+
+void read_s_w(const char *str, char *ptr, int width, int *position)
+{
+
+  int j=0;
+  int start = *position;
+
+  while(str[*position]!='\0'&&j<width&&str[*position]!=' ')
+  {
+    ptr[j]=str[start];
+    start++;
+    (*position)++;
+    j++;
+  }
+  ptr[j]='\0';
+}
+
+void read_c(const char *str, char *ptr, const char delimiter, int *position)
+{
+  int i=0, j=0;
+  int start = *position;
+  char *temp;
+  
+  while(str[*position]!=delimiter&&str[*position]!='\0')
+  {
+    (*position)++;
+    i++;
+  }
+  temp = (char*)calloc(i+1, sizeof(char) );
+  for( j=0;j<i;j++)
+  {
+    temp[j]=str[start];
+    start++;
+  }
+  *ptr = temp[0];
+}
+
+void read_u(const char *str, unsigned int **ptr, const char delimiter, int *position)
+{
+
+  int i=0, j=0;
+  int start = *position;
+  char *temp;
+
+  while(str[*position]!=delimiter&&str[*position]!='\0'&&str[*position]!=' ')
+  {
+    (*position)++;
+    i++;
+  }
+  temp = (char*)calloc(i+1, sizeof(char) );
+  for( j=0;j<i;j++)
+  {
+    temp[j]=str[start];
+    start++;
+  }
+  temp[j]='\0';
+  *ptr = (unsigned int*)atoi(temp);
+}
diff -ruN vdr-1.6.0-orig/darwinutils.h vdr-1.6.0-2-darwin-2/darwinutils.h
--- vdr-1.6.0-orig/darwinutils.h	1970-01-01 02:00:00.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/darwinutils.h	2009-02-11 21:43:09.000000000 +0200
@@ -0,0 +1,23 @@
+#define SIZE_MAX ((size_t) -1)
+#define __set_errno(e) errno = (e)
+
+inline int max(int a,int b) { return a > b ? a : b; };
+inline int min(int a,int b) { return a > b ? b : a; };
+
+extern char *strchrnul_darwin (const char *s, int c_in);
+char *strndup_darwin(const char *str, size_t len);
+ssize_t getdelim_darwin (char **lineptr, size_t *n, int delimiter, FILE *stream);
+ssize_t getline_darwin (char **lineptr, size_t *n, FILE *stream);
+
+char *__realpath_darwin (const char *name, char *resolved);
+char *canonicalize_file_name_darwin (const char *);
+
+int sscanf_darwin(const char *str, const char *format, ...);
+
+void read_a(const char *str, char **ptr, const char delimiter, int *position);
+void read_d(const char *str, int **ptr, const char delimiter, int *position);
+void read_x(const char *str, unsigned int **ptr, const char delimiter, int *position);
+void read_x_w(const char *str, unsigned int **ptr, int width, int *position);
+void read_s_w(const char *str, char *ptr, int width, int *position);
+void read_c(const char *str, char *ptr, const char delimiter, int *position);
+void read_u(const char *str, unsigned int **ptr, const char delimiter, int *position);
diff -ruN vdr-1.6.0-orig/device.c vdr-1.6.0-2-darwin-2/device.c
--- vdr-1.6.0-orig/device.c	2008-03-09 12:03:34.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/device.c	2009-02-11 21:43:09.000000000 +0200
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: device.c 1.157 2008/03/09 10:03:34 kls Exp $
+ * $Id: device.c 1.157.1.1 2008/04/13 11:16:00 kls Exp $
  */
 
 #include "device.h"
@@ -1273,7 +1273,7 @@
                uchar SubStreamIndex = SubStreamId & 0x1F;
 
                // Compatibility mode for old VDR recordings, where 0xBD was only AC3:
-pre_1_3_19_PrivateStreamDeteced:
+pre_1_3_19_PrivateStreamDetected:
                if (pre_1_3_19_PrivateStream > MIN_PRE_1_3_19_PRIVATESTREAM) {
                   SubStreamId = c;
                   SubStreamType = 0x80;
@@ -1314,7 +1314,8 @@
                          if (pre_1_3_19_PrivateStream > MIN_PRE_1_3_19_PRIVATESTREAM) {
                             dsyslog("switching to pre 1.3.19 Dolby Digital compatibility mode - substream id = %02X", SubStreamId);
                             ClrAvailableTracks();
-                            goto pre_1_3_19_PrivateStreamDeteced;
+                            pre_1_3_19_PrivateStream = MIN_PRE_1_3_19_PRIVATESTREAM + 1;
+                            goto pre_1_3_19_PrivateStreamDetected;
                             }
                          }
                  }
diff -ruN vdr-1.6.0-orig/diseqc.c vdr-1.6.0-2-darwin-2/diseqc.c
--- vdr-1.6.0-orig/diseqc.c	2008-02-10 16:09:27.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/diseqc.c	2009-02-11 21:43:09.000000000 +0200
@@ -11,6 +11,9 @@
 #include <ctype.h>
 #include "sources.h"
 #include "thread.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 // --- cDiseqc ---------------------------------------------------------------
 
@@ -30,7 +33,11 @@
 {
   bool result = false;
   char *sourcebuf = NULL;
+#ifdef __APPLE__
+  int fields = sscanf_darwin(s, "%a[^ ] %d %c %d %a[^\n]", &sourcebuf, &slof, &polarization, &lof, &commands);
+#else
   int fields = sscanf(s, "%a[^ ] %d %c %d %a[^\n]", &sourcebuf, &slof, &polarization, &lof, &commands);
+#endif
   if (fields == 4)
      commands = NULL; //XXX Apparently sscanf() doesn't work correctly if the last %a argument results in an empty string
   if (4 <= fields && fields <= 5) {
diff -ruN vdr-1.6.0-orig/dvbdevice.c vdr-1.6.0-2-darwin-2/dvbdevice.c
--- vdr-1.6.0-orig/dvbdevice.c	2008-02-09 18:11:44.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/dvbdevice.c	2009-02-11 21:43:09.000000000 +0200
@@ -10,7 +10,11 @@
 #include "dvbdevice.h"
 #include <errno.h>
 #include <limits.h>
+#ifdef __APPLE__
+#include <linux/videodev_darwin.h>
+#else
 #include <linux/videodev.h>
+#endif
 #include <linux/dvb/audio.h>
 #include <linux/dvb/dmx.h>
 #include <linux/dvb/frontend.h>
diff -ruN vdr-1.6.0-orig/eit.c vdr-1.6.0-2-darwin-2/eit.c
--- vdr-1.6.0-orig/eit.c	2007-08-26 13:56:33.000000000 +0300
+++ vdr-1.6.0-2-darwin-2/eit.c	2009-02-11 21:43:09.000000000 +0200
@@ -8,7 +8,7 @@
  * Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>.
  * Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg <marcel.wiesweg@gmx.de>.
  *
- * $Id: eit.c 1.126 2007/08/26 10:56:33 kls Exp $
+ * $Id: eit.c 1.126.1.1 2008/04/13 11:46:38 kls Exp $
  */
 
 #include "eit.h"
@@ -300,9 +300,12 @@
   if (diff > 2) {
      mutex.Lock();
      if (abs(diff - lastDiff) < 3) {
-        isyslog("System Time = %s (%ld)", *TimeToString(loctim), loctim);
-        isyslog("Local Time  = %s (%ld)", *TimeToString(sattim), sattim);
-        if (stime(&sattim) < 0)
+//stime not defined in darwin
+#ifndef __APPLE__
+        if (stime(&sattim) == 0)
+           isyslog("system Time changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(sattim), sattim);
+        else
+#endif
            esyslog("ERROR while setting system time: %m");
         }
      lastDiff = diff;
diff -ruN vdr-1.6.0-orig/epg.c vdr-1.6.0-2-darwin-2/epg.c
--- vdr-1.6.0-orig/epg.c	2008-02-16 18:09:12.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/epg.c	2009-02-11 21:43:09.000000000 +0200
@@ -16,6 +16,16 @@
 #include <time.h>
 #include "libsi/si.h"
 #include "timers.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#ifdef __MAC_OS_X_VERSION_10_5
+#ifdef __i386__
+#include <i386/limits.h>
+#else
+#include <ppc/limits.h>
+#endif
+#endif
+#endif
 
 #define RUNNINGSTATUSTIMEOUT 30 // seconds before the running status is considered unknown
 
@@ -31,7 +41,11 @@
 bool tComponent::FromString(const char *s)
 {
   unsigned int Stream, Type;
+#ifdef __APPLE__
+  int n = sscanf_darwin(s, "%X %02X %7s %a[^\n]", &Stream, &Type, language, &description); // 7 = MAXLANGCODE2 - 1
+#else
   int n = sscanf(s, "%X %02X %7s %a[^\n]", &Stream, &Type, language, &description); // 7 = MAXLANGCODE2 - 1
+#endif
   if (n != 4 || isempty(description)) {
      free(description);
      description = NULL;
diff -ruN vdr-1.6.0-orig/font.c vdr-1.6.0-2-darwin-2/font.c
--- vdr-1.6.0-orig/font.c	2008-03-01 12:19:41.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/font.c	2009-02-11 21:43:09.000000000 +0200
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: font.c 1.25 2008/03/01 10:19:41 kls Exp $
+ * $Id: font.c 1.25.1.1 2008/05/03 09:59:24 kls Exp $
  */
 
 #include "font.h"
@@ -395,7 +395,7 @@
      FcFontSetDestroy(fontset);
      FcPatternDestroy(pat);
      FcObjectSetDestroy(os);
-     FcFini();
+     //FcFini(); // older versions of fontconfig are broken - and FcInit() can be called more than once
      FontNames->Sort();
      }
   return FontNames->Size() > 0;
@@ -431,7 +431,7 @@
         esyslog("ERROR: no usable font found for '%s'", FontName);
      FcPatternDestroy(pat);
      free(fn);
-     FcFini();
+     //FcFini(); // older versions of fontconfig are broken - and FcInit() can be called more than once
      }
   return FontFileName;
 }
diff -ruN vdr-1.6.0-orig/i18n.c vdr-1.6.0-2-darwin-2/i18n.c
--- vdr-1.6.0-orig/i18n.c	2008-01-19 14:07:11.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/i18n.c	2009-02-11 21:43:09.000000000 +0200
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: i18n.c 1.319 2008/01/19 12:07:11 kls Exp $
+ * $Id: i18n.c 1.319.1.1 2008/09/06 12:21:17 kls Exp $
  *
  *
  */
@@ -45,7 +45,7 @@
   "por",
   "fra,fre",
   "nor",
-  "fin,smi",
+  "fin,suo",
   "pol",
   "esl,spa",
   "ell,gre",
diff -ruN vdr-1.6.0-orig/i18n.h vdr-1.6.0-2-darwin-2/i18n.h
--- vdr-1.6.0-orig/i18n.h	2008-01-19 13:56:19.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/i18n.h	2009-02-11 21:43:09.000000000 +0200
@@ -13,6 +13,10 @@
 #include <stdio.h>
 #include "tools.h"
 
+#ifdef __APPLE__
+# define __attribute_format_arg__(x) /* Ignore */
+#endif
+
 typedef const char *tI18nPhrase[22]; ///< obsolete - switch to 'gettext'!
 
 #define I18N_DEFAULT_LOCALE "en_US"
diff -ruN vdr-1.6.0-orig/libsi/Makefile vdr-1.6.0-2-darwin-2/libsi/Makefile
--- vdr-1.6.0-orig/libsi/Makefile	2006-05-26 13:40:19.000000000 +0300
+++ vdr-1.6.0-2-darwin-2/libsi/Makefile	2009-02-11 21:43:09.000000000 +0200
@@ -15,6 +15,11 @@
 
 ### The directory environment:
 
+MAC_OS_X_VERSION_10_5 = $(shell gcc -dumpmachine | grep -q 'apple-darwin9' && echo "1" || echo "0")
+ifeq ($(MAC_OS_X_VERSION_10_5), 1)
+INCLUDES += -I/sw/include -I/opt/local/include
+endif
+
 INCLUDES +=
 
 DEFINES +=
diff -ruN vdr-1.6.0-orig/libsi/headers.h vdr-1.6.0-2-darwin-2/libsi/headers.h
--- vdr-1.6.0-orig/libsi/headers.h	2007-02-03 13:45:58.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/libsi/headers.h	2009-02-11 21:43:09.000000000 +0200
@@ -17,7 +17,11 @@
 #ifndef LIBSI_HEADERS_H
 #define LIBSI_HEADERS_H
 
+#ifdef __APPLE__
+#include <machine/endian.h>
+#else
 #include <endian.h>
+#endif
 
 namespace SI {
 
diff -ruN vdr-1.6.0-orig/libsi/si.c vdr-1.6.0-2-darwin-2/libsi/si.c
--- vdr-1.6.0-orig/libsi/si.c	2008-03-05 19:00:55.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/libsi/si.c	2009-02-11 21:43:09.000000000 +0200
@@ -13,7 +13,9 @@
 #include "si.h"
 #include <errno.h>
 #include <iconv.h>
+#ifndef __APPLE__
 #include <malloc.h>
+#endif
 #include <stdlib.h> // for broadcaster stupidity workaround
 #include <string.h>
 #include "descriptor.h"
diff -ruN vdr-1.6.0-orig/libsi/si.h vdr-1.6.0-2-darwin-2/libsi/si.h
--- vdr-1.6.0-orig/libsi/si.h	2007-04-22 16:32:09.000000000 +0300
+++ vdr-1.6.0-2-darwin-2/libsi/si.h	2009-02-11 21:43:09.000000000 +0200
@@ -6,7 +6,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   $Id: si.h 1.17 2007/04/22 13:32:09 kls Exp $
+ *   $Id: si.h 1.17.1.1 2008/09/06 12:40:49 kls Exp $
  *                                                                         *
  ***************************************************************************/
 
@@ -28,7 +28,7 @@
                TableIdNIT_other  = 0x41, //network information section, other network
                TableIdSDT = 0x42, //service description section
                TableIdSDT_other  = 0x46,
-               TableIdBAT = 0x46, //bouquet association section
+               TableIdBAT = 0x4A, //bouquet association section
                TableIdEIT_presentFollowing = 0x4E, //event information section
                TableIdEIT_presentFollowing_other = 0x4F,
                //range from 0x50 to 0x5F
diff -ruN vdr-1.6.0-orig/menu.c vdr-1.6.0-2-darwin-2/menu.c
--- vdr-1.6.0-orig/menu.c	2008-03-16 13:15:28.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/menu.c	2009-02-11 21:43:09.000000000 +0200
@@ -29,6 +29,9 @@
 #include "timers.h"
 #include "transfer.h"
 #include "videodir.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 #define MAXWAIT4EPGINFO   3 // seconds
 #define MODETIMEOUT       3 // seconds
@@ -1720,7 +1723,11 @@
         int l = p ? p - s : strlen(s);
         cOsdItem *item = new cOsdItem;
         item->SetSelectable(false);
+#ifdef __APPLE__
+        item->SetText(strndup_darwin(s, l), false);
+#else
         item->SetText(strndup(s, l), false);
+#endif
         Add(item);
         s = p ? p + 1 : p;
         }
diff -ruN vdr-1.6.0-orig/menuitems.h vdr-1.6.0-2-darwin-2/menuitems.h
--- vdr-1.6.0-orig/menuitems.h	2008-02-16 18:09:58.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/menuitems.h	2009-02-11 21:43:09.000000000 +0200
@@ -12,6 +12,13 @@
 
 #include <limits.h>
 #include "osdbase.h"
+#ifdef __MAC_OS_X_VERSION_10_5
+#ifdef __i386__
+#include <i386/limits.h>
+#else
+#include <ppc/limits.h>
+#endif
+#endif
 
 extern const char *FileNameChars;
 
diff -ruN vdr-1.6.0-orig/pat.c vdr-1.6.0-2-darwin-2/pat.c
--- vdr-1.6.0-orig/pat.c	2008-02-08 15:48:31.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/pat.c	2009-02-11 21:43:09.000000000 +0200
@@ -8,7 +8,11 @@
  */
 
 #include "pat.h"
+#ifdef __APPLE__
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 #include "channels.h"
 #include "libsi/section.h"
 #include "libsi/descriptor.h"
diff -ruN vdr-1.6.0-orig/po/it_IT.po vdr-1.6.0-2-darwin-2/po/it_IT.po
--- vdr-1.6.0-orig/po/it_IT.po	2008-03-23 12:31:29.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/po/it_IT.po	2009-02-11 21:45:24.000000000 +0200
@@ -12,9 +12,9 @@
 "Project-Id-Version: VDR 1.6.0\n"
 "Report-Msgid-Bugs-To: <vdr-bugs@cadsoft.de>\n"
 "POT-Creation-Date: 2008-02-10 12:22+0100\n"
-"PO-Revision-Date: 2008-03-08 21:06+0100\n"
+"PO-Revision-Date: 2008-04-17 01:07+0100\n"
 "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
-"Language-Team:  Italian\n"
+"Language-Team: Italian\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=ISO-8859-15\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -221,7 +221,7 @@
 msgstr "Disco"
 
 msgid "free"
-msgstr "liberi"
+msgstr "disponibile"
 
 msgid "Free To Air"
 msgstr "in chiaro"
@@ -230,7 +230,7 @@
 msgstr "codificato"
 
 msgid "auto"
-msgstr "automatico"
+msgstr "automatica"
 
 msgid "Edit channel"
 msgstr "Modifica canale"
@@ -293,7 +293,7 @@
 msgstr "CoderateH"
 
 msgid "none"
-msgstr "nessuno"
+msgstr "nessuna"
 
 msgid "CoderateL"
 msgstr "CoderateL"
@@ -404,20 +404,20 @@
 msgstr "Prossimi programmi"
 
 msgid "Button$Next"
-msgstr "Prossimo"
+msgstr "Prossimi"
 
 msgid "Button$Now"
 msgstr "Adesso"
 
 msgid "Button$Schedule"
-msgstr "Programma"
+msgstr "Programmi"
 
 msgid "Can't switch channel!"
 msgstr "Impossibile cambiare canale!"
 
 #, c-format
 msgid "Schedule - %s"
-msgstr "Programma - %s"
+msgstr "Programmi - %s"
 
 #, c-format
 msgid "This event - %s"
@@ -500,7 +500,7 @@
 msgstr "Altezza OSD"
 
 msgid "Setup.OSD$Message time (s)"
-msgstr "Tempo del messaggio (s)"
+msgstr "Durata del messaggio (s)"
 
 msgid "Setup.OSD$Use small font"
 msgstr "Utilizza caratteri piccoli"
@@ -572,7 +572,7 @@
 msgstr "Mostra vecchi dati EPG (min)"
 
 msgid "Setup.EPG$Set system time"
-msgstr "Imposta orario automatico"
+msgstr "Imposta orario di sistema"
 
 msgid "Setup.EPG$Use time from transponder"
 msgstr "Utilizza orario da transponder"
@@ -628,7 +628,7 @@
 msgstr "Dolby Digital"
 
 msgid "Setup.DVB$Update channels"
-msgstr "Aggiorna i canali"
+msgstr "Aggiornamento canali"
 
 msgid "Setup.DVB$Audio languages"
 msgstr "Lingue audio"
@@ -739,7 +739,7 @@
 msgstr "Nome reg. immediata"
 
 msgid "Setup.Recording$Instant rec. time (min)"
-msgstr "Tempo reg. immediata (min)"
+msgstr "Durata reg. immediata (min)"
 
 msgid "Setup.Recording$Max. video file size (MB)"
 msgstr "Dim. massima file video (MB)"
@@ -899,7 +899,7 @@
 msgstr "Plugin"
 
 msgid "Up/Dn for new location - OK to move"
-msgstr "Su/Giù per nuova posizione - OK per muovere"
+msgstr "Su/Giù per nuova posizione - OK per spostare"
 
 msgid "Channel locked (recording)!"
 msgstr "Canale bloccato (in registrazione)!"
diff -ruN vdr-1.6.0-orig/recording.c vdr-1.6.0-2-darwin-2/recording.c
--- vdr-1.6.0-orig/recording.c	2008-02-24 12:28:53.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/recording.c	2009-02-11 21:43:09.000000000 +0200
@@ -1204,7 +1204,11 @@
               delta = buf.st_size % sizeof(tIndex);
               if (delta) {
                  delta = sizeof(tIndex) - delta;
+#ifdef __APPLE__
+                 esyslog("ERROR: invalid file size (%ld) in '%s'", (long int)buf.st_size, fileName);
+#else
                  esyslog("ERROR: invalid file size (%ld) in '%s'", buf.st_size, fileName);
+#endif
                  }
               last = (buf.st_size + delta) / sizeof(tIndex) - 1;
               if (!Record && last >= 0) {
diff -ruN vdr-1.6.0-orig/remote.c vdr-1.6.0-2-darwin-2/remote.c
--- vdr-1.6.0-orig/remote.c	2008-02-23 16:14:46.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/remote.c	2009-02-11 21:44:04.000000000 +0200
@@ -358,5 +358,8 @@
                  Put(KBDKEY(func));
               }
            }
+#ifdef __APPLE__
+        usleep(5000);
+#endif
         }
 }
diff -ruN vdr-1.6.0-orig/remux.h vdr-1.6.0-2-darwin-2/remux.h
--- vdr-1.6.0-orig/remux.h	2007-09-02 13:19:06.000000000 +0300
+++ vdr-1.6.0-2-darwin-2/remux.h	2009-02-11 21:43:09.000000000 +0200
@@ -4,14 +4,12 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: remux.h 1.17 2007/09/02 10:19:06 kls Exp $
+ * $Id: remux.h 1.17.1.1 2008/09/06 14:34:42 kls Exp $
  */
 
 #ifndef __REMUX_H
 #define __REMUX_H
 
-#include <time.h> //XXX FIXME: DVB/linux/dvb/dmx.h should include <time.h> itself!!!
-#include <linux/dvb/dmx.h>
 #include "ringbuffer.h"
 #include "tools.h"
 
diff -ruN vdr-1.6.0-orig/sections.c vdr-1.6.0-2-darwin-2/sections.c
--- vdr-1.6.0-orig/sections.c	2007-10-14 15:52:07.000000000 +0300
+++ vdr-1.6.0-2-darwin-2/sections.c	2009-02-11 21:44:40.000000000 +0200
@@ -221,5 +221,8 @@
                   }
                }
            }
+#ifdef __APPLE__
+        usleep(5000);
+#endif
         }
 }
diff -ruN vdr-1.6.0-orig/skins.c vdr-1.6.0-2-darwin-2/skins.c
--- vdr-1.6.0-orig/skins.c	2008-02-17 13:31:09.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/skins.c	2009-02-11 21:43:09.000000000 +0200
@@ -10,6 +10,9 @@
 #include "skins.h"
 #include "interface.h"
 #include "status.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 // --- cSkinQueuedMessage ----------------------------------------------------
 
@@ -93,10 +96,18 @@
      return NULL;
   static char buffer[1000];
   const char *a = s;
+#ifdef __APPLE__
+  const char *b = strchrnul_darwin(a, '\t');
+#else
   const char *b = strchrnul(a, '\t');
+#endif
   while (*b && Tab-- > 0) {
         a = b + 1;
+#ifdef __APPLE__
+        b = strchrnul_darwin(a, '\t');
+#else
         b = strchrnul(a, '\t');
+#endif
         }
   if (!*b)
      return (Tab <= 0) ? a : NULL;
diff -ruN vdr-1.6.0-orig/sources.c vdr-1.6.0-2-darwin-2/sources.c
--- vdr-1.6.0-orig/sources.c	2008-02-10 16:07:26.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/sources.c	2009-02-11 21:43:09.000000000 +0200
@@ -9,6 +9,9 @@
 
 #include "sources.h"
 #include <ctype.h>
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 // --- cSource ---------------------------------------------------------------
 
@@ -26,7 +29,11 @@
 bool cSource::Parse(const char *s)
 {
   char *codeBuf = NULL;
+#ifdef __APPLE__
+  if (2 == sscanf_darwin(s, "%a[^ ] %a[^\n]", &codeBuf, &description))
+#else
   if (2 == sscanf(s, "%a[^ ] %a[^\n]", &codeBuf, &description))
+#endif
      code = FromString(codeBuf);
   free(codeBuf);
   return code != stNone && description && *description;
diff -ruN vdr-1.6.0-orig/sources.conf vdr-1.6.0-2-darwin-2/sources.conf
--- vdr-1.6.0-orig/sources.conf	2007-02-17 18:15:13.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/sources.conf	2009-02-11 21:43:09.000000000 +0200
@@ -19,29 +19,34 @@
 
 # Europe
 
-S5E     Sirius 2/3
+S3E     Telecom 2C
+S4E     Eurobird 4
+S5E     Sirius 4
 S7E     Eutelsat W3A
+S9E     Eurobird 9
 S10E    Eutelsat W1
-S13E    Hotbird 1-3/6/7A
+S13E    Hotbird 6/7A/8
 S16E    Eutelsat W2
-S19.2E  Astra 1B/C/E/F/G/H/2C
+S19.2E  Astra F/G/H/KR/L
 S21.0E  Afristar 1
 S21.6E  Eutelsat W6
-S23.5E  Astra 1D 3A
-S26E    Arabsat 2D/2C/3A
+S23.5E  Astra 1E/3A
+S25.5E  Eurobird 2
+S26E    Badr 3/4/6
 S28.2E  Astra 2D/A/B
-S28.5E  Eurobird 1 & Astra 2A/B/D
+S28.5E  Eurobird 1 & Astra 2A/B/C/D
 S30.5E  Arabsat 2B
+S31.5E  Astra 1D/5A
 S33E    Eurobird 3 & Intelsat 802
 S36E    Eutelsat W4 & Sesat
 S38E    Paksat 1
 S39E    Hellas Sat 2
 S40E    Express AM1
-S42E    Turksat 1C/2A
+S42E    Turksat 2A/3A
 S45E    Intelsat 12
 S49E    Yamal 202
 S53E    Express AM 22
-S55E    Insat 3E & Intelsat 702
+S55E    Insat 3E 
 S56E    Bonum 1
 S57E    NSS 703
 S60E    Intelsat 904
@@ -54,10 +59,10 @@
 
 # Asia
 
-S74E    Insat 3C & Edusat
-S75E    LMI 1
+S74E    Insat 3C/4CR & Edusat
+S75E    ABS 1
 S76.5E  Telstar 10
-S78.5E  Thaicom 2/3
+S78.5E  Thaicom 2/5
 S80E    Express AM2
 S83E    Insat 2E/3B/4A
 S85.2E  Intelsat 709
@@ -65,14 +70,17 @@
 S88E    ST 1
 S90E    Yamal 201
 S91.5E  Measat 1
-S93.5E  Insat 3A
+S92.2E  Chinasat 9
+S93.5E  Insat 3A/4B
 S95E    NSS 6
-S96.5E  Express AM 11
+S96.5E  Express AM 33
+S98.5E  Protostar 1
 S100.5E Asiasat 2
 S103E   Express A2
+S105E   Asiastar
 S105.5E Asiasat 3S
 S107.7E Cakrawarta 1
-S108E   Telkom 1 & AAP 1
+S108E   Telkom 1 & NSS 11
 S110E   N-Sat 110 & BSAT 1A/2A
 S110.5E Sinosat 1
 S113E   Palapa C2 & Koreasat 2
@@ -81,38 +89,38 @@
 S120E   Thaicom 1A
 S122.2E Asiasat 4
 S124E   JCSAT 4a
+S125E   Sinosat 3
 S128E   JCSAT 3
-S132E   N-Star A
+S132E   Vinasat 1 & JCSAT5a
 S134E   Apstar 6
-S136E   N-Star B
 S138E   Telstar 18
 S140E   Express AM 3
 S144E   Superbird C
 S146E   Agila 2
 S148E   Measat 2
 S150E   JCSAT R
-S152E   Optus B3
+S152E   Optus D2
 S154E   JCSAT 2A
 S156E   Optus C1
 S158E   Superbird A
-S160E   Optus B1
+S160E   Optus D1
 S162E   Superbird B2
-S164E   Optus A3
+S164E   Optus B3
 S166E   Intelsat 8
 S169E   Intelsat 2
-S172E   AMC 23
+S172E   GE 23
 S180E   Intelsat 701
 S177W   NSS 5
 
 # Atlantic
 
-S1W     Thor 2/3 & Intelsat 10-02
-S4W     Amos 1/2
+S1W     Thor 3/5 & Intelsat 10-02
+S4W     Amos 1/2/3
 S5W     Atlantic Bird 3
-S7W     Nilesat 101 & 102
+S7W     Nilesat 101/102 & Atlantic Bird 4
 S8W     Telecom 2D & Atlantic Bird 2
 S11W    Express A3
-S12.5W  Atlantic Bird 2
+S12.5W  Atlantic Bird 1
 S14W    Express A4
 S15W    Telstar 12
 S18W    Intelsat 901
@@ -123,9 +131,9 @@
 S30W    Hispasat 1C/1D
 S31.5W  Intelsat 801
 S34.5W  Intelsat 903
-S37.5W  Telstar 11 & AMC 12
+S37.5W  NSS 10
 S40.5W  NSS 806
-S43W    Intelsat 3R/6B
+S43W    Intelsat 3R/11
 S45W    Intelsat 1R
 S50W    Intelsat 705
 S53W    Intelsat 707
@@ -137,47 +145,45 @@
 
 S61.5W  Echostar 3 & Rainbow 1
 S63W    Estrelo de Sul 1
-S65W    Brasilsat B2
-S70W    Brasilsat B1
+S65W    Star One C1
+S70W    Star One C2
 S72W    Nahuel 1 & AMC 6
-S72.5W  DirecTV 1
-S74W    SBS 6
-S77W    Echostar 4
+S72.5W  DirecTV 1R & Echostar 6
+S74W    Horizons 2
+S77W    Echostar 4 & Galaxy 4R
 S79W    AMC5
-S79.5W  Nimiq 3
 S82W    Nimiq 2
 S83W    AMC 9
-S84W    Brasilsat B3
-S85W    AMC 2
+S84W    Brasilsat B3/4
+S85W    AMC 16
 S85.1W  XM 3
 S87W    AMC3
 S89W    Galaxy 28
-S91W    Galaxy 11 & Nimiq 1
-S91.5W  DirecTV 2
-S92W    Brasilsat B4
+S91W    Galaxy 11/17 & Nimiq 1
+S92W    Brasilsat B2
 S93W    Galaxy 26
 S95W    Galaxy 3C
 S97W    Galaxy 25
-S99W    Galaxy 4R
-S99.2W  Spaceway 2
-S101W   DirecTV 1R/4S/8 & AMC4
+S99W    Galaxy 16
+S99.2W  Spaceway 2 & DirecTV 11
+S101W   DirecTV 4S/8 & AMC 2/4
 S103W   AMC1
-S105W   AMC15
+S105W   AMC15/18
 S107.3W Anik F1/F1R
-S110W   DirecTV 5 & Echostar 6/8/10
+S110W   DirecTV 5 & Echostar 8/10
 S111.1W Anik F2
-S113W   Solidaridad 2
-S119W   Echostar 7 & DirecTV 7S
+S113W   SatMex 6
+S116.8W SatMex 5
+S119W   Anik F3 & Echostar 7 & DirecTV 7S
 S121W   Echostar 9 & Galaxy 23
-S123W   Galaxy 10R
+S123W   Galaxy 18
 S125W   Galaxy 14
 S127W   Galaxy 13/Horizons 1
 S129W   Echostar 5 & Galaxy 27
 S131W   AMC 11
-S133W   Galaxy15/1R
+S133W   Galaxy15
 S135W   AMC 10
 S137W   AMC 7
-S138.5W Echostar 10
 S139W   AMC 8
 S148W   Echostar 1/2
 
diff -ruN vdr-1.6.0-orig/svdrp.c vdr-1.6.0-2-darwin-2/svdrp.c
--- vdr-1.6.0-orig/svdrp.c	2008-02-17 15:36:01.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/svdrp.c	2009-02-11 21:43:10.000000000 +0200
@@ -10,7 +10,7 @@
  * and interact with the Video Disk Recorder - or write a full featured
  * graphical interface that sits on top of an SVDRP connection.
  *
- * $Id: svdrp.c 1.109 2008/02/17 13:36:01 kls Exp $
+ * $Id: svdrp.c 1.109.1.1 2008/05/02 14:29:16 kls Exp $
  */
 
 #include "svdrp.h"
@@ -474,7 +474,11 @@
   if (*Option) {
      int n = -1;
      int d = 0;
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         int o = strtol(Option, NULL, 10);
         if (o >= 1 && o <= Channels.MaxNumber())
            n = o;
@@ -539,7 +543,11 @@
 {
   if (*Option) {
      tChannelID ChannelID = tChannelID::InvalidID;
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         int o = strtol(Option, NULL, 10);
         if (o >= 1 && o <= Channels.MaxNumber())
            ChannelID = Channels.GetByNumber(o)->GetChannelID();
@@ -593,7 +601,11 @@
 void cSVDRP::CmdDELC(const char *Option)
 {
   if (*Option) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         if (!Channels.BeingEdited()) {
            cChannel *channel = Channels.GetByNumber(strtol(Option, NULL, 10));
            if (channel) {
@@ -640,7 +652,11 @@
 void cSVDRP::CmdDELR(const char *Option)
 {
   if (*Option) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         cRecording *recording = Recordings.Get(strtol(Option, NULL, 10) - 1);
         if (recording) {
            cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
@@ -668,7 +684,11 @@
 void cSVDRP::CmdDELT(const char *Option)
 {
   if (*Option) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         if (!Timers.BeingEdited()) {
            cTimer *timer = Timers.Get(strtol(Option, NULL, 10) - 1);
            if (timer) {
@@ -697,7 +717,11 @@
 void cSVDRP::CmdEDIT(const char *Option)
 {
   if (*Option) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         cRecording *recording = Recordings.Get(strtol(Option, NULL, 10) - 1);
         if (recording) {
            cMarks Marks;
@@ -758,7 +782,11 @@
            p = strtok_r(NULL, delim, &strtok_next);
            }
         if (p) {
+#ifdef __APPLE__
+           if (isnumber_darwin(p))
+#else
            if (isnumber(p))
+#endif
               Quality = atoi(p);
            else {
               Reply(501, "Invalid quality \"%s\"", p);
@@ -768,14 +796,22 @@
         }
      // image size:
      if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
+#ifdef __APPLE__
+        if (isnumber_darwin(p))
+#else
         if (isnumber(p))
+#endif
            SizeX = atoi(p);
         else {
            Reply(501, "Invalid sizex \"%s\"", p);
            return;
            }
         if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
+#ifdef __APPLE__
+           if (isnumber_darwin(p))
+#else
            if (isnumber(p))
+#endif
               SizeY = atoi(p);
            else {
               Reply(501, "Invalid sizey \"%s\"", p);
@@ -912,7 +948,11 @@
 {
   bool WithGroupSeps = strcasecmp(Option, ":groups") == 0;
   if (*Option && !WithGroupSeps) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         cChannel *channel = Channels.GetByNumber(strtol(Option, NULL, 10));
         if (channel)
            Reply(250, "%d %s", channel->Number(), *channel->ToText());
@@ -970,7 +1010,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 {
                        Reply(501, "Invalid time");
@@ -984,7 +1028,11 @@
                  }
               else if (!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(Option));
@@ -1035,7 +1083,11 @@
 {
   bool recordings = Recordings.Update(true);
   if (*Option) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option)) {
+#else
      if (isnumber(Option)) {
+#endif
         cRecording *recording = Recordings.Get(strtol(Option, NULL, 10) - 1);
         if (recording) {
            FILE *f = fdopen(file, "w");
@@ -1076,7 +1128,11 @@
      char *strtok_next;
      char *p = strtok_r(buf, delim, &strtok_next);
      while (p) {
+#ifdef __APPLE__
+           if (isnumber_darwin(p))
+#else
            if (isnumber(p))
+#endif
               Number = strtol(p, NULL, 10);
            else if (strcasecmp(p, "ID") == 0)
               Id = true;
@@ -1329,7 +1385,11 @@
            option++;
      char c = *option;
      *option = 0;
+#ifdef __APPLE__
+     if (isnumber_darwin(num)) {
+#else
      if (isnumber(num)) {
+#endif
         cRecording *recording = Recordings.Get(strtol(num, NULL, 10) - 1);
         if (recording) {
            if (c)
@@ -1522,7 +1582,11 @@
 void cSVDRP::CmdVOLU(const char *Option)
 {
   if (*Option) {
+#ifdef __APPLE__
+     if (isnumber_darwin(Option))
+#else
      if (isnumber(Option))
+#endif
         cDevice::PrimaryDevice()->SetVolume(strtol(Option, NULL, 10), true);
      else if (strcmp(Option, "+") == 0)
         cDevice::PrimaryDevice()->SetVolume(VOLUMEDELTA);
@@ -1606,7 +1670,7 @@
         char buffer[BUFSIZ];
         gethostname(buffer, sizeof(buffer));
         time_t now = time(NULL);
-        Reply(220, "%s SVDRP VideoDiskRecorder %s; %s", buffer, VDRVERSION, *TimeToString(now));
+        Reply(220, "%s SVDRP VideoDiskRecorder %s; %s; %s", buffer, VDRVERSION, *TimeToString(now), cCharSetConv::SystemCharacterTable() ? cCharSetConv::SystemCharacterTable() : "UTF-8");
         }
      if (NewConnection)
         lastActivity = time(NULL);
diff -ruN vdr-1.6.0-orig/themes.c vdr-1.6.0-2-darwin-2/themes.c
--- vdr-1.6.0-orig/themes.c	2008-02-10 18:25:00.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/themes.c	2009-02-11 21:43:10.000000000 +0200
@@ -12,6 +12,9 @@
 #include <string.h>
 #include "config.h"
 #include "tools.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 // --- cTheme ----------------------------------------------------------------
 
@@ -47,7 +50,11 @@
                     // FileName is ok
                     if (SetName) {
                        free(name);
+#ifdef __APPLE__
+                       name = strndup_darwin(n, e - n);
+#else
                        name = strndup(n, e - n);
+#endif
                        }
                     }
                  else
diff -ruN vdr-1.6.0-orig/thread.c vdr-1.6.0-2-darwin-2/thread.c
--- vdr-1.6.0-orig/thread.c	2008-02-15 16:17:42.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/thread.c	2009-02-11 21:43:10.000000000 +0200
@@ -4,13 +4,21 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: thread.c 1.64 2008/02/15 14:17:42 kls Exp $
+ * $Id: thread.c 1.64.1.1 2008/08/16 11:00:40 kls Exp $
  */
 
 #include "thread.h"
 #include <errno.h>
+#ifdef __APPLE__
+#include <stdlib.h>
+#include <pthread.h>
+#ifdef __MAC_OS_X_VERSION_10_5
+#include <signal.h>
+#endif
+#else
 #include <linux/unistd.h>
 #include <malloc.h>
+#endif
 #include <stdarg.h>
 #include <stdlib.h>
 #include <sys/resource.h>
@@ -24,11 +32,12 @@
 {
   struct timeval now;
   if (gettimeofday(&now, NULL) == 0) {           // get current time
-     now.tv_usec += MillisecondsFromNow * 1000;  // add the timeout
-     while (now.tv_usec >= 1000000) {            // take care of an overflow
-           now.tv_sec++;
-           now.tv_usec -= 1000000;
-           }
+     now.tv_sec  += MillisecondsFromNow / 1000;  // add full seconds
+     now.tv_usec += (MillisecondsFromNow % 1000) * 1000;  // add microseconds
+     if (now.tv_usec >= 1000000) {               // take care of an overflow
+        now.tv_sec++;
+        now.tv_usec -= 1000000;
+        }
      Abstime->tv_sec = now.tv_sec;          // seconds
      Abstime->tv_nsec = now.tv_usec * 1000; // nano seconds
      return true;
@@ -141,7 +150,9 @@
 {
   pthread_rwlockattr_t attr;
   pthread_rwlockattr_init(&attr);
+#ifndef __APPLE__
   pthread_rwlockattr_setkind_np(&attr, PreferWriter ? PTHREAD_RWLOCK_PREFER_WRITER_NP : PTHREAD_RWLOCK_PREFER_READER_NP);
+#endif
   pthread_rwlock_init(&rwlock, &attr);
 }
 
@@ -159,9 +170,15 @@
         TimeoutMs = 0;
      }
   if (Write)
+#ifdef __APPLE__
+     Result = TimeoutMs ? pthread_rwlock_wrlock(&rwlock) : pthread_rwlock_wrlock(&rwlock);
+  else
+     Result = TimeoutMs ? pthread_rwlock_rdlock(&rwlock) : pthread_rwlock_rdlock(&rwlock);
+#else
      Result = TimeoutMs ? pthread_rwlock_timedwrlock(&rwlock, &abstime) : pthread_rwlock_wrlock(&rwlock);
   else
      Result = TimeoutMs ? pthread_rwlock_timedrdlock(&rwlock, &abstime) : pthread_rwlock_rdlock(&rwlock);
+#endif
   return Result == 0;
 }
 
@@ -177,7 +194,11 @@
   locked = 0;
   pthread_mutexattr_t attr;
   pthread_mutexattr_init(&attr);
+#ifdef __APPLE__
+  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+#else
   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
+#endif
   pthread_mutex_init(&mutex, &attr);
 }
 
@@ -322,7 +343,11 @@
 
 tThreadId cThread::ThreadId(void)
 {
+#ifdef __APPLE__
+  return -ENOSYS;
+#else
   return syscall(__NR_gettid);
+#endif
 }
 
 void cThread::SetMainThreadId(void)
diff -ruN vdr-1.6.0-orig/timers.c vdr-1.6.0-2-darwin-2/timers.c
--- vdr-1.6.0-orig/timers.c	2008-02-16 16:47:40.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/timers.c	2009-02-11 21:43:10.000000000 +0200
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: timers.c 1.73 2008/02/16 14:47:40 kls Exp $
+ * $Id: timers.c 1.73.1.1 2008/04/13 12:47:12 kls Exp $
  */
 
 #include "timers.h"
@@ -16,6 +16,9 @@
 #include "recording.h"
 #include "remote.h"
 #include "status.h"
+#ifdef __APPLE__
+#include "darwinutils.h"
+#endif
 
 #define VFAT_MAX_FILENAME 40 // same as MAX_SUBTITLE_LENGTH in recording.c
 
@@ -92,6 +95,7 @@
   channel = NULL;
   aux = NULL;
   event = NULL;
+  flags = tfNone;
   *this = Timer;
 }
 
@@ -281,7 +285,11 @@
      s = s2;
      }
   bool result = false;
+#ifdef __APPLE__
+  if (8 <= sscanf_darwin(s, "%u :%a[^:]:%a[^:]:%d :%d :%d :%d :%a[^:\n]:%a[^\n]", &flags, &channelbuffer, &daybuffer, &start, &stop, &priority, &lifetime, &filebuffer, &aux)) {
+#else
   if (8 <= sscanf(s, "%u :%a[^:]:%a[^:]:%d :%d :%d :%d :%a[^:\n]:%a[^\n]", &flags, &channelbuffer, &daybuffer, &start, &stop, &priority, &lifetime, &filebuffer, &aux)) {
+#endif
      ClrFlags(tfRecording);
      if (aux && !*skipspace(aux)) {
         free(aux);
@@ -303,7 +311,11 @@
         }
      Utf8Strn0Cpy(file, filebuffer, MaxFileName);
      strreplace(file, '|', ':');
+#ifdef __APPLE__
+     if (isnumber_darwin(channelbuffer))
+#else
      if (isnumber(channelbuffer))
+#endif
         channel = Channels.GetByNumber(atoi(channelbuffer));
      else
         channel = Channels.GetByChannelID(tChannelID::FromString(channelbuffer), true, true);
diff -ruN vdr-1.6.0-orig/tools.c vdr-1.6.0-2-darwin-2/tools.c
--- vdr-1.6.0-orig/tools.c	2008-03-05 19:23:47.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/tools.c	2009-02-11 21:43:10.000000000 +0200
@@ -21,7 +21,12 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <sys/time.h>
+#ifdef __APPLE__
+#include "darwinutils.h"
+#include <sys/mount.h>
+#else
 #include <sys/vfs.h>
+#endif
 #include <time.h>
 #include <unistd.h>
 #include <utime.h>
@@ -254,7 +259,11 @@
   return res;
 }
 
+#ifdef __APPLE__
+bool isnumber_darwin(const char *s)
+#else
 bool isnumber(const char *s)
+#endif
 {
   if (!*s)
      return false;
@@ -484,7 +493,11 @@
 {
   if (!FileName)
      return NULL;
+#ifdef __APPLE__
+  char *TargetName = canonicalize_file_name_darwin(FileName);
+#else
   char *TargetName = canonicalize_file_name(FileName);
+#endif
   if (!TargetName) {
      if (errno == ENOENT) // file doesn't exist
         TargetName = strdup(FileName);
@@ -508,7 +521,11 @@
          int f = open(buf, O_WRONLY | O_CREAT, DEFFILEMODE);
          // O_SYNC doesn't work on all file systems
          if (f >= 0) {
+#ifdef __APPLE__
+            if (fsync(f) < 0)
+#else
             if (fdatasync(f) < 0)
+#endif
                LOG_ERROR_STR(*buf);
             close(f);
             remove(buf);
@@ -1146,7 +1163,11 @@
 
 char *cReadLine::Read(FILE *f)
 {
+#ifdef __APPLE__
+  int n = getline_darwin(&buffer, &size, f);
+#else
   int n = getline(&buffer, &size, f);
+#endif
   if (n > 0) {
      n--;
      if (buffer[n] == '\n') {
@@ -1465,9 +1486,11 @@
   readahead = KILOBYTE(128);
   written = 0;
   totwritten = 0;
+#ifndef __APPLE__
   if (fd >= 0)
      posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM); // we could use POSIX_FADV_SEQUENTIAL, but we do our own readahead, disabling the kernel one.
 #endif
+#endif
   return fd;
 }
 
@@ -1476,8 +1499,12 @@
 #ifdef USE_FADVISE
   if (fd >= 0) {
      if (totwritten)    // if we wrote anything make sure the data has hit the disk before
+#ifdef __APPLE__
+        fsync(fd);  // calling fadvise, as this is our last chance to un-cache it.
+#else
         fdatasync(fd);  // calling fadvise, as this is our last chance to un-cache it.
      posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
+#endif
      }
 #endif
   int OldFd = fd;
@@ -1501,7 +1528,11 @@
 int cUnbufferedFile::FadviseDrop(off_t Offset, off_t Len)
 {
   // rounding up the window to make sure that not PAGE_SIZE-aligned data gets freed.
+#ifndef __APPLE__
   return posix_fadvise(fd, Offset - (FADVGRAN - 1), Len + (FADVGRAN - 1) * 2, POSIX_FADV_DONTNEED);
+#else
+  return 0; // returning all is fine also on darwin
+#endif
 }
 
 off_t cUnbufferedFile::Seek(off_t Offset, int Whence)
@@ -1538,7 +1569,9 @@
            // 1/2 of the previously requested area. This avoids calling
            // fadvise() after every read() call.
            if (ahead - curpos < (off_t)(readahead / 2)) {
+#ifndef __APPLE__
               posix_fadvise(fd, curpos, readahead, POSIX_FADV_WILLNEED);
+#endif
               ahead = curpos + readahead;
               cachedend = max(cachedend, ahead);
               }
@@ -1589,8 +1622,10 @@
               //    last (partial) page might be skipped, writeback will start only after
               //    second call; the third call will still include this page and finally
               //    drop it from cache.
+#ifndef __APPLE__
               off_t headdrop = min(begin, WRITE_BUFFER * 2L);
               posix_fadvise(fd, begin - headdrop, lastpos - begin + headdrop, POSIX_FADV_DONTNEED);
+#endif
               }
            begin = lastpos = curpos;
            totwritten += written;
@@ -1608,8 +1643,10 @@
               // kind of write gathering enabled), but the syncs cause (io) load..
               // Uncomment the next line if you think you need them.
               //fdatasync(fd);
+#ifndef __APPLE__
               off_t headdrop = min(curpos - totwritten, totwritten * 2L);
               posix_fadvise(fd, curpos - totwritten - headdrop, totwritten + headdrop, POSIX_FADV_DONTNEED);
+#endif
               totwritten = 0;
               }
            }
diff -ruN vdr-1.6.0-orig/tools.h vdr-1.6.0-2-darwin-2/tools.h
--- vdr-1.6.0-orig/tools.h	2008-02-17 15:41:27.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/tools.h	2009-02-11 21:43:10.000000000 +0200
@@ -23,9 +23,16 @@
 #include <syslog.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#ifdef __APPLE__
+#include <sys/syslimits.h>
+#endif
 
 typedef unsigned char uchar;
 
+#ifdef __APPLE__
+typedef int (*__compar_fn_t) (__const void *, __const void *);
+#endif
+
 extern int SysLogLevel;
 
 #define esyslog(a...) void( (SysLogLevel > 0) ? syslog_with_tid(LOG_ERR, a) : void() )
@@ -191,7 +198,11 @@
 bool endswith(const char *s, const char *p);
 bool isempty(const char *s);
 int numdigits(int n);
+#ifdef __APPLE__
+bool isnumber_darwin(const char *s);
+#else
 bool isnumber(const char *s);
+#endif
 cString itoa(int n);
 cString AddDirectory(const char *DirName, const char *FileName);
 bool EntriesOnSameFileSystem(const char *File1, const char *File2);
diff -ruN vdr-1.6.0-orig/vdr.c vdr-1.6.0-2-darwin-2/vdr.c
--- vdr-1.6.0-orig/vdr.c	2008-03-14 15:22:39.000000000 +0200
+++ vdr-1.6.0-2-darwin-2/vdr.c	2009-02-11 21:43:10.000000000 +0200
@@ -22,7 +22,7 @@
  *
  * The project's page is at http://www.cadsoft.de/vdr
  *
- * $Id: vdr.c 1.313 2008/03/14 13:22:39 kls Exp $
+ * $Id: vdr.c 1.313.1.1 2008/09/06 11:07:52 kls Exp $
  */
 
 #include <getopt.h>
@@ -32,8 +32,10 @@
 #include <pwd.h>
 #include <signal.h>
 #include <stdlib.h>
+#ifndef __APPLE__
 #include <sys/capability.h>
 #include <sys/prctl.h>
+#endif
 #include <termios.h>
 #include <unistd.h>
 #include "audio.h"
@@ -106,8 +108,10 @@
         fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno));
         return false;
         }
+#ifndef __APPLE__
      if (UserDump && prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
         fprintf(stderr, "vdr: warning - cannot set dumpable: %s\n", strerror(errno));
+#endif
      }
   return true;
 }
@@ -115,6 +119,7 @@
 static bool SetCapSysTime(void)
 {
   // drop all capabilities except cap_sys_time
+#ifndef __APPLE__
   cap_t caps = cap_from_text("= cap_sys_time=ep");
   if (!caps) {
      fprintf(stderr, "vdr: cap_from_text failed: %s\n", strerror(errno));
@@ -126,22 +131,24 @@
      return false;
      }
   cap_free(caps);
+#endif
   return true;
 }
 
 static bool SetKeepCaps(bool On)
 {
+#ifndef __APPLE__
   // set keeping capabilities during setuid() on/off
   if (prctl(PR_SET_KEEPCAPS, On ? 1 : 0, 0, 0, 0) != 0) {
      fprintf(stderr, "vdr: prctl failed\n");
      return false;
      }
+#endif
   return true;
 }
 
 static void SignalHandler(int signum)
 {
-  isyslog("caught signal %d", signum);
   switch (signum) {
     case SIGPIPE:
          break;
@@ -256,7 +263,11 @@
           case 'c': ConfigDirectory = optarg;
                     break;
           case 'd': DaemonMode = true; break;
+#ifdef __APPLE__
+          case 'D': if (isnumber_darwin(optarg)) {
+#else
           case 'D': if (isnumber(optarg)) {
+#endif
                        int n = atoi(optarg);
                        if (0 <= n && n < MAXDEVICES) {
                           cDevice::SetUseDevice(n);
@@ -276,13 +287,21 @@
                       char *p = strchr(optarg, '.');
                       if (p)
                          *p = 0;
+#ifdef __APPLE__
+                      if (isnumber_darwin(optarg)) {
+#else
                       if (isnumber(optarg)) {
+#endif
                          int l = atoi(optarg);
                          if (0 <= l && l <= 3) {
                             SysLogLevel = l;
                             if (!p)
                                break;
+#ifdef __APPLE__
+                            if (isnumber_darwin(p + 1)) {
+#else
                             if (isnumber(p + 1)) {
+#endif
                                int l = atoi(p + 1);
                                if (0 <= l && l <= 7) {
                                   int targets[] = { LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
@@ -321,7 +340,11 @@
           case 'n' | 0x100:
                     UseKbd = false;
                     break;
+#ifdef __APPLE__
+          case 'p': if (isnumber_darwin(optarg))
+#else
           case 'p': if (isnumber(optarg))
+#endif
                        SVDRPport = atoi(optarg);
                     else {
                        fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
@@ -358,7 +381,11 @@
                     while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/')
                           optarg[strlen(optarg) - 1] = 0;
                     break;
+#ifdef __APPLE__
+          case 'w': if (isnumber_darwin(optarg)) {
+#else
           case 'w': if (isnumber(optarg)) {
+#endif
                        int t = atoi(optarg);
                        if (t >= 0) {
                           WatchdogTimeout = t;
@@ -498,9 +525,12 @@
      }
   else if (Terminal) {
      // Claim new controlling terminal
+     // Not needed on darwin
+#ifndef __APPLE__
      stdin  = freopen(Terminal, "r", stdin);
      stdout = freopen(Terminal, "w", stdout);
      stderr = freopen(Terminal, "w", stderr);
+#endif
      HasStdin = true;
      }
 
@@ -1288,9 +1318,11 @@
   ReportEpgBugFixStats();
   if (WatchdogTimeout > 0)
      dsyslog("max. latency time %d seconds", MaxLatencyTime);
-  isyslog("exiting, exit code %d", ShutdownHandler.GetExitCode());
+  if (LastSignal)
+     isyslog("caught signal %d", LastSignal);
   if (ShutdownHandler.EmergencyExitRequested())
      esyslog("emergency exit!");
+  isyslog("exiting, exit code %d", ShutdownHandler.GetExitCode());
   if (SysLogLevel > 0)
      closelog();
   if (HasStdin)

