cmdline: no CamelCase
Renamed type, variables and functions.
This commit is contained in:
parent
c76f71e8d6
commit
62f9df98b4
@ -77,7 +77,7 @@ static const char *summary =
|
|||||||
"Music Player Daemon - a daemon for playing music.";
|
"Music Player Daemon - a daemon for playing music.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void parseOptions(int argc, char **argv, Options *options)
|
void parse_cmdline(int argc, char **argv, struct options *options)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
@ -96,7 +96,7 @@ void parseOptions(int argc, char **argv, Options *options)
|
|||||||
"don't create database, even if it doesn't exist", NULL },
|
"don't create database, even if it doesn't exist", NULL },
|
||||||
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &option_no_daemon,
|
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &option_no_daemon,
|
||||||
"don't detach from console", NULL },
|
"don't detach from console", NULL },
|
||||||
{ "stdout", 0, 0, G_OPTION_ARG_NONE, &options->stdOutput,
|
{ "stdout", 0, 0, G_OPTION_ARG_NONE, &options->stderr,
|
||||||
"print messages to stderr", NULL },
|
"print messages to stderr", NULL },
|
||||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &options->verbose,
|
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &options->verbose,
|
||||||
"verbose logging", NULL },
|
"verbose logging", NULL },
|
||||||
@ -107,9 +107,9 @@ void parseOptions(int argc, char **argv, Options *options)
|
|||||||
|
|
||||||
options->kill = false;
|
options->kill = false;
|
||||||
options->daemon = true;
|
options->daemon = true;
|
||||||
options->stdOutput = false;
|
options->stderr = false;
|
||||||
options->verbose = false;
|
options->verbose = false;
|
||||||
options->createDB = 0;
|
options->create_db = 0;
|
||||||
|
|
||||||
context = g_option_context_new("[path/to/mpd.conf]");
|
context = g_option_context_new("[path/to/mpd.conf]");
|
||||||
g_option_context_add_main_entries(context, entries, NULL);
|
g_option_context_add_main_entries(context, entries, NULL);
|
||||||
@ -137,9 +137,9 @@ void parseOptions(int argc, char **argv, Options *options)
|
|||||||
g_error("Cannot use both --create-db and --no-create-db\n");
|
g_error("Cannot use both --create-db and --no-create-db\n");
|
||||||
|
|
||||||
if (option_no_create_db)
|
if (option_no_create_db)
|
||||||
options->createDB = -1;
|
options->create_db = -1;
|
||||||
else if (option_create_db)
|
else if (option_create_db)
|
||||||
options->createDB = 1;
|
options->create_db = 1;
|
||||||
|
|
||||||
options->daemon = !option_no_daemon;
|
options->daemon = !option_no_daemon;
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
typedef struct _Options {
|
struct options {
|
||||||
gboolean kill;
|
gboolean kill;
|
||||||
gboolean daemon;
|
gboolean daemon;
|
||||||
gboolean stdOutput;
|
gboolean stderr;
|
||||||
gboolean verbose;
|
gboolean verbose;
|
||||||
int createDB;
|
int create_db;
|
||||||
} Options;
|
};
|
||||||
|
|
||||||
void parseOptions(int argc, char **argv, Options *options);
|
void parse_cmdline(int argc, char **argv, struct options *options);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
14
src/main.c
14
src/main.c
@ -96,7 +96,7 @@ struct notify main_notify;
|
|||||||
* process has been daemonized.
|
* process has been daemonized.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
openDB(const Options *options)
|
openDB(const struct options *options)
|
||||||
{
|
{
|
||||||
const char *path = config_get_path(CONF_DB_FILE);
|
const char *path = config_get_path(CONF_DB_FILE);
|
||||||
bool ret;
|
bool ret;
|
||||||
@ -115,7 +115,7 @@ openDB(const Options *options)
|
|||||||
|
|
||||||
db_init(path);
|
db_init(path);
|
||||||
|
|
||||||
if (options->createDB > 0)
|
if (options->create_db > 0)
|
||||||
/* don't attempt to load the old database */
|
/* don't attempt to load the old database */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ openDB(const Options *options)
|
|||||||
g_warning("Failed to load database: %s", error->message);
|
g_warning("Failed to load database: %s", error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
|
|
||||||
if (options->createDB < 0)
|
if (options->create_db < 0)
|
||||||
g_error("can't open db file and using "
|
g_error("can't open db file and using "
|
||||||
"\"--no-create-db\" command line option");
|
"\"--no-create-db\" command line option");
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ idle_event_emitted(void)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Options options;
|
struct options options;
|
||||||
clock_t start;
|
clock_t start;
|
||||||
bool create_db;
|
bool create_db;
|
||||||
#ifdef ENABLE_SQLITE
|
#ifdef ENABLE_SQLITE
|
||||||
@ -255,7 +255,7 @@ int main(int argc, char *argv[])
|
|||||||
tag_pool_init();
|
tag_pool_init();
|
||||||
config_global_init();
|
config_global_init();
|
||||||
|
|
||||||
parseOptions(argc, argv, &options);
|
parse_cmdline(argc, argv, &options);
|
||||||
|
|
||||||
daemonize_init(config_get_string(CONF_USER, NULL),
|
daemonize_init(config_get_string(CONF_USER, NULL),
|
||||||
config_get_path(CONF_PID_FILE));
|
config_get_path(CONF_PID_FILE));
|
||||||
@ -265,7 +265,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
stats_global_init();
|
stats_global_init();
|
||||||
tag_lib_init();
|
tag_lib_init();
|
||||||
log_init(options.verbose, options.stdOutput);
|
log_init(options.verbose, options.stderr);
|
||||||
|
|
||||||
listen_global_init();
|
listen_global_init();
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
daemonize(options.daemon);
|
daemonize(options.daemon);
|
||||||
|
|
||||||
setup_log_output(options.stdOutput);
|
setup_log_output(options.stderr);
|
||||||
|
|
||||||
initSigHandlers();
|
initSigHandlers();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user