# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Process this file with automake to produce Makefile.in SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ CC = @CC@ CPP = @CPP@ CURSES_INCLUDEDIR = @CURSES_INCLUDEDIR@ CURSES_LIBS = @CURSES_LIBS@ DRVLIBS = @DRVLIBS@ HAVE_LIB = @HAVE_LIB@ LIB = @LIB@ LN_S = @LN_S@ LTLIB = @LTLIB@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ PLUGINLIBS = @PLUGINLIBS@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ VERSION = @VERSION@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ AUTOMAKE_OPTIONS = gnu CLEANFILES = *~ DRIVERS = @DRIVERS@ PLUGINS = @PLUGINS@ bin_PROGRAMS = lcd4linux AM_CFLAGS = -D_GNU_SOURCE -Wall -W lcd4linux_LDFLAGS = lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@ lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@ lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h plugin.c plugin.h plugin_cfg.c plugin_math.c plugin_string.c plugin_test.c plugin_time.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 drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDTerm.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_X11.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.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_python.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.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.Drivers README.Plugins README.KDE plugin_sample.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ X_CFLAGS = @X_CFLAGS@ X_LIBS = @X_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ lcd4linux_OBJECTS = lcd4linux.o cfg.o debug.o drv.o evaluator.o hash.o \ layout.o pid.o timer.o thread.o udelay.o qprintf.o widget.o \ widget_text.o widget_bar.o widget_icon.o plugin.o plugin_cfg.o \ plugin_math.o plugin_string.o plugin_test.o plugin_time.o CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS TODO aclocal.m4 config.guess config.h.in \ config.sub configure configure.in install-sh ltmain.sh missing \ mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.P \ .deps/drv_BeckmannEgle.P .deps/drv_Crystalfontz.P .deps/drv_Curses.P \ .deps/drv_Cwlinux.P .deps/drv_HD44780.P .deps/drv_Image.P \ .deps/drv_LCDLinux.P .deps/drv_LCDTerm.P .deps/drv_M50530.P \ .deps/drv_MatrixOrbital.P .deps/drv_MilfordInstruments.P \ .deps/drv_NULL.P .deps/drv_Noritake.P .deps/drv_RouterBoard.P \ .deps/drv_SimpleLCD.P .deps/drv_T6963.P .deps/drv_Trefon.P \ .deps/drv_USBLCD.P .deps/drv_X11.P .deps/drv_generic_graphic.P \ .deps/drv_generic_i2c.P .deps/drv_generic_parport.P \ .deps/drv_generic_serial.P .deps/drv_generic_text.P \ .deps/drv_serdisplib.P .deps/evaluator.P .deps/hash.P .deps/layout.P \ .deps/lcd4linux.P .deps/pid.P .deps/plugin.P .deps/plugin_apm.P \ .deps/plugin_cfg.P .deps/plugin_cpuinfo.P .deps/plugin_diskstats.P \ .deps/plugin_dvb.P .deps/plugin_exec.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_python.P .deps/plugin_seti.P \ .deps/plugin_statfs.P .deps/plugin_string.P .deps/plugin_test.P \ .deps/plugin_time.P .deps/plugin_uname.P .deps/plugin_uptime.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) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) config.h: stamp-h @if test ! -f $@; then \ rm -f stamp-h; \ $(MAKE) stamp-h; \ else :; fi stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=config.h \ $(SHELL) ./config.status @echo timestamp > stamp-h 2> /dev/null $(srcdir)/config.h.in: $(srcdir)/stamp-h.in @if test ! -f $@; then \ rm -f $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h.in; \ else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOHEADER) @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: clean-hdr: distclean-hdr: -rm -f config.h maintainer-clean-hdr: mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: lcd4linux: $(lcd4linux_OBJECTS) $(lcd4linux_DEPENDENCIES) @rm -f lcd4linux $(LINK) $(lcd4linux_LDFLAGS) $(lcd4linux_OBJECTS) $(lcd4linux_LDADD) $(LIBS) tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP)) mostlyclean-tags: clean-tags: distcl
/* $Id$
* $URL$
*
* plugin for ISDN subsystem
*
* Copyright (C) 2003 Michael Reinelt <reinelt@eunet.at>
* Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* Based on the old isdn client (isdn.c) which is
* Copyright (C) 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.
*
*/
/*
* exported functions:
*
* int plugin_init_isdn (void)
* adds functions to access ISDN information
*
*/
#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>
#ifdef HAVE_LINUX_ISDN_H
#include <linux/isdn.h>
#else
#warning isdn.h not found. CPS support deactivated.
#endif
#include "debug.h"
#include "plugin.h"
#include "qprintf.h"
#include "hash.h"
typedef struct {
unsigned long in;
unsigned long out;
} CPS;
static HASH ISDN_INFO;
static HASH ISDN_CPS;
static void hash_put_info(const char *name, const int channel, const char *val)
{
char key[16];
qprintf(key, sizeof(key), "%s[%d]", name, channel);
hash_put(&ISDN_INFO, key, val);
}
static int parse_isdninfo(void)
{
int age;
FILE *stream;
long flags;
/* reread every 10 msec only */
age = hash_age(&ISDN_INFO, NULL);
if (age > 0 && age <= 10)
return 0;
/* open file */
stream = fopen("/dev/isdninfo", "r");
if (stream == NULL) {
error("open(/dev/isdninfo) failed: %s", strerror(errno));
return -1;
}
/* get flags */
flags = fcntl(fileno(stream), F_GETFL);
if (flags < 0) {
error("fcntl(/dev/isdninfo, F_GETFL) failed: %s", strerror(errno));
return -1;
}
/* set O_NONBLOCK */
if (fcntl(fileno(stream), F_SETFL, flags | O_NONBLOCK) < 0) {
error("fcntl(/dev/isdninfo, F_SETFL, O_NONBLOCK) failed: %s", strerror(errno));
return -1;
}
while (!feof(stream)) {
char buffer[4096];
char *beg, *end;
if (fgets(buffer, sizeof(buffer), stream) == NULL)
break;
beg = strchr(buffer, ':');
if (beg != NULL) {
char delim[] = " \t\n";
int i = 0;
*beg++ = '\0';
while (*beg && strchr(delim, *beg))
beg++;
while (beg && *beg) {
if ((end = strpbrk(beg, delim)))
*end = '\0';
hash_put_info(buffer, i, beg);
beg = end ? end + 1 : NULL;
while (*beg && strchr(delim, *beg))
beg++;
i++;
}
} else {
error("Huh? no colon found in <%s>", buffer);
}
}
fclose(stream);
return 0;
}
static void my_isdn_info(RESULT * result, RESULT * arg1, RESULT * arg2)
{
char key[16], *val;
if (parse_isdninfo() < 0) {
SetResult(&result, R_STRING, "");
return;
}
qprintf(key, sizeof(key), "%s[%d]", R2S(arg1), (int) R2N(arg2));
val = hash_get(&ISDN_INFO, key, NULL);
if (val == NULL)
val = "";
SetResult(&result, R_STRING, val);
}
#ifdef HAVE_LINUX_ISDN_H
static void hash_put_cps(const int channel, const CPS * cps)
{
char key[16], val[16];
qprintf(key, sizeof(key), channel < 0 ? "i" : "i%d", channel);
qprintf(val, sizeof(val), "%u", cps->in);
hash_put_delta(&ISDN_CPS, key, val);
qprintf(key, sizeof(key), channel < 0 ? "o" : "o%d", channel);
qprintf(val, sizeof(val), "%u", cps->out);
hash_put_delta(&ISDN_CPS, key, val);
}
static int get_cps(void)
{
int age, i;
static int fd = -2;
CPS cps[ISDN_MAX_CHANNELS];
CPS sum;
/* reread every 10 msec only */
age = hash_age(&ISDN_CPS, NULL);
if (age > 0 && age <= 10)
return 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;
}
}
if (ioctl(fd, IIOCGETCPS, &cps)) {
error("ioctl(IIOCGETCPS) failed: %s", strerror(errno));
fd = -1;
return -1;
}
sum.in = 0;
sum.out = 0;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
sum.in += cps[i].in;
sum.out += cps[i].out;
hash_put_cps(i, &cps[i]);
}
hash_put_cps(-1, &sum);
return 0;
}
static void my_isdn_cps(RESULT * result, RESULT * arg1, RESULT * arg2)
{
double value;
if (get_cps() < 0) {
SetResult(&result, R_STRING, "");
return;
}
value = hash_get_delta(&ISDN_CPS, R2S(arg1), NULL, R2N(arg2));
SetResult(&result, R_NUMBER, &value);
}
#endif
int plugin_init_isdn(void)
{
hash_create(&ISDN_INFO);
hash_create(&ISDN_CPS);
AddFunction("isdn::info", 2, my_isdn_info);
#ifdef HAVE_LINUX_ISDN_H
AddFunction("isdn::cps", 2, my_isdn_cps);
#endif
return 0;
}
void plugin_exit_isdn(void)
{
hash_destroy(&ISDN_INFO);
hash_destroy(&ISDN_CPS);
}