summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e7981e0)
raw | patch | inline | side by side (parent: e7981e0)
author | Max Kellermann <max@duempel.org> | |
Mon, 15 Sep 2008 11:27:32 +0000 (13:27 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 15 Sep 2008 11:27:32 +0000 (13:27 +0200) |
In main.c, the global variable "options" is used all over, except in
main(), which contains a shadowing declaration of it. Remove this
local variable, and use the global "options" instead. Also don't
pollute conf.c's namespace with the global variable with a CPP hack
(to be removed when we have fixed more of ncmpc's namespace
pollution).
main(), which contains a shadowing declaration of it. Remove this
local variable, and use the global "options" instead. Also don't
pollute conf.c's namespace with the global variable with a CPP hack
(to be removed when we have fixed more of ncmpc's namespace
pollution).
src/conf.c | patch | blob | history | |
src/main.c | patch | blob | history | |
src/options.h | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index b49eeb2440ad4e920660252f7f63ff0d017470c4..970bc0889d1650ed8fbcab6646091cfa0240d30b 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
*
*/
+#define NO_GLOBAL_OPTIONS
#include "conf.h"
#include "config.h"
#include "ncmpc.h"
diff --git a/src/main.c b/src/main.c
index 97bfdd3f96bc2abace0146e570d082e52b8d45b9..7350a50f69b9a8ac1c32bc6ba032f737db1e2c6c 100644 (file)
--- a/src/main.c
+++ b/src/main.c
int
main(int argc, const char *argv[])
{
- options_t *options;
struct sigaction act;
const char *charset = NULL;
gboolean key_error;
#endif
/* initialize options */
- options = options_init();
+ options_init();
/* parse command line options - 1 pass get configuration files */
options_parse(argc, argv);
/* read configuration */
- read_configuration(options);
+ read_configuration(&options);
/* check key bindings */
key_error = check_key_bindings(NULL, NULL, 0);
mpd = mpdclient_new();
if (mpdclient_connect(mpd,
- options->host,
- options->port,
+ options.host,
+ options.port,
10.0,
- options->password))
+ options.password))
exit(EXIT_FAILURE);
/* if no password is used, but the mpd wants one, the connection
timer = g_timer_new();
connected = TRUE;
- while (connected || options->reconnect) {
+ while (connected || options.reconnect) {
static gdouble t = G_MAXDOUBLE;
if( key_error ) {
}
else
screen_idle(mpd);
- } else if (options->reconnect) {
+ } else if( options.reconnect ) {
screen_status_printf(_("Connecting to %s... [Press %s to abort]"),
- options->host, get_key_names(CMD_QUIT,0) );
+ options.host, get_key_names(CMD_QUIT,0) );
if( get_keyboard_command_with_timeout(MPD_RECONNECT_TIME)==CMD_QUIT)
exit(EXIT_SUCCESS);
if (mpdclient_connect(mpd,
- options->host, options->port,
+ options.host, options.port,
1.5,
- options->password) == 0) {
- screen_status_printf(_("Connected to %s!"), options->host);
+ options.password) == 0) {
+ screen_status_printf(_("Connected to %s!"), options.host);
connected = TRUE;
}
doupdate();
}
- if (options->enable_xterm_title)
+ if (options.enable_xterm_title)
update_xterm_title();
t = g_timer_elapsed(timer, NULL);
diff --git a/src/options.h b/src/options.h
index 380b43eca01d4023d3b429237b3f326bd705038a..d0a068f846e98d430f60d5b850933f2c435d5742 100644 (file)
--- a/src/options.h
+++ b/src/options.h
gboolean scroll;
} 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);