summaryrefslogtreecommitdiffstats
path: root/lib/libdvbmisc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/libdvbmisc/dvbmisc.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/libdvbmisc/dvbmisc.h b/lib/libdvbmisc/dvbmisc.h
new file mode 100644
index 0000000..8ac6eee
--- /dev/null
+++ b/lib/libdvbmisc/dvbmisc.h
@@ -0,0 +1,72 @@
+/*
+ libdvbmisc - DVB miscellaneous library
+
+ Copyright (C) 2005 Manu Abraham <abraham.manu@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+*/
+
+#ifndef DVB_MISC_H
+#define DVB_MISC_H
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#define ERROR 0
+#define NOTICE 1
+#define INFO 2
+#define DEBUG 3
+
+#define print(x, y, z, fmt, arg...) do { \
+ if (z) { \
+ if ((x > ERROR) && (x > y)) \
+ vprint("%s: " fmt "\n", __func__ , ##arg); \
+ else if ((x > NOTICE) && (x > y)) \
+ vprint("%s: " fmt "\n",__func__ , ##arg); \
+ else if ((x > INFO) && (x > y)) \
+ vprint("%s: " fmt "\n", __func__ , ##arg); \
+ else if ((x > DEBUG) && (x > y)) \
+ vprint("%s: " fmt "\n", __func__ , ##arg); \
+ } else { \
+ if (x > y) \
+ vprint(fmt, ##arg); \
+ } \
+} while(0)
+
+static inline void vprint(char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+}
+
+static inline int time_after(struct timeval oldtime, uint32_t delta_ms)
+{
+ // calculate the oldtime + add on the delta
+ uint64_t oldtime_ms = (oldtime.tv_sec * 1000) + (oldtime.tv_usec / 1000);
+ oldtime_ms += delta_ms;
+
+ // calculate the nowtime
+ struct timeval nowtime;
+ gettimeofday(&nowtime, 0);
+ uint64_t nowtime_ms = (nowtime.tv_sec * 1000) + (nowtime.tv_usec / 1000);
+
+ // check
+ return nowtime_ms > oldtime_ms;
+}
+
+#endif
ChangeLog git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@238 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-10[lcd4linux @ 2003-09-10 14:01:52 by reinelt]reinelt6-21/+110 icons nearly finished\! git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@237 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-10[lcd4linux @ 2003-09-10 08:37:09 by reinelt]reinelt2-50/+73 icons: reorganized tick_* again... git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@236 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-10[lcd4linux @ 2003-09-10 03:48:22 by reinelt]reinelt7-47/+130 Icons for M50530, new processing scheme (Ticks.Text...) git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@235 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-09[lcd4linux @ 2003-09-09 11:47:47 by reinelt]reinelt3-14/+37 basic icon support for HD44780 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@234 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-09[lcd4linux @ 2003-09-09 06:54:43 by reinelt]reinelt15-135/+177 new function 'cfg_number()' git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@233 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-09[lcd4linux @ 2003-09-09 05:30:33 by reinelt]reinelt11-90/+243 even more icons stuff git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@232 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-01[lcd4linux @ 2003-09-01 07:07:03 by reinelt]reinelt8-402/+13825 shared liblcd4linux git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@231 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-09-01[lcd4linux @ 2003-09-01 04:09:34 by reinelt]reinelt9-28/+127 icons nearly finished, but MatrixOrbital only git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@230 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-24[lcd4linux @ 2003-08-24 05:28:31 by reinelt]reinelt1-119/+156 ChangeLog git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@229 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-24[lcd4linux @ 2003-08-24 05:17:58 by reinelt]reinelt25-131/+217 liblcd4linux patch from Patrick Schemitz git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@228 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-24[lcd4linux @ 2003-08-24 04:31:56 by reinelt]reinelt6-11/+154 icon.c icon.h added git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@227 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-22[lcd4linux @ 2003-08-22 03:45:08 by reinelt]reinelt3-8/+25 bug in parallel port code fixed, more icons stuff git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@226 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-20[lcd4linux @ 2003-08-20 05:26:43 by reinelt]reinelt1-9/+11 small bug in bar compaction fixed git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@225 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-19[lcd4linux @ 2003-08-19 05:23:55 by reinelt]reinelt2-62/+123 HD44780 dual-controller patch from Jesse Brook Kovach git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@224 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-19[lcd4linux @ 2003-08-19 04:28:41 by reinelt]reinelt4-19/+42 more Icon stuff, minor glitches fixed git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@223 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-17[lcd4linux @ 2003-08-17 16:37:39 by reinelt]reinelt5-23/+77 more icon framework git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@222 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-17[lcd4linux @ 2003-08-17 12:11:58 by reinelt]reinelt6-27/+118 framework for icons prepared git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@221 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-17[lcd4linux @ 2003-08-17 08:25:30 by reinelt]reinelt6-46/+185 preparations for liblcd4linux; minor bugs in SIN.c and Skeleton.c git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@220 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2003-08-17[lcd4linux @ 2003-08-17 06:57:04 by reinelt]reinelt5-544/+325 complete rewrite of the Crystalfontz driver git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@219 3ae390bd-cb1e-0410-b409-cd5a39f66f1f