pkg: implement resolver-side support for some pkg-config clone's --env-only option

feature/tap-sh
William Pitcock 2012-05-02 23:16:32 +00:00
parent 187b4e538f
commit e59b9864ea
2 changed files with 7 additions and 3 deletions

9
pkg.c
View File

@ -87,9 +87,12 @@ pkg_find(const char *name, unsigned int flags)
free(path); free(path);
} }
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, PKG_DEFAULT_PATH, name); if (!(flags & PKGF_ENV_ONLY))
if (f = fopen(locbuf, "r")) {
return parse_file(locbuf, f); snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, PKG_DEFAULT_PATH, name);
if (f = fopen(locbuf, "r"))
return parse_file(locbuf, f);
}
return NULL; return NULL;
} }

1
pkg.h
View File

@ -102,6 +102,7 @@ struct pkg_ {
#define PKGF_NONE 0x0 #define PKGF_NONE 0x0
#define PKGF_SEARCH_PRIVATE 0x1 #define PKGF_SEARCH_PRIVATE 0x1
#define PKGF_ENV_ONLY 0x2
pkg_t *pkg_find(const char *name, unsigned int flags); pkg_t *pkg_find(const char *name, unsigned int flags);
void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth, unsigned int flags); void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth, unsigned int flags);