index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2008-03-09 12:03:54 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-03-09 12:03:54 -0500 |
commit | 91b7f288fe65b96d4af64f6308b0e33b14ad85e0 (patch) | |
tree | c60650d6bcd9677c53e757a8e98c645dfab8377a /src/util | |
parent | fc48dc3118318d4b26b63a9453cd23cf2158cba3 (diff) | |
parent | 51e0303e840c94e5943f30e311d053058f657327 (diff) |
-rw-r--r-- | src/util/testpkg.c | 48 |
diff --git a/src/util/testpkg.c b/src/util/testpkg.c index e32b013d..64056ce4 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -29,44 +29,58 @@ static void output_cb(pmloglevel_t level, char *fmt, va_list args) { - if(strlen(fmt)) { - switch(level) { - case PM_LOG_ERROR: printf("error: "); break; - case PM_LOG_WARNING: printf("warning: "); break; - default: break; - } - vprintf(fmt, args); - } + if(fmt[0] == '\0') { + return; + } + switch(level) { + case PM_LOG_ERROR: printf("error: "); break; + case PM_LOG_WARNING: printf("warning: "); break; + default: return; /* skip other messages */ + } + vprintf(fmt, args); } int main(int argc, char **argv) { - int retval = 1; /* default = false */ - pmpkg_t *pkg = NULL; + int retval = 1; /* default = false */ + pmpkg_t *pkg = NULL; - if(argc != 2) { + if(argc != 2) { fprintf(stderr, "usage: %s <package file>\n", BASENAME); return(1); } if(alpm_initialize() == -1) { - fprintf(stderr, "cannot initilize alpm: %s\n", alpm_strerrorlast()); - return(1); + fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerrorlast()); + return(1); } - /* let us get log messages from libalpm */ + /* let us get log messages from libalpm */ alpm_option_set_logcb(output_cb); if(alpm_pkg_load(argv[1], 1, &pkg) == -1 || pkg == NULL) { - retval = 1; + switch(pm_errno) { + case PM_ERR_PKG_OPEN: + printf("Cannot open the given file.\n"); + break; + case PM_ERR_LIBARCHIVE_ERROR: + case PM_ERR_PKG_INVALID: + printf("Package is invalid.\n"); + break; + default: + printf("libalpm error: %s\n", alpm_strerrorlast()); + break; + } + retval = 1; } else { alpm_pkg_free(pkg); - retval = 0; + printf("Package is valid.\n"); + retval = 0; } if(alpm_release() == -1) { fprintf(stderr, "error releasing alpm: %s\n", alpm_strerrorlast()); } - return(retval); + return(retval); } |