From 9cd75dc72c567208d839e73ee6e4ecf484a08b7c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sat, 25 Aug 2012 08:24:49 +0000 Subject: [PATCH] use bool def from stdbool.h or define it if it does not exist added slog.h in the distribution --- config.h.in | 18 +++--------------- configure.ac | 2 +- po/Makefile.in | 2 +- src/cfg.c | 22 +++++++++++----------- src/cfg.h | 25 +++++++++++++------------ src/lib/Makefile.am | 3 ++- src/lib/Makefile.in | 20 ++++++++++---------- src/lib/bool.h | 30 ++++++++++++++++++++++++++++++ src/lib/psensor.h | 9 +++++---- 9 files changed, 76 insertions(+), 55 deletions(-) create mode 100644 src/lib/bool.h diff --git a/config.h.in b/config.h.in index 965f4fa..10e6356 100644 --- a/config.h.in +++ b/config.h.in @@ -13,9 +13,6 @@ /* Use AppIndicator 0.2.9 */ #undef HAVE_APPINDICATOR_029 -/* Define to 1 if you have the header file. */ -#undef HAVE_ARPA_INET_H - /* Use libatasmart */ #undef HAVE_ATASMART @@ -34,9 +31,6 @@ */ #undef HAVE_DCGETTEXT -/* Define to 1 if you have the header file. */ -#undef HAVE_GETOPT_H - /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT @@ -77,9 +71,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - /* Define to 1 if you have the header file. */ #undef HAVE_NVCTRL_NVCTRLLIB_H @@ -105,6 +96,9 @@ /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET +/* Define to 1 if you have the header file. */ +#undef HAVE_STDBOOL_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H @@ -123,15 +117,9 @@ /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKET_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H diff --git a/configure.ac b/configure.ac index 9cd2deb..897f40e 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AC_PROG_RANLIB # Checks for header files. AC_PATH_X -AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h]) +AC_CHECK_HEADERS([stdbool.h]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T diff --git a/po/Makefile.in b/po/Makefile.in index e5e2145..70e0621 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /tmp +prefix = /usr/local exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/cfg.c b/src/cfg.c index 459193b..f0e53aa 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -141,7 +141,7 @@ static struct color *get_foreground_color() return c; } -static unsigned int is_alpha_channel_enabled() +static bool is_alpha_channel_enabled() { return gconf_client_get_bool(client, KEY_ALPHA_CHANNEL_ENABLED, NULL); } @@ -302,7 +302,7 @@ config_set_sensor_alarm_low_threshold(const char *sid, int threshold) free(key); } -int config_get_sensor_alarm_enabled(const char *sid) +bool config_get_sensor_alarm_enabled(const char *sid) { gboolean b; char *key; @@ -314,7 +314,7 @@ int config_get_sensor_alarm_enabled(const char *sid) return b; } -void config_set_sensor_alarm_enabled(const char *sid, int enabled) +void config_set_sensor_alarm_enabled(const char *sid, bool enabled) { char *key; @@ -323,7 +323,7 @@ void config_set_sensor_alarm_enabled(const char *sid, int enabled) free(key); } -int config_is_sensor_enabled(const char *sid) +bool config_is_sensor_enabled(const char *sid) { gboolean b; char *key; @@ -335,7 +335,7 @@ int config_is_sensor_enabled(const char *sid) return b; } -void config_set_sensor_enabled(const char *sid, int enabled) +void config_set_sensor_enabled(const char *sid, bool enabled) { char *key; @@ -364,7 +364,7 @@ void config_set_sensor_name(const char *sid, const char *name) free(key); } -unsigned int config_is_appindicator_enabled(const char *sid) +bool config_is_appindicator_enabled(const char *sid) { char *key; gboolean b; @@ -376,7 +376,7 @@ unsigned int config_is_appindicator_enabled(const char *sid) return !b; } -void config_set_appindicator_enabled(const char *sid, unsigned int enabled) +void config_set_appindicator_enabled(const char *sid, bool enabled) { char *key; @@ -386,28 +386,28 @@ void config_set_appindicator_enabled(const char *sid, unsigned int enabled) } -static int is_window_decoration_enabled() +static bool is_window_decoration_enabled() { return !gconf_client_get_bool(client, KEY_INTERFACE_WINDOW_DECORATION_DISABLED, NULL); } -static int is_window_keep_below_enabled() +static bool is_window_keep_below_enabled() { return gconf_client_get_bool(client, KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, NULL); } -static void set_window_decoration_enabled(int enabled) +static void set_window_decoration_enabled(bool enabled) { gconf_client_set_bool (client, KEY_INTERFACE_WINDOW_DECORATION_DISABLED, !enabled, NULL); } -static void set_window_keep_below_enabled(int enabled) +static void set_window_keep_below_enabled(bool enabled) { gconf_client_set_bool(client, KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, diff --git a/src/cfg.h b/src/cfg.h index 754880c..4319db9 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -19,6 +19,7 @@ #ifndef _PSENSOR_CONFIG_H_ #define _PSENSOR_CONFIG_H_ +#include "bool.h" #include "color.h" enum temperature_unit { @@ -39,16 +40,16 @@ struct config { double graph_bg_alpha; - int alpha_channel_enabled; + bool alpha_channel_enabled; /* * Position of the sensors list table */ enum sensorlist_position sensorlist_position; - int window_decoration_enabled; - int window_keep_below_enabled; - int window_restore_enabled; + bool window_decoration_enabled; + bool window_keep_below_enabled; + bool window_restore_enabled; /* Last saved position of the window. */ int window_x; int window_y; @@ -64,9 +65,9 @@ struct config { int sensor_values_max_length; int sensor_update_interval; - int menu_bar_disabled; + bool menu_bar_disabled; - int unity_launcher_count_disabled; + bool unity_launcher_count_disabled; int hide_on_startup; @@ -91,16 +92,16 @@ void config_set_sensor_alarm_high_threshold(const char *, int); int config_get_sensor_alarm_low_threshold(const char *); void config_set_sensor_alarm_low_threshold(const char *, int); -int config_get_sensor_alarm_enabled(const char *); -void config_set_sensor_alarm_enabled(const char *, int); +bool config_get_sensor_alarm_enabled(const char *); +void config_set_sensor_alarm_enabled(const char *, bool); -int config_is_sensor_enabled(const char *); -void config_set_sensor_enabled(const char *, int); +bool config_is_sensor_enabled(const char *); +void config_set_sensor_enabled(const char *, bool); char *config_get_sensor_name(const char *); void config_set_sensor_name(const char *, const char *); -unsigned int config_is_appindicator_enabled(const char *); -void config_set_appindicator_enabled(const char *, unsigned int); +bool config_is_appindicator_enabled(const char *); +void config_set_appindicator_enabled(const char *, bool); #endif diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index cd55b3c..5a22d4d 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -2,6 +2,7 @@ noinst_LIBRARIES = libpsensor.a libpsensor_a_SOURCES = \ amd.h \ + bool.h \ color.h color.c \ cpu.h \ hdd.h hdd_hddtemp.c\ @@ -11,7 +12,7 @@ libpsensor_a_SOURCES = \ nvidia.h \ psensor.h psensor.c\ pio.h pio.c \ - slog.c \ + slog.c slog.h \ url.c url.h AM_CPPFLAGS = -Wall -Werror diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 1c5d84a..8255b3a 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -62,11 +62,11 @@ AR = ar ARFLAGS = cru libpsensor_a_AR = $(AR) $(ARFLAGS) libpsensor_a_LIBADD = -am__libpsensor_a_SOURCES_DIST = amd.h color.h color.c cpu.h hdd.h \ - hdd_hddtemp.c lmsensor.h lmsensor.c log.h log.c measure.h \ - measure.c nvidia.h psensor.h psensor.c pio.h pio.c slog.c \ - url.c url.h hdd_atasmart.c nvidia.c amd.c cpu.c psensor_json.h \ - psensor_json.c +am__libpsensor_a_SOURCES_DIST = amd.h bool.h color.h color.c cpu.h \ + hdd.h hdd_hddtemp.c lmsensor.h lmsensor.c log.h log.c \ + measure.h measure.c nvidia.h psensor.h psensor.c pio.h pio.c \ + slog.c slog.h url.c url.h hdd_atasmart.c nvidia.c amd.c cpu.c \ + psensor_json.h psensor_json.c @ATASMART_TRUE@am__objects_1 = hdd_atasmart.$(OBJEXT) @NVIDIA_TRUE@am__objects_2 = nvidia.$(OBJEXT) @LIBATIADL_TRUE@am__objects_3 = amd.$(OBJEXT) @@ -242,11 +242,11 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LIBRARIES = libpsensor.a -libpsensor_a_SOURCES = amd.h color.h color.c cpu.h hdd.h hdd_hddtemp.c \ - lmsensor.h lmsensor.c log.h log.c measure.h measure.c nvidia.h \ - psensor.h psensor.c pio.h pio.c slog.c url.c url.h \ - $(am__append_1) $(am__append_4) $(am__append_7) \ - $(am__append_8) $(am__append_11) +libpsensor_a_SOURCES = amd.h bool.h color.h color.c cpu.h hdd.h \ + hdd_hddtemp.c lmsensor.h lmsensor.c log.h log.c measure.h \ + measure.c nvidia.h psensor.h psensor.c pio.h pio.c slog.c \ + slog.h url.c url.h $(am__append_1) $(am__append_4) \ + $(am__append_7) $(am__append_8) $(am__append_11) AM_CPPFLAGS = -Wall -Werror $(am__append_3) $(am__append_6) \ $(am__append_10) $(am__append_13) EXTRA_DIST = $(libpsensor_a_SOURCES) \ diff --git a/src/lib/bool.h b/src/lib/bool.h new file mode 100644 index 0000000..4d5f2c1 --- /dev/null +++ b/src/lib/bool.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2010-2012 jeanfi@gmail.com + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#ifndef _PSENSOR_BOOL_H_ +#define _PSENSOR_BOOL_H_ + +#include "config.h" + +#if HAVE_STDBOOL +#include +#else +#define bool char +#endif + +#endif diff --git a/src/lib/psensor.h b/src/lib/psensor.h index 3b18a66..012bd12 100644 --- a/src/lib/psensor.h +++ b/src/lib/psensor.h @@ -19,13 +19,14 @@ #ifndef _PSENSOR_PSENSOR_H_ #define _PSENSOR_PSENSOR_H_ -#include "config.h" #include +#include "config.h" #ifdef HAVE_ATASMART #include #endif +#include "bool.h" #include "color.h" #include "log.h" #include "measure.h" @@ -73,7 +74,7 @@ struct psensor { struct color *color; /* Whether the graph sensor is displayed. */ - unsigned int enabled; + bool enabled; /* see psensor_type */ unsigned int type; @@ -85,7 +86,7 @@ struct psensor { double min; /* Whether alarm alert is enabled for this sensor */ - unsigned int alarm_enabled; + bool alarm_enabled; int alarm_high_threshold; int alarm_low_threshold; @@ -110,7 +111,7 @@ struct psensor { char *url; - unsigned int appindicator_enabled; + bool appindicator_enabled; }; struct psensor *psensor_create(char *id, -- 2.7.4