diff --git a/libpkgconf/audit.c b/libpkgconf/audit.c index c95f619..066e1e6 100644 --- a/libpkgconf/audit.c +++ b/libpkgconf/audit.c @@ -15,38 +15,36 @@ #include -static FILE *pkgconf_auditf = NULL; - void -pkgconf_audit_open_log(FILE *auditf) +pkgconf_audit_set_log(pkgconf_client_t *client, FILE *auditf) { - pkgconf_auditf = auditf; + client->auditf = auditf; } void -pkgconf_audit_log(const char *format, ...) +pkgconf_audit_log(pkgconf_client_t *client, const char *format, ...) { va_list va; - if (pkgconf_auditf == NULL) + if (client->auditf == NULL) return; va_start(va, format); - vfprintf(pkgconf_auditf, format, va); + vfprintf(client->auditf, format, va); va_end(va); } void -pkgconf_audit_log_dependency(const pkgconf_pkg_t *dep, const pkgconf_dependency_t *depnode) +pkgconf_audit_log_dependency(pkgconf_client_t *client, const pkgconf_pkg_t *dep, const pkgconf_dependency_t *depnode) { - if (pkgconf_auditf == NULL) + if (client->auditf == NULL) return; - fprintf(pkgconf_auditf, "%s ", dep->id); + fprintf(client->auditf, "%s ", dep->id); if (depnode->version != NULL && depnode->compare != PKGCONF_CMP_ANY) { - fprintf(pkgconf_auditf, "%s %s ", pkgconf_pkg_get_comparator(depnode), depnode->version); + fprintf(client->auditf, "%s %s ", pkgconf_pkg_get_comparator(depnode), depnode->version); } - fprintf(pkgconf_auditf, "[%s]\n", dep->version); + fprintf(client->auditf, "[%s]\n", dep->version); } diff --git a/libpkgconf/client.c b/libpkgconf/client.c index 4d4e3b3..bb4044a 100644 --- a/libpkgconf/client.c +++ b/libpkgconf/client.c @@ -19,6 +19,7 @@ void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler) { client->error_handler = error_handler; + client->auditf = NULL; } pkgconf_client_t * diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 5021389..57e59e2 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -145,6 +145,8 @@ struct pkgconf_client_ { pkgconf_list_t global_vars; pkgconf_error_handler_func_t error_handler; + + FILE *auditf; }; /* client.c */ @@ -252,9 +254,9 @@ void pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg); void pkgconf_cache_free(pkgconf_client_t *client); /* audit.c */ -void pkgconf_audit_open_log(FILE *auditf); -void pkgconf_audit_log(const char *format, ...) PRINTFLIKE(1, 2); -void pkgconf_audit_log_dependency(const pkgconf_pkg_t *dep, const pkgconf_dependency_t *depnode); +void pkgconf_audit_set_log(pkgconf_client_t *client, FILE *auditf); +void pkgconf_audit_log(pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3); +void pkgconf_audit_log_dependency(pkgconf_client_t *client, const pkgconf_pkg_t *dep, const pkgconf_dependency_t *depnode); /* path.c */ void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist); diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index 7c9606f..1078062 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -1048,7 +1048,7 @@ pkgconf_pkg_report_graph_error(pkgconf_client_t *client, pkgconf_pkg_t *parent, } pkgconf_error(client, "Package '%s', required by '%s', not found\n", node->package, parent->id); - pkgconf_audit_log("%s NOT-FOUND\n", node->package); + pkgconf_audit_log(client, "%s NOT-FOUND\n", node->package); } else if (eflags & PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH) { @@ -1104,7 +1104,7 @@ pkgconf_pkg_walk_list(pkgconf_client_t *client, continue; } - pkgconf_audit_log_dependency(pkgdep, depnode); + pkgconf_audit_log_dependency(client, pkgdep, depnode); pkgdep->flags |= PKGCONF_PKG_PROPF_SEEN; eflags |= pkgconf_pkg_traverse(client, pkgdep, func, data, depth - 1, flags); diff --git a/main.c b/main.c index 9effa8b..f56f36b 100644 --- a/main.c +++ b/main.c @@ -853,7 +853,7 @@ main(int argc, char *argv[]) if (logfile_arg != NULL) { logfile_out = fopen(logfile_arg, "w"); - pkgconf_audit_open_log(logfile_out); + pkgconf_audit_set_log(&pkg_client, logfile_out); } if (required_module_version != NULL)