diff options
author | Aurelien Foret <aurelien@archlinux.org> | 2005-10-10 15:05:12 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2005-10-10 15:05:12 +0000 |
commit | 6c7f5212985e6171abe943b386694c17c2240322 (patch) | |
tree | 9cb1bde5837be0592ab9c65459003a23da3e5c75 | |
parent | 75800d4ec283b260e679c729a5a064b87824367c (diff) | |
download | pacman-6c7f5212985e6171abe943b386694c17c2240322.tar.xz |
improved query_fileowner() function
-rw-r--r-- | src/pacman/query.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c index 71c02c71..d13c1af9 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -54,12 +54,12 @@ static int query_fileowner(PM_DB *db, char *filename) return(0); } if(filename == NULL || strlen(filename) == 0) { - fprintf(stderr, "error: no file was specified for --owns\n"); + ERR(NL, "no file was specified for --owns\n"); return(1); } if(stat(filename, &buf) == -1 || S_ISDIR(buf.st_mode) || realpath(filename, rpath) == NULL) { - fprintf(stderr, "error: %s is not a file.\n", filename); + ERR(NL, "%s is not a file.\n", filename); return(1); } @@ -67,23 +67,16 @@ static int query_fileowner(PM_DB *db, char *filename) for(lp = alpm_db_getpkgcache(db); lp && !gotcha; lp = alpm_list_next(lp)) { PM_PKG *info; - char *pkgname; PM_LIST *i; - pkgname = alpm_pkg_getinfo(alpm_list_getdata(lp), PM_PKG_NAME); - - info = alpm_db_readpkg(db, pkgname); - if(info == NULL) { - fprintf(stderr, "error: package %s not found\n", pkgname); - return(1); - } + info = alpm_list_getdata(lp); for(i = alpm_pkg_getinfo(info, PM_PKG_FILES); i && !gotcha; i = alpm_list_next(i)) { char path[PATH_MAX]; snprintf(path, PATH_MAX, "%s%s", root, (char *)alpm_list_getdata(i)); if(!strcmp(path, rpath)) { - printf("%s is owned by %s %s\n", filename, pkgname, + printf("%s is owned by %s %s\n", filename, (char *)alpm_pkg_getinfo(info, PM_PKG_NAME), (char *)alpm_pkg_getinfo(info, PM_PKG_VERSION)); gotcha = 1; break; @@ -91,7 +84,7 @@ static int query_fileowner(PM_DB *db, char *filename) } } if(!gotcha) { - fprintf(stderr, "No package owns %s\n", filename); + ERR(NL, "No package owns %s\n", filename); return(1); } |