[lcd4linux @ 2004-04-12 11:12:24 by reinelt]

added plugin_isdn, removed old ISDN client
fixed some real bad bugs in the evaluator

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@418 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
reinelt
2004-04-12 11:12:26 +00:00
parent 938a093e5f
commit bbfa7a3b4f
10 changed files with 287 additions and 302 deletions
+1
View File
@@ -77,6 +77,7 @@ plugin_dvb.c \
plugin_exec.c \
plugin_i2c_sensors.c \
plugin_imon.c \
plugin_isdn.c \
plugin_loadavg.c \
plugin_meminfo.c \
plugin_mysql.c \
+8 -8
View File
@@ -102,7 +102,7 @@ lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h deb
#liblcd4linux_la_SOURCES =
EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h BeckmannEgle.c drv_Crystalfontz.c drv_Cwlinux.c drv_HD44780.c drv_M50530.c drv_T6963.c drv_USBLCD.c drv_MatrixOrbital.c MilfordInstruments.c PalmPilot.c Raster.c drv_X11.c Text.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_seti.c plugin_uname.c plugin_wireless.c plugin_xmms.c
EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h BeckmannEgle.c drv_Crystalfontz.c drv_Cwlinux.c drv_HD44780.c drv_M50530.c drv_T6963.c drv_USBLCD.c drv_MatrixOrbital.c MilfordInstruments.c PalmPilot.c Raster.c drv_X11.c Text.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_seti.c plugin_uname.c plugin_wireless.c plugin_xmms.c
EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Rows README.Tokens README.Drivers README.Plugins README.KDE plugin_sample.c
@@ -150,13 +150,13 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/MilfordInstruments.P \
.deps/hash.P .deps/layout.P .deps/lcd4linux.P .deps/lock.P .deps/pid.P \
.deps/plugin.P .deps/plugin_apm.P .deps/plugin_cfg.P \
.deps/plugin_cpuinfo.P .deps/plugin_dvb.P .deps/plugin_exec.P \
.deps/plugin_i2c_sensors.P .deps/plugin_imon.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/plugin_i2c_sensors.P .deps/plugin_imon.P .deps/plugin_isdn.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
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
+6
View File
@@ -49,6 +49,9 @@
/* Define to 1 if you have the <linux/dvb/frontend.h> header file. */
#undef HAVE_LINUX_DVB_FRONTEND_H
/* Define to 1 if you have the <linux/isdn.h> header file. */
#undef HAVE_LINUX_ISDN_H
/* Define to 1 if you have the <linux/parport.h> header file. */
#undef HAVE_LINUX_PARPORT_H
@@ -245,6 +248,9 @@
/* imon plugin */
#undef PLUGIN_IMON
/* ISDN plugin */
#undef PLUGIN_ISDN
/* loadavg plugin */
#undef PLUGIN_LOADAVG
Vendored
+185 -18
View File
@@ -6099,6 +6099,7 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;}
PLUGIN_EXEC="yes"
PLUGIN_I2C_SENSORS="yes"
PLUGIN_IMON="yes"
PLUGIN_ISDN="yes"
PLUGIN_LOADAVG="yes"
PLUGIN_MEMINFO="yes"
PLUGIN_MYSQL="yes"
@@ -6129,6 +6130,9 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;}
imon)
PLUGIN_IMON=$val
;;
isdn)
PLUGIN_ISDN=$val
;;
loadavg)
PLUGIN_LOADAVG=$val
;;
@@ -6348,8 +6352,8 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF
else
{ echo "$as_me:$LINENO: WARNING: linux/dvb/frontend.h header not found: dvb driver disabled" >&5
echo "$as_me: WARNING: linux/dvb/frontend.h header not found: dvb driver disabled" >&2;}
{ echo "$as_me:$LINENO: WARNING: linux/dvb/frontend.h header not found: dvb plugin disabled" >&5
echo "$as_me: WARNING: linux/dvb/frontend.h header not found: dvb plugin disabled" >&2;}
fi
fi
if test "$PLUGIN_EXEC" = "yes"; then
@@ -6375,6 +6379,169 @@ cat >>confdefs.h <<\_ACEOF
#define PLUGIN_IMON 1
_ACEOF
fi
if test "$PLUGIN_ISDN" = "yes"; then
for ac_header in linux/isdn.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
## ------------------------------- ##
## Report this to reinelt@eunet.at ##
## ------------------------------- ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
has_isdn_header=true
else
has_isdn_header=false
fi
done
if test "$has_dvb_header" = false; then
{ echo "$as_me:$LINENO: WARNING: linux/isdn.h header not found: isdn plugin CPS disabled" >&5
echo "$as_me: WARNING: linux/isdn.h header not found: isdn plugin CPS disabled" >&2;}
fi
PLUGINS="$PLUGINS plugin_isdn.o"
cat >>confdefs.h <<\_ACEOF
#define PLUGIN_ISDN 1
_ACEOF
fi
if test "$PLUGIN_LOADAVG" = "yes"; then
PLUGINS="$PLUGINS plugin_loadavg.o"
@@ -6545,9 +6712,9 @@ fi
done
if test "$has_mysql_header" = true; then
echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6
if test "${ac_cv_lib_mysqlclient_mysql_init_+set}" = set; then
echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6
if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -6565,11 +6732,11 @@ extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char mysql_init ();
char mysql_init ();
int
main ()
{
mysql_init ();
mysql_init ();
;
return 0;
}
@@ -6595,20 +6762,20 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_mysqlclient_mysql_init_=yes
ac_cv_lib_mysqlclient_mysql_init=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_mysqlclient_mysql_init_=no
ac_cv_lib_mysqlclient_mysql_init=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init_" >&5
echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init_" >&6
if test $ac_cv_lib_mysqlclient_mysql_init_ = yes; then
echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5
echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init" >&6
if test $ac_cv_lib_mysqlclient_mysql_init = yes; then
has_mysql_lib=true
else
has_mysql_lib=false
@@ -6623,12 +6790,12 @@ _ACEOF
PLUGINLIBS="$PLUGINLIBS -lmysqlclient"
else
{ echo "$as_me:$LINENO: WARNING: mysqlclient lib not found: mysql driver disabled" >&5
echo "$as_me: WARNING: mysqlclient lib not found: mysql driver disabled" >&2;}
{ echo "$as_me:$LINENO: WARNING: mysqlclient lib not found: mysql plugin disabled" >&5
echo "$as_me: WARNING: mysqlclient lib not found: mysql plugin disabled" >&2;}
fi
else
{ echo "$as_me:$LINENO: WARNING: mysql/mysql.h header not found: mysql driver disabled" >&5
echo "$as_me: WARNING: mysql/mysql.h header not found: mysql driver disabled" >&2;}
{ echo "$as_me:$LINENO: WARNING: mysql/mysql.h header not found: mysql plugin disabled" >&5
echo "$as_me: WARNING: mysql/mysql.h header not found: mysql plugin disabled" >&2;}
fi
fi
if test "$PLUGIN_NETDEV" = "yes"; then
@@ -6807,8 +6974,8 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF
else
{ echo "$as_me:$LINENO: WARNING: net/if_ppp.h header not found: ppp driver disabled" >&5
echo "$as_me: WARNING: net/if_ppp.h header not found: ppp driver disabled" >&2;}
{ echo "$as_me:$LINENO: WARNING: net/if_ppp.h header not found: ppp plugin disabled" >&5
echo "$as_me: WARNING: net/if_ppp.h header not found: ppp plugin disabled" >&2;}
fi
fi
if test "$PLUGIN_PROC_STAT" = "yes"; then
+18 -10
View File
@@ -1,4 +1,4 @@
/* $Id: evaluator.c,v 1.18 2004/03/11 06:39:58 reinelt Exp $
/* $Id: evaluator.c,v 1.19 2004/04/12 11:12:25 reinelt Exp $
*
* expression evaluation
*
@@ -23,6 +23,10 @@
*
*
* $Log: evaluator.c,v $
* Revision 1.19 2004/04/12 11:12:25 reinelt
* added plugin_isdn, removed old ISDN client
* fixed some real bad bugs in the evaluator
*
* Revision 1.18 2004/03/11 06:39:58 reinelt
* big patch from Martin:
* - reuse filehandles
@@ -336,7 +340,8 @@ static RESULT* DupResult (RESULT *result)
RESULT* SetResult (RESULT **result, int type, void *value)
{
if (*result == NULL) {
if ((*result = NewResult()) == NULL) return NULL;
if ((*result = NewResult()) == NULL)
return NULL;
} else if (type == R_NUMBER) {
DelResult(*result);
}
@@ -347,11 +352,12 @@ RESULT* SetResult (RESULT **result, int type, void *value)
(*result)->length = -1;
(*result)->string = NULL;
}
else if (type == R_STRING) {
int len = strlen((char*)value);
(*result)->type = R_STRING;
(*result)->number = 0.0;
if (len > (*result)->length) {
if ((*result)->string == NULL || len > (*result)->length) {
// buffer is either empty or too small
if ((*result)->string) free((*result)->string);
// allocate memory in multiples of CHUNK_SIZE
@@ -464,8 +470,8 @@ int SetVariableString (char *name, char *value)
{
RESULT result = {0, 0, 0, NULL};
RESULT *rp = &result;
SetResult(&rp, R_STRING, value );
SetResult(&rp, R_STRING, value);
return SetVariable (name, rp);
}
@@ -768,7 +774,7 @@ static NODE* Level11 (void)
Root = Level12();
if (sign == O_SUB || sign == O_NOT) {
if (sign == O_SGN || sign == O_NOT) {
Root = NewNode (Root);
Root->Token = T_OPERATOR;
Root->Operator = sign;
@@ -971,6 +977,7 @@ static int EvalTree (NODE *Root)
int type = -1;
double number = 0.0;
double dummy;
int freeme = 0;
char *string = NULL;
char *s1, *s2;
RESULT *param[10];
@@ -1017,7 +1024,7 @@ static int EvalTree (NODE *Root)
i = Root->Children-1;
type = Root->Child[i]->Result->type;
number = Root->Child[i]->Result->number;
string = strdup(Root->Child[i]->Result->string);
string = Root->Child[i]->Result->string;
break;
case O_SET: // variable assignment
@@ -1025,14 +1032,14 @@ static int EvalTree (NODE *Root)
Root->Variable->value = DupResult (Root->Child[0]->Result);
type = Root->Child[0]->Result->type;
number = Root->Child[0]->Result->number;
string = strdup(Root->Child[0]->Result->string);
string = Root->Child[0]->Result->string;
break;
case O_CND: // conditional expression
i = 1+(R2N(Root->Child[0]->Result) == 0.0);
type = Root->Child[i]->Result->type;
number = Root->Child[i]->Result->number;
string = strdup(Root->Child[i]->Result->string);
string = Root->Child[i]->Result->string;
break;
case O_OR: // logical OR
@@ -1097,6 +1104,7 @@ static int EvalTree (NODE *Root)
string = malloc(strlen(s1)+strlen(s2)+1);
strcpy (string, s1);
strcat (string, s2);
freeme = 1;
break;
case O_MUL: // multiplication
@@ -1148,7 +1156,7 @@ static int EvalTree (NODE *Root)
}
if (type==R_STRING) {
SetResult (&Root->Result, R_STRING, string);
if (string) free (string);
if (freeme) free (string);
return 0;
}
error ("Evaluator: internal error: unhandled type <%d>", type);
-203
View File
@@ -1,203 +0,0 @@
/* $Id: isdn.c,v 1.13 2004/01/29 04:40:02 reinelt Exp $
*
* ISDN specific functions
*
* Copyright 1999, 2000 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: isdn.c,v $
* Revision 1.13 2004/01/29 04:40:02 reinelt
* every .c file includes "config.h" now
*
* Revision 1.12 2003/11/24 11:34:54 reinelt
*
* 'Fixed' Rows which do not scroll by Lars Kempe
* temporary workaround for debian kernel-header bug
*
* Revision 1.11 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
* Revision 1.10 2003/06/21 05:46:18 reinelt
* DVB client integrated
*
* Revision 1.9 2001/05/27 07:19:28 reinelt
*
* fixed a warning in pixmap.c
* temporarily fixed a bug in isdn.c (ISDN_MAX_CHANNELS is no longer defined?)
* fixed a bug in configure.in (--with-drivers=xyz did not work)
*
* Revision 1.8 2000/08/10 18:42:20 reinelt
*
* fixed some bugs with the new syslog code
*
* Revision 1.7 2000/08/10 09:44:09 reinelt
*
* new debugging scheme: error(), info(), debug()
* uses syslog if in daemon mode
*
* Revision 1.6 2000/04/15 11:56:35 reinelt
*
* more debug messages
*
* Revision 1.5 2000/03/13 15:58:24 reinelt
*
* release 0.9
* moved row parsing to parser.c
* all basic work finished
*
* Revision 1.4 2000/03/10 17:36:02 reinelt
*
* first unstable but running release
*
* Revision 1.3 2000/03/07 11:01:34 reinelt
*
* system.c cleanup
*
* Revision 1.2 2000/03/06 06:04:06 reinelt
*
* minor cleanups
*
*/
/*
* exported functions:
*
* Isdn (int *rx, int *tx, int *usage)
* returns 0 if ok, -1 if error
* sets *usage to all channels USAGE or'ed together
* sets received/transmitted bytes in *rx, *tx
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
// Fixme: my debian has some bugs with kernel headers
#if 0
#include <linux/isdn.h>
#else
#define IIOCGETCPS _IO('I',21)
#endif
// Fixme: ISDN_MAX_CHANNELS seems undefined in recent kernels
#ifndef ISDN_MAX_CHANNELS
#define ISDN_MAX_CHANNELS 64
#endif
#include "debug.h"
#include "isdn.h"
#include "filter.h"
typedef struct {
unsigned long in;
unsigned long out;
} CPS;
static int Usage (void)
{
static int fd=0;
char buffer[4096], *p;
int i, usage;
if (fd==-1) return 0;
fd=open ("/dev/isdninfo", O_RDONLY | O_NDELAY);
if (fd==-1) {
error ("open(/dev/isdninfo) failed: %s", strerror(errno));
return 0;
}
if (read (fd, buffer, sizeof(buffer))==-1) {
error ("read(/dev/isdninfo) failed: %s", strerror(errno));
fd=-1;
return 0;
}
if (close(fd)==-1) {
error ("close(/dev/isdninfo) failed: %s", strerror(errno));
fd=-1;
return 0;
}
p=strstr(buffer, "usage:");
if (p==NULL) {
error ("parse(/dev/isdninfo) failed: no usage line");
fd=-1;
return 0;
}
p+=6;
usage=0;
for (i=0; i<ISDN_MAX_CHANNELS; i++) {
usage|=strtol(p, &p, 10);
}
return usage;
}
int Isdn (int *rx, int *tx, int *usage)
{
static int fd=-2;
CPS cps[ISDN_MAX_CHANNELS];
double cps_i, cps_o;
int i;
*usage=0;
*rx=0;
*tx=0;
if (fd==-1) return -1;
if (fd==-2) {
fd = open("/dev/isdninfo", O_RDONLY | O_NDELAY);
if (fd==-1) {
error ("open(/dev/isdninfo) failed: %s", strerror(errno));
return -1;
}
debug ("open (/dev/isdninfo)=%d", fd);
}
if (ioctl(fd, IIOCGETCPS, &cps)) {
error("ioctl(IIOCGETCPS) failed: %s", strerror(errno));
fd=-1;
return -1;
}
cps_i=0;
cps_o=0;
for (i=0; i<ISDN_MAX_CHANNELS; i++) {
cps_i+=cps[i].in;
cps_o+=cps[i].out;
}
*rx=(int)smooth("isdn_rx", 1000, cps_i);
*tx=(int)smooth("isdn_tx", 1000, cps_o);
*usage=Usage();
return 0;
}
-53
View File
@@ -1,53 +0,0 @@
/* $Id: isdn.h,v 1.6 2003/10/05 17:58:50 reinelt Exp $
*
* ISDN specific functions
*
* Copyright 1999, 2000 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: isdn.h,v $
* Revision 1.6 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
* Revision 1.5 2000/03/13 15:58:24 reinelt
*
* release 0.9
* moved row parsing to parser.c
* all basic work finished
*
* Revision 1.4 2000/03/10 17:36:02 reinelt
*
* first unstable but running release
*
* Revision 1.3 2000/03/07 11:01:34 reinelt
*
* system.c cleanup
*
* Revision 1.2 2000/03/06 06:04:06 reinelt
*
* minor cleanups
*
*/
#ifndef _ISDN_H_
#define _ISDN_H_
int Isdn (int *rx, int *tx, int *usage);
#endif
+13 -1
View File
@@ -1,4 +1,4 @@
/* $Id: plugin.c,v 1.27 2004/04/09 06:09:55 reinelt Exp $
/* $Id: plugin.c,v 1.28 2004/04/12 11:12:26 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -22,6 +22,10 @@
*
*
* $Log: plugin.c,v $
* 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
*
* Revision 1.27 2004/04/09 06:09:55 reinelt
* big configure rework from Xavier
*
@@ -180,6 +184,8 @@ int plugin_init_i2c_sensors (void);
void plugin_exit_i2c_sensors (void);
int plugin_init_imon(void);
void plugin_exit_imon(void);
int plugin_init_isdn(void);
void plugin_exit_isdn(void);
int plugin_init_loadavg (void);
void plugin_exit_loadavg (void);
int plugin_init_meminfo (void);
@@ -228,6 +234,9 @@ int plugin_init (void)
#ifdef PLUGIN_IMON
plugin_init_imon();
#endif
#ifdef PLUGIN_ISDN
plugin_init_isdn();
#endif
#ifdef PLUGIN_LOADAVG
plugin_init_loadavg();
#endif
@@ -283,6 +292,9 @@ void plugin_exit(void) {
#ifdef PLUGIN_IMON
plugin_exit_imon();
#endif
#ifdef PLUGIN_ISDN
plugin_exit_isdn();
#endif
#ifdef PLUGIN_LOADAVG
plugin_exit_loadavg();
#endif
+18 -6
View File
@@ -36,6 +36,7 @@ for plugin in $plugins; do
PLUGIN_EXEC="yes"
PLUGIN_I2C_SENSORS="yes"
PLUGIN_IMON="yes"
PLUGIN_ISDN="yes"
PLUGIN_LOADAVG="yes"
PLUGIN_MEMINFO="yes"
PLUGIN_MYSQL="yes"
@@ -66,6 +67,9 @@ for plugin in $plugins; do
imon)
PLUGIN_IMON=$val
;;
isdn)
PLUGIN_ISDN=$val
;;
loadavg)
PLUGIN_LOADAVG=$val
;;
@@ -120,7 +124,7 @@ if test "$PLUGIN_DVB" = "yes"; then
PLUGINS="$PLUGINS plugin_dvb.o"
AC_DEFINE(PLUGIN_DVB,1,[dvb plugin])
else
AC_MSG_WARN(linux/dvb/frontend.h header not found: dvb driver disabled)
AC_MSG_WARN(linux/dvb/frontend.h header not found: dvb plugin disabled)
fi
fi
if test "$PLUGIN_EXEC" = "yes"; then
@@ -135,6 +139,14 @@ if test "$PLUGIN_IMON" = "yes"; then
PLUGINS="$PLUGINS plugin_imon.o"
AC_DEFINE(PLUGIN_IMON,1,[imon plugin])
fi
if test "$PLUGIN_ISDN" = "yes"; then
AC_CHECK_HEADERS(linux/isdn.h, [has_isdn_header=true], [has_isdn_header=false])
if test "$has_dvb_header" = false; then
AC_MSG_WARN(linux/isdn.h header not found: isdn plugin CPS disabled)
fi
PLUGINS="$PLUGINS plugin_isdn.o"
AC_DEFINE(PLUGIN_ISDN,1,[ISDN plugin])
fi
if test "$PLUGIN_LOADAVG" = "yes"; then
PLUGINS="$PLUGINS plugin_loadavg.o"
AC_DEFINE(PLUGIN_LOADAVG,1,[loadavg plugin])
@@ -145,17 +157,17 @@ if test "$PLUGIN_MEMINFO" = "yes"; then
fi
if test "$PLUGIN_MYSQL" = "yes"; then
AC_CHECK_HEADERS(mysql/mysql.h, [has_mysql_header=true], [has_mysql_header=false])
if test "$has_mysql_header" = true; then
AC_CHECK_LIB(mysqlclient,mysql_init ,[has_mysql_lib=true], [has_mysql_lib=false])
if test "$has_mysql_header" = true; then
AC_CHECK_LIB(mysqlclient, mysql_init, [has_mysql_lib=true], [has_mysql_lib=false])
if test "$has_mysql_lib" = true; then
PLUGINS="$PLUGINS plugin_mysql.o"
AC_DEFINE(PLUGIN_MYSQL,1,[mysql plugin])
PLUGINLIBS="$PLUGINLIBS -lmysqlclient"
else
AC_MSG_WARN(mysqlclient lib not found: mysql driver disabled)
AC_MSG_WARN(mysqlclient lib not found: mysql plugin disabled)
fi
else
AC_MSG_WARN(mysql/mysql.h header not found: mysql driver disabled)
AC_MSG_WARN(mysql/mysql.h header not found: mysql plugin disabled)
fi
fi
if test "$PLUGIN_NETDEV" = "yes"; then
@@ -172,7 +184,7 @@ if test "$PLUGIN_PPP" = "yes"; then
PLUGINS="$PLUGINS plugin_ppp.o"
AC_DEFINE(PLUGIN_PPP,1,[ppp plugin])
else
AC_MSG_WARN(net/if_ppp.h header not found: ppp driver disabled)
AC_MSG_WARN(net/if_ppp.h header not found: ppp plugin disabled)
fi
fi
if test "$PLUGIN_PROC_STAT" = "yes"; then
+38 -3
View File
@@ -1,4 +1,4 @@
/* $Id: qprintf.c,v 1.2 2004/04/08 10:48:25 reinelt Exp $
/* $Id: qprintf.c,v 1.3 2004/04/12 11:12:26 reinelt Exp $
*
* simple but quick snprintf() replacement
*
@@ -26,6 +26,10 @@
*
*
* $Log: qprintf.c,v $
* Revision 1.3 2004/04/12 11:12:26 reinelt
* added plugin_isdn, removed old ISDN client
* fixed some real bad bugs in the evaluator
*
* Revision 1.2 2004/04/08 10:48:25 reinelt
* finished plugin_exec
* modified thread handling
@@ -84,7 +88,29 @@ static char *itoa(char* buffer, size_t size, int value)
}
static char *itox(char* buffer, size_t size, unsigned int value)
static char *utoa(char* buffer, size_t size, unsigned int value)
{
char *p;
// sanity checks
if (buffer==NULL || size<2) return (NULL);
// p points to last char
p = buffer+size-1;
// set terminating zero
*p='\0';
do {
*--p = value%10 + '0';
value = value/10;
} while (value!=0 && p>buffer);
return p;
}
static char *utox(char* buffer, size_t size, unsigned int value)
{
char *p;
int digit;
@@ -148,10 +174,19 @@ int qprintf(char *str, size_t size, const char *format, ...) {
*dst++ = *s++;
}
break;
case 'u':
src++;
u = va_arg(ap, unsigned int);
s = utoa (buf, sizeof(buf), u);
while (len < size && *s != '\0') {
len++;
*dst++ = *s++;
}
break;
case 'x':
src++;
u = va_arg(ap, unsigned int);
s = itox (buf, sizeof(buf), u);
s = utox (buf, sizeof(buf), u);
while (len < size && *s != '\0') {
len++;
*dst++ = *s++;