parser.c parser.h \
processor.c processor.h \
evaluator.c evaluator.h \
-expression.c expression.h \
+client.c client.h \
system.c system.h \
isdn.c isdn.h \
mail.c mail.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 expression.c expression.h system.c system.h isdn.c isdn.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
+lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h evaluator.c evaluator.h client.c client.h system.c system.h isdn.c isdn.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
liblcd4linux_la_DEPENDENCIES = @DRIVERS@
PROGRAMS = $(bin_PROGRAMS)
lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) pid.$(OBJEXT) parser.$(OBJEXT) \
-processor.$(OBJEXT) evaluator.$(OBJEXT) expression.$(OBJEXT) \
+processor.$(OBJEXT) evaluator.$(OBJEXT) client.$(OBJEXT) \
system.$(OBJEXT) isdn.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) \
battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) widget.$(OBJEXT) \
exec.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT)
.deps/HD44780.P .deps/M50530.P .deps/MatrixOrbital.P \
.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/expression.P .deps/filter.P .deps/fontmap.P .deps/icon.P \
-.deps/isdn.P .deps/lcd4linux.P .deps/lock.P .deps/mail.P .deps/mail2.P \
+.deps/XWindow.P .deps/bar.P .deps/battery.P .deps/cfg.P .deps/client.P \
+.deps/debug.P .deps/display.P .deps/dvb.P .deps/evaluator.P \
+.deps/exec.P .deps/filter.P .deps/fontmap.P .deps/icon.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/processor.P .deps/seti.P .deps/socket.P .deps/system.P \
.deps/udelay.P .deps/widget.P
-/* $Id: cfg.c,v 1.17 2003/10/05 17:58:50 reinelt Exp $^
+/* $Id: cfg.c,v 1.18 2003/10/11 06:01:52 reinelt Exp $^
*
* config file stuff
*
*
*
* $Log: cfg.c,v $
+ * Revision 1.18 2003/10/11 06:01:52 reinelt
+ *
+ * renamed expression.{c,h} to client.{c,h}
+ * added config file client
+ * new functions 'AddNumericVariable()' and 'AddStringVariable()'
+ * new parameter '-i' for interactive mode
+ *
* Revision 1.17 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
#include "debug.h"
#include "cfg.h"
-
+#include "client.h"
typedef struct {
char *key;
}
+static void cfg_client (RESULT *result, RESULT *arg1)
+{
+ char *value=cfg_get(R2S(arg1), "");
+ SetResult(&result, R_STRING, value);
+}
+
+
int l4l_cfg_init (char *file)
{
FILE *stream;
cfg_add (line, p, 0);
}
fclose (stream);
+
+ // register as a client
+ AddFunction ("cfg", 1, cfg_client);
+
return 0;
}
--- /dev/null
+/* $Id: client.c,v 1.1 2003/10/11 06:01:52 reinelt Exp $
+ *
+ * client function handling
+ *
+ * Copyright 2003 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: client.c,v $
+ * Revision 1.1 2003/10/11 06:01:52 reinelt
+ *
+ * renamed expression.{c,h} to client.{c,h}
+ * added config file client
+ * new functions 'AddNumericVariable()' and 'AddStringVariable()'
+ * new parameter '-i' for interactive mode
+ *
+ * Revision 1.3 2003/10/06 05:51:15 reinelt
+ * functions: min(), max()
+ *
+ * Revision 1.2 2003/10/06 05:47:27 reinelt
+ * operators: ==, \!=, <=, >=
+ *
+ * Revision 1.1 2003/10/06 04:34:06 reinelt
+ * expression evaluator added
+ *
+ */
+
+/*
+ * exported functions:
+ *
+ * int Client_init (void)
+ * initializes the expression evaluator
+ * adds some handy constants and functions
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#include "debug.h"
+#include "client.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 client_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);
+
+ // min, max
+ AddFunction ("min", 2, my_min);
+ AddFunction ("max", 2, my_max);
+
+ // register some basic string functions
+ AddFunction ("strlen", 1, my_strlen);
+
+
+ return 0;
+}
+
+
--- /dev/null
+/* $Id: client.h,v 1.1 2003/10/11 06:01:52 reinelt Exp $
+ *
+ * client function handling
+ *
+ * Copyright 2003 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: client.h,v $
+ * Revision 1.1 2003/10/11 06:01:52 reinelt
+ *
+ * renamed expression.{c,h} to client.{c,h}
+ * added config file client
+ * new functions 'AddNumericVariable()' and 'AddStringVariable()'
+ * new parameter '-i' for interactive mode
+ *
+ * Revision 1.1 2003/10/06 04:34:06 reinelt
+ * expression evaluator added
+ *
+ */
+
+
+#include "evaluator.h"
+
+#ifndef _CLIENT_H_
+#define _CLIENT_H_
+
+int client_init (void);
+
+#endif
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
-timestamp='2003-07-02'
+timestamp='2003-10-07'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
*:UNICOS/mp:*:*)
- echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
- *:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
+ *:FreeBSD:*:*)
# Determine whether the default compiler uses glibc.
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- # GNU/FreeBSD systems have a "k" prefix to indicate we are using
+ # GNU/KFreeBSD systems have a "k" prefix to indicate we are using
# FreeBSD's kernel, but not the complete OS.
case ${LIBC} in gnu) kernel_only='k' ;; esac
echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
+ # the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit 0 ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
LIBC=gnuaout
#endif
#endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
- NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
+ NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
-timestamp='2003-07-17'
+timestamp='2003-10-07'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- nto-qnx* | linux-gnu* | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ nto-qnx* | linux-gnu* | linux-dietlibc | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
+ | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-/* $Id: evaluator.c,v 1.2 2003/10/06 05:47:27 reinelt Exp $
+/* $Id: evaluator.c,v 1.3 2003/10/11 06:01:52 reinelt Exp $
*
* expression evaluation
*
* FIXME: GPL or not GPL????
*
* $Log: evaluator.c,v $
+ * Revision 1.3 2003/10/11 06:01:52 reinelt
+ *
+ * renamed expression.{c,h} to client.{c,h}
+ * added config file client
+ * new functions 'AddNumericVariable()' and 'AddStringVariable()'
+ * new parameter '-i' for interactive mode
+ *
* Revision 1.2 2003/10/06 05:47:27 reinelt
* operators: ==, \!=, <=, >=
*
/*
* exported functions:
*
- * int AddConstant (char *name, double value)
+ * int AddNumericVariable(char *name, double value)
+ * adds a numerical variable to the evaluator
+ *
+ * int AddStringVariable(char *name, char *value)
* adds a numerical variable to the evaluator
*
* int AddFunction (char *name, int args, void (*func)())
}
-int AddConstant (char *name, double value)
-{
- RESULT result;
-
- result.type=R_NUMBER;
- result.number=value;
- result.string=NULL;
-
- return SetVariable (name, &result);
-}
-
-
// bsearch compare function for functions
static int f_lookup (const void *a, const void *b)
{
}
-int AddFunction (char *name, int args, void (*func)())
-{
- FUNCTION *F;
-
- F=bsearch(name, Function, nFunction, sizeof(FUNCTION), f_lookup);
- if (F!=NULL) {
- if (F->name) free (F->name);
- F->name=strdup(name);
- F->args=args;
- F->func=func;
- return 1;
- }
-
- // Fixme: we append the func at the end and re-sort
- // the whole array! This should be optimized...
- nFunction++;
- Function=realloc(Function, nFunction*sizeof(FUNCTION));
- Function[nFunction-1].name=strdup(name);
- Function[nFunction-1].args=args;
- Function[nFunction-1].func=func;
- qsort(Function, nFunction, sizeof(FUNCTION), f_sort);
-
- return 0;
-}
-
-
-
// Prototypes
static void Level01 (RESULT *result);
static void Level02 (RESULT *result);
}
+int AddNumericVariable (char *name, double value)
+{
+ RESULT result;
+
+ result.type=R_NUMBER;
+ result.number=value;
+ result.string=NULL;
+
+ return SetVariable (name, &result);
+}
+
+
+int AddStringVariable (char *name, char *value)
+{
+ RESULT result;
+
+ result.type=R_STRING;
+ result.number=0.0;
+ result.string=strdup(value);
+
+ return SetVariable (name, &result);
+}
+
+
+int AddFunction (char *name, int args, void (*func)())
+{
+ FUNCTION *F;
+
+ F=bsearch(name, Function, nFunction, sizeof(FUNCTION), f_lookup);
+ if (F!=NULL) {
+ if (F->name) free (F->name);
+ F->name=strdup(name);
+ F->args=args;
+ F->func=func;
+ return 1;
+ }
+
+ // Fixme: we append the func at the end and re-sort
+ // the whole array! This should be optimized...
+ nFunction++;
+ Function=realloc(Function, nFunction*sizeof(FUNCTION));
+ Function[nFunction-1].name=strdup(name);
+ Function[nFunction-1].args=args;
+ Function[nFunction-1].func=func;
+ qsort(Function, nFunction, sizeof(FUNCTION), f_sort);
+
+ return 0;
+}
+
+
int Eval (char* expression, RESULT *result)
{
int err;
if (*Token!='\0') ERROR (E_SYNTAX);
return 0;
}
-
-
-/* $Id: evaluator.h,v 1.1 2003/10/06 04:34:06 reinelt Exp $
+/* $Id: evaluator.h,v 1.2 2003/10/11 06:01:53 reinelt Exp $
*
* expression evaluation
*
* FIXME: GPL or not GPL????
*
* $Log: evaluator.h,v $
+ * Revision 1.2 2003/10/11 06:01:53 reinelt
+ *
+ * renamed expression.{c,h} to client.{c,h}
+ * added config file client
+ * new functions 'AddNumericVariable()' and 'AddStringVariable()'
+ * new parameter '-i' for interactive mode
+ *
* Revision 1.1 2003/10/06 04:34:06 reinelt
* expression evaluator added
*
#define E_EMPTY 8 /* Empty expression */
-int AddConstant (char *name, double value);
-int AddFunction (char *name, int args, void (*func)());
+int AddNumericVariable (char *name, double value);
+int AddStringVariable (char *name, char *value);
+int AddFunction (char *name, int args, void (*func)());
RESULT* SetResult (RESULT **result, int type, void *value);
+++ /dev/null
-/* $Id: expression.c,v 1.3 2003/10/06 05:51:15 reinelt Exp $
- *
- * expression handling
- *
- * Copyright 2003 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: expression.c,v $
- * Revision 1.3 2003/10/06 05:51:15 reinelt
- * functions: min(), max()
- *
- * Revision 1.2 2003/10/06 05:47:27 reinelt
- * operators: ==, \!=, <=, >=
- *
- * Revision 1.1 2003/10/06 04:34:06 reinelt
- * expression evaluator added
- *
- */
-
-/*
- * exported functions:
- *
- * int EX_init (void)
- * initializes the expression evaluator
- * adds some handy constants and functions
- *
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-
-#include "debug.h"
-#include "cfg.h"
-#include "evaluator.h"
-#include "expression.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);
-}
-
-
-static void my_cfg (RESULT *result, RESULT *arg1)
-{
- char *value=cfg_get(R2S(arg1), "");
- SetResult(&result, R_STRING, value);
-}
-
-
-int EX_init (void)
-{
- // set some handy constants
- AddConstant ("Pi", M_PI);
- AddConstant ("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);
-
- // min, max
- AddFunction ("min", 2, my_min);
- AddFunction ("max", 2, my_max);
-
- // register some basic string functions
- AddFunction ("strlen", 1, my_strlen);
-
- // config file access
- AddFunction ("cfg", 1, my_cfg);
-
-
- return 0;
-}
-
-
-int EX_test(int argc, char* argv[])
-{
- int ec;
- char line[1024];
- RESULT result = {0, 0.0, NULL};
-
- printf("\nEE> ");
- for(gets(line); !feof(stdin); gets(line)) {
- ec=Eval(line, &result);
- if (result.type==R_NUMBER) {
- printf ("%g\n", R2N(&result));
- } else if (result.type==R_STRING) {
- printf ("<%s>\n", R2S(&result));
- }
- printf("EE> ");
- }
-
- return 0;
-}
+++ /dev/null
-/* $Id: expression.h,v 1.1 2003/10/06 04:34:06 reinelt Exp $
- *
- * expression handling
- *
- * Copyright 2003 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: expression.h,v $
- * Revision 1.1 2003/10/06 04:34:06 reinelt
- * expression evaluator added
- *
- */
-
-
-#ifndef _EXPRESSION_H_
-#define _EXPRESSION_H_
-
-int EX_init (void);
-
-#endif
-/* $Id: lcd4linux.c,v 1.48 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.49 2003/10/11 06:01:53 reinelt Exp $
*
* LCD4Linux
*
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.49 2003/10/11 06:01:53 reinelt
+ *
+ * renamed expression.{c,h} to client.{c,h}
+ * added config file client
+ * new functions 'AddNumericVariable()' and 'AddStringVariable()'
+ * new parameter '-i' for interactive mode
+ *
* Revision 1.48 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
#include "udelay.h"
#include "display.h"
#include "processor.h"
+#include "client.h"
#define PIDFILE "/var/run/lcd4linux.pid"
int tick, tack;
extern char* output;
+
static void usage(void)
{
printf ("%s\n", release);
#ifdef USE_OLD_UDELAY
printf (" lcd4linux [-d]\n");
#endif
+ printf (" lcd4linux [-c key=value] [-i] [-f config-file] [-v]\n");
printf (" lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n");
}
+
int hello (void)
{
int i, x, y, flag;
return flag;
}
+
#ifdef USE_OLD_UDELAY
void calibrate (void)
{
}
#endif
+
void handler (int signal)
{
debug ("got signal %d", signal);
got_signal=signal;
}
+
int main (int argc, char *argv[])
{
char *cfg="/etc/lcd4linux.conf";
char *driver;
int c;
int quiet=0;
+ int interactive=0;
// save arguments for restart
my_argv=malloc(sizeof(char*)*(argc+1));
running_foreground=0;
running_background=0;
-
+
#ifdef USE_OLD_UDELAY
- while ((c=getopt (argc, argv, "c:dFf:hlo:qv"))!=EOF) {
+ while ((c=getopt (argc, argv, "c:dFf:hilo:qv"))!=EOF) {
#else
- while ((c=getopt (argc, argv, "c:dFf:hlo:qv"))!=EOF) {
+ while ((c=getopt (argc, argv, "c:dFf:hilo:qv"))!=EOF) {
#endif
switch (c) {
case 'c':
case 'h':
usage();
exit(0);
+ case 'i':
+ interactive++;
+ break;
case 'l':
printf ("%s\n", release);
lcd_list();
exit(2);
}
+ // do not fork in interactive mode
+ if (interactive) {
+ running_foreground=1;
+ }
+
info ("Version " VERSION " starting");
if (!running_foreground && (my_argv[0]==NULL || my_argv[0][0]!='/')) {
info ("invoked without full path; restart may not work!");
}
- if (cfg_init (cfg)==-1)
+ if (client_init()==-1)
exit (1);
- // Fixme:
- EX_init();
- EX_test();
+ if (cfg_init(cfg)==-1)
+ exit (1);
driver=cfg_get("display",NULL);
if (driver==NULL || *driver=='\0') {
signal(SIGQUIT, handler);
signal(SIGTERM, handler);
-
// process_init sets global vars tick, tack
process_init();
- lcd_clear(1);
+
+ // maybe go into interactive mode
+ if (interactive) {
+ char line[1024];
+ RESULT result = {0, 0.0, NULL};
+
+ printf("\neval> ");
+ for(fgets(line, 1024, stdin); !feof(stdin); fgets(line, 1024, stdin)) {
+ if (line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
+ Eval(line, &result);
+ if (result.type==R_NUMBER) {
+ printf ("%g\n", R2N(&result));
+ } else if (result.type==R_STRING) {
+ printf ("'%s'\n", R2S(&result));
+ }
+ printf("eval> ");
+ }
+ printf ("\n");
+ lcd_clear(1);
+ lcd_quit();
+ pid_exit(PIDFILE);
+ exit (0);
+ }
if (!quiet && hello()) {
sleep (3);