]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-01-21 10:48:17 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 21 Jan 2004 10:48:17 +0000 (10:48 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 21 Jan 2004 10:48:17 +0000 (10:48 +0000)
hash_age function added

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

config.guess
config.sub
hash.c
hash.h
libtool
ltmain.sh
plugin_cpuinfo.c
plugin_meminfo.c
plugin_proc_stat.c
plugin_xmms.c

index 11271623bbd264b4e32e6ea38bd50497b50e6f86..e8c6fc0c33c53bdff623861c24afba20775adc7c 100755 (executable)
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
-timestamp='2003-10-07'
+timestamp='2004-01-05'
 
 # 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
@@ -221,6 +221,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     mvmeppc:OpenBSD:*:*)
        echo powerpc-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
+    pegasos:OpenBSD:*:*)
+       echo powerpc-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
     pmax:OpenBSD:*:*)
        echo mipsel-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
@@ -307,6 +310,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:OS/390:*:*)
        echo i370-ibm-openedition
        exit 0 ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit 0 ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
        echo arm-acorn-riscix${UNAME_RELEASE}
        exit 0;;
@@ -742,6 +748,11 @@ EOF
         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
         echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
         exit 0 ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit 0 ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
        echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
        exit 0 ;;
@@ -986,6 +997,9 @@ EOF
     i*86:atheos:*:*)
        echo ${UNAME_MACHINE}-unknown-atheos
        exit 0 ;;
+       i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit 0 ;;
     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
        echo i386-unknown-lynxos${UNAME_RELEASE}
        exit 0 ;;
@@ -1172,7 +1186,7 @@ EOF
     *:QNX:*:4*)
        echo i386-pc-qnx
        exit 0 ;;
-    NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*)
+    NSR-?:NONSTOP_KERNEL:*:*)
        echo nsr-tandem-nsk${UNAME_RELEASE}
        exit 0 ;;
     *:NonStop-UX:*:*)
@@ -1216,6 +1230,9 @@ EOF
     SEI:*:*:SEIUX)
         echo mips-sei-seiux${UNAME_RELEASE}
        exit 0 ;;
+    *:DRAGONFLY:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE}
+       exit 0 ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
index 79657cd182242a10caec0d995dabbc673fc3970e..463186dbfd6bfed73ffd84bfc728f2315fafcb03 100755 (executable)
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
-timestamp='2003-10-07'
+timestamp='2004-01-05'
 
 # 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,8 @@ 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* | linux-dietlibc | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+  kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -379,6 +380,9 @@ case $basic_machine in
        amd64)
                basic_machine=x86_64-pc
                ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        amdahl)
                basic_machine=580-amdahl
                os=-sysv
@@ -743,6 +747,10 @@ case $basic_machine in
                basic_machine=or32-unknown
                os=-coff
                ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
        OSE68000 | ose68000)
                basic_machine=m68000-ericsson
                os=-ose
@@ -963,6 +971,10 @@ case $basic_machine in
        tower | tower-32)
                basic_machine=m68k-ncr
                ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
        udi29k)
                basic_machine=a29k-amd
                os=-udi
@@ -1137,13 +1149,13 @@ case $os in
              | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
              | -chorusos* | -chorusrdb* \
              | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
              | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
              | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
              | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
              | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
              | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-             | -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        -qnx*)
@@ -1182,6 +1194,9 @@ case $os in
        -opened*)
                os=-openedition
                ;;
+        -os400*)
+               os=-os400
+               ;;
        -wince*)
                os=-wince
                ;;
@@ -1203,6 +1218,9 @@ case $os in
        -atheos*)
                os=-atheos
                ;;
+       -syllable*)
+               os=-syllable
+               ;;
        -386bsd)
                os=-bsd
                ;;
@@ -1225,6 +1243,9 @@ case $os in
        -sinix*)
                os=-sysv4
                ;;
+        -tpf*)
+               os=-tpf
+               ;;
        -triton*)
                os=-sysv3
                ;;
@@ -1473,9 +1494,15 @@ case $basic_machine in
                        -mvs* | -opened*)
                                vendor=ibm
                                ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
                        -ptx*)
                                vendor=sequent
                                ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
                        -vxsim* | -vxworks* | -windiss*)
                                vendor=wrs
                                ;;
diff --git a/hash.c b/hash.c
index 1c8cb63ad78e5da4cb73d9716a09cd8d9ae9b287..22545294a16d370a8b95a0bc1d068cb0b38c0dee 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.6 2004/01/20 05:36:59 reinelt Exp $
+/* $Id: hash.c,v 1.7 2004/01/21 10:48:17 reinelt Exp $
  *
  * hashes (associative arrays)
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: hash.c,v $
+ * Revision 1.7  2004/01/21 10:48:17  reinelt
+ * hash_age function added
+ *
  * Revision 1.6  2004/01/20 05:36:59  reinelt
  * moved text-display-specific stuff to drv_generic_text
  * moved all the bar stuff from drv_generic_bar to generic_text
@@ -142,6 +145,7 @@ static HASH_ITEM* hash_set_string (HASH *Hash, char *key, char *val)
   if (Item!=NULL) {
     if (Item->val) free (Item->val);
     Item->val = strdup(val);
+    gettimeofday(&(Item->time), NULL);
     return Item;
   }
 
@@ -155,7 +159,11 @@ static HASH_ITEM* hash_set_string (HASH *Hash, char *key, char *val)
   Item->key   = strdup(key);
   Item->val   = strdup(val);
   Item->Slot  = NULL;
-  
+
+  // set timestamps
+  gettimeofday(&Hash->time, NULL);
+  Item->time=Hash->time;
+
   return Item;
 }
 
@@ -199,11 +207,41 @@ char *hash_get (HASH *Hash, char *key)
   return Item?Item->val:NULL;
 }
 
+
+// return the age in milliseconds of an entry from the hash table
+// or from the hash table itself if key is NULL
+// returns -1 if entry does not exist
+// if **value is set, return the value, too
+int hash_age (HASH *Hash, char *key, char **value)
+{
+  HASH_ITEM *Item;
+  timeval now, *stamp;
+  int age;
+  
+  if (key!=NULL) {
+    Item=hash_lookup(Hash, key, 1);
+    if (value) *value=Item?Item->val:NULL;
+    if (Item==NULL) {
+      return -1;
+    }
+    stamp=&Item->time;
+  } else {
+    stamp=&Hash->time;
+  }
+  
+  gettimeofday(&now, NULL);
+  
+  age = (now.tv_sec - stamp->tv_sec)*1000 + (now.tv_usec - stamp->tv_usec)/1000;
+
+  return age;
+}
+
+
 // get a delta value from the filter table
 double hash_get_filter (HASH *Hash, char *key, int delay)
 {
   HASH_ITEM *Item;
-  struct timeval now, end;
+  timeval now, end;
   int i;
   double dv, dt;
   
diff --git a/hash.h b/hash.h
index f29ccdb937613b91bf403b7c2fe0bcb7930a9d88..58e2a7031f6d38854965996664817172948205d2 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -1,4 +1,4 @@
-/* $Id: hash.h,v 1.5 2004/01/18 09:01:45 reinelt Exp $
+/* $Id: hash.h,v 1.6 2004/01/21 10:48:17 reinelt Exp $
  *
  * hashes (associative arrays)
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: hash.h,v $
+ * Revision 1.6  2004/01/21 10:48:17  reinelt
+ * hash_age function added
+ *
  * Revision 1.5  2004/01/18 09:01:45  reinelt
  * /proc/stat parsing finished
  *
 // struct timeval
 #include <sys/time.h>
 
+typedef struct timeval timeval;
 
 typedef struct {
-  struct timeval time;
-  double val;
+  timeval time;
+  double  val;
 } HASH_SLOT;
 
 
 typedef struct {
   char      *key;
   char      *val;
+  timeval   time;
   HASH_SLOT *Slot;
 } HASH_ITEM;
 
 
 typedef struct {
   int       sorted;
+  timeval   time;
   int       nItems;
   HASH_ITEM *Items;
 } HASH;
@@ -76,6 +82,7 @@ typedef struct {
 
 void   hash_set        (HASH *Hash, char *key, char *val);
 void   hash_set_filter (HASH *Hash, char *key, char *val);
+int    hash_age        (HASH *Hash, char *key, char **value);
 char  *hash_get        (HASH *Hash, char *key);
 double hash_get_filter (HASH *Hash, char *key, int delay);
 void   hash_destroy    (HASH *Hash);
diff --git a/libtool b/libtool
index 53475fc9cf4d306d8b2ca7028b1f4b4d52ab79f8..9bd9ab0c5f75a7c30ebd0492f7227374e6f7f82f 100755 (executable)
--- a/libtool
+++ b/libtool
@@ -400,7 +400,7 @@ modename="$progname"
 PROGRAM=ltmain.sh
 PACKAGE=libtool
 VERSION=1.5.0a
-TIMESTAMP=" (1.1220.2.35 2003/11/12 18:51:58) Debian$Rev: 159 $"
+TIMESTAMP=" (1.1220.2.35 2003/11/12 18:51:58) Debian$Rev: 179 $"
 
 default_mode=
 help="Try \`$progname --help' for more information."
@@ -1202,7 +1202,7 @@ EOF
       ;;
     esac
     libtool_args="$nonopt"
-    base_compile="$nonopt"
+    base_compile="$nonopt $@"
     compile_command="$nonopt"
     finalize_command="$nonopt"
 
@@ -1252,7 +1252,7 @@ EOF
     # Only attempt this if the compiler in the base link
     # command doesn't match the default compiler.
     if test -n "$available_tags" && test -z "$tagname"; then
-      case "$base_compile " in
+      case $base_compile in
       # Blanks in the command may have been stripped by the calling shell,
       # but not from the CC environment variable when configure was run.
       "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;;
@@ -1263,7 +1263,7 @@ EOF
          if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
            # Evaluate the configuration.
            eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
-           case "$base_compile " in
+           case $base_compile in
            "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
              # The compiler in $compile_command matches
              # the one in the tagged configuration.
@@ -1319,7 +1319,6 @@ EOF
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
       arg="$1"
-      base_compile="$base_compile $arg"
       shift
       case $arg in
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
@@ -5982,7 +5981,7 @@ relink_command=\"$relink_command\""
              tmpdir="/tmp"
              test -n "$TMPDIR" && tmpdir="$TMPDIR"
              tmpdir="$tmpdir/libtool-$$"
-             if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+             if $mkdir "$tmpdir" && chmod 700 "$tmpdir"; then :
              else
                $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
                continue
index b5afd12a8fb3c46d3b431682684e0d9b003bc61f..99938a5c092f81a3d10f53b63a191f04b25aebd1 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -56,7 +56,7 @@ modename="$progname"
 PROGRAM=ltmain.sh
 PACKAGE=libtool
 VERSION=1.5.0a
-TIMESTAMP=" (1.1220.2.35 2003/11/12 18:51:58) Debian$Rev: 159 $"
+TIMESTAMP=" (1.1220.2.35 2003/11/12 18:51:58) Debian$Rev: 179 $"
 
 default_mode=
 help="Try \`$progname --help' for more information."
@@ -858,7 +858,7 @@ EOF
       ;;
     esac
     libtool_args="$nonopt"
-    base_compile="$nonopt"
+    base_compile="$nonopt $@"
     compile_command="$nonopt"
     finalize_command="$nonopt"
 
@@ -908,7 +908,7 @@ EOF
     # Only attempt this if the compiler in the base link
     # command doesn't match the default compiler.
     if test -n "$available_tags" && test -z "$tagname"; then
-      case "$base_compile " in
+      case $base_compile in
       # Blanks in the command may have been stripped by the calling shell,
       # but not from the CC environment variable when configure was run.
       "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;;
@@ -919,7 +919,7 @@ EOF
          if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
            # Evaluate the configuration.
            eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
-           case "$base_compile " in
+           case $base_compile in
            "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
              # The compiler in $compile_command matches
              # the one in the tagged configuration.
@@ -975,7 +975,6 @@ EOF
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
       arg="$1"
-      base_compile="$base_compile $arg"
       shift
       case $arg in
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
@@ -5638,7 +5637,7 @@ relink_command=\"$relink_command\""
              tmpdir="/tmp"
              test -n "$TMPDIR" && tmpdir="$TMPDIR"
              tmpdir="$tmpdir/libtool-$$"
-             if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+             if $mkdir "$tmpdir" && chmod 700 "$tmpdir"; then :
              else
                $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
                continue
index 11020564c3d181004cf284fd45273b26dc6720fe..fc98789bcd74b339bd74114ce9a2e5be18d60d52 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: plugin_cpuinfo.c,v 1.5 2004/01/16 11:12:26 reinelt Exp $
+/* $Id: plugin_cpuinfo.c,v 1.6 2004/01/21 10:48:17 reinelt Exp $
  *
  * plugin for /proc/cpuinfo parsing
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: plugin_cpuinfo.c,v $
+ * Revision 1.6  2004/01/21 10:48:17  reinelt
+ * hash_age function added
+ *
  * Revision 1.5  2004/01/16 11:12:26  reinelt
  * some bugs in plugin_xmms fixed, parsing moved to own function
  * plugin_proc_stat nearly finished
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
-#include <time.h>
 
 #include "debug.h"
 #include "plugin.h"
 #include "hash.h"
 
 
-static HASH CPUinfo = { 0, 0, NULL };
+static HASH CPUinfo = { 0, };
 
 
 static int parse_cpuinfo (void)
 {
-  static time_t now=0;
+  int age;
   FILE *stream;
-
+  
   // reread every second only
-  if (time(NULL)==now) return 0;
-  time(&now);
+  age=hash_age(&CPUinfo, NULL, NULL);
+  if (age>0 && age<=1000) return 0;
   
     
   stream=fopen("/proc/cpuinfo", "r");
@@ -136,4 +138,3 @@ int plugin_init_cpuinfo (void)
   AddFunction ("cpuinfo", 1, my_cpuinfo);
   return 0;
 }
-
index ec8e6119928bc82fc135f5623e47ed3c8c0c40fa..b455f7199f08901b5b290957b1533d4b0f7a1a10 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: plugin_meminfo.c,v 1.2 2004/01/16 07:26:25 reinelt Exp $
+/* $Id: plugin_meminfo.c,v 1.3 2004/01/21 10:48:17 reinelt Exp $
  *
  * plugin for /proc/meminfo parsing
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: plugin_meminfo.c,v $
+ * Revision 1.3  2004/01/21 10:48:17  reinelt
+ * hash_age function added
+ *
  * Revision 1.2  2004/01/16 07:26:25  reinelt
  * moved various /proc parsing to own functions
  * made some progress with /proc/stat parsing
@@ -49,7 +52,6 @@
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
-#include <time.h>
 
 #include "debug.h"
 #include "plugin.h"
 #include "hash.h"
 
 
-static HASH MemInfo = { 0, 0, NULL };
+static HASH MemInfo = { 0, };
 
 
 static int parse_meminfo (void)
 {
-  static time_t now=0;
-  FILE *stream;
+  int age;
   int line;
+  FILE *stream;
   
-  // reread every second only
-  if (time(NULL)==now) return 0;
-  time(&now);
+  // reread every 100 msec only
+  age=hash_age(&MemInfo, NULL, NULL);
+  if (age>0 && age<=100) return 0;
   
   stream=fopen("/proc/meminfo", "r");
   if (stream==NULL) {
index 52c0ad6d9d7c411b2a2bd881447a20bc5cbd2b5a..d7d56c8eaa626cb65392f1fa0827019ae018573f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: plugin_proc_stat.c,v 1.6 2004/01/20 12:45:47 reinelt Exp $
+/* $Id: plugin_proc_stat.c,v 1.7 2004/01/21 10:48:17 reinelt Exp $
  *
  * plugin for /proc/stat parsing
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: plugin_proc_stat.c,v $
+ * Revision 1.7  2004/01/21 10:48:17  reinelt
+ * hash_age function added
+ *
  * Revision 1.6  2004/01/20 12:45:47  reinelt
  * "Default screen" working with MatrixOrbital
  *
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
-#include <time.h>
-#include <sys/time.h>
 
 #include "debug.h"
 #include "plugin.h"
 #include "hash.h"
 
 
-static HASH Stat = { 0, 0, NULL };
-
-
-static int renew(int msec)
-{
-  static struct timeval end = {0, 0};
-  struct timeval now;
-
-  // update every 10 msec
-  gettimeofday(&now, NULL);
-  if (now.tv_sec==end.tv_sec?now.tv_usec<end.tv_usec:now.tv_sec<end.tv_sec) {
-    return 0;
-  }
-  end.tv_sec  = now.tv_sec;
-  end.tv_usec = now.tv_usec + 1000*msec;
-  while (end.tv_usec > 1000000) {
-    end.tv_usec -= 1000000;
-    end.tv_sec++;
-  }
-  return 1;
-}
-
+static HASH Stat = { 0, };
 
 static void hash_set1 (char *key1, char *val) 
 {
@@ -122,8 +102,9 @@ static int parse_proc_stat (void)
 {
   FILE *stream;
   
-  // update every 10 msec
-  if (!renew(10)) return 0;
+  // reread every 10 msec only
+  age=hash_age(&Stat, NULL, NULL);
+  if (age>0 && age<=10) return 0;
   
   stream=fopen("/proc/stat", "r");
   if (stream==NULL) {
index 4759196e0e4e083ed836921965abaafc6d2e5d11..eacf6753dec785993ce0523843b3947b232400a9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: plugin_xmms.c,v 1.4 2004/01/16 11:12:26 reinelt Exp $
+/* $Id: plugin_xmms.c,v 1.5 2004/01/21 10:48:17 reinelt Exp $
  *
  * XMMS-Plugin for LCD4Linux
  * Copyright 2003 Markus Keil <markus_keil@t-online.de>
@@ -21,6 +21,9 @@
  *
  *
  * $Log: plugin_xmms.c,v $
+ * Revision 1.5  2004/01/21 10:48:17  reinelt
+ * hash_age function added
+ *
  * Revision 1.4  2004/01/16 11:12:26  reinelt
  * some bugs in plugin_xmms fixed, parsing moved to own function
  * plugin_proc_stat nearly finished
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
-#include <time.h>
 
 #include "hash.h"
 #include "debug.h"
 #include "plugin.h"
 
 
-static HASH xmms = { 0, 0, NULL };
+static HASH xmms = { 0, };
 
 
 static int parse_xmms_info (void)
 {
-  static time_t now=0;
   FILE *xmms_stream;
   char zeile[200];
   
-  // reread every second only
-  if (time(NULL)==now) return 0;
-  time(&now);
+  // reread every 100msec only
+  age=hash_age(&xmms, NULL, NULL);
+  if (age>0 && age<=100) return 0;
   
   // Open Filestream for '/tmp/xmms-info'
   xmms_stream = fopen("/tmp/xmms-info","r");