diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-11-04 21:27:12 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-11-04 21:27:12 +0000 |
commit | 5844a33f0be1af942ee33feae38b9d46169fd61c (patch) | |
tree | 7a2feaab269107da3131a6baa2932aad3dc4377a /polyp/module-match.c | |
parent | 2aad9e3ae2aa53d13458faf148946cf7e7d87627 (diff) |
some commenting
change alogrithm for checking for configuration files
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@273 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/module-match.c')
-rw-r--r-- | polyp/module-match.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/polyp/module-match.c b/polyp/module-match.c index 6689cc59..176c338f 100644 --- a/polyp/module-match.c +++ b/polyp/module-match.c @@ -48,6 +48,13 @@ PA_MODULE_VERSION(PACKAGE_VERSION) #define WHITESPACE "\n\r \t" +#ifndef DEFAULT_CONFIG_DIR +#define DEFAULT_CONFIG_DIR "/etc/polypaudio" +#endif + +#define DEFAULT_MATCH_TABLE_FILE DEFAULT_CONFIG_DIR"/match.table" +#define DEFAULT_MATCH_TABLE_FILE_USER ".polypaudio/.match.table" + static const char* const valid_modargs[] = { "table", NULL, @@ -69,9 +76,14 @@ static int load_rules(struct userdata *u, const char *filename) { int n = 0; int ret = -1; struct rule *end = NULL; + char *fn = NULL; - if (!(f = fopen(filename, "r"))) { - pa_log(__FILE__": failed to open file '%s': %s\n", filename, strerror(errno)); + f = filename ? + fopen(fn = pa_xstrdup(filename), "r") : + pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn); + + if (!f) { + pa_log(__FILE__": failed to open file '%s': %s\n", fn, strerror(errno)); goto finish; } @@ -135,6 +147,9 @@ finish: if (f) fclose(f); + if (fn) + pa_xfree(fn); + return ret; } |