filter.c filter.h \
widget.c widget.h \
exec.c exec.h \
+expr.c expr.h \
mail2.c \
socket.c socket.h \
imon.c imon.h
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 plugin_math.c plugin_string.c plugin_xmms.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
+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 plugin_xmms.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 expr.c expr.h mail2.c socket.c socket.h imon.c imon.h
liblcd4linux_la_DEPENDENCIES = @DRIVERS@
plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) plugin_xmms.$(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)
+widget.$(OBJEXT) exec.$(OBJEXT) expr.$(OBJEXT) mail2.$(OBJEXT) \
+socket.$(OBJEXT) imon.$(OBJEXT)
lcd4linux_DEPENDENCIES = liblcd4linux.la
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
.deps/MilfordInstruments.P .deps/PalmPilot.P .deps/Raster.P .deps/SIN.P \
.deps/Skeleton.P .deps/T6963.P .deps/Text.P .deps/USBLCD.P \
.deps/XWindow.P .deps/bar.P .deps/battery.P .deps/cfg.P .deps/debug.P \
-.deps/display.P .deps/dvb.P .deps/evaluator.P .deps/exec.P \
+.deps/display.P .deps/dvb.P .deps/evaluator.P .deps/exec.P .deps/expr.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 \
--- /dev/null
+/* $Id: expr.c,v 1.1 2004/01/05 11:57:38 reinelt Exp $
+ *
+ * expr ('y*') functions
+ * This is only a workaround to make the Evaluator usable until
+ * it's fully integrated into lcd4linux.
+ *
+ * Copyright 2004 Michael Reinelt <reinelt@eunet.at>
+ *
+ * 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: expr.c,v $
+ * Revision 1.1 2004/01/05 11:57:38 reinelt
+ * added %y tokens to make the Evaluator useable
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+#include <errno.h>
+#define IN_EXPR
+#include "expr.h"
+#include "plugin.h"
+#include "debug.h"
+#include "cfg.h"
+
+
+int Expr(int index, char result[EXPR_TXT_LEN], double *val)
+{
+ RESULT Result = {0, 0.0, NULL};
+ static int errs[EXPRS+1];
+ char *expression;
+ char yn[4];
+
+ if (index < 0 || index > EXPRS)
+ return -1;
+
+ if (errs[index])
+ return -1;
+
+ sprintf(yn, "y%d", index);
+ expression = cfg_get(yn,NULL);
+
+ if (!expression || !*expression) {
+ error("Empty expression for 'y%d'", index);
+ errs[index]++;
+ return -1;
+ }
+
+ Eval(expression, &Result);
+ strcpy(result, R2S(&Result));
+
+ debug("%s: <%s> = '%s'",yn, expression, result);
+
+ if (isdigit(*result)) {
+ double max, min;
+ *val = atof(result);
+ sprintf(yn, "Max_y%d", index);
+ max = atof(cfg_get(yn,"100"));
+ sprintf(yn, "Min_y%d", index);
+ min = atof(cfg_get(yn,"0"));
+ if (max != min)
+ *val = (*val - min)/(max - min);
+ }
+ return 0;
+}
+
--- /dev/null
+/* $Id: expr.h,v 1.1 2004/01/05 11:57:38 reinelt Exp $
+ *
+ * expr ('y*') functions
+ * This is only a workaround to make the Evaluator usable until
+ * it's fully integrated into lcd4linux.
+ *
+ * Copyright 2004 Michael Reinelt <reinelt@eunet.at>
+ *
+ * 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: expr.h,v $
+ * Revision 1.1 2004/01/05 11:57:38 reinelt
+ * added %y tokens to make the Evaluator useable
+ *
+ */
+
+#ifndef _EXPR_H
+#define _EXPR_H_
+
+#define EXPRS 9
+#define EXPR_TXT_LEN 256
+
+#ifdef IN_EXPR
+ #define EXTERN extern
+#else
+ #define EXTERN
+#endif
+
+EXTERN struct { char s[EXPR_TXT_LEN]; double val; } expr[EXPRS+1];
+
+int Expr (int index, char txt[EXPR_TXT_LEN], double *val);
+
+
+#endif
-/* $Id: parser.c,v 1.23 2003/11/11 04:40:20 reinelt Exp $
+/* $Id: parser.c,v 1.24 2004/01/05 11:57:38 reinelt Exp $
*
* row definition parser
*
*
*
* $Log: parser.c,v $
+ * Revision 1.24 2004/01/05 11:57:38 reinelt
+ * added %y tokens to make the Evaluator useable
+ *
* Revision 1.23 2003/11/11 04:40:20 reinelt
* WIFI patch from Xavier Vello
*
{ "u*", T_MAIL_UNSEEN,C_MAIL, 0 },
{ "s*", T_SENSOR, C_SENSOR, 1 },
{ "x*", T_EXEC, C_EXEC, 1 },
+ { "y*", T_EXPR, C_EXPR, 1 },
{ "jc", T_IMON_CPU, C_IMON, 1 },
{ "jv", T_IMON_VER, C_IMON, 0 },
{ "jd", T_IMON_DATE, C_IMON, 0 },
-/* $Id: parser.h,v 1.16 2003/11/11 04:40:20 reinelt Exp $
+/* $Id: parser.h,v 1.17 2004/01/05 11:57:38 reinelt Exp $
*
* row definition parser
*
*
*
* $Log: parser.h,v $
+ * Revision 1.17 2004/01/05 11:57:38 reinelt
+ * added %y tokens to make the Evaluator useable
+ *
* Revision 1.16 2003/11/11 04:40:20 reinelt
* WIFI patch from Xavier Vello
*
T_MAIL, T_MAIL_UNSEEN,
T_SENSOR,
T_EXEC,
+ T_EXPR,
T_IMON_CPU, T_IMON_VER, T_IMON_DATE, T_IMON_TIME, T_IMON_RIN, T_IMON_ROUT,
T_IMON_STATUS, T_IMON_PHONE, T_IMON_IP, T_IMON_OTIME, T_IMON_CHARGE,
T_TELMON_NUMBER, T_TELMON_MSN, T_TELMON_TIME, T_TELMON_DATE
typedef enum {
C_GENERIC, C_MEM, C_LOAD, C_CPU, C_DISK, C_ETH, C_PPP, C_ISDN, C_WIFI, C_SETI, C_BATT, C_DVB,
- C_MAIL, C_SENSOR, C_EXEC, C_IMON, C_TELMON
+ C_MAIL, C_SENSOR, C_EXEC, C_EXPR, C_IMON, C_TELMON
} CLASS;
char *parse_row (char *string, int supported_bars, int usage[]);
-/* $Id: processor.c,v 1.51 2003/11/24 11:34:54 reinelt Exp $
+/* $Id: processor.c,v 1.52 2004/01/05 11:57:38 reinelt Exp $
*
* main data processing
*
*
*
* $Log: processor.c,v $
+ * Revision 1.52 2004/01/05 11:57:38 reinelt
+ * added %y tokens to make the Evaluator useable
+ *
* Revision 1.51 2003/11/24 11:34:54 reinelt
*
* 'Fixed' Rows which do not scroll by Lars Kempe
#include "dvb.h"
#include "seti.h"
#include "exec.h"
+#include "expr.h"
#include "imon.h"
#define ROWS 64
case T_EXEC:
return exec[(token>>8)-'0'].val;
+ case T_EXPR:
+ return expr[(token>>8)-'0'].val;
+
case T_IMON_CPU:
return imon.cpu;
*p+=sprintf (*p, "%.*s",cols-(int)(*p-start), exec[i].s);
break;
+ case T_EXPR:
+ i = (token>>8)-'0';
+ *p+=sprintf (*p, "%.*s",cols-(int)(*p-start), expr[i].s);
+ break;
+
case T_IMON_VER:
*p+=sprintf (*p, "%s", ImonVer());
break;
}
}
+ for (i=0; i<=EXPRS; i++) {
+ if (token_usage[T_EXPR]&(1<<i)) {
+ Expr (i, expr[i].s, &exec[i].val);
+ }
+ }
+
}