summaryrefslogtreecommitdiff
path: root/graphtft-fe/common.cc
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2017-03-05 16:47:41 +0100
committerhorchi <vdr@jwendel.de>2017-03-05 16:47:41 +0100
commit22ffee20bbacbc3378e4ba0df5b7f0c3daaeffc0 (patch)
treede46c945c62d43d1febb027b5bfa075e58c5b69a /graphtft-fe/common.cc
downloadvdr-plugin-graphtftng-0.6.16.tar.gz
vdr-plugin-graphtftng-0.6.16.tar.bz2
Diffstat (limited to 'graphtft-fe/common.cc')
-rw-r--r--graphtft-fe/common.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/graphtft-fe/common.cc b/graphtft-fe/common.cc
new file mode 100644
index 0000000..0d60aad
--- /dev/null
+++ b/graphtft-fe/common.cc
@@ -0,0 +1,52 @@
+//***************************************************************************
+// Group VDR/GraphTFT
+// File common.cc
+// Date 04.11.06 - Jörg Wendel
+// This code is distributed under the terms and conditions of the
+// GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
+//***************************************************************************
+
+#include <sys/time.h>
+#include <stdarg.h>
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <graphtft.hpp>
+
+//***************************************************************************
+// Tell
+//***************************************************************************
+
+int tell(int eloquence, const char* format, ...)
+{
+ const int sizeTime = 8; // "12:12:34"
+ const int sizeMSec = 4; // ",142"
+ const int sizeHeader = sizeTime + sizeMSec + 1;
+ const int maxBuf = 1000;
+
+ struct timeval tp;
+ char buf[maxBuf];
+ va_list ap;
+ time_t now;
+
+ va_start(ap, format);
+
+ if (GraphTft::getEloquence() >= eloquence)
+ {
+ time(&now);
+ gettimeofday(&tp, 0);
+
+ vsnprintf(buf + sizeHeader, maxBuf - sizeHeader, format, ap);
+ strftime(buf, sizeTime+1, "%H:%M:%S", localtime(&now));
+
+ sprintf(buf+sizeTime, ",%3.3ld", tp.tv_usec / 1000);
+
+ buf[sizeHeader-1] = ' ';
+ printf("%s\n", buf);
+ }
+
+ va_end(ap);
+
+ return 0;
+}