summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 88af2c3)
raw | patch | inline | side by side (parent: 88af2c3)
author | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 12:25:45 +0000 (14:25 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 12:25:45 +0000 (14:25 +0200) |
Just make everybody use the global "options" variable. This
eliminates namespace confusion and the NO_GLOBAL_OPTIONS hack.
eliminates namespace confusion and the NO_GLOBAL_OPTIONS hack.
src/conf.c | patch | blob | history | |
src/conf.h | patch | blob | history | |
src/main.c | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index 4485cda5981660676f4de691d81bdf7a9cde96ff..1630f6231752d04ded067543802b561f0a20aa7a 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
*
*/
-#define NO_GLOBAL_OPTIONS
#include "conf.h"
#include "config.h"
#include "defaults.h"
}
static int
-read_rc_file(char *filename, options_t *options)
+read_rc_file(char *filename)
{
int fd;
int quit = 0;
/* enable colors */
else if(!strcasecmp(CONF_ENABLE_COLORS, name))
#ifdef ENABLE_COLORS
- options->enable_colors = str2bool(value);
+ options.enable_colors = str2bool(value);
#else
{}
#endif
/* auto center */
else if (!strcasecmp(CONF_AUTO_CENTER, name))
- options->auto_center = str2bool(value);
+ options.auto_center = str2bool(value);
/* color assignment */
else if (!strcasecmp(CONF_COLOR, name))
#ifdef ENABLE_COLORS
#endif
/* wide cursor */
else if (!strcasecmp(CONF_WIDE_CURSOR, name))
- options->wide_cursor = str2bool(value);
+ options.wide_cursor = str2bool(value);
/* welcome screen list */
else if (!strcasecmp(CONF_WELCOME_SCREEN_LIST, name))
- options->welcome_screen_list = str2bool(value);
+ options.welcome_screen_list = str2bool(value);
/* visible bitrate */
else if (!strcasecmp(CONF_VISIBLE_BITRATE, name))
- options->visible_bitrate = str2bool(value);
+ options.visible_bitrate = str2bool(value);
/* timer display type */
else if (!strcasecmp(CONF_TIMEDISPLAY_TYPE, name)) {
- g_free(options->timedisplay_type);
- options->timedisplay_type=g_strdup(parse_timedisplay_type(value));
+ g_free(options.timedisplay_type);
+ options.timedisplay_type=g_strdup(parse_timedisplay_type(value));
/* color definition */
} else if (!strcasecmp(CONF_COLOR_DEFINITION, name))
#ifdef ENABLE_COLORS
#endif
/* list format string */
else if (!strcasecmp(CONF_LIST_FORMAT, name)) {
- g_free(options->list_format);
- options->list_format = get_format(value);
+ g_free(options.list_format);
+ options.list_format = get_format(value);
/* status format string */
} else if (!strcasecmp(CONF_STATUS_FORMAT, name)) {
- g_free(options->status_format);
- options->status_format = get_format(value);
+ g_free(options.status_format);
+ options.status_format = get_format(value);
/* xterm title format string */
} else if (!strcasecmp(CONF_XTERM_TITLE_FORMAT, name)) {
- g_free(options->xterm_title_format);
- options->xterm_title_format = get_format(value);
+ g_free(options.xterm_title_format);
+ options.xterm_title_format = get_format(value);
} else if (!strcasecmp(CONF_LIST_WRAP, name))
- options->list_wrap = str2bool(value);
+ options.list_wrap = str2bool(value);
else if (!strcasecmp(CONF_FIND_WRAP, name))
- options->find_wrap = str2bool(value);
+ options.find_wrap = str2bool(value);
else if (!strcasecmp(CONF_FIND_SHOW_LAST,name))
- options->find_show_last_pattern = str2bool(value);
+ options.find_show_last_pattern = str2bool(value);
else if (!strcasecmp(CONF_AUDIBLE_BELL, name))
- options->audible_bell = str2bool(value);
+ options.audible_bell = str2bool(value);
else if (!strcasecmp(CONF_VISIBLE_BELL, name))
- options->visible_bell = str2bool(value);
+ options.visible_bell = str2bool(value);
else if (!strcasecmp(CONF_XTERM_TITLE, name))
- options->enable_xterm_title = str2bool(value);
+ options.enable_xterm_title = str2bool(value);
else if (!strcasecmp(CONF_ENABLE_MOUSE, name))
- options->enable_mouse = str2bool(value);
+ options.enable_mouse = str2bool(value);
else if (!strcasecmp(CONF_CROSSFADE_TIME, name))
- options->crossfade_time = atoi(value);
+ options.crossfade_time = atoi(value);
else if (!strcasecmp(CONF_SEARCH_MODE, name))
- options->search_mode = atoi(value);
+ options.search_mode = atoi(value);
else if (!strcasecmp(CONF_HIDE_CURSOR, name))
- options->hide_cursor = atoi(value);
+ options.hide_cursor = atoi(value);
else if (!strcasecmp(CONF_SEEK_TIME, name))
- options->seek_time = atoi(value);
+ options.seek_time = atoi(value);
else if (!strcasecmp(CONF_SCREEN_LIST, name)) {
- g_strfreev(options->screen_list);
- options->screen_list = check_screen_list(value);
+ g_strfreev(options.screen_list);
+ options.screen_list = check_screen_list(value);
} else if (!strcasecmp(CONF_SHOW_SPLASH, name)) {
/* the splash screen was removed */
} else if (!strcasecmp(CONF_HOST, name))
- options->host = get_format(value);
+ options.host = get_format(value);
else if (!strcasecmp(CONF_PORT, name))
- options->port = atoi(get_format(value));
+ options.port = atoi(get_format(value));
else if (!strcasecmp(CONF_PASSWORD, name))
- options->password = get_format(value);
+ options.password = get_format(value);
else if (!strcasecmp(CONF_LYRICS_TIMEOUT, name))
- options->lyrics_timeout = atoi(get_format(value));
+ options.lyrics_timeout = atoi(get_format(value));
else if (!strcasecmp(CONF_SCROLL, name))
- options->scroll = str2bool(value);
+ options.scroll = str2bool(value);
else if (!strcasecmp(CONF_SCROLL_SEP, name)) {
- g_free(options->scroll_sep);
- options->scroll_sep = get_format(value);
+ g_free(options.scroll_sep);
+ options.scroll_sep = get_format(value);
} else
match_found = 0;
}
int
-read_configuration(options_t *options)
+read_configuration(void)
{
char *filename = NULL;
/* check for command line configuration file */
- if (options->config_file)
- filename = g_strdup(options->config_file);
+ if (options.config_file)
+ filename = g_strdup(options.config_file);
/* check for user configuration ~/.ncmpc/config */
if (filename == NULL) {
/* load configuration */
if (filename) {
- read_rc_file(filename, options);
+ read_rc_file(filename);
g_free(filename);
filename = NULL;
}
/* check for command line key binding file */
- if (options->key_file)
- filename = g_strdup(options->key_file);
+ if (options.key_file)
+ filename = g_strdup(options.key_file);
/* check for user key bindings ~/.ncmpc/keys */
if (filename == NULL) {
/* load key bindings */
if (filename) {
- read_rc_file(filename, options);
+ read_rc_file(filename);
g_free(filename);
filename = NULL;
}
diff --git a/src/conf.h b/src/conf.h
index 97e73b3d8abe3e27cc0bd2f9755f0f97262ed0ad..3203a2d43e71e4ab893a8c5a8955a629faa47a4c 100644 (file)
--- a/src/conf.h
+++ b/src/conf.h
char *get_user_key_binding_filename(void);
-int read_configuration(options_t *options);
+int read_configuration(void);
diff --git a/src/main.c b/src/main.c
index e701712fd871974057e43ee5d8842a580df4e019..3a6243c37fbe8065397ebff4d71e5262ada591eb 100644 (file)
--- a/src/main.c
+++ b/src/main.c
options_parse(argc, argv);
/* read configuration */
- read_configuration(&options);
+ read_configuration();
/* check key bindings */
check_key_bindings(NULL, NULL, 0);
diff --git a/src/options.c b/src/options.c
index 1b592a567fa39e0035144255b081a7e96371ae2b..53f54b7ebfa099d6edc867ae7180aafdec95bdcd 100644 (file)
--- a/src/options.c
+++ b/src/options.c
break;
#ifndef NDEBUG
case 'K': /* --dump-keys */
- read_configuration(&options);
+ read_configuration();
write_key_bindings(stdout, KEYDEF_WRITE_ALL | KEYDEF_COMMENT_ALL);
exit(EXIT_SUCCESS);
break;
}
}
-options_t *
+void
options_parse(int argc, const char *argv[])
{
int i;
option_cb (opt->shortopt, NULL);
else if (opt && opt->argument)
option_error(ERROR_MISSING_ARGUMENT, opt->longopt, opt->argument);
-
- return &options;
}
-options_t *
+void
options_init(void)
{
const char *value;
options.lyrics_timeout = DEFAULT_LYRICS_TIMEOUT;
options.scroll = DEFAULT_SCROLL;
options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
-
- return &options;
}
diff --git a/src/options.h b/src/options.h
index e7e9e8f4c358b03598d32a009d2500f24b6b41cb..0f9fa13c1105854a0436bfc5a5de6cfe783f0c68 100644 (file)
--- a/src/options.h
+++ b/src/options.h
bool welcome_screen_list;
} options_t;
-#ifndef NO_GLOBAL_OPTIONS
extern options_t options;
-#endif
-options_t *options_init(void);
-options_t *options_parse(int argc, const char **argv);
+void options_init(void);
+void options_parse(int argc, const char **argv);
#endif