mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
testpkg rework
* mainly code cosmetics (indent fixes) * remove debug message "spam" * print also user friendly result Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Dan: a few more whitespace/linebreak cleanups added] Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
aecc2fd190
commit
17eca54b32
@ -29,15 +29,16 @@
|
||||
|
||||
static void output_cb(pmloglevel_t level, char *fmt, va_list args)
|
||||
{
|
||||
if(strlen(fmt)) {
|
||||
if(fmt[0] == '\0') {
|
||||
return;
|
||||
}
|
||||
switch(level) {
|
||||
case PM_LOG_ERROR: printf("error: "); break;
|
||||
case PM_LOG_WARNING: printf("warning: "); break;
|
||||
default: break;
|
||||
default: return; /* skip other messages */
|
||||
}
|
||||
vprintf(fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -50,7 +51,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if(alpm_initialize() == -1) {
|
||||
fprintf(stderr, "cannot initilize alpm: %s\n", alpm_strerrorlast());
|
||||
fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerrorlast());
|
||||
return(1);
|
||||
}
|
||||
|
||||
@ -58,9 +59,22 @@ int main(int argc, char **argv)
|
||||
alpm_option_set_logcb(output_cb);
|
||||
|
||||
if(alpm_pkg_load(argv[1], 1, &pkg) == -1 || pkg == NULL) {
|
||||
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);
|
||||
printf("Package is valid.\n");
|
||||
retval = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user