libpkgconf: audit: migrate to pkgconf_client_t

feature/tap-sh
William Pitcock 2016-12-02 00:34:48 -06:00
parent c05ecdfc9d
commit 011d8c77d6
5 changed files with 19 additions and 18 deletions

View File

@ -15,38 +15,36 @@
#include <libpkgconf/libpkgconf.h>
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);
}

View File

@ -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 *

View File

@ -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);

View File

@ -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);

2
main.c
View File

@ -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)