Drop global.h, and use DBG() macro from libxfce4util instead of the hand-rolled PRINT_DBG()

master
Landry Breuil 2016-05-14 15:37:34 +02:00
parent 39ba253ed3
commit b02c6f44e9
3 changed files with 22 additions and 65 deletions

View File

@ -1,42 +0,0 @@
/*
* Copyright 2005 Bernhard Walle <bernhard@bwalle.de>
* -------------------------------------------------------------------------------------------------
*
* 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; either version 2 of the License, or (at your option)
* any later 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 <config.h>
#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 */

View File

@ -33,6 +33,8 @@
#include <config.h> #include <config.h>
#endif #endif
#include <libxfce4util/libxfce4util.h>
/* From Wormulon */ /* From Wormulon */
#include "net.h" #include "net.h"
#include "os.h" #include "os.h"
@ -42,8 +44,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include "global.h"
#ifdef __HPUX__ #ifdef __HPUX__
# include "wormulon/hpux.h" # include "wormulon/hpux.h"
# include "wormulon/hpux.c" # include "wormulon/hpux.c"
@ -104,7 +104,7 @@ int init_netload(netdata* data, const char* device)
data->correct_interface = TRUE; data->correct_interface = TRUE;
PRINT_DBG("The netload plugin was initialized for '%s'.", device); DBG("The netload plugin was initialized for '%s'.", device);
return TRUE; return TRUE;
} }
@ -190,14 +190,14 @@ int get_interface_up(netdata* data)
/* get the value from the operating system */ /* get the value from the operating system */
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{ {
PRINT_DBG("Error in socket: %s", strerror(errno)); DBG("Error in socket: %s", strerror(errno));
return FALSE; return FALSE;
} }
snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", data->ifdata.if_name); snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", data->ifdata.if_name);
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) != 0) if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) != 0)
{ {
PRINT_DBG("Error in ioctl(sockfd): %s", strerror(errno)); DBG("Error in ioctl(sockfd): %s", strerror(errno));
close(sockfd); close(sockfd);
return FALSE; return FALSE;
} }
@ -227,7 +227,7 @@ char* get_ip_address(netdata* data)
/* get the value from the operating system */ /* get the value from the operating system */
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{ {
PRINT_DBG("Error in socket: %s", strerror(errno)); DBG("Error in socket: %s", strerror(errno));
return NULL; return NULL;
} }
@ -236,7 +236,7 @@ char* get_ip_address(netdata* data)
{ {
if (errno != EADDRNOTAVAIL) if (errno != EADDRNOTAVAIL)
{ {
PRINT_DBG("Error in ioctl(sockfd): %s", strerror(errno)); DBG("Error in ioctl(sockfd): %s", strerror(errno));
} }
close(sockfd); close(sockfd);
return NULL; return NULL;
@ -247,7 +247,7 @@ char* get_ip_address(netdata* data)
if (!inet_ntop(AF_INET, &p_sa->sin_addr, data->ip_address, IP_ADDRESS_LENGTH)) if (!inet_ntop(AF_INET, &p_sa->sin_addr, data->ip_address, IP_ADDRESS_LENGTH))
{ {
PRINT_DBG("Error in inet_ntop: %s", strerror(errno)); DBG("Error in inet_ntop: %s", strerror(errno));
return NULL; return NULL;
} }

View File

@ -25,7 +25,6 @@
#include "net.h" #include "net.h"
#include "utils.h" #include "utils.h"
#include "global.h"
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -217,15 +216,15 @@ static gboolean update_monitors(t_global_monitor *global)
switch (i) switch (i)
{ {
case IN: case IN:
PRINT_DBG("input: Max = %lu", global->monitor->net_max[i]); DBG("input: Max = %lu", global->monitor->net_max[i]);
break; break;
case OUT: case OUT:
PRINT_DBG("output: Max = %lu", global->monitor->net_max[i]); DBG("output: Max = %lu", global->monitor->net_max[i]);
break; break;
case TOT: case TOT:
PRINT_DBG("total: Max = %lu", global->monitor->net_max[i]); DBG("total: Max = %lu", global->monitor->net_max[i]);
break; break;
} }
#endif /* DEBUG */ #endif /* DEBUG */
@ -296,7 +295,7 @@ static gboolean monitor_set_size(XfcePanelPlugin *plugin, int size, t_global_mon
gint i; gint i;
XfcePanelPluginMode mode = xfce_panel_plugin_get_mode (plugin); XfcePanelPluginMode mode = xfce_panel_plugin_get_mode (plugin);
PRINT_DBG("monitor_set_size"); DBG("monitor_set_size");
if (mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR) if (mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
{ {
@ -331,7 +330,7 @@ static void monitor_set_mode (XfcePanelPlugin *plugin, XfcePanelPluginMode mode,
{ {
gint i; gint i;
PRINT_DBG("monitor_set_mode"); DBG("monitor_set_mode");
if (global->timeout_id) if (global->timeout_id)
{ {
@ -666,7 +665,7 @@ static void monitor_read_config(XfcePanelPlugin *plugin, t_global_monitor *globa
global->monitor->options.values_as_bits = xfce_rc_read_bool_entry (rc, "Values_As_Bits", FALSE); global->monitor->options.values_as_bits = xfce_rc_read_bool_entry (rc, "Values_As_Bits", FALSE);
PRINT_DBG("monitor_read_config"); DBG("monitor_read_config");
setup_monitor(global, TRUE); setup_monitor(global, TRUE);
xfce_rc_close (rc); xfce_rc_close (rc);
@ -761,7 +760,7 @@ static void monitor_apply_options(t_global_monitor *global)
GTK_SPIN_BUTTON(global->monitor->update_spinner) ) * 1000 + 0.5); GTK_SPIN_BUTTON(global->monitor->update_spinner) ) * 1000 + 0.5);
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("monitor_apply_options_cb"); DBG("monitor_apply_options_cb");
} }
@ -777,7 +776,7 @@ static void label_changed(GtkWidget *button, t_global_monitor *global)
g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->opt_entry))); g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->opt_entry)));
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("label_changed"); DBG("label_changed");
} }
@ -792,7 +791,7 @@ static void max_label_changed(GtkWidget *button, t_global_monitor *global)
} }
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("max_label_changed"); DBG("max_label_changed");
} }
@ -808,7 +807,7 @@ static void network_changed(GtkWidget *button, t_global_monitor *global)
g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->net_entry))); g_strdup(gtk_entry_get_text(GTK_ENTRY(global->monitor->net_entry)));
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("network_changed"); DBG("network_changed");
} }
@ -822,7 +821,7 @@ static void label_toggled(GtkWidget *check_button, t_global_monitor *global)
global->monitor->options.use_label); global->monitor->options.use_label);
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("label_toggled"); DBG("label_toggled");
} }
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */
@ -832,7 +831,7 @@ static void as_bits_toggled(GtkWidget *check_button, t_global_monitor *global)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(global->monitor->opt_as_bits), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(global->monitor->opt_as_bits),
global->monitor->options.values_as_bits); global->monitor->options.values_as_bits);
PRINT_DBG("label_toggled"); DBG("label_toggled");
} }
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */
@ -848,7 +847,7 @@ static void present_data_combobox_changed(GtkWidget *combobox, t_global_monitor
global->monitor->options.show_values); global->monitor->options.show_values);
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("present_data_combobox_changed"); DBG("present_data_combobox_changed");
} }
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */
@ -870,7 +869,7 @@ static void max_label_toggled(GtkWidget *check_button, t_global_monitor *global)
} }
} }
setup_monitor(global, FALSE); setup_monitor(global, FALSE);
PRINT_DBG("max_label_toggled"); DBG("max_label_toggled");
} }