summaryrefslogtreecommitdiffstats
path: root/polyp/conf-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'polyp/conf-parser.c')
-rw-r--r--polyp/conf-parser.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/polyp/conf-parser.c b/polyp/conf-parser.c
index 20e8e723..3d922c20 100644
--- a/polyp/conf-parser.c
+++ b/polyp/conf-parser.c
@@ -89,13 +89,13 @@ static int parse_line(const char *filename, unsigned line, const struct pa_confi
}
-int pa_config_parse(const char *filename, const struct pa_config_item *t, void *userdata) {
- FILE *f;
+int pa_config_parse(const char *filename, FILE *f, const struct pa_config_item *t, void *userdata) {
int r = -1;
unsigned line = 0;
+ int do_close = !f;
assert(filename && t);
- if (!(f = fopen(filename, "r"))) {
+ if (!f && !(f = fopen(filename, "r"))) {
if (errno == ENOENT) {
r = 0;
goto finish;
@@ -123,7 +123,7 @@ int pa_config_parse(const char *filename, const struct pa_config_item *t, void *
finish:
- if (f)
+ if (do_close && f)
fclose(f);
return r;