diff options
author | reinelt <> | 2003-10-11 06:01:53 +0000 |
---|---|---|
committer | reinelt <> | 2003-10-11 06:01:53 +0000 |
commit | 23aa2f85a50e8f4d5c2010965709700bc23d2340 (patch) | |
tree | e02f046b82dcc8b29b3451189ec512bc0acef1f0 | |
parent | 34664450b1f0ea1292b9bc5f34c185600889ad54 (diff) | |
download | lcd4linux-23aa2f85a50e8f4d5c2010965709700bc23d2340.tar.gz |
[lcd4linux @ 2003-10-11 06:01:52 by reinelt]
renamed expression.{c,h} to client.{c,h}
added config file client
new functions 'AddNumericVariable()' and 'AddStringVariable()'
new parameter '-i' for interactive mode
Diffstat (limited to '')
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.in | 12 | ||||
-rw-r--r-- | cfg.c | 22 | ||||
-rw-r--r-- | client.c (renamed from expression.c) | 54 | ||||
-rw-r--r-- | client.h (renamed from expression.h) | 21 | ||||
-rwxr-xr-x | config.guess | 20 | ||||
-rwxr-xr-x | config.sub | 11 | ||||
-rw-r--r-- | evaluator.c | 105 | ||||
-rw-r--r-- | evaluator.h | 14 | ||||
-rw-r--r-- | lcd4linux.c | 63 |
10 files changed, 205 insertions, 119 deletions
diff --git a/Makefile.am b/Makefile.am index eebbefa..e5b17f2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ pid.c pid.h \ 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 \ diff --git a/Makefile.in b/Makefile.in index eba9f09..215a70b 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 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@ @@ -137,7 +137,7 @@ bin_PROGRAMS = lcd4linux$(EXEEXT) 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) @@ -161,10 +161,10 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \ .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 @@ -1,4 +1,4 @@ -/* $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 * @@ -22,6 +22,13 @@ * * * $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 * @@ -135,7 +142,7 @@ #include "debug.h" #include "cfg.h" - +#include "client.h" typedef struct { char *key; @@ -308,6 +315,13 @@ static int check_cfg_source(char *file) } +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; @@ -350,6 +364,10 @@ int l4l_cfg_init (char *file) cfg_add (line, p, 0); } fclose (stream); + + // register as a client + AddFunction ("cfg", 1, cfg_client); + return 0; } @@ -1,6 +1,6 @@ -/* $Id: expression.c,v 1.3 2003/10/06 05:51:15 reinelt Exp $ +/* $Id: client.c,v 1.1 2003/10/11 06:01:52 reinelt Exp $ * - * expression handling + * client function handling * * Copyright 2003 Michael Reinelt <reinelt@eunet.at> * @@ -21,7 +21,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * $Log: expression.c,v $ + * $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() * @@ -36,7 +43,7 @@ /* * exported functions: * - * int EX_init (void) + * int Client_init (void) * initializes the expression evaluator * adds some handy constants and functions * @@ -49,9 +56,7 @@ #include <string.h> #include "debug.h" -#include "cfg.h" -#include "evaluator.h" -#include "expression.h" +#include "client.h" @@ -122,18 +127,11 @@ static void my_strlen (RESULT *result, RESULT *arg1) } -static void my_cfg (RESULT *result, RESULT *arg1) -{ - char *value=cfg_get(R2S(arg1), ""); - SetResult(&result, R_STRING, value); -} - - -int EX_init (void) +int client_init (void) { // set some handy constants - AddConstant ("Pi", M_PI); - AddConstant ("e", M_E); + AddNumericVariable ("Pi", M_PI); + AddNumericVariable ("e", M_E); // register some basic math functions AddFunction ("sqrt", 1, my_sqrt); @@ -151,30 +149,8 @@ int EX_init (void) // 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; -} @@ -1,6 +1,6 @@ -/* $Id: expression.h,v 1.1 2003/10/06 04:34:06 reinelt Exp $ +/* $Id: client.h,v 1.1 2003/10/11 06:01:52 reinelt Exp $ * - * expression handling + * client function handling * * Copyright 2003 Michael Reinelt <reinelt@eunet.at> * @@ -21,16 +21,25 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * $Log: expression.h,v $ + * $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 * */ -#ifndef _EXPRESSION_H_ -#define _EXPRESSION_H_ +#include "evaluator.h" + +#ifndef _CLIENT_H_ +#define _CLIENT_H_ -int EX_init (void); +int client_init (void); #endif diff --git a/config.guess b/config.guess index 0e30d56..1127162 100755 --- a/config.guess +++ b/config.guess @@ -3,7 +3,7 @@ # 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 @@ -734,7 +734,7 @@ EOF 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'` @@ -751,7 +751,7 @@ EOF *: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 @@ -763,7 +763,7 @@ EOF #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} @@ -799,8 +799,13 @@ EOF 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 ;; @@ -948,6 +953,9 @@ EOF 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 @@ -1049,7 +1057,7 @@ EOF 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` @@ -1164,7 +1172,7 @@ EOF *: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:*:*) @@ -3,7 +3,7 @@ # 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 @@ -118,7 +118,7 @@ esac # 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/'` ;; @@ -248,6 +248,7 @@ case $basic_machine in | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ @@ -320,6 +321,7 @@ case $basic_machine in | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ @@ -1129,7 +1131,7 @@ case $os in | -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* \ @@ -1165,6 +1167,9 @@ case $os in -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; diff --git a/evaluator.c b/evaluator.c index 995b61a..ac5bd93 100644 --- a/evaluator.c +++ b/evaluator.c @@ -1,4 +1,4 @@ -/* $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 * @@ -10,6 +10,13 @@ * 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: ==, \!=, <=, >= * @@ -56,7 +63,10 @@ /* * 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)()) @@ -339,18 +349,6 @@ static int SetVariable (char *name, RESULT *value) } -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) { @@ -369,33 +367,6 @@ static int f_sort (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); @@ -749,6 +720,56 @@ static void Level11 (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; @@ -766,5 +787,3 @@ int Eval (char* expression, RESULT *result) if (*Token!='\0') ERROR (E_SYNTAX); return 0; } - - diff --git a/evaluator.h b/evaluator.h index 661b967..f15ee32 100644 --- a/evaluator.h +++ b/evaluator.h @@ -1,4 +1,4 @@ -/* $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 * @@ -10,6 +10,13 @@ * 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 * @@ -77,8 +84,9 @@ typedef struct { #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); diff --git a/lcd4linux.c b/lcd4linux.c index a9be90a..9af5a6a 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $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 * @@ -22,6 +22,13 @@ * * * $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 * @@ -247,6 +254,7 @@ #include "udelay.h" #include "display.h" #include "processor.h" +#include "client.h" #define PIDFILE "/var/run/lcd4linux.pid" @@ -257,6 +265,7 @@ static int got_signal=0; int tick, tack; extern char* output; + static void usage(void) { printf ("%s\n", release); @@ -265,9 +274,11 @@ static void usage(void) #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; @@ -304,6 +315,7 @@ int hello (void) return flag; } + #ifdef USE_OLD_UDELAY void calibrate (void) { @@ -322,18 +334,21 @@ 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)); @@ -344,11 +359,11 @@ int main (int argc, char *argv[]) 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': @@ -374,6 +389,9 @@ int main (int argc, char *argv[]) case 'h': usage(); exit(0); + case 'i': + interactive++; + break; case 'l': printf ("%s\n", release); lcd_list(); @@ -397,17 +415,21 @@ int main (int argc, char *argv[]) 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') { @@ -479,10 +501,31 @@ int main (int argc, char *argv[]) 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); |