diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-07 19:41:33 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-09 21:24:45 +0200 |
commit | 7968d30510de5a6031af39da498be5c821290b82 (patch) | |
tree | 234c6c99ca5ce0efd5034c4eaedb9b89f1e81686 | |
parent | e826c143d3e9d21485f72c5490b2a907c936024e (diff) | |
download | pacman-7968d30510de5a6031af39da498be5c821290b82.tar.gz pacman-7968d30510de5a6031af39da498be5c821290b82.tar.xz |
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 <dan@archlinux.org>
-rw-r--r-- | lib/libalpm/add.c | 34 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 2 | ||||
-rw-r--r-- | lib/libalpm/log.c | 4 | ||||
-rw-r--r-- | lib/libalpm/remove.c | 2 | ||||
-rw-r--r-- | lib/libalpm/trans.c | 2 | ||||
-rw-r--r-- | lib/libalpm/util.c | 14 | ||||
-rw-r--r-- | lib/libalpm/util.h | 2 | ||||
-rw-r--r-- | src/pacman/callback.c | 6 | ||||
-rw-r--r-- | src/pacman/pacman.c | 2 | ||||
-rw-r--r-- | src/pacman/sync.c | 4 |
10 files changed, 36 insertions, 36 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 0e216b6d..2e81146c 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -103,7 +103,7 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) return 0; } -static int perform_extraction(struct archive *archive, +static int perform_extraction(pmhandle_t *handle, struct archive *archive, struct archive_entry *entry, const char *filename, const char *origname) { int ret; @@ -121,7 +121,7 @@ static int perform_extraction(struct archive *archive, } else if(ret != ARCHIVE_OK) { _alpm_log(PM_LOG_ERROR, _("could not extract %s (%s)\n"), origname, archive_error_string(archive)); - alpm_logaction("error: could not extract %s (%s)\n", + alpm_logaction(handle, "error: could not extract %s (%s)\n", origname, archive_error_string(archive)); return 1; } @@ -169,7 +169,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, if(alpm_list_find_str(handle->noextract, entryname)) { _alpm_log(PM_LOG_DEBUG, "%s is in NoExtract, skipping extraction\n", entryname); - alpm_logaction("note: %s is in NoExtract, skipping extraction\n", + alpm_logaction(handle, "note: %s is in NoExtract, skipping extraction\n", entryname); archive_read_data_skip(archive); return 0; @@ -209,7 +209,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, _alpm_log(PM_LOG_WARNING, _("directory permissions differ on %s\n" "filesystem: %o package: %o\n"), entryname, lsbuf.st_mode & mask, entrymode & mask); - alpm_logaction("warning: directory permissions differ on %s\n" + alpm_logaction(handle, "warning: directory permissions differ on %s\n" "filesystem: %o package: %o\n", entryname, lsbuf.st_mode & mask, entrymode & mask); } @@ -284,7 +284,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, snprintf(checkfile, PATH_MAX, "%s.paccheck", filename); - ret = perform_extraction(archive, entry, checkfile, entryname_orig); + ret = perform_extraction(handle, archive, entry, checkfile, entryname_orig); if(ret == 1) { /* error */ FREE(hash_orig); @@ -331,7 +331,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, if(rename(filename, newpath)) { _alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), filename, newpath, strerror(errno)); - alpm_logaction("error: could not rename %s to %s (%s)\n", + alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", filename, newpath, strerror(errno)); errors++; } else { @@ -339,12 +339,12 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, if(rename(checkfile, filename)) { _alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), checkfile, filename, strerror(errno)); - alpm_logaction("error: could not rename %s to %s (%s)\n", + alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", checkfile, filename, strerror(errno)); errors++; } else { _alpm_log(PM_LOG_WARNING, _("%s saved as %s\n"), filename, newpath); - alpm_logaction("warning: %s saved as %s\n", filename, newpath); + alpm_logaction(handle, "warning: %s saved as %s\n", filename, newpath); } } } else { @@ -363,7 +363,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, if(rename(checkfile, filename)) { _alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), checkfile, filename, strerror(errno)); - alpm_logaction("error: could not rename %s to %s (%s)\n", + alpm_logaction(handle, "error: could not rename %s to %s (%s)\n", checkfile, filename, strerror(errno)); errors++; } @@ -393,12 +393,12 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, if(rename(checkfile, newpath)) { _alpm_log(PM_LOG_ERROR, _("could not install %s as %s (%s)\n"), filename, newpath, strerror(errno)); - alpm_logaction("error: could not install %s as %s (%s)\n", + alpm_logaction(handle, "error: could not install %s as %s (%s)\n", filename, newpath, strerror(errno)); } else { _alpm_log(PM_LOG_WARNING, _("%s installed as %s\n"), filename, newpath); - alpm_logaction("warning: %s installed as %s\n", + alpm_logaction(handle, "warning: %s installed as %s\n", filename, newpath); } } @@ -415,7 +415,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, /* change the path to a .pacnew extension */ _alpm_log(PM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename); _alpm_log(PM_LOG_WARNING, _("extracting %s as %s.pacnew\n"), filename, filename); - alpm_logaction("warning: extracting %s as %s.pacnew\n", filename, filename); + alpm_logaction(handle, "warning: extracting %s as %s.pacnew\n", filename, filename); strncat(filename, ".pacnew", PATH_MAX - strlen(filename)); } else { _alpm_log(PM_LOG_DEBUG, "extracting %s\n", filename); @@ -428,7 +428,7 @@ static int extract_single_file(pmhandle_t *handle, struct archive *archive, unlink(filename); } - ret = perform_extraction(archive, entry, filename, entryname_orig); + ret = perform_extraction(handle, archive, entry, filename, entryname_orig); if(ret == 1) { /* error */ FREE(entryname_orig); @@ -532,7 +532,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg, /* prepare directory for database entries so permission are correct after changelog/install script installation (FS#12263) */ if(_alpm_local_db_prepare(db, newpkg)) { - alpm_logaction("error: could not create database entry %s-%s\n", + alpm_logaction(handle, "error: could not create database entry %s-%s\n", alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg)); pm_errno = PM_ERR_DB_WRITE; ret = -1; @@ -632,12 +632,12 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg, if(is_upgrade) { _alpm_log(PM_LOG_ERROR, _("problem occurred while upgrading %s\n"), newpkg->name); - alpm_logaction("error: problem occurred while upgrading %s\n", + alpm_logaction(handle, "error: problem occurred while upgrading %s\n", newpkg->name); } else { _alpm_log(PM_LOG_ERROR, _("problem occurred while installing %s\n"), newpkg->name); - alpm_logaction("error: problem occurred while installing %s\n", + alpm_logaction(handle, "error: problem occurred while installing %s\n", newpkg->name); } } @@ -652,7 +652,7 @@ static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg, if(_alpm_local_db_write(db, newpkg, INFRQ_ALL)) { _alpm_log(PM_LOG_ERROR, _("could not update database entry %s-%s\n"), alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg)); - alpm_logaction("error: could not update database entry %s-%s\n", + alpm_logaction(handle, "error: could not update database entry %s-%s\n", alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg)); pm_errno = PM_ERR_DB_WRITE; ret = -1; diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index ee55d0b9..f46c1548 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -100,7 +100,7 @@ typedef enum _pmloglevel_t { } pmloglevel_t; typedef void (*alpm_cb_log)(pmloglevel_t, const char *, va_list); -int alpm_logaction(const char *fmt, ...); +int alpm_logaction(pmhandle_t *handle, const char *fmt, ...); /* * Downloading diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c index 20d1ec37..30d1d6f8 100644 --- a/lib/libalpm/log.c +++ b/lib/libalpm/log.c @@ -42,7 +42,7 @@ extern pmhandle_t *handle; * @param fmt output format * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int SYMEXPORT alpm_logaction(const char *fmt, ...) +int SYMEXPORT alpm_logaction(pmhandle_t *handle, const char *fmt, ...) { int ret; va_list args; @@ -67,7 +67,7 @@ int SYMEXPORT alpm_logaction(const char *fmt, ...) } va_start(args, fmt); - ret = _alpm_logaction(handle->usesyslog, handle->logstream, fmt, args); + ret = _alpm_logaction(handle, fmt, args); va_end(args); /* TODO We should add a prefix to log strings depending on who called us. diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index a4b60cf4..f32e77d8 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -261,7 +261,7 @@ static void unlink_file(pmhandle_t *handle, pmpkg_t *info, char *filename, snprintf(newpath, PATH_MAX, "%s.pacsave", file); rename(file, newpath); _alpm_log(PM_LOG_WARNING, _("%s saved as %s\n"), file, newpath); - alpm_logaction("warning: %s saved as %s\n", file, newpath); + alpm_logaction(handle, "warning: %s saved as %s\n", file, newpath); return; } } diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 58bcc38b..a7d762ea 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -292,7 +292,7 @@ int SYMEXPORT alpm_trans_release(void) if(remove_lock(handle)) { _alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"), alpm_option_get_lockfile()); - alpm_logaction("warning: could not remove lock file %s\n", + alpm_logaction(handle, "warning: could not remove lock file %s\n", alpm_option_get_lockfile()); } } 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); diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index c1a92a08..86968ae5 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -93,7 +93,7 @@ char *_alpm_strtrim(char *str); int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn); int _alpm_unpack(const char *archive, const char *prefix, alpm_list_t *list, int breakfirst); int _alpm_rmrf(const char *path); -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 _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]); int _alpm_ldconfig(pmhandle_t *handle); int _alpm_str_cmp(const void *s1, const void *s2); diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 4a025742..4ac3b56b 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -176,7 +176,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) } break; case PM_TRANS_EVT_ADD_DONE: - alpm_logaction("installed %s (%s)\n", + alpm_logaction(config->handle, "installed %s (%s)\n", alpm_pkg_get_name(data1), alpm_pkg_get_version(data1)); display_optdepends(data1); @@ -187,7 +187,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) } break; case PM_TRANS_EVT_REMOVE_DONE: - alpm_logaction("removed %s (%s)\n", + alpm_logaction(config->handle, "removed %s (%s)\n", alpm_pkg_get_name(data1), alpm_pkg_get_version(data1)); break; @@ -197,7 +197,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) } break; case PM_TRANS_EVT_UPGRADE_DONE: - alpm_logaction("upgraded %s (%s -> %s)\n", + alpm_logaction(config->handle, "upgraded %s (%s -> %s)\n", (char *)alpm_pkg_get_name(data1), (char *)alpm_pkg_get_version(data2), (char *)alpm_pkg_get_version(data1)); diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 4b54eb34..544a26fe 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -735,7 +735,7 @@ static void cl_to_log(int argc, char* argv[]) *p++ = ' '; } strcpy(p, argv[i]); - alpm_logaction("Running '%s'\n", cl_text); + alpm_logaction(config->handle, "Running '%s'\n", cl_text); free(cl_text); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 884504f3..ffc30ce5 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -757,7 +757,7 @@ static int sync_trans(alpm_list_t *targets) if(config->op_s_upgrade) { printf(_(":: Starting full system upgrade...\n")); - alpm_logaction("starting full system upgrade\n"); + alpm_logaction(config->handle, "starting full system upgrade\n"); if(alpm_sync_sysupgrade(config->op_s_upgrade >= 2) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, "%s\n", alpm_strerrorlast()); retval = 1; @@ -919,7 +919,7 @@ int pacman_sync(alpm_list_t *targets) if(config->op_s_sync) { /* grab a fresh package list */ printf(_(":: Synchronizing package databases...\n")); - alpm_logaction("synchronizing package lists\n"); + alpm_logaction(config->handle, "synchronizing package lists\n"); if(!sync_synctree(config->op_s_sync, sync_dbs)) { return 1; } |