]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2005-04-03 07:07:43 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 3 Apr 2005 07:07:51 +0000 (07:07 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 3 Apr 2005 07:07:51 +0000 (07:07 +0000)
added statfs plugin

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@524 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

Makefile.am
Makefile.in
config.h.in
configure
configure.in
plugin.c
plugin_statfs.c [new file with mode: 0644]
plugins.m4

index f4c1497ed81944807bc62e43778778ab317064b8..477e4aca4355ae80dd32008c58faa084cfc0a422 100644 (file)
@@ -96,6 +96,7 @@ plugin_pop3.c               \
 plugin_ppp.c                \
 plugin_proc_stat.c          \
 plugin_seti.c               \
+plugin_statfs.c             \
 plugin_uname.c              \
 plugin_uptime.c             \
 plugin_wireless.c           \
index ad3e2ad7b97194b05899d631b0d785dc46125d5b..9259628f2c14976aab9e6b674bb1d85187bda73b 100644 (file)
@@ -100,7 +100,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       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_NULL.c                  drv_RouterBoard.c           drv_SimpleLCD.c             drv_T6963.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_seti.c               plugin_uname.c              plugin_uptime.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       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_NULL.c                  drv_RouterBoard.c           drv_SimpleLCD.c             drv_T6963.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_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
@@ -154,11 +154,11 @@ DEP_FILES =  .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.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_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/plugin_proc_stat.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)
index 7a01663c6605d15e5709566dfda3c3294bc1cd1e..3fcaba18035ed74687ed3c82a20363cda168fb12 100644 (file)
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
+/* Define to 1 if you have the <sys/statfs.h> header file. */
+#undef HAVE_SYS_STATFS_H
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
 /* seti plugin */
 #undef PLUGIN_SETI
 
+/* statfs plugin */
+#undef PLUGIN_STATFS
+
 /* uname plugin */
 #undef PLUGIN_UNAME
 
index c4c8b9033d03624cd44fced8ca67a03db441149b..aab90ad561918f0295e419eb899bc9e018ca77e5 100755 (executable)
--- a/configure
+++ b/configure
@@ -6366,6 +6366,7 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;}
          PLUGIN_PPP="yes"
          PLUGIN_PROC_STAT="yes"
          PLUGIN_SETI="yes"
+         PLUGIN_STATFS="yes"
          PLUGIN_UNAME="yes"
          PLUGIN_UPTIME="yes"
          PLUGIN_WIRELESS="yes"
@@ -6419,6 +6420,9 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;}
       seti)
          PLUGIN_SETI=$val
          ;;
+      statfs)
+         PLUGIN_STATFS=$val
+         ;;
       uname)
          PLUGIN_UNAME=$val
          ;;
@@ -7266,6 +7270,14 @@ cat >>confdefs.h <<\_ACEOF
 #define PLUGIN_SETI 1
 _ACEOF
 
+fi
+if test "$PLUGIN_STATFS" = "yes"; then
+   PLUGINS="$PLUGINS plugin_statfs.o"
+
+cat >>confdefs.h <<\_ACEOF
+#define PLUGIN_STATFS 1
+_ACEOF
+
 fi
 if test "$PLUGIN_UNAME" = "yes"; then
    PLUGINS="$PLUGINS plugin_uname.o"
@@ -7820,7 +7832,8 @@ fi
 
 
 
-for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h termios.h unistd.h
+
+for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/statfs.h sys/time.h syslog.h termios.h unistd.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
index 3240e65304ac186f8b75de8c83ddb53e6a608b2b..651f9b99f5ed80678ce09960b07f7f23c65b9d5d 100644 (file)
@@ -73,7 +73,7 @@ sinclude(plugins.m4)
 # Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h termios.h unistd.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/statfs.h sys/time.h syslog.h termios.h unistd.h])
 AC_CHECK_HEADERS(sys/io.h asm/io.h)
 AC_CHECK_HEADERS(linux/parport.h linux/ppdev.h)
 AC_CHECK_HEADERS(asm/msr.h)
index 9075f56d91d85cfd4ceaafaec4edb9c5e75379f4..29a63e35e1b066385e0f60f91a4d0ec214c1dc28 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.35 2005/01/18 06:30:23 reinelt Exp $
+/* $Id: plugin.c,v 1.36 2005/04/03 07:07:51 reinelt Exp $
  *
  * plugin handler for the Evaluator
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: plugin.c,v $
+ * Revision 1.36  2005/04/03 07:07:51  reinelt
+ * added statfs plugin
+ *
  * Revision 1.35  2005/01/18 06:30:23  reinelt
  * added (C) to all copyright statements
  *
@@ -237,6 +240,8 @@ int  plugin_init_proc_stat (void);
 void plugin_exit_proc_stat (void);
 int  plugin_init_seti(void);
 void plugin_exit_seti(void);
+int  plugin_init_statfs(void);
+void plugin_exit_statfs(void);
 int  plugin_init_uname (void);
 void plugin_exit_uname (void);
 int  plugin_init_uptime (void);
@@ -303,6 +308,9 @@ int plugin_init (void)
 #ifdef PLUGIN_SETI
   plugin_init_seti();
 #endif
+#ifdef PLUGIN_STATFS
+  plugin_init_statfs();
+#endif
 #ifdef PLUGIN_UNAME
   plugin_init_uname();
 #endif
@@ -369,6 +377,9 @@ void plugin_exit(void) {
 #ifdef PLUGIN_SETI
   plugin_exit_seti();
 #endif
+#ifdef PLUGIN_STATFS
+  plugin_exit_statfs();
+#endif
 #ifdef PLUGIN_UNAME
   plugin_exit_uname();
 #endif
diff --git a/plugin_statfs.c b/plugin_statfs.c
new file mode 100644 (file)
index 0000000..9bf9510
--- /dev/null
@@ -0,0 +1,104 @@
+/* $Id: plugin_statfs.c,v 1.1 2005/04/03 07:07:51 reinelt Exp $
+ *
+ * plugin for statfs() syscall
+ *
+ * Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2005 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * 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: plugin_statfs.c,v $
+ * Revision 1.1  2005/04/03 07:07:51  reinelt
+ * added statfs plugin
+ *
+ */
+
+/* 
+ * exported functions:
+ *
+ * int plugin_init_statfs (void)
+ *  adds statfs() functions
+ *
+ */
+
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/vfs.h>
+
+#include "debug.h"
+#include "plugin.h"
+
+
+
+static void my_statfs (RESULT *result, RESULT *arg1, RESULT *arg2)
+{
+  struct statfs buf;
+  char *path, *key;
+  double value;
+  
+  path = R2S(arg1);
+  key  = R2S(arg2);
+  
+  if (statfs(path, &buf)!=0) {
+    error("statfs(%s) failed: %s", path, strerror(errno));
+    SetResult(&result, R_STRING, ""); 
+    return;
+  }
+
+  if (strcasecmp(key, "type")==0) {
+    value = buf.f_type;
+  } else if  (strcasecmp(key, "bsize")==0) {
+    value = buf.f_bsize;
+  } else if  (strcasecmp(key, "blocks")==0) {
+    value = buf.f_blocks;
+  } else if  (strcasecmp(key, "bfree")==0) {
+    value = buf.f_bfree;
+  } else if  (strcasecmp(key, "bavail")==0) {
+    value = buf.f_bavail;
+  } else if  (strcasecmp(key, "files")==0) {
+    value = buf.f_files;
+  } else if  (strcasecmp(key, "ffree")==0) {
+    value = buf.f_ffree;
+#if 0
+  } else if  (strcasecmp(key, "fsid")==0) {
+    value = buf.f_fsid;
+#endif
+  } else if  (strcasecmp(key, "namelen")==0) {
+    value = buf.f_namelen;
+  } else {
+    error("statfs: unknown field '%s'", key);
+    value = -1;
+  }
+
+  SetResult(&result, R_NUMBER, &value); 
+}
+
+
+int plugin_init_statfs (void)
+{
+  AddFunction ("statfs", 2, my_statfs);
+  return 0;
+}
+
+void plugin_exit_statfs(void) 
+{
+}
index 90fc339775daa4807df9f527652ddd7ba436168f..cf122f53e783a6d8d8b1cc247121acb31c93ef9e 100644 (file)
@@ -65,6 +65,7 @@ for plugin in $plugins; do
          PLUGIN_PPP="yes"
          PLUGIN_PROC_STAT="yes"
          PLUGIN_SETI="yes"
+         PLUGIN_STATFS="yes"
          PLUGIN_UNAME="yes"
          PLUGIN_UPTIME="yes"
          PLUGIN_WIRELESS="yes"
@@ -118,6 +119,9 @@ for plugin in $plugins; do
       seti)
          PLUGIN_SETI=$val
          ;;
+      statfs)
+         PLUGIN_STATFS=$val
+         ;;
       uname)
          PLUGIN_UNAME=$val
          ;;
@@ -226,6 +230,10 @@ if test "$PLUGIN_SETI" = "yes"; then
    PLUGINS="$PLUGINS plugin_seti.o"
    AC_DEFINE(PLUGIN_SETI,1,[seti plugin])
 fi
+if test "$PLUGIN_STATFS" = "yes"; then
+   PLUGINS="$PLUGINS plugin_statfs.o"
+   AC_DEFINE(PLUGIN_STATFS,1,[statfs plugin])
+fi
 if test "$PLUGIN_UNAME" = "yes"; then
    PLUGINS="$PLUGINS plugin_uname.o"
    AC_DEFINE(PLUGIN_UNAME,1,[uname plugin])