Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/util/testpkg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/testpkg.c')
-rw-r--r--src/util/testpkg.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index a64e6b34..d724bb8a 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -2,7 +2,7 @@
* testpkg.c : Test a pacman package for validity
*
* Copyright (c) 2007 by Aaron Griffin <aaronmgriffin@gmail.com>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -15,27 +15,29 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libgen.h>
+#include <stdio.h> /* printf */
+#include <stdarg.h> /* va_list */
+#include <string.h> /* strlen */
#include <alpm.h>
-void output_cb(unsigned short level, char *msg)
+#define BASENAME "testpkg"
+
+static void output_cb(pmloglevel_t level, char *fmt, va_list args)
{
- if(strlen(msg)) {
+ if(strlen(fmt)) {
switch(level) {
case PM_LOG_ERROR: printf("error: "); break;
case PM_LOG_WARNING: printf("warning: "); break;
+ default: break;
}
- puts(msg);
+ vprintf(fmt, args);
}
}
@@ -45,27 +47,27 @@ int main(int argc, char **argv)
pmpkg_t *pkg = NULL;
if(argc != 2) {
- fprintf(stderr, "usage: %s <package file>\n", basename(argv[0]));
+ fprintf(stderr, "usage: %s <package file>\n", BASENAME);
return(1);
}
if(alpm_initialize() == -1) {
- fprintf(stderr, "cannot initilize alpm: %s\n", alpm_strerror(pm_errno));
+ fprintf(stderr, "cannot initilize alpm: %s\n", alpm_strerrorlast());
return(1);
}
/* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb);
- if(alpm_pkg_load(argv[1], &pkg) == -1 || pkg == NULL) {
+ if(alpm_pkg_load(argv[1], 1, &pkg) == -1 || pkg == NULL) {
retval = 1;
} else {
alpm_pkg_free(pkg);
retval = 0;
}
-
+
if(alpm_release() == -1) {
- fprintf(stderr, "error releasing alpm: %s\n", alpm_strerror(pm_errno));
+ fprintf(stderr, "error releasing alpm: %s\n", alpm_strerrorlast());
}
return(retval);