From 22959322fbacd8bb1b126d0d2b3578e358ea7e44 Mon Sep 17 00:00:00 2001 From: Bernhard Walle Date: Sun, 31 Jul 2005 22:54:22 +0000 Subject: [PATCH] * Fixed error output if not in debug mode (#4707) * Increased version number to 0.3.3. (Old svn revision: 756) --- ChangeLog | 4 +++ compile | 8 +++--- configure.ac | 2 +- depcomp | 53 +++++++++++++++++++++++----------------- missing | 16 +++++++----- panel-plugin/Makefile.am | 1 + panel-plugin/global.h | 39 +++++++++++++++++++++++++++++ panel-plugin/net.c | 14 +++++------ panel-plugin/netload.c | 45 +++++++++++----------------------- 9 files changed, 110 insertions(+), 72 deletions(-) create mode 100644 panel-plugin/global.h diff --git a/ChangeLog b/ChangeLog index 8c52522..6419e7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-08-01 Bernhard Walle + * Fixed error output if not in debug mode (#4707) + * Increased version number to 0.3.3. + 2005-05-17 Bernhard Walle * Fixed memory leak (#971). diff --git a/compile b/compile index 3d21703..ad57e2f 100755 --- a/compile +++ b/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2004-10-12.08 +scriptversion=2005-02-03.08 -# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -47,11 +47,11 @@ right script to run: please start by reading the file `INSTALL'. Report bugs to . EOF - exit 0 + exit $? ;; -v | --v*) echo "compile $scriptversion" - exit 0 + exit $? ;; esac diff --git a/configure.ac b/configure.ac index 44a6318..41e5b70 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_INIT([panel-plugin/netload.c]) AM_CONFIG_HEADER([config.h]) -AM_INIT_AUTOMAKE([xfce4-netload-plugin], [0.3.2]) +AM_INIT_AUTOMAKE([xfce4-netload-plugin], [0.3.3]) AM_MAINTAINER_MODE diff --git a/depcomp b/depcomp index 11e2d3b..ffcd540 100755 --- a/depcomp +++ b/depcomp @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2004-05-31.23 +scriptversion=2005-02-09.22 -# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,11 +50,11 @@ Environment variables: Report bugs to . EOF - exit 0 + exit $? ;; -v | --v*) echo "depcomp $scriptversion" - exit 0 + exit $? ;; esac @@ -287,36 +287,43 @@ tru64) base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then - # Dependencies are output in .lo.d with libtool 1.4. - # With libtool 1.5 they are output both in $dir.libs/$base.o.d - # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the - # latter, because the former will be cleaned when $dir.libs is - # erased. - tmpdepfile1="$dir.libs/$base.lo.d" - tmpdepfile2="$dir$base.o.d" - tmpdepfile3="$dir.libs/$base.d" + # With Tru64 cc, shared objects can also be used to make a + # static library. This mecanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else - tmpdepfile1="$dir$base.o.d" - tmpdepfile2="$dir$base.d" - tmpdepfile3="$dir$base.d" + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - elif test -f "$tmpdepfile2"; then - tmpdepfile="$tmpdepfile2" - else - tmpdepfile="$tmpdepfile3" - fi + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. diff --git a/missing b/missing index 64b5f90..09edd88 100755 --- a/missing +++ b/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2004-09-07.08 +scriptversion=2005-02-08.22 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. @@ -87,12 +87,12 @@ Supported PROGRAM values: yacc create \`y.tab.[ch]', if possible, from existing .[ch] Send bug reports to ." - exit 0 + exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" - exit 0 + exit $? ;; -*) @@ -288,10 +288,14 @@ WARNING: \`$1' is $msg. You should only need it if call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi touch $file ;; diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am index 91c828b..30d1f75 100644 --- a/panel-plugin/Makefile.am +++ b/panel-plugin/Makefile.am @@ -20,6 +20,7 @@ libnetload_la_SOURCES = \ net.c \ os.h \ wormulon.h \ + global.h \ slurm.h libnetload_la_CFLAGS = \ diff --git a/panel-plugin/global.h b/panel-plugin/global.h new file mode 100644 index 0000000..94a5af6 --- /dev/null +++ b/panel-plugin/global.h @@ -0,0 +1,39 @@ +/* + * Id: $Id$ + * ------------------------------------------------------------------------------------------------- + * + * This program 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; You may only use + * version 2 of the License, you have no option to use any other version. + * + * This program 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. + * + * ------------------------------------------------------------------------------------------------- + */ +#ifndef GLOBAL_H +#define GLOBAL_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef DEBUG + +# define PRINT_DBG(fmt, ...) \ + { \ + fprintf(stderr, "DEBUG[%s:%d]: "fmt, __FILE__, __LINE__, \ + ## __VA_ARGS__); \ + } + +#else + +# define PRINT_DBG(fmt, ...) { do {} while(0); } + +#endif + +#endif /* GLOBAL_H */ diff --git a/panel-plugin/net.c b/panel-plugin/net.c index e341f3e..e31b423 100644 --- a/panel-plugin/net.c +++ b/panel-plugin/net.c @@ -1,5 +1,5 @@ /* - * Id: $Id: net.c,v 1.8 2005/02/04 18:14:41 bwalle Exp $ + * Id: $Id$ * ------------------------------------------------------------------------------------------------- * * This program is free software; you can redistribute it and/or modify it under the terms of the @@ -36,7 +36,9 @@ #include "slurm.h" /* slurm structs */ #include +#include +#include "global.h" #ifdef __HPUX__ # include "wormulon/hpux.h" @@ -96,9 +98,7 @@ int init_netload(netdata* data, const char* device) data->correct_interface = TRUE; -#ifdef DEBUG - fprintf( stderr, "The netload plugin was initialized for '%s'.\n", device ); -#endif /* DEBUG */ + PRINT_DBG("The netload plugin was initialized for '%s'.", device); return TRUE; } @@ -184,7 +184,7 @@ char* get_ip_address(netdata* data) /* get the value from the operating system */ if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - perror("Error in socket"); + PRINT_DBG("Error in socket: %s", strerror(errno)); return NULL; } @@ -192,7 +192,7 @@ char* get_ip_address(netdata* data) if (ioctl(sockfd, SIOCGIFADDR, &ifr) != 0) { close(sockfd); - perror("Error in ictl(sockfd)"); + PRINT_DBG("Error in ictl(sockfd): %s", strerror(errno)); return NULL; } close(sockfd); @@ -201,7 +201,7 @@ char* get_ip_address(netdata* data) if (!inet_ntop(AF_INET, &p_sa->sin_addr, data->ip_address, IP_ADDRESS_LENGTH)) { - perror("Error in inet_ntop"); + PRINT_DBG("Error in inet_ntop: %s", strerror(errno)); return NULL; } diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c index 2983128..288713f 100644 --- a/panel-plugin/netload.c +++ b/panel-plugin/netload.c @@ -1,5 +1,5 @@ /* - * Id: $Id: netload.c,v 1.12 2005/02/04 18:12:01 bwalle Exp $ + * Id: $Id$ * ------------------------------------------------------------------------------------------------- * * This program is free software; you can redistribute it and/or modify it under the terms of the @@ -21,6 +21,7 @@ #include "net.h" #include "utils.h" +#include "global.h" #include @@ -188,15 +189,15 @@ static gboolean update_monitors(t_global_monitor *global) switch (i) { case IN: - fprintf(stderr, "input: Max = %lu\n", global->monitor->net_max[i]); + PRINT_DBG("input: Max = %lu", global->monitor->net_max[i]); break; case OUT: - fprintf(stderr, "output: Max = %lu\n", global->monitor->net_max[i]); + PRINT_DBG("output: Max = %lu", global->monitor->net_max[i]); break; case TOT: - fprintf(stderr, "total: Max = %lu\n", global->monitor->net_max[i]); + PRINT_DBG("total: Max = %lu", global->monitor->net_max[i]); break; } #endif /* DEBUG */ @@ -627,9 +628,7 @@ static void monitor_read_config(Control *ctrl, xmlNodePtr node) break; } } -#ifdef DEBUG - printf("monitor_read_config\n"); -#endif + PRINT_DBG("monitor_read_config"); setup_monitor(global, TRUE); } @@ -722,9 +721,7 @@ static void monitor_set_size(Control *ctrl, int size) } gtk_widget_queue_resize(GTK_WIDGET(global->monitor->status[i])); } -#ifdef DEBUG - printf("monitor_set_size\n"); -#endif + PRINT_DBG("monitor_set_size"); setup_monitor(global, TRUE); } @@ -764,9 +761,7 @@ static void monitor_apply_options_cb(GtkWidget *button, t_global_monitor *global GTK_SPIN_BUTTON(global->monitor->update_spinner) ) * 1000 + 0.5); setup_monitor(global, FALSE); -#ifdef DEBUG - printf("monitor_apply_options_cb\n"); -#endif + PRINT_DBG("monitor_apply_options_cb"); } @@ -782,9 +777,7 @@ static void label_changed(GtkWidget *button, t_global_monitor *global) g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->opt_entry))); setup_monitor(global, FALSE); -#ifdef DEBUG - printf("label_changed\n"); -#endif + PRINT_DBG("label_changed"); } @@ -800,9 +793,7 @@ static void max_label_changed(GtkWidget *button, t_global_monitor *global) } setup_monitor(global, FALSE); -#ifdef DEBUG - printf("max_label_changed\n"); -#endif + PRINT_DBG("max_label_changed"); } @@ -818,9 +809,7 @@ static void network_changed(GtkWidget *button, t_global_monitor *global) g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->net_entry))); setup_monitor(global, FALSE); -#ifdef DEBUG - printf("network_changed\n"); -#endif + PRINT_DBG("network_changed"); } @@ -835,9 +824,7 @@ static void label_toggled(GtkWidget *check_button, t_global_monitor *global) global->monitor->options.use_label); setup_monitor(global, FALSE); -#ifdef DEBUG - printf("label_toggled\n"); -#endif + PRINT_DBG("label_toggled"); } @@ -860,9 +847,7 @@ static void max_label_toggled(GtkWidget *check_button, t_global_monitor *global) } } setup_monitor(global, FALSE); -#ifdef DEBUG - printf("max_label_toggled\n"); -#endif + PRINT_DBG("max_label_toggled"); } @@ -915,9 +900,7 @@ static void change_color(GtkWidget *button, t_global_monitor *global, gint type) &global->monitor->options.color[type]); setup_monitor(global, FALSE); } -#ifdef DEBUG - printf("change_color\n"); -#endif + PRINT_DBG("change_color"); gtk_widget_destroy(dialog); }