freebsd-ports/multimedia/vdr/files/patch-vdr-1.7.28_FreeBSD
Tijl Coosemans 074ea5282a converters/libiconv:
- Remove const qualifier from iconv(3) to match POSIX:
  http://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html
- Patch iconv.h to expose more GNU extensions when LIBICONV_PLUG is
  defined because the base system iconv supports these extensions too.

Add/remove patches to/from ports to call iconv with non-const arguments.

This breaks some ports on FreeBSD 10 because base system iconv.h still has
the const qualifier.  Fix this by letting USES=iconv add a build dependency
on converters/libiconv so ports can use its iconv.h (with LIBICONV_PLUG
defined) instead of the base system iconv.h.

This exposed some ports that link with libiconv when it is available instead
of using libc iconv.  In these cases one of the following changes has been
made:
- patch configure scripts to test for libc iconv first
- add ac_cv_lib_iconv_libiconv=no or similar to CONFIGURE_ARGS to disable
  some configure tests
- converters/wkhtmltopdf: this includes Qt4 so add a patch from devel/qt4
- lang/gcc5-aux: respect CFLAGS and friends during configure such that
  LIBICONV_PLUG is defined in the iconv test, also switch to external
  gettext
- mail/gnarwl: replace patches with CPPFLAGS/LIBS
- multimedia/ffmpeg2theora: remove iconv test from SConstruct and use
  ICONV_LIB in port Makefile instead, also fix a bug in subtitles.c
- net-im/licq: finish conversion to cmake
- net-mgmt/bandwidthd, net-mgmt/icinga, net-mgmt/nagios, net-mgmt/nagios4:
  don't need iconv
- textproc/p5-XML-TinyXML: finish conversion to USES=perl5

Other changes:
- databases/qdbm and slaves: respect CFLAGS and friends, also enable bzip2
  and lzo support
- games/ldmud: respect CFLAGS and friends
- graphics/inventor: replace some patches with MAKE_ARGS/MAKE_ENV to respect
  CFLAGS and friends, also remove FreeBSD/alpha patch and add missing xorg
  dependencies

PR:		199099
Exp-run by:	antoine
Approved by:	portmgr (antoine)
2015-04-15 08:20:27 +00:00

1222 lines
35 KiB
Text

Index: Make.config.template
@@ -8,6 +8,11 @@
#
# $Id: Make.config.template 2.8 2012/03/20 11:20:13 kls Exp $
+OSTYPE ?= $(shell uname -s)
+ifeq ($(OSTYPE),FreeBSD)
+FREEBSD=1
+endif
+
### The C compiler and options:
CC = gcc
@@ -28,11 +33,22 @@ PREFIX = $(DESTDIR)/usr/local
MANDIR = $(PREFIX)/man
BINDIR = $(PREFIX)/bin
+ifdef FREEBSD
+# you have to set DVBDIR to a valid path!!!
+# you will need extra patches for DVBDIR!!!
+#DVBDIR = /usr/local/include
+LOCDIR = $(PREFIX)/share/locale
+PLUGINDIR = ./PLUGINS
+PLUGINLIBDIR = $(PREFIX)/lib/vdr
+VIDEODIR = /video
+CONFDIR = $(PREFIX)/etc/vdr
+else
LOCDIR = ./locale
PLUGINDIR = ./PLUGINS
PLUGINLIBDIR = $(PLUGINDIR)/lib
VIDEODIR = /video
CONFDIR = $(VIDEODIR)
+endif
### The remote control:
@@ -46,3 +62,7 @@ LIRC_DEVICE = /var/run/lirc/lircd
ifdef DVBDIR
INCLUDES += -I$(DVBDIR)/include
endif
+
+ifdef FREEBSD
+INCLUDES += -I$(VDRDIR)/include -I/usr/local/include
+endif
Index: Makefile
@@ -8,6 +8,11 @@
.DELETE_ON_ERROR:
+OSTYPE ?= $(shell uname -s)
+ifeq ($(OSTYPE),FreeBSD)
+FREEBSD=1
+endif
+
CC ?= gcc
CFLAGS ?= -g -O3 -Wall
@@ -21,7 +26,11 @@ MANDIR ?= $(PREFIX)/share/man
BINDIR ?= $(PREFIX)/bin
INCDIR ?= $(PREFIX)/include
LOCDIR ?= ./locale
+ifdef FREEBSD
+LIBS = -ljpeg -lpthread -lrt -lutil -lintl -liconv $(shell pkg-config --libs freetype2 fontconfig)
+else
LIBS = -ljpeg -lpthread -ldl -lcap -lrt $(shell pkg-config --libs freetype2 fontconfig)
+endif
INCLUDES ?= $(shell pkg-config --cflags freetype2 fontconfig)
PLUGINDIR= ./PLUGINS
@@ -150,7 +159,11 @@ i18n: $(I18Nmsgs)
install-i18n:
@mkdir -p $(DESTDIR)$(LOCDIR)
+ifdef FREEBSD
+ @(cd $(LOCALEDIR); cp -R * $(DESTDIR)$(LOCDIR))
+else
@(cd $(LOCALEDIR); cp -r --parents * $(DESTDIR)$(LOCDIR))
+endif
# The 'include' directory (for plugins):
@@ -189,7 +202,11 @@ install: install-bin install-conf instal
install-bin: vdr
@mkdir -p $(DESTDIR)$(BINDIR)
+ifdef FREEBSD
+ @cp -f vdr svdrpsend $(DESTDIR)$(BINDIR)
+else
@cp --remove-destination vdr svdrpsend $(DESTDIR)$(BINDIR)
+endif
# Configuration files:
@@ -212,13 +229,18 @@ install-doc:
install-plugins: plugins
@mkdir -p $(DESTDIR)$(PLUGINLIBDIR)
+ifdef FREEBSD
+ @cp -f $(PLUGINDIR)/lib/lib*-*.so.$(APIVERSION) $(DESTDIR)$(PLUGINLIBDIR)
+else
@cp --remove-destination $(PLUGINDIR)/lib/lib*-*.so.$(APIVERSION) $(DESTDIR)$(PLUGINLIBDIR)
+endif
# Includes:
install-includes: include-dir
@mkdir -p $(DESTDIR)$(INCDIR)
@cp -pLR include/vdr include/libsi $(DESTDIR)$(INCDIR)
+ @cp Make.config Make.global $(DESTDIR)$(INCDIR)/vdr
# pkg-config file:
Index: channels.c
@@ -29,7 +29,12 @@ tChannelID tChannelID::FromString(const
int tid;
int sid;
int rid = 0;
+#ifdef __FreeBSD__
+ sourcebuf = MALLOC(char, 10);
+ int fields = sscanf(s, "%9[^-]-%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);
@@ -554,7 +559,18 @@ bool cChannel::Parse(const char *s)
char *apidbuf = NULL;
char *tpidbuf = NULL;
char *caidbuf = NULL;
+#ifdef __FreeBSD__
+ namebuf = MALLOC(char, 256);
+ sourcebuf = MALLOC(char, 10);
+ parambuf = MALLOC(char, 256);
+ vpidbuf = MALLOC(char, 256);
+ apidbuf = MALLOC(char, 256);
+ tpidbuf = MALLOC(char, 256);
+ caidbuf = MALLOC(char, 256);
+ int fields = sscanf(s, "%255[^:]:%d :%255[^:]:%255[^:] :%d :%255[^:]:%255[^:]:%255[^:]:%255[^:]:%d :%d :%d :%d ", namebuf, &frequency, parambuf, sourcebuf, &srate, vpidbuf, apidbuf, tpidbuf, caidbuf, &sid, &nid, &tid, &rid);
+#else
int fields = sscanf(s, "%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%a[^:]:%a[^:]:%d :%d :%d :%d ", &namebuf, &frequency, &parambuf, &sourcebuf, &srate, &vpidbuf, &apidbuf, &tpidbuf, &caidbuf, &sid, &nid, &tid, &rid);
+#endif
if (fields >= 9) {
if (fields == 9) {
// allow reading of old format
Index: ci.c
===================================================================
RCS file: /progs/network/ccvs/vdr/ci.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- ci.c 2010/02/17 10:14:44 1.1.1.2
+++ ci.c 2010/02/17 10:46:55 1.3
@@ -10,7 +10,11 @@
#include "ci.h"
#include <ctype.h>
#include <linux/dvb/ca.h>
+#ifdef __FreeBSD__
+#include <stdlib.h>
+#else
#include <malloc.h>
+#endif
#include <netinet/in.h>
#include <poll.h>
#include <string.h>
Index: config.c
===================================================================
RCS file: /progs/network/ccvs/vdr/config.c,v
retrieving revision 1.1.1.4
retrieving revision 1.4
diff -u -r1.1.1.4 -r1.4
--- config.c 2010/06/07 09:07:28 1.1.1.4
+++ config.c 2010/06/07 09:12:57 1.4
@@ -10,6 +10,9 @@
#include "config.h"
#include <ctype.h>
#include <stdlib.h>
+#ifdef __FreeBSD__
+#include <netinet/in.h>
+#endif
#include "device.h"
#include "i18n.h"
#include "interface.h"
Index: diseqc.c
@@ -114,7 +114,14 @@ bool cDiseqc::Parse(const char *s)
return true;
bool result = false;
char *sourcebuf = NULL;
+#ifdef __FreeBSD__
+ sourcebuf = MALLOC(char, 10);
+ if (commands == NULL)
+ commands = MALLOC(char, 256);
+ int fields = sscanf(s, "%9[^ ] %d %c %d %255[^\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) {
Index: eit.c
===================================================================
RCS file: /progs/network/ccvs/vdr/eit.c,v
retrieving revision 1.1.1.3
retrieving revision 1.5
diff -u -r1.1.1.3 -r1.5
--- eit.c 2010/06/07 09:07:27 1.1.1.3
+++ eit.c 2010/06/07 09:12:57 1.5
@@ -339,10 +339,15 @@
if (diff > 2) {
mutex.Lock();
if (abs(diff - lastDiff) < 3) {
+#ifdef __FreeBSD__
+ isyslog("system time would have changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(sattim), sattim);
+ esyslog("stime() not available on FreeBSD, maybe use adjtime()?");
+#else
if (stime(&sattim) == 0)
isyslog("system time changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(sattim), sattim);
else
esyslog("ERROR while setting system time: %m");
+#endif
}
lastDiff = diff;
mutex.Unlock();
Index: epg.c
===================================================================
RCS file: /progs/network/ccvs/vdr/epg.c,v
retrieving revision 1.1.1.3
retrieving revision 1.5
diff -u -r1.1.1.3 -r1.5
--- epg.c 2010/03/01 09:42:48 1.1.1.3
+++ epg.c 2010/03/01 09:58:06 1.5
@@ -31,7 +31,13 @@
bool tComponent::FromString(const char *s)
{
unsigned int Stream, Type;
+#ifdef __FreeBSD__
+ if (description == NULL)
+ description = MALLOC(char, 256);
+ int n = sscanf(s, "%X %02X %7s %255[^\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;
Index: font.c
===================================================================
RCS file: /progs/network/ccvs/vdr/font.c,v
retrieving revision 1.1.1.3
retrieving revision 1.5
diff -u -r1.1.1.3 -r1.5
--- font.c 2010/10/19 20:28:48 1.1.1.3
+++ font.c 2010/10/19 20:32:58 1.5
@@ -383,7 +383,11 @@
{
if (!FontNames->Size()) {
FcInit();
+#ifdef __FreeBSD__
+ FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, (char *)NULL);
+#else
FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, NULL);
+#endif
FcPattern *pat = FcPatternCreate();
FcPatternAddBool(pat, FC_SCALABLE, FcTrue);
if (Monospaced)
Index: i18n.h
===================================================================
RCS file: /progs/network/ccvs/vdr/i18n.h,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- i18n.h 2010/02/17 10:14:45 1.1.1.2
+++ i18n.h 2010/02/17 10:46:55 1.3
@@ -48,7 +48,11 @@
///< have an actual locale installed. The rest are just dummy entries
///< to allow having three letter language codes for other languages
///< that have no actual locale on this system.
+#ifdef __FreeBSD__
+const char *I18nTranslate(const char *s, const char *Plugin = NULL) __format_arg(1);
+#else
const char *I18nTranslate(const char *s, const char *Plugin = NULL) __attribute_format_arg__(1);
+#endif
///< Translates the given string (with optional Plugin context) into
///< the current language. If no translation is available, the original
///< string will be returned.
Index: menu.c
===================================================================
RCS file: /progs/network/ccvs/vdr/menu.c,v
retrieving revision 1.1.1.6
retrieving revision 1.7
diff -u -r1.1.1.6 -r1.7
Index: menuitems.c
===================================================================
RCS file: /progs/network/ccvs/vdr/menuitems.c,v
retrieving revision 1.1.1.4
retrieving revision 1.5
diff -u -r1.1.1.4 -r1.5
--- menuitems.c 2010/06/07 09:07:27 1.1.1.4
+++ menuitems.c 2010/06/07 09:12:57 1.5
@@ -838,7 +838,11 @@
struct tm tm_r;
localtime_r(value, &tm_r);
strftime(buf, DATEBUFFERSIZE, "%Y-%m-%d ", &tm_r);
+#ifdef __FreeBSD__
+ strcat(buf, WeekDayNameReal(tm_r.tm_wday));
+#else
strcat(buf, WeekDayName(tm_r.tm_wday));
+#endif
}
else
*buf = 0;
Index: pat.c
===================================================================
RCS file: /progs/network/ccvs/vdr/pat.c,v
retrieving revision 1.1.1.5
retrieving revision 1.6
diff -u -r1.1.1.5 -r1.6
--- pat.c 2010/10/19 20:28:48 1.1.1.5
+++ pat.c 2010/10/19 20:32:58 1.6
@@ -8,7 +8,11 @@
*/
#include "pat.h"
+#ifdef __FreeBSD__
+#include <stdlib.h>
+#else
#include <malloc.h>
+#endif
#include "channels.h"
#include "libsi/section.h"
#include "libsi/descriptor.h"
Index: recording.c
===================================================================
RCS file: /progs/network/ccvs/vdr/recording.c,v
retrieving revision 1.1.1.3
retrieving revision 1.5
diff -u -r1.1.1.3 -r1.5
--- recording.c 2010/03/16 15:18:58 1.1.1.3
+++ recording.c 2010/03/16 15:21:05 1.5
@@ -1825,7 +1829,11 @@
// Search for a PAT packet from the end of the file:
cPatPmtParser PatPmtParser;
sprintf(pFileNumber, RECORDFILESUFFIXTS, Number);
+#ifdef __FreeBSD__
+ int fd = open(fileName, O_RDONLY, DEFFILEMODE);
+#else
int fd = open(fileName, O_RDONLY | O_LARGEFILE, DEFFILEMODE);
+#endif
if (fd >= 0) {
off_t pos = lseek(fd, -TS_SIZE, SEEK_END);
while (pos >= 0) {
@@ -1866,14 +1874,22 @@
int BlockingFlag = blocking ? 0 : O_NONBLOCK;
if (record) {
dsyslog("recording to '%s'", fileName);
+#ifdef __FreeBSD__
+ file = OpenVideoFile(fileName, O_RDWR | O_CREAT | BlockingFlag);
+#else
file = OpenVideoFile(fileName, O_RDWR | O_CREAT | O_LARGEFILE | BlockingFlag);
+#endif
if (!file)
LOG_ERROR_STR(fileName);
}
else {
if (access(fileName, R_OK) == 0) {
dsyslog("playing '%s'", fileName);
+#ifdef __FreeBSD__
+ file = cUnbufferedFile::Create(fileName, O_RDONLY | BlockingFlag);
+#else
file = cUnbufferedFile::Create(fileName, O_RDONLY | O_LARGEFILE | BlockingFlag);
+#endif
if (!file)
LOG_ERROR_STR(fileName);
}
Index: skins.c
===================================================================
RCS file: /progs/network/ccvs/vdr/skins.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- skins.c 2010/02/17 10:14:45 1.1.1.2
+++ skins.c 2010/02/17 10:46:55 1.3
@@ -11,6 +11,20 @@
#include "interface.h"
#include "status.h"
+#if defined(__FreeBSD__) && __FreeBSD_version < 1000029
+/* XXX Implement strchrnul for FreeBSD. */
+static char *
+strchrnul (const char *s, int c_in)
+{
+ char c = c_in;
+ while (*s && (*s != c))
+ s++;
+
+ return (char *) s;
+}
+#endif
+
+
// --- cSkinQueuedMessage ----------------------------------------------------
class cSkinQueuedMessage : public cListObject {
Index: sources.c
===================================================================
RCS file: /progs/network/ccvs/vdr/sources.c,v
retrieving revision 1.1.1.4
retrieving revision 1.5
diff -u -r1.1.1.4 -r1.5
--- sources.c 2010/03/16 15:18:58 1.1.1.4
+++ sources.c 2010/03/16 15:21:05 1.5
@@ -31,7 +31,14 @@
bool cSource::Parse(const char *s)
{
char *codeBuf = NULL;
+#ifdef __FreeBSD__
+ codeBuf = MALLOC(char, 10);
+ if (description == NULL)
+ description = MALLOC(char, 256);
+ if (2 == sscanf(s, "%9[^ ] %255[^\n]", codeBuf, description))
+#else
if (2 == sscanf(s, "%a[^ ] %a[^\n]", &codeBuf, &description))
+#endif
code = FromString(codeBuf);
free(codeBuf);
return code != stNone && description && *description;
Index: svdrp.c
@@ -40,6 +40,12 @@
#include "tools.h"
#include "videodir.h"
+/* FreeBSD has it's own version of isnumber(),
+ but VDR's version is incompatible */
+#ifdef __FreeBSD__
+#undef isnumber
+#endif
+
// --- cSocket ---------------------------------------------------------------
cSocket::cSocket(int Port, int Queue)
@@ -124,6 +130,23 @@ int cSocket::Accept(void)
}
else if (errno != EINTR && errno != EAGAIN)
LOG_ERROR;
+#ifdef __FreeBSD__
+ // Linux' accept() doesn't inherit O_NONBLOCK... (this fixes
+ // cSVDRP::Send() failing due to EAGAIN when vdradmin-am downloads EPG.)
+ if (newsock >= 0) {
+ // make it blocking:
+ int oldflags = fcntl(newsock, F_GETFL, 0);
+ if (oldflags < 0) {
+ LOG_ERROR;
+ return -1;
+ }
+ oldflags &= ~O_NONBLOCK;
+ if (fcntl(newsock, F_SETFL, oldflags) < 0) {
+ LOG_ERROR;
+ return -1;
+ }
+ }
+#endif
return newsock;
}
return -1;
Index: themes.c
===================================================================
RCS file: /progs/network/ccvs/vdr/themes.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- themes.c 2010/02/17 10:14:44 1.1.1.2
+++ themes.c 2010/02/17 10:46:55 1.3
@@ -47,7 +47,11 @@
// FileName is ok
if (SetName) {
free(name);
+#ifdef __FreeBSD__
+ name = (char *)strndup(n, e - n);
+#else
name = strndup(n, e - n);
+#endif
}
}
else
Index: thread.c
===================================================================
RCS file: /progs/network/ccvs/vdr/thread.c,v
retrieving revision 1.1.1.2
retrieving revision 1.6
diff -u -r1.1.1.2 -r1.6
--- thread.c 2010/02/17 10:14:45 1.1.1.2
+++ thread.c 2010/02/24 08:41:13 1.6
@@ -9,15 +9,22 @@
#include "thread.h"
#include <errno.h>
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#include <stdlib.h>
+#else
#include <linux/unistd.h>
#include <malloc.h>
+#endif
#include <stdarg.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/wait.h>
+#ifndef __FreeBSD__
#include <sys/prctl.h>
+#endif
#include <unistd.h>
#include "tools.h"
@@ -143,7 +150,9 @@
{
pthread_rwlockattr_t attr;
pthread_rwlockattr_init(&attr);
+#ifndef __FreeBSD__
pthread_rwlockattr_setkind_np(&attr, PreferWriter ? PTHREAD_RWLOCK_PREFER_WRITER_NP : PTHREAD_RWLOCK_PREFER_READER_NP);
+#endif
pthread_rwlock_init(&rwlock, &attr);
}
@@ -179,7 +188,11 @@
locked = 0;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
+#ifdef __FreeBSD__
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+#else
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
+#endif
pthread_mutex_init(&mutex, &attr);
}
@@ -228,8 +241,12 @@
void cThread::SetIOPriority(int Priority)
{
+#ifdef __FreeBSD__
+ esyslog("ERROR: syscall(SYS_ioprio_set ...) unsupported on FreeBSD");
+#else
if (syscall(SYS_ioprio_set, 1, 0, (Priority & 0xff) | (2 << 13)) < 0) // best effort class
LOG_ERROR;
+#endif
}
void cThread::SetDescription(const char *Description, ...)
@@ -335,7 +352,11 @@
tThreadId cThread::ThreadId(void)
{
+#ifdef __FreeBSD__
+ return reinterpret_cast<long>(::pthread_self());
+#else
return syscall(__NR_gettid);
+#endif
}
void cThread::SetMainThreadId(void)
@@ -461,7 +482,11 @@
int MaxPossibleFileDescriptors = getdtablesize();
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
close(i); //close all dup'ed filedescriptors
+#ifdef __FreeBSD__
+ if (execl("/bin/sh", "sh", "-c", Command, (char *)NULL) == -1) {
+#else
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) {
+#endif
LOG_ERROR_STR(Command);
close(fd[1 - iopipe]);
_exit(-1);
@@ -544,7 +569,11 @@
int MaxPossibleFileDescriptors = getdtablesize();
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
close(i); //close all dup'ed filedescriptors
+#ifdef __FreeBSD__
+ if (execl("/bin/sh", "sh", "-c", Command, (char *)NULL) == -1) {
+#else
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) {
+#endif
LOG_ERROR_STR(Command);
_exit(-1);
}
Index: thread.h
===================================================================
RCS file: /progs/network/ccvs/vdr/thread.h,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- thread.h 2010/02/17 10:14:44 1.1.1.2
+++ thread.h 2010/02/17 10:46:55 1.3
@@ -13,6 +13,9 @@
#include <pthread.h>
#include <stdio.h>
#include <sys/types.h>
+#ifdef __FreeBSD__
+#include <signal.h>
+#endif
class cCondWait {
private:
Index: timers.c
===================================================================
RCS file: /progs/network/ccvs/vdr/timers.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- timers.c 2010/02/17 10:14:45 1.1.1.2
+++ timers.c 2010/02/17 10:46:55 1.3
@@ -23,6 +23,12 @@
// format characters in order to allow any number of blanks after a numeric
// value!
+/* FreeBSD has it's own version of isnumber(),
+ but VDR's version is incompatible */
+#ifdef __FreeBSD__
+#undef isnumber
+#endif
+
// --- cTimer ----------------------------------------------------------------
cTimer::cTimer(bool Instant, bool Pause, cChannel *Channel)
@@ -292,7 +298,15 @@
s = s2;
}
bool result = false;
+#ifdef __FreeBSD__
+ channelbuffer = MALLOC(char, 256);
+ daybuffer = MALLOC(char, 256);
+ filebuffer = MALLOC(char, 256);
+ aux = MALLOC(char, 256);
+ if (8 <= sscanf(s, "%u :%255[^:]:%255[^:]:%d :%d :%d :%d :%255[^:\n]:%255[^\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);
Index: tools.c
===================================================================
RCS file: /progs/network/ccvs/vdr/tools.c,v
retrieving revision 1.1.1.5
retrieving revision 1.8
diff -u -r1.1.1.5 -r1.8
--- tools.c 2010/10/19 20:28:48 1.1.1.5
+++ tools.c 2010/10/19 20:32:58 1.8
@@ -21,13 +21,24 @@
#include <stdarg.h>
#include <stdlib.h>
#include <sys/time.h>
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#include <sys/mount.h>
+#else
#include <sys/vfs.h>
+#endif
#include <time.h>
#include <unistd.h>
#include <utime.h>
#include "i18n.h"
#include "thread.h"
+/* FreeBSD has it's own version of isnumber(),
+ but VDR's version is incompatible */
+#ifdef __FreeBSD__
+#undef isnumber
+#endif
+
int SysLogLevel = 3;
#define MAXSYSLOGBUF 256
@@ -493,6 +504,18 @@
{
if (!FileName)
return NULL;
+#ifdef __FreeBSD__
+ char *resolved_path = NULL;
+ resolved_path = MALLOC(char, PATH_MAX+1);
+ if (realpath(FileName, resolved_path) == NULL)
+ {
+ if (errno != ENOENT) // some other error occurred
+ LOG_ERROR_STR(FileName);
+ else // file doesn't exist
+ resolved_path = strdup(FileName);
+ }
+ return resolved_path;
+#else
char *TargetName = canonicalize_file_name(FileName);
if (!TargetName) {
if (errno == ENOENT) // file doesn't exist
@@ -501,6 +524,7 @@
LOG_ERROR_STR(FileName);
}
return TargetName;
+#endif
}
bool SpinUpDisk(const char *FileName)
@@ -517,7 +541,11 @@
int f = open(buf, O_WRONLY | O_CREAT, DEFFILEMODE);
// O_SYNC doesn't work on all file systems
if (f >= 0) {
+#ifdef __FreeBSD__
+ if (fsync(f) < 0)
+#else
if (fdatasync(f) < 0)
+#endif
LOG_ERROR_STR(*buf);
close(f);
remove(buf);
@@ -920,7 +952,11 @@
return cString(buffer, true);
}
+#ifdef __FreeBSD__
+cString WeekDayNameReal(int WeekDay)
+#else
cString WeekDayName(int WeekDay)
+#endif
{
char buffer[16];
WeekDay = WeekDay == 0 ? 6 : WeekDay - 1; // we start with Monday==0!
@@ -938,10 +974,18 @@
cString WeekDayName(time_t t)
{
struct tm tm_r;
+#ifdef __FreeBSD__
+ return WeekDayNameReal(localtime_r(&t, &tm_r)->tm_wday);
+#else
return WeekDayName(localtime_r(&t, &tm_r)->tm_wday);
+#endif
}
+#ifdef __FreeBSD__
+cString WeekDayNameFullReal(int WeekDay)
+#else
cString WeekDayNameFull(int WeekDay)
+#endif
{
WeekDay = WeekDay == 0 ? 6 : WeekDay - 1; // we start with Monday==0!
switch (WeekDay) {
@@ -959,7 +1003,11 @@
cString WeekDayNameFull(time_t t)
{
struct tm tm_r;
+#ifdef __FreeBSD__
+ return WeekDayNameFullReal(localtime_r(&t, &tm_r)->tm_wday);
+#else
return WeekDayNameFull(localtime_r(&t, &tm_r)->tm_wday);
+#endif
}
cString DayDateTime(time_t t)
@@ -969,7 +1017,11 @@
time(&t);
struct tm tm_r;
tm *tm = localtime_r(&t, &tm_r);
+#ifdef __FreeBSD__
+ snprintf(buffer, sizeof(buffer), "%s %02d.%02d. %02d:%02d", *WeekDayNameReal(tm->tm_wday), tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
+#else
snprintf(buffer, sizeof(buffer), "%s %02d.%02d. %02d:%02d", *WeekDayName(tm->tm_wday), tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
+#endif
return buffer;
}
@@ -988,7 +1040,11 @@
char buf[32];
struct tm tm_r;
tm *tm = localtime_r(&t, &tm_r);
+#ifdef __FreeBSD__
+ char *p = stpcpy(buf, WeekDayNameReal(tm->tm_wday));
+#else
char *p = stpcpy(buf, WeekDayName(tm->tm_wday));
+#endif
*p++ = ' ';
strftime(p, sizeof(buf) - (p - buf), "%d.%m.%Y", tm);
return buf;
@@ -1315,7 +1371,11 @@
if (!IsOpen()) {
f = FileDes;
if (f >= 0) {
+#ifdef __FreeBSD__
+ if ((uint)f < FD_SETSIZE) {
+#else
if (f < FD_SETSIZE) {
+#endif
if (f >= maxFiles)
maxFiles = f + 1;
if (!files[f])
@@ -1356,7 +1416,11 @@
if (files[i])
FD_SET(i, &set);
}
+#ifdef __FreeBSD__
+ if (0 <= FileDes && (uint)FileDes < FD_SETSIZE && !files[FileDes])
+#else
if (0 <= FileDes && FileDes < FD_SETSIZE && !files[FileDes])
+#endif
FD_SET(FileDes, &set); // in case we come in with an arbitrary descriptor
if (TimeoutMs == 0)
TimeoutMs = 10; // load gets too heavy with 0
@@ -1451,7 +1515,9 @@
// --- cUnbufferedFile -------------------------------------------------------
+#ifndef __FreeBSD__
#define USE_FADVISE
+#endif
#define WRITE_BUFFER KILOBYTE(800)
@@ -1512,11 +1578,13 @@
readahead = ra;
}
+#ifdef USE_FADVISE
int cUnbufferedFile::FadviseDrop(off_t Offset, off_t Len)
{
// rounding up the window to make sure that not PAGE_SIZE-aligned data gets freed.
return posix_fadvise(fd, Offset - (FADVGRAN - 1), Len + (FADVGRAN - 1) * 2, POSIX_FADV_DONTNEED);
}
+#endif
off_t cUnbufferedFile::Seek(off_t Offset, int Whence)
{
Index: tools.h
@@ -27,6 +27,12 @@
#include <sys/stat.h>
#include <sys/types.h>
+#ifdef __FreeBSD__
+#include <sys/param.h>
+typedef int (*__compar_fn_t) (__const void *, __const void *);
+#undef isnumber
+#endif
+
typedef unsigned char uchar;
extern int SysLogLevel;
@@ -227,12 +233,20 @@ bool SpinUpDisk(const char *FileName);
void TouchFile(const char *FileName);
time_t LastModifiedTime(const char *FileName);
off_t FileSize(const char *FileName); ///< returns the size of the given file, or -1 in case of an error (e.g. if the file doesn't exist)
+#ifdef __FreeBSD__
+cString WeekDayNameReal(int WeekDay);
+#else
cString WeekDayName(int WeekDay);
+#endif
///< Converts the given WeekDay (0=Sunday, 1=Monday, ...) to a three letter
///< day name.
cString WeekDayName(time_t t);
///< Converts the week day of the given time to a three letter day name.
+#ifdef __FreeBSD__
+cString WeekDayNameFullReal(int WeekDay);
+#else
cString WeekDayNameFull(int WeekDay);
+#endif
///< Converts the given WeekDay (0=Sunday, 1=Monday, ...) to a full
///< day name.
cString WeekDayNameFull(time_t t);
Index: vdr.c
--- vdr.c
+++ vdr.c
@@ -32,8 +32,13 @@
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
+#ifndef __FreeBSD__
#include <sys/capability.h>
#include <sys/prctl.h>
+#else
+#include <sys/types.h>
+#include <login_cap.h>
+#endif
#include <termios.h>
#include <unistd.h>
#include "audio.h"
@@ -107,12 +112,15 @@ static bool SetUser(const char *UserName
fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno));
return false;
}
+#ifndef __FreeBSD__
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;
}
+#ifndef __FreeBSD__
static bool DropCaps(void)
{
// drop all capabilities except selected ones
@@ -139,6 +147,7 @@ static bool SetKeepCaps(bool On)
}
return true;
}
+#endif
static void SignalHandler(int signum)
{
@@ -400,14 +409,18 @@ int main(int argc, char *argv[])
if (VdrUser && geteuid() == 0) {
StartedAsRoot = true;
if (strcmp(VdrUser, "root")) {
+#ifndef __FreeBSD__
if (!SetKeepCaps(true))
return 2;
+#endif
if (!SetUser(VdrUser, UserDump))
return 2;
+#ifndef __FreeBSD__
if (!SetKeepCaps(false))
return 2;
if (!DropCaps())
return 2;
+#endif
}
}
@@ -556,6 +569,25 @@ int main(int argc, char *argv[])
CodeSet++; // skip the dot
}
}
+#ifdef __FreeBSD__
+ // If we are started without a locale query login.conf(5) for
+ // a lang setting
+
+ if (!CodeSet || !strcmp(CodeSet, "US-ASCII")) {
+ struct passwd *User = getpwnam(VdrUser);
+ login_cap_t *Lc = login_getuserclass(User);
+ if (!Lc)
+ Lc = login_getpwclass(User);
+ if (Lc) {
+ const char *Lang = login_getcapstr(Lc, "lang", NULL, NULL);
+ if (Lang && setlocale(LC_CTYPE, Lang)) {
+ CodeSet = nl_langinfo(CODESET);
+ setenv("LANG", Lang, 1);
+ }
+ login_close(Lc);
+ }
+ }
+#endif
if (CodeSet) {
bool known = SI::SetSystemCharacterTable(CodeSet);
isyslog("codeset is '%s' - %s", CodeSet, known ? "known" : "unknown");
Index: PLUGINS/src/svdrpdemo/svdrpdemo.c
===================================================================
RCS file: /progs/network/ccvs/vdr/PLUGINS/src/svdrpdemo/svdrpdemo.c,v
retrieving revision 1.1.1.2
retrieving revision 1.4
diff -u -r1.1.1.2 -r1.4
Index: libsi/headers.h
===================================================================
RCS file: /progs/network/ccvs/vdr/libsi/headers.h,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- libsi/headers.h 2010/02/17 10:14:45 1.1.1.2
+++ libsi/headers.h 2010/02/17 10:46:56 1.3
@@ -17,7 +17,11 @@
#ifndef LIBSI_HEADERS_H
#define LIBSI_HEADERS_H
+#ifdef __FreeBSD__
+#include <sys/endian.h>
+#else
#include <endian.h>
+#endif
namespace SI {
Index: libsi/si.c
===================================================================
RCS file: /progs/network/ccvs/vdr/libsi/si.c,v
retrieving revision 1.1.1.4
retrieving revision 1.7
diff -u -r1.1.1.4 -r1.7
--- libsi/si.c 2010/03/01 09:42:49 1.1.1.4
+++ libsi/si.c 2010/03/01 09:58:08 1.7
@@ -13,7 +13,9 @@
#include "si.h"
#include <errno.h>
#include <iconv.h>
+#ifndef __FreeBSD__
#include <malloc.h>
+#endif
#include <stdlib.h> // for broadcaster stupidity workaround
#include <string.h>
#include "descriptor.h"
--- PLUGINS/src/dvbsddevice/Makefile.orig
+++ PLUGINS/src/dvbsddevice/Makefile
@@ -45,7 +45,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -100,7 +100,11 @@ i18n: $(I18Nmsgs) $(I18Npot)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/hello/Makefile.orig
+++ PLUGINS/src/hello/Makefile
@@ -45,7 +45,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -100,7 +100,11 @@ i18n: $(I18Nmsgs)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/osddemo/Makefile.orig
+++ PLUGINS/src/osddemo/Makefile
@@ -43,7 +43,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -73,7 +73,11 @@ $(DEPFILE): Makefile
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/pictures/Makefile.orig
+++ PLUGINS/src/pictures/Makefile
@@ -45,7 +45,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -100,7 +100,11 @@ i18n: $(I18Nmsgs) $(I18Npot)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/servicedemo/Makefile.orig
+++ PLUGINS/src/servicedemo/Makefile
@@ -45,7 +45,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -75,11 +75,19 @@ $(DEPFILE): Makefile
libvdr-$(PLUGIN1).so: $(PLUGIN1).o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(PLUGIN1).o -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
libvdr-$(PLUGIN2).so: $(PLUGIN2).o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(PLUGIN2).o -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/skincurses/Makefile.orig
+++ PLUGINS/src/skincurses/Makefile
@@ -45,7 +45,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -100,7 +100,11 @@ i18n: $(I18Nmsgs) $(I18Npot)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -lncursesw -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/status/Makefile.orig
+++ PLUGINS/src/status/Makefile
@@ -43,7 +43,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -73,7 +73,11 @@ $(DEPFILE): Makefile
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/svdrpdemo/Makefile.orig
+++ PLUGINS/src/svdrpdemo/Makefile
@@ -43,7 +43,7 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
-INCLUDES += -I$(VDRDIR)/include
+INCLUDES = -I$(VDRDIR)/include -I${LOCALBASE}/include
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
@@ -73,7 +73,11 @@ $(DEPFILE): Makefile
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
- @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
+ @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/epgtableid0/Makefile.orig
+++ PLUGINS/src/epgtableid0/Makefile
@@ -100,7 +100,11 @@ i18n: $(I18Nmsgs) $(I18Npot)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
--- PLUGINS/src/rcu/Makefile.orig
+++ PLUGINS/src/rcu/Makefile
@@ -100,7 +100,11 @@ i18n: $(I18Nmsgs) $(I18Npot)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)