aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <>2003-12-19 05:49:23 +0000
committerreinelt <>2003-12-19 05:49:23 +0000
commite107a9b0e8241de1e0f7392a60b8a74272665245 (patch)
tree087cfb9b126c466979bfa703975d3084b528e1b1
parent8f59bbc584905f461dc4d628e7347839612b3fcf (diff)
downloadlcd4linux-e107a9b0e8241de1e0f7392a60b8a74272665245.tar.gz
[lcd4linux @ 2003-12-19 05:49:23 by reinelt]
extracted plugin_math and plugin_string into extra files
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in15
-rw-r--r--plugin.c96
3 files changed, 19 insertions, 94 deletions
diff --git a/Makefile.am b/Makefile.am
index 733f526..42e82ce 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,8 @@ parser.c parser.h \
processor.c processor.h \
evaluator.c evaluator.h \
plugin.c plugin.h \
+plugin_math.c \
+plugin_string.c \
system.c system.h \
isdn.c isdn.h \
wifi.c wifi.h \
diff --git a/Makefile.in b/Makefile.in
index 265e687..25c32fb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -101,7 +101,7 @@ AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall
lcd4linux_LDFLAGS = $(X_LIBS)
lcd4linux_LDADD = liblcd4linux.la @DRVLIBS@
-lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h evaluator.c evaluator.h plugin.c plugin.h system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h widget.c widget.h exec.c exec.h mail2.c socket.c socket.h imon.c imon.h
+lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h evaluator.c evaluator.h plugin.c plugin.h plugin_math.c plugin_string.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h widget.c widget.h exec.c exec.h mail2.c socket.c socket.h imon.c imon.h
liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -138,10 +138,10 @@ PROGRAMS = $(bin_PROGRAMS)
lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) pid.$(OBJEXT) parser.$(OBJEXT) \
processor.$(OBJEXT) evaluator.$(OBJEXT) plugin.$(OBJEXT) \
-system.$(OBJEXT) isdn.$(OBJEXT) wifi.$(OBJEXT) mail.$(OBJEXT) \
-seti.$(OBJEXT) battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) \
-widget.$(OBJEXT) exec.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT) \
-imon.$(OBJEXT)
+plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) system.$(OBJEXT) \
+isdn.$(OBJEXT) wifi.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) \
+battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) widget.$(OBJEXT) \
+exec.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT) imon.$(OBJEXT)
lcd4linux_DEPENDENCIES = liblcd4linux.la
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -167,8 +167,9 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \
.deps/filter.P .deps/fontmap.P .deps/icon.P .deps/imon.P .deps/isdn.P \
.deps/lcd4linux.P .deps/lock.P .deps/mail.P .deps/mail2.P \
.deps/parport.P .deps/parser.P .deps/pid.P .deps/pixmap.P \
-.deps/plugin.P .deps/processor.P .deps/seti.P .deps/socket.P \
-.deps/system.P .deps/udelay.P .deps/widget.P .deps/wifi.P
+.deps/plugin.P .deps/plugin_math.P .deps/plugin_string.P \
+.deps/processor.P .deps/seti.P .deps/socket.P .deps/system.P \
+.deps/udelay.P .deps/widget.P .deps/wifi.P
SOURCES = $(liblcd4linux_la_SOURCES) $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(liblcd4linux_la_OBJECTS) $(lcd4linux_OBJECTS)
diff --git a/plugin.c b/plugin.c
index d34d1cb..5ff0596 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.1 2003/12/19 05:35:14 reinelt Exp $
+/* $Id: plugin.c,v 1.2 2003/12/19 05:49:23 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -22,6 +22,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.2 2003/12/19 05:49:23 reinelt
+ * extracted plugin_math and plugin_string into extra files
+ *
* Revision 1.1 2003/12/19 05:35:14 reinelt
* renamed 'client' to 'plugin'
*
@@ -55,103 +58,22 @@
#include <stdlib.h>
#include <stdio.h>
-#include <math.h>
#include <string.h>
#include "debug.h"
#include "plugin.h"
-
-static void my_sqrt (RESULT *result, RESULT *arg1)
-{
- double value=sqrt(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_exp (RESULT *result, RESULT *arg1)
-{
- double value=exp(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_ln (RESULT *result, RESULT *arg1)
-{
- double value=log(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_log (RESULT *result, RESULT *arg1)
-{
- double value=log10(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_sin (RESULT *result, RESULT *arg1)
-{
- double value=sin(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_cos (RESULT *result, RESULT *arg1)
-{
- double value=cos(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_tan (RESULT *result, RESULT *arg1)
-{
- double value=tan(R2N(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
-
-
-static void my_min (RESULT *result, RESULT *arg1, RESULT *arg2)
-{
- double a1=R2N(arg1);
- double a2=R2N(arg2);
- double value=a1<a2?a1:a2;
- SetResult(&result, R_NUMBER, &value);
-}
-
-static void my_max (RESULT *result, RESULT *arg1, RESULT *arg2)
-{
- double a1=R2N(arg1);
- double a2=R2N(arg2);
- double value=a1>a2?a1:a2;
- SetResult(&result, R_NUMBER, &value);
-}
-
-
-static void my_strlen (RESULT *result, RESULT *arg1)
-{
- double value=strlen(R2S(arg1));
- SetResult(&result, R_NUMBER, &value);
-}
+int plugin_init_math (void);
+int plugin_init_string (void);
int plugin_init (void)
{
- // set some handy constants
- AddNumericVariable ("Pi", M_PI);
- AddNumericVariable ("e", M_E);
-
- // register some basic math functions
- AddFunction ("sqrt", 1, my_sqrt);
- AddFunction ("exp", 1, my_exp);
- AddFunction ("ln", 1, my_ln);
- AddFunction ("log", 1, my_log);
- AddFunction ("sin", 1, my_sin);
- AddFunction ("cos", 1, my_cos);
- AddFunction ("tan", 1, my_tan);
+ // math plugin
+ plugin_init_math();
+ plugin_init_string();
- // min, max
- AddFunction ("min", 2, my_min);
- AddFunction ("max", 2, my_max);
-
- // register some basic string functions
- AddFunction ("strlen", 1, my_strlen);
-
return 0;
}