summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2012-11-28 09:17:32 +0100
committerhorchi <vdr@jwendel.de>2012-11-28 09:17:32 +0100
commit0197b5c98cdeec3740644655963e1f100d73998e (patch)
tree029168cfc6a31cb3bb6309f2b8ae577302307d8d /common.c
downloadvdr-plugin-seduatmo-0197b5c98cdeec3740644655963e1f100d73998e.tar.gz
vdr-plugin-seduatmo-0197b5c98cdeec3740644655963e1f100d73998e.tar.bz2
initial Release of vdr-plugin-seduatmo
Diffstat (limited to 'common.c')
-rw-r--r--common.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/common.c b/common.c
new file mode 100644
index 0000000..524e614
--- /dev/null
+++ b/common.c
@@ -0,0 +1,80 @@
+/*
+ * common.c: EPG2VDR plugin for the Video Disk Recorder
+ *
+ * See the README file for copyright information and how to reach the author.
+ *
+ */
+
+#include <sys/time.h>
+#include <stdarg.h>
+#include <string.h>
+#include <syslog.h>
+
+#include <vdr/thread.h>
+
+#include "common.h"
+#include "config.h"
+
+cMutex logMutex;
+
+//***************************************************************************
+// Tell
+//***************************************************************************
+
+void tell(int eloquence, const char* format, ...)
+{
+ if (cfg.loglevel < eloquence)
+ return ;
+
+ const int sizeBuffer = 100000;
+ char t[sizeBuffer+100]; *t = 0;
+ va_list ap;
+
+ cMutexLock lock(&logMutex);
+
+ va_start(ap, format);
+
+ snprintf(t, sizeBuffer, "SEDUATMO: ");
+ vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap);
+
+ syslog(LOG_ERR, "%s", t);
+
+ va_end(ap);
+}
+
+//***************************************************************************
+// Error
+//***************************************************************************
+
+int error(const char* format, ...)
+{
+ const int sizeBuffer = 100000;
+ char t[sizeBuffer+100]; *t = 0;
+ va_list ap;
+
+ cMutexLock lock(&logMutex);
+
+ va_start(ap, format);
+
+ snprintf(t, sizeBuffer, "SEDUATMO: ");
+ vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap);
+
+ syslog(LOG_ERR, "%s", t);
+
+ va_end(ap);
+
+ return fail;
+}
+
+//***************************************************************************
+// msNow
+//***************************************************************************
+
+MsTime msNow()
+{
+ timeval tv;
+
+ gettimeofday(&tv, 0);
+
+ return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+}