From: Max Kellermann Date: Thu, 2 Oct 2008 15:47:01 +0000 (+0200) Subject: options: use stdbool X-Git-Tag: v0.12_alpha1~110 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4522707accad358bd3098a6b1dd6966da5564610;p=ncmpc.git options: use stdbool Use the standard "bool" type instead of glib's "gboolean". This way, options.h doesn't have to include the fat glib.h. --- diff --git a/src/conf.c b/src/conf.c index e0214ce..66f125d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -83,13 +83,11 @@ typedef enum { KEY_PARSER_DONE } key_parser_state_t; -static gboolean +static bool str2bool(char *str) { - if (!strcasecmp(str, "yes") || !strcasecmp(str, "true") || - !strcasecmp(str, "on") || !strcasecmp(str, "1")) - return TRUE; - return FALSE; + return strcasecmp(str, "yes") == 0 || strcasecmp(str, "true") == 0 || + strcasecmp(str, "on") == 0 || strcasecmp(str, "1") == 0; } static int diff --git a/src/options.c b/src/options.c index 2a02dca..421eda7 100644 --- a/src/options.c +++ b/src/options.c @@ -165,19 +165,19 @@ handle_option(int c, const char *arg) printf("\n"); exit(EXIT_SUCCESS); case 'c': /* --colors */ - options.enable_colors = TRUE; + options.enable_colors = true; break; case 'C': /* --no-colors */ - options.enable_colors = FALSE; + options.enable_colors = false; break; case 'm': /* --mouse */ - options.enable_mouse = TRUE; + options.enable_mouse = true; break; case 'M': /* --no-mouse */ - options.enable_mouse = FALSE; + options.enable_mouse = false; break; case 'e': /* --exit */ - options.reconnect = FALSE; + options.reconnect = false; break; case 'p': /* --port */ options.port = atoi(arg); @@ -212,7 +212,7 @@ handle_option(int c, const char *arg) exit(EXIT_SUCCESS); break; case 'D': /* --debug */ - options.debug = TRUE; + options.debug = true; break; #endif default: @@ -335,11 +335,11 @@ options_init( void ) /* default option values */ options.list_format = g_strdup(DEFAULT_LIST_FORMAT); options.status_format = g_strdup(DEFAULT_STATUS_FORMAT); - options.reconnect = TRUE; - options.find_wrap = TRUE; - options.wide_cursor = TRUE; - options.welcome_screen_list = TRUE; - options.audible_bell = TRUE; + options.reconnect = true; + options.find_wrap = true; + options.wide_cursor = true; + options.welcome_screen_list = true; + options.audible_bell = true; options.crossfade_time = DEFAULT_CROSSFADE_TIME; options.seek_time = 1; options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0); diff --git a/src/options.h b/src/options.h index f29014c..70853f4 100644 --- a/src/options.h +++ b/src/options.h @@ -1,7 +1,7 @@ #ifndef OPTIONS_H #define OPTIONS_H -#include +#include #define MPD_HOST_ENV "MPD_HOST" #define MPD_PORT_ENV "MPD_PORT" @@ -24,21 +24,21 @@ typedef struct { int hide_cursor; int seek_time; int lyrics_timeout; - gboolean reconnect; - gboolean debug; - gboolean find_wrap; - gboolean find_show_last_pattern; - gboolean list_wrap; - gboolean auto_center; - gboolean wide_cursor; - gboolean enable_colors; - gboolean audible_bell; - gboolean visible_bell; - gboolean enable_xterm_title; - gboolean enable_mouse; - gboolean scroll; - gboolean visible_bitrate; - gboolean welcome_screen_list; + bool reconnect; + bool debug; + bool find_wrap; + bool find_show_last_pattern; + bool list_wrap; + bool auto_center; + bool wide_cursor; + bool enable_colors; + bool audible_bell; + bool visible_bell; + bool enable_xterm_title; + bool enable_mouse; + bool scroll; + bool visible_bitrate; + bool welcome_screen_list; } options_t; #ifndef NO_GLOBAL_OPTIONS