From 7968d30510de5a6031af39da498be5c821290b82 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 7 Jun 2011 12:41:33 -0500 Subject: Require handle argument to alpm_logaction() This is the first in a series of patches to update the API to remove the implicit global handle variable. Signed-off-by: Dan McGee --- lib/libalpm/util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index d24a51a6..68732d13 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -385,11 +385,11 @@ int _alpm_rmrf(const char *path) return 0; } -int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) +int _alpm_logaction(pmhandle_t *handle, const char *fmt, va_list args) { int ret = 0; - if(usesyslog) { + if(handle->usesyslog) { /* we can't use a va_list more than once, so we need to copy it * so we can use the original when calling vfprintf below. */ va_list args_syslog; @@ -398,7 +398,7 @@ int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) va_end(args_syslog); } - if(f) { + if(handle->logstream) { time_t t; struct tm *tm; @@ -406,11 +406,11 @@ int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) tm = localtime(&t); /* Use ISO-8601 date format */ - fprintf(f, "[%04d-%02d-%02d %02d:%02d] ", + fprintf(handle->logstream, "[%04d-%02d-%02d %02d:%02d] ", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min); - ret = vfprintf(f, fmt, args); - fflush(f); + ret = vfprintf(handle->logstream, fmt, args); + fflush(handle->logstream); } return ret; @@ -496,7 +496,7 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]) char line[PATH_MAX]; if(fgets(line, PATH_MAX, pipe) == NULL) break; - alpm_logaction("%s", line); + alpm_logaction(handle, "%s", line); EVENT(handle->trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL); } fclose(pipe); -- cgit v1.2.3-24-g4f1b