main: add a function for processing a single package

feature/tap-sh
William Pitcock 2011-07-24 23:54:39 -05:00
parent 4603ceb885
commit b55a4ce39f
1 changed files with 17 additions and 5 deletions

18
main.c
View File

@ -23,6 +23,9 @@
#include "pkg.h" #include "pkg.h"
static int want_cflags = 1;
static int want_libs = 1;
static void static void
print_cflags(pkg_t *pkg, void *unused) print_cflags(pkg_t *pkg, void *unused)
{ {
@ -38,22 +41,31 @@ print_libs(pkg_t *pkg, void *unused)
} }
int int
main(int argc, const char *argv[]) handle_package(const char *package)
{ {
pkg_t *pkg; pkg_t *pkg;
pkg = pkg_find(argv[1]); pkg = pkg_find(package);
if (pkg) if (pkg)
{ {
if (want_cflags)
pkg_traverse(pkg, print_cflags, NULL); pkg_traverse(pkg, print_cflags, NULL);
if (want_libs)
pkg_traverse(pkg, print_libs, NULL); pkg_traverse(pkg, print_libs, NULL);
printf("\n"); printf("\n");
} }
else else
{ {
printf("%s not found\n", argv[1]); fprintf(stderr, "dependency '%s' could not be satisfied, see PKG_CONFIG_PATH.\n", package);
return -1; return -1;
} }
}
int
main(int argc, const char *argv[])
{
handle_package(argv[1]);
return 0; return 0;
} }