From afea99da321e089982de90bd0d2423b8cb783a97 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Mon, 11 Feb 2013 13:33:31 -0200 Subject: [PATCH] [xmp] Add --norc option and fix option parsing Add the --norc option to bypass configuration files. When parsing lines in the configuration file, disable paramter matching if we're not in the section that match the current file's MD5 sum. Signed-off-by: Claudio Matsuoka --- src/common.h | 1 + src/main.c | 8 ++++++-- src/options.c | 6 ++++++ src/read_config.c | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common.h b/src/common.h index 0565058..38c9977 100644 --- a/src/common.h +++ b/src/common.h @@ -21,6 +21,7 @@ struct options { int info; /* display information and exit */ int probeonly; /* probe sound driver and exit */ int nocmd; /* disable interactive commands */ + int norc; /* don't read the configuration files */ int dparm; /* driver parameter index */ char *driver_id; /* sound driver ID */ char *out_file; /* output file name */ diff --git a/src/main.c b/src/main.c index 4e2e463..0ca6e2c 100644 --- a/src/main.c +++ b/src/main.c @@ -178,7 +178,9 @@ int main(int argc, char **argv) opt.dsp = XMP_DSP_LOWPASS; /* read configuration file */ - read_config(&opt); + if (!opt.norc) { + read_config(&opt); + } get_options(argc, argv, &opt); @@ -316,7 +318,9 @@ int main(int argc, char **argv) } xmp_get_module_info(handle, &mi); - read_modconf(&opt, mi.md5); + if (!opt.norc) { + read_modconf(&opt, mi.md5); + } skipprev = 0; control.time = 0.0; diff --git a/src/options.c b/src/options.c index e2e5ca6..a18f31d 100644 --- a/src/options.c +++ b/src/options.c @@ -34,6 +34,7 @@ enum { OPT_NOCMD, OPT_VBLANK, OPT_FIXLOOP, + OPT_NORC, }; static void usage(char *s) @@ -66,6 +67,7 @@ static void usage(char *s) " -l --loop Enable module looping\n" " -M --mute ch-list Mute the specified channels\n" " --nocmd Disable interactive commands\n" +" --norc Don't read configuration files\n" " --offset-bug-emulation Emulate Protracker 2.x bug in effect 9\n" " -R --random Random order playing\n" " -S --solo ch-list Set channels to solo mode\n" @@ -113,6 +115,7 @@ static struct option lopt[] = { { "mute", 1, 0, 'M' }, { "null", 0, 0, 'N' }, { "nocmd", 0, 0, OPT_NOCMD }, + { "norc", 0, 0, OPT_NORC }, { "nofilter", 0, 0, 'F' }, { "offset-bug-emulation",0, 0, OPT_FX9BUG }, { "output-file", 1, 0, 'o' }, @@ -209,6 +212,9 @@ void get_options(int argc, char **argv, struct options *options) case OPT_NOCMD: options->nocmd = 1; break; + case OPT_NORC: + options->norc = 1; + break; case 'o': options->out_file = optarg; if (strlen(optarg) >= 4 && diff --git a/src/read_config.c b/src/read_config.c index d710542..6a8eebb 100644 --- a/src/read_config.c +++ b/src/read_config.c @@ -198,6 +198,8 @@ static void parse_modconf(struct options *o, char *confname, unsigned char *md5) if (line[0] == '[') { if (compare_md5(md5, line + 1) == 0) { active = 1; + } else { + active = 0; } continue; }