From 5844a33f0be1af942ee33feae38b9d46169fd61c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 4 Nov 2004 21:27:12 +0000 Subject: 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 --- polyp/module-match.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'polyp/module-match.c') 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; } -- cgit