aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--Makefile.in14
-rw-r--r--plugin.c20
-rw-r--r--plugin_time.c79
4 files changed, 102 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am
index 0f26e5a..84710b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,9 +37,10 @@ widget_bar.c widget_bar.h \
widget_icon.c widget_icon.h \
\
plugin.c plugin.h \
+plugin_cfg.c \
plugin_math.c \
plugin_string.c \
-plugin_cfg.c
+plugin_time.c
#liblcd4linux_la_DEPENDENCIES = @DRIVERS@
#liblcd4linux_la_LDFLAGS = -version-info 9:12:9
diff --git a/Makefile.in b/Makefile.in
index d9de5e3..f95b582 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -92,7 +92,7 @@ lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@
#remove next line for liblcd4linux
lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@
-lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h lock.c lock.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c
+lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h lock.c lock.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h plugin.c plugin.h plugin_cfg.c plugin_math.c plugin_string.c plugin_time.c
#liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -123,8 +123,8 @@ X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
lcd4linux_OBJECTS = lcd4linux.o cfg.o debug.o drv.o evaluator.o hash.o \
layout.o lock.o pid.o timer.o thread.o udelay.o qprintf.o widget.o \
-widget_text.o widget_bar.o widget_icon.o plugin.o plugin_math.o \
-plugin_string.o plugin_cfg.o
+widget_text.o widget_bar.o widget_icon.o plugin.o plugin_cfg.o \
+plugin_math.o plugin_string.o plugin_time.o
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
@@ -153,10 +153,10 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/MilfordInstruments.P \
.deps/plugin_loadavg.P .deps/plugin_math.P .deps/plugin_meminfo.P \
.deps/plugin_mysql.P .deps/plugin_netdev.P .deps/plugin_pop3.P \
.deps/plugin_ppp.P .deps/plugin_proc_stat.P .deps/plugin_seti.P \
-.deps/plugin_string.P .deps/plugin_uname.P .deps/plugin_wireless.P \
-.deps/plugin_xmms.P .deps/qprintf.P .deps/thread.P .deps/timer.P \
-.deps/udelay.P .deps/widget.P .deps/widget_bar.P .deps/widget_icon.P \
-.deps/widget_text.P
+.deps/plugin_string.P .deps/plugin_time.P .deps/plugin_uname.P \
+.deps/plugin_wireless.P .deps/plugin_xmms.P .deps/qprintf.P \
+.deps/thread.P .deps/timer.P .deps/udelay.P .deps/widget.P \
+.deps/widget_bar.P .deps/widget_icon.P .deps/widget_text.P
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
diff --git a/plugin.c b/plugin.c
index 4a0e92c..5e2a58e 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.28 2004/04/12 11:12:26 reinelt Exp $
+/* $Id: plugin.c,v 1.29 2004/05/20 07:47:51 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -22,6 +22,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.29 2004/05/20 07:47:51 reinelt
+ * added plugin_time
+ *
* Revision 1.28 2004/04/12 11:12:26 reinelt
* added plugin_isdn, removed old ISDN client
* fixed some real bad bugs in the evaluator
@@ -165,12 +168,14 @@
// Prototypes
+int plugin_init_cfg (void);
+void plugin_exit_cfg (void);
int plugin_init_math (void);
void plugin_exit_math (void);
int plugin_init_string (void);
void plugin_exit_string (void);
-int plugin_init_cfg (void);
-void plugin_exit_cfg (void);
+int plugin_init_time (void);
+void plugin_exit_time (void);
int plugin_init_apm (void);
void plugin_exit_apm (void);
@@ -212,9 +217,10 @@ void plugin_exit_xmms (void);
int plugin_init (void)
{
+ plugin_init_cfg();
plugin_init_math();
plugin_init_string();
- plugin_init_cfg();
+ plugin_init_time();
#ifdef PLUGIN_APM
plugin_init_apm();
@@ -270,9 +276,11 @@ int plugin_init (void)
#ifdef PLUGIN_XMMS
plugin_init_xmms();
#endif
+
return 0;
}
+
void plugin_exit(void) {
#ifdef PLUGIN_APM
plugin_exit_apm();
@@ -330,9 +338,9 @@ void plugin_exit(void) {
#endif
plugin_exit_cfg();
- plugin_exit_string();
plugin_exit_math();
-
+ plugin_exit_string();
+ plugin_exit_time();
DeleteFunctions();
DeleteVariables();
diff --git a/plugin_time.c b/plugin_time.c
new file mode 100644
index 0000000..4cd0338
--- /dev/null
+++ b/plugin_time.c
@@ -0,0 +1,79 @@
+/* $Id: plugin_time.c,v 1.1 2004/05/20 07:47:51 reinelt Exp $
+ *
+ * time plugin
+ *
+ * Copyright 2003,2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * This file is part of LCD4Linux.
+ *
+ * LCD4Linux is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * LCD4Linux 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * $Log: plugin_time.c,v $
+ * Revision 1.1 2004/05/20 07:47:51 reinelt
+ * added plugin_time
+ *
+ */
+
+/*
+ * exported functions:
+ *
+ * int plugin_init_time (void)
+ * adds some handy time functions
+ *
+ */
+
+
+#include "config.h"
+
+#include <time.h>
+
+#include "debug.h"
+#include "plugin.h"
+
+
+static void my_time (RESULT *result)
+{
+ double value = time(NULL);
+ SetResult(&result, R_NUMBER, &value);
+}
+
+
+static void my_strftime (RESULT *result, RESULT *arg1, RESULT *arg2)
+{
+ char value[256];
+ time_t t = R2N(arg2);
+
+ value[0] = '\0';
+ strftime(value, sizeof(value), R2S(arg1), localtime(&t));
+
+ SetResult(&result, R_STRING, value);
+}
+
+
+int plugin_init_time (void)
+{
+
+ // register some basic time functions
+ AddFunction ("time", 0, my_time);
+ AddFunction ("strftime", 2, my_strftime);
+
+ return 0;
+}
+
+void plugin_exit_time(void)
+{
+}