}
-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;
finish:
- if (f)
+ if (do_close && f)
fclose(f);
return r;