libpkgconf: begin removing global state from libpkgconf library by introducing a "client" object which holds the state

pull/100/head
William Pitcock 2016-12-01 15:05:03 -06:00
parent 4bb46e20e3
commit 8740c5cd55
8 changed files with 209 additions and 180 deletions

View File

@ -80,6 +80,7 @@ pkginclude_HEADERS = libpkgconf/bsdstubs.h libpkgconf/iter.h libpkgconf/libpkgco
libpkgconf_la_SOURCES = \ libpkgconf_la_SOURCES = \
libpkgconf/audit.c \ libpkgconf/audit.c \
libpkgconf/cache.c \ libpkgconf/cache.c \
libpkgconf/client.c \
libpkgconf/pkg.c \ libpkgconf/pkg.c \
libpkgconf/bsdstubs.c \ libpkgconf/bsdstubs.c \
libpkgconf/fragment.c \ libpkgconf/fragment.c \

View File

@ -218,9 +218,9 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
} }
void void
pkgconf_dependency_parse(pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends) pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends)
{ {
char *kvdepends = pkgconf_tuple_parse(&pkg->vars, depends); char *kvdepends = pkgconf_tuple_parse(client, &pkg->vars, depends);
pkgconf_dependency_parse_str(deplist, kvdepends); pkgconf_dependency_parse_str(deplist, kvdepends);
free(kvdepends); free(kvdepends);

View File

@ -71,12 +71,12 @@ pkgconf_fragment_is_special(const char *string)
} }
static inline void static inline void
pkgconf_fragment_munge(char *buf, size_t buflen, const char *source, const char *sysroot_dir) pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen, const char *source, const char *sysroot_dir)
{ {
*buf = '\0'; *buf = '\0';
if (sysroot_dir == NULL) if (sysroot_dir == NULL)
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir"); sysroot_dir = pkgconf_tuple_find_global(client, "pc_sysrootdir");
if (pkgconf_fragment_should_munge(source, sysroot_dir)) if (pkgconf_fragment_should_munge(source, sysroot_dir))
strlcat(buf, sysroot_dir, buflen); strlcat(buf, sysroot_dir, buflen);
@ -85,7 +85,7 @@ pkgconf_fragment_munge(char *buf, size_t buflen, const char *source, const char
} }
static inline char * static inline char *
pkgconf_fragment_copy_munged(const char *source, unsigned int flags) pkgconf_fragment_copy_munged(const pkgconf_client_t *client, const char *source, unsigned int flags)
{ {
char mungebuf[PKGCONF_BUFSIZE]; char mungebuf[PKGCONF_BUFSIZE];
char *sysroot_dir; char *sysroot_dir;
@ -93,15 +93,15 @@ pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
if (!(flags & PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX)) if (!(flags & PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX))
return strdup(source); return strdup(source);
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir"); sysroot_dir = pkgconf_tuple_find_global(client, "pc_sysrootdir");
pkgconf_fragment_munge(mungebuf, sizeof mungebuf, source, sysroot_dir); pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, source, sysroot_dir);
return strdup(mungebuf); return strdup(mungebuf);
} }
void void
pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags) pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string, unsigned int flags)
{ {
pkgconf_fragment_t *frag; pkgconf_fragment_t *frag;
@ -113,7 +113,7 @@ pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flag
frag = calloc(sizeof(pkgconf_fragment_t), 1); frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = *(string + 1); frag->type = *(string + 1);
frag->data = pkgconf_fragment_copy_munged(string + 2, flags); frag->data = pkgconf_fragment_copy_munged(client, string + 2, flags);
} }
else else
{ {
@ -128,7 +128,7 @@ pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flag
size_t len; size_t len;
char *newdata; char *newdata;
pkgconf_fragment_munge(mungebuf, sizeof mungebuf, string, NULL); pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, string, NULL);
len = strlen(parent->data) + strlen(mungebuf) + 2; len = strlen(parent->data) + strlen(mungebuf) + 2;
newdata = malloc(len); newdata = malloc(len);
@ -260,16 +260,16 @@ pkgconf_fragment_free(pkgconf_list_t *list)
} }
void void
pkgconf_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags) pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags)
{ {
int i, argc; int i, argc;
char **argv; char **argv;
char *repstr = pkgconf_tuple_parse(vars, value); char *repstr = pkgconf_tuple_parse(client, vars, value);
pkgconf_argv_split(repstr, &argc, &argv); pkgconf_argv_split(repstr, &argc, &argv);
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
pkgconf_fragment_add(list, argv[i], flags); pkgconf_fragment_add(client, list, argv[i], flags);
pkgconf_argv_free(argv); pkgconf_argv_free(argv);
free(repstr); free(repstr);

View File

@ -53,6 +53,7 @@ typedef struct pkgconf_dependency_ pkgconf_dependency_t;
typedef struct pkgconf_tuple_ pkgconf_tuple_t; typedef struct pkgconf_tuple_ pkgconf_tuple_t;
typedef struct pkgconf_fragment_ pkgconf_fragment_t; typedef struct pkgconf_fragment_ pkgconf_fragment_t;
typedef struct pkgconf_path_ pkgconf_path_t; typedef struct pkgconf_path_ pkgconf_path_t;
typedef struct pkgconf_client_ pkgconf_client_t;
#define PKGCONF_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #define PKGCONF_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
@ -127,6 +128,30 @@ struct pkgconf_pkg_ {
unsigned int flags; unsigned int flags;
}; };
typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data);
typedef void (*pkgconf_pkg_traverse_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags);
typedef bool (*pkgconf_queue_apply_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags);
typedef bool (*pkgconf_error_handler_func_t)(const char *msg);
struct pkgconf_client_ {
pkgconf_list_t dir_list;
#ifdef XXX_NOTYET
pkgconf_list_t filter_libdirs;
pkgconf_list_t filter_includedirs;
#endif
pkgconf_list_t global_vars;
pkgconf_error_handler_func_t error_handler;
};
/* client.c */
void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler);
pkgconf_client_t *pkgconf_client_new(pkgconf_error_handler_func_t error_handler);
void pkgconf_client_deinit(pkgconf_client_t *client);
void pkgconf_client_free(pkgconf_client_t *client);
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c))) #define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c)))
#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=') #define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
@ -149,11 +174,6 @@ struct pkgconf_pkg_ {
#define PKGCONF_PKG_ERRF_PACKAGE_CONFLICT 0x4 #define PKGCONF_PKG_ERRF_PACKAGE_CONFLICT 0x4
#define PKGCONF_PKG_ERRF_DEPGRAPH_BREAK 0x8 #define PKGCONF_PKG_ERRF_DEPGRAPH_BREAK 0x8
typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data);
typedef void (*pkgconf_pkg_traverse_func_t)(pkgconf_pkg_t *pkg, void *data, unsigned int flags);
typedef bool (*pkgconf_queue_apply_func_t)(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags);
typedef bool (*pkgconf_error_handler_func_t)(const char *msg);
/* pkg.c */ /* pkg.c */
#if defined(__GNUC__) || defined(__INTEL_COMPILER) #if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define PRINTFLIKE(fmtarg, firstvararg) \ #define PRINTFLIKE(fmtarg, firstvararg) \
@ -172,23 +192,23 @@ void pkgconf_set_error_handler(pkgconf_error_handler_func_t func);
pkgconf_pkg_t *pkgconf_pkg_ref(pkgconf_pkg_t *pkg); pkgconf_pkg_t *pkgconf_pkg_ref(pkgconf_pkg_t *pkg);
void pkgconf_pkg_unref(pkgconf_pkg_t *pkg); void pkgconf_pkg_unref(pkgconf_pkg_t *pkg);
void pkgconf_pkg_free(pkgconf_pkg_t *pkg); void pkgconf_pkg_free(pkgconf_pkg_t *pkg);
pkgconf_pkg_t *pkgconf_pkg_find(const char *name, unsigned int flags); pkgconf_pkg_t *pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags);
unsigned int pkgconf_pkg_traverse(pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags); unsigned int pkgconf_pkg_traverse(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
unsigned int pkgconf_pkg_verify_graph(pkgconf_pkg_t *root, int depth, unsigned int flags); unsigned int pkgconf_pkg_verify_graph(const pkgconf_client_t *client, pkgconf_pkg_t *root, int depth, unsigned int flags);
pkgconf_pkg_t *pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); pkgconf_pkg_t *pkgconf_pkg_verify_dependency(const pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep); const char *pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep);
int pkgconf_pkg_cflags(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags); int pkgconf_pkg_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
int pkgconf_pkg_libs(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags); int pkgconf_pkg_libs(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name); pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name);
pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name); pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name);
int pkgconf_compare_version(const char *a, const char *b); int pkgconf_compare_version(const char *a, const char *b);
pkgconf_pkg_t *pkgconf_scan_all(void *ptr, pkgconf_pkg_iteration_func_t func); pkgconf_pkg_t *pkgconf_scan_all(pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func);
/* parse.c */ /* parse.c */
pkgconf_pkg_t *pkgconf_pkg_new_from_file(const char *path, FILE *f, unsigned int flags); pkgconf_pkg_t *pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *path, FILE *f, unsigned int flags);
void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends); void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends);
void pkgconf_dependency_parse(pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends); void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail); void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
void pkgconf_dependency_free(pkgconf_list_t *list); void pkgconf_dependency_free(pkgconf_list_t *list);
pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare); pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare);
@ -198,8 +218,8 @@ int pkgconf_argv_split(const char *src, int *argc, char ***argv);
void pkgconf_argv_free(char **argv); void pkgconf_argv_free(char **argv);
/* fragment.c */ /* fragment.c */
void pkgconf_fragment_parse(pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags); void pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags);
void pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flags); void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string, unsigned int flags);
void pkgconf_fragment_copy(pkgconf_list_t *list, pkgconf_fragment_t *base, unsigned int flags, bool is_private); void pkgconf_fragment_copy(pkgconf_list_t *list, pkgconf_fragment_t *base, unsigned int flags, bool is_private);
void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node); void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
void pkgconf_fragment_free(pkgconf_list_t *list); void pkgconf_fragment_free(pkgconf_list_t *list);
@ -208,21 +228,21 @@ void pkgconf_fragment_free(pkgconf_list_t *list);
char *pkgconf_fgetline(char *line, size_t size, FILE *stream); char *pkgconf_fgetline(char *line, size_t size, FILE *stream);
/* tuple.c */ /* tuple.c */
pkgconf_tuple_t *pkgconf_tuple_add(pkgconf_list_t *parent, const char *key, const char *value, bool parse); pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *parent, const char *key, const char *value, bool parse);
char *pkgconf_tuple_find(pkgconf_list_t *list, const char *key); char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key);
char *pkgconf_tuple_parse(pkgconf_list_t *list, const char *value); char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *list, const char *value);
void pkgconf_tuple_free(pkgconf_list_t *list); void pkgconf_tuple_free(pkgconf_list_t *list);
void pkgconf_tuple_add_global(const char *key, const char *value); void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value);
char *pkgconf_tuple_find_global(const char *key); char *pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key);
void pkgconf_tuple_free_global(void); void pkgconf_tuple_free_global(pkgconf_client_t *client);
void pkgconf_tuple_define_global(const char *kv); void pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv);
/* queue.c */ /* queue.c */
void pkgconf_queue_push(pkgconf_list_t *list, const char *package); void pkgconf_queue_push(pkgconf_list_t *list, const char *package);
bool pkgconf_queue_compile(pkgconf_pkg_t *world, pkgconf_list_t *list); bool pkgconf_queue_compile(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list);
void pkgconf_queue_free(pkgconf_list_t *list); void pkgconf_queue_free(pkgconf_list_t *list);
bool pkgconf_queue_apply(pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data); bool pkgconf_queue_apply(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data);
bool pkgconf_queue_validate(pkgconf_list_t *list, int maxdepth, unsigned int flags); bool pkgconf_queue_validate(const pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth, unsigned int flags);
/* cache.c */ /* cache.c */
pkgconf_pkg_t *pkgconf_cache_lookup(const char *id); pkgconf_pkg_t *pkgconf_cache_lookup(const char *id);

View File

@ -115,21 +115,19 @@ pkg_get_parent_dir(pkgconf_pkg_t *pkg)
return buf; return buf;
} }
static pkgconf_list_t pkg_dir_list = PKGCONF_LIST_INITIALIZER;
static void static void
pkgconf_pkg_dir_list_build(unsigned int flags) pkgconf_pkg_dir_list_build(pkgconf_client_t *client, unsigned int flags)
{ {
if (pkg_dir_list.head != NULL || pkg_dir_list.tail != NULL) if (client->dir_list.head != NULL || client->dir_list.tail != NULL)
return; return;
pkgconf_path_build_from_environ("PKG_CONFIG_PATH", NULL, &pkg_dir_list); pkgconf_path_build_from_environ("PKG_CONFIG_PATH", NULL, &client->dir_list);
if (!(flags & PKGCONF_PKG_PKGF_ENV_ONLY)) if (!(flags & PKGCONF_PKG_PKGF_ENV_ONLY))
pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", get_default_pkgconfig_path(), &pkg_dir_list); pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", get_default_pkgconfig_path(), &client->dir_list);
} }
typedef void (*pkgconf_pkg_parser_keyword_func_t)(pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags); typedef void (*pkgconf_pkg_parser_keyword_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags);
typedef struct { typedef struct {
const char *keyword; const char *keyword;
const pkgconf_pkg_parser_keyword_func_t func; const pkgconf_pkg_parser_keyword_func_t func;
@ -143,28 +141,28 @@ static int pkgconf_pkg_parser_keyword_pair_cmp(const void *key, const void *ptr)
} }
static void static void
pkgconf_pkg_parser_tuple_func(pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags) pkgconf_pkg_parser_tuple_func(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags)
{ {
char **dest = ((void *) pkg + offset); char **dest = ((void *) pkg + offset);
(void) flags; (void) flags;
*dest = pkgconf_tuple_parse(&pkg->vars, value); *dest = pkgconf_tuple_parse(client, &pkg->vars, value);
} }
static void static void
pkgconf_pkg_parser_fragment_func(pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags) pkgconf_pkg_parser_fragment_func(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags)
{ {
pkgconf_list_t *dest = ((void *) pkg + offset); pkgconf_list_t *dest = ((void *) pkg + offset);
pkgconf_fragment_parse(dest, &pkg->vars, value, flags); pkgconf_fragment_parse(client, dest, &pkg->vars, value, flags);
} }
static void static void
pkgconf_pkg_parser_dependency_func(pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags) pkgconf_pkg_parser_dependency_func(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value, unsigned int flags)
{ {
pkgconf_list_t *dest = ((void *) pkg + offset); pkgconf_list_t *dest = ((void *) pkg + offset);
(void) flags; (void) flags;
pkgconf_dependency_parse(pkg, dest, value); pkgconf_dependency_parse(client, pkg, dest, value);
} }
/* keep this in alphabetical order */ /* keep this in alphabetical order */
@ -183,7 +181,7 @@ static const pkgconf_pkg_parser_keyword_pair_t pkgconf_pkg_parser_keyword_funcs[
}; };
static bool static bool
pkgconf_pkg_parser_keyword_set(pkgconf_pkg_t *pkg, const char *keyword, char *value, unsigned int flags) pkgconf_pkg_parser_keyword_set(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const char *keyword, char *value, unsigned int flags)
{ {
const pkgconf_pkg_parser_keyword_pair_t *pair = bsearch(keyword, const pkgconf_pkg_parser_keyword_pair_t *pair = bsearch(keyword,
pkgconf_pkg_parser_keyword_funcs, PKGCONF_ARRAY_SIZE(pkgconf_pkg_parser_keyword_funcs), pkgconf_pkg_parser_keyword_funcs, PKGCONF_ARRAY_SIZE(pkgconf_pkg_parser_keyword_funcs),
@ -192,7 +190,7 @@ pkgconf_pkg_parser_keyword_set(pkgconf_pkg_t *pkg, const char *keyword, char *va
if (pair == NULL || pair->func == NULL) if (pair == NULL || pair->func == NULL)
return false; return false;
pair->func(pkg, pair->offset, value, flags); pair->func(client, pkg, pair->offset, value, flags);
return true; return true;
} }
@ -202,7 +200,7 @@ pkgconf_pkg_parser_keyword_set(pkgconf_pkg_t *pkg, const char *keyword, char *va
* Parse a .pc file into a pkgconf_pkg_t object structure. * Parse a .pc file into a pkgconf_pkg_t object structure.
*/ */
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags) pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename, FILE *f, unsigned int flags)
{ {
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
char readbuf[PKGCONF_BUFSIZE]; char readbuf[PKGCONF_BUFSIZE];
@ -210,7 +208,7 @@ pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
pkg = calloc(sizeof(pkgconf_pkg_t), 1); pkg = calloc(sizeof(pkgconf_pkg_t), 1);
pkg->filename = strdup(filename); pkg->filename = strdup(filename);
pkgconf_tuple_add(&pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg), true); pkgconf_tuple_add(client, &pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg), true);
/* make module id */ /* make module id */
if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL) if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL)
@ -253,12 +251,12 @@ pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
switch (op) switch (op)
{ {
case ':': case ':':
if (!pkgconf_pkg_parser_keyword_set(pkg, key, value, flags)) if (!pkgconf_pkg_parser_keyword_set(client, pkg, key, value, flags))
/* XXX: warning? */ /* XXX: warning? */
; ;
break; break;
case '=': case '=':
pkgconf_tuple_add(&pkg->vars, key, value, true); pkgconf_tuple_add(client, &pkg->vars, key, value, true);
break; break;
default: default:
break; break;
@ -332,7 +330,7 @@ pkgconf_pkg_unref(pkgconf_pkg_t *pkg)
} }
static inline pkgconf_pkg_t * static inline pkgconf_pkg_t *
pkgconf_pkg_try_specific_path(const char *path, const char *name, unsigned int flags) pkgconf_pkg_try_specific_path(const pkgconf_client_t *client, const char *path, const char *name, unsigned int flags)
{ {
pkgconf_pkg_t *pkg = NULL; pkgconf_pkg_t *pkg = NULL;
FILE *f; FILE *f;
@ -344,17 +342,17 @@ pkgconf_pkg_try_specific_path(const char *path, const char *name, unsigned int f
if (!(flags & PKGCONF_PKG_PKGF_NO_UNINSTALLED) && (f = fopen(uninst_locbuf, "r")) != NULL) if (!(flags & PKGCONF_PKG_PKGF_NO_UNINSTALLED) && (f = fopen(uninst_locbuf, "r")) != NULL)
{ {
pkg = pkgconf_pkg_new_from_file(uninst_locbuf, f, flags); pkg = pkgconf_pkg_new_from_file(client, uninst_locbuf, f, flags);
pkg->flags |= PKGCONF_PKG_PROPF_UNINSTALLED; pkg->flags |= PKGCONF_PKG_PROPF_UNINSTALLED;
} }
else if ((f = fopen(locbuf, "r")) != NULL) else if ((f = fopen(locbuf, "r")) != NULL)
pkg = pkgconf_pkg_new_from_file(locbuf, f, flags); pkg = pkgconf_pkg_new_from_file(client, locbuf, f, flags);
return pkg; return pkg;
} }
static pkgconf_pkg_t * static pkgconf_pkg_t *
pkgconf_pkg_scan_dir(const char *path, void *data, pkgconf_pkg_iteration_func_t func) pkgconf_pkg_scan_dir(const pkgconf_client_t *client, const char *path, void *data, pkgconf_pkg_iteration_func_t func)
{ {
DIR *dir; DIR *dir;
struct dirent *dirent; struct dirent *dirent;
@ -383,7 +381,7 @@ pkgconf_pkg_scan_dir(const char *path, void *data, pkgconf_pkg_iteration_func_t
if (f == NULL) if (f == NULL)
continue; continue;
pkg = pkgconf_pkg_new_from_file(filebuf, f, 0); pkg = pkgconf_pkg_new_from_file(client, filebuf, f, 0);
if (pkg != NULL) if (pkg != NULL)
{ {
if (func(pkg, data)) if (func(pkg, data))
@ -402,18 +400,18 @@ out:
} }
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_scan_all(void *data, pkgconf_pkg_iteration_func_t func) pkgconf_scan_all(pkgconf_client_t *client, void *data, pkgconf_pkg_iteration_func_t func)
{ {
pkgconf_node_t *n; pkgconf_node_t *n;
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkgconf_pkg_dir_list_build(0); pkgconf_pkg_dir_list_build(client, 0);
PKGCONF_FOREACH_LIST_ENTRY(pkg_dir_list.head, n) PKGCONF_FOREACH_LIST_ENTRY(client->dir_list.head, n)
{ {
pkgconf_path_t *pnode = n->data; pkgconf_path_t *pnode = n->data;
if ((pkg = pkgconf_pkg_scan_dir(pnode->path, data, func)) != NULL) if ((pkg = pkgconf_pkg_scan_dir(client, pnode->path, data, func)) != NULL)
return pkg; return pkg;
} }
@ -459,13 +457,13 @@ pkgconf_pkg_find_in_registry_key(HKEY hkey, const char *name, unsigned int flags
#endif #endif
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_pkg_find(const char *name, unsigned int flags) pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags)
{ {
pkgconf_pkg_t *pkg = NULL; pkgconf_pkg_t *pkg = NULL;
pkgconf_node_t *n; pkgconf_node_t *n;
FILE *f; FILE *f;
pkgconf_pkg_dir_list_build(flags); pkgconf_pkg_dir_list_build(client, flags);
/* name might actually be a filename. */ /* name might actually be a filename. */
if (str_has_suffix(name, PKG_CONFIG_EXT)) if (str_has_suffix(name, PKG_CONFIG_EXT))
@ -474,8 +472,8 @@ pkgconf_pkg_find(const char *name, unsigned int flags)
{ {
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkg = pkgconf_pkg_new_from_file(name, f, flags); pkg = pkgconf_pkg_new_from_file(client, name, f, flags);
pkgconf_path_add(pkg_get_parent_dir(pkg), &pkg_dir_list); pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list);
return pkg; return pkg;
} }
@ -495,11 +493,11 @@ pkgconf_pkg_find(const char *name, unsigned int flags)
} }
} }
PKGCONF_FOREACH_LIST_ENTRY(pkg_dir_list.head, n) PKGCONF_FOREACH_LIST_ENTRY(client->dir_list.head, n)
{ {
pkgconf_path_t *pnode = n->data; pkgconf_path_t *pnode = n->data;
pkg = pkgconf_pkg_try_specific_path(pnode->path, name, flags); pkg = pkgconf_pkg_try_specific_path(client, pnode->path, name, flags);
if (pkg != NULL) if (pkg != NULL)
goto out; goto out;
} }
@ -974,7 +972,7 @@ pkgconf_pkg_scan_provides_entry(const pkgconf_pkg_t *pkg, const pkgconf_pkg_scan
* scan all available packages to see if a Provides rule matches the pkgdep. * scan all available packages to see if a Provides rule matches the pkgdep.
*/ */
static pkgconf_pkg_t * static pkgconf_pkg_t *
pkgconf_pkg_scan_providers(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags) pkgconf_pkg_scan_providers(const pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags)
{ {
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkgconf_pkg_scan_providers_ctx_t ctx = { pkgconf_pkg_scan_providers_ctx_t ctx = {
@ -982,7 +980,7 @@ pkgconf_pkg_scan_providers(pkgconf_dependency_t *pkgdep, unsigned int flags, uns
.flags = flags .flags = flags
}; };
pkg = pkgconf_scan_all(&ctx, (pkgconf_pkg_iteration_func_t) pkgconf_pkg_scan_provides_entry); pkg = pkgconf_scan_all(client, &ctx, (pkgconf_pkg_iteration_func_t) pkgconf_pkg_scan_provides_entry);
if (pkg != NULL) if (pkg != NULL)
return pkg; return pkg;
@ -999,14 +997,14 @@ pkgconf_pkg_scan_providers(pkgconf_dependency_t *pkgdep, unsigned int flags, uns
* return the appropriate pkgconf_pkg_t object, else NULL. * return the appropriate pkgconf_pkg_t object, else NULL.
*/ */
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags) pkgconf_pkg_verify_dependency(const pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags)
{ {
pkgconf_pkg_t *pkg = NULL; pkgconf_pkg_t *pkg = NULL;
if (eflags != NULL) if (eflags != NULL)
*eflags = PKGCONF_PKG_ERRF_OK; *eflags = PKGCONF_PKG_ERRF_OK;
pkg = pkgconf_pkg_find(pkgdep->package, flags); pkg = pkgconf_pkg_find(client, pkgdep->package, flags);
if (pkg == NULL) if (pkg == NULL)
{ {
if (flags & PKGCONF_PKG_PKGF_SKIP_PROVIDES) if (flags & PKGCONF_PKG_PKGF_SKIP_PROVIDES)
@ -1017,7 +1015,7 @@ pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags,
return NULL; return NULL;
} }
return pkgconf_pkg_scan_providers(pkgdep, flags, eflags); return pkgconf_pkg_scan_providers(client, pkgdep, flags, eflags);
} }
if (pkg->id == NULL) if (pkg->id == NULL)
@ -1039,9 +1037,9 @@ pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags,
* pkgconf_pkg_traverse(). * pkgconf_pkg_traverse().
*/ */
unsigned int unsigned int
pkgconf_pkg_verify_graph(pkgconf_pkg_t *root, int depth, unsigned int flags) pkgconf_pkg_verify_graph(const pkgconf_client_t *client, pkgconf_pkg_t *root, int depth, unsigned int flags)
{ {
return pkgconf_pkg_traverse(root, NULL, NULL, depth, flags); return pkgconf_pkg_traverse(client, root, NULL, NULL, depth, flags);
} }
static unsigned int static unsigned int
@ -1079,7 +1077,8 @@ pkgconf_pkg_report_graph_error(pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgcon
} }
static inline unsigned int static inline unsigned int
pkgconf_pkg_walk_list(pkgconf_pkg_t *parent, pkgconf_pkg_walk_list(const pkgconf_client_t *client,
pkgconf_pkg_t *parent,
pkgconf_list_t *deplist, pkgconf_list_t *deplist,
pkgconf_pkg_traverse_func_t func, pkgconf_pkg_traverse_func_t func,
void *data, void *data,
@ -1098,7 +1097,7 @@ pkgconf_pkg_walk_list(pkgconf_pkg_t *parent,
if (*depnode->package == '\0') if (*depnode->package == '\0')
continue; continue;
pkgdep = pkgconf_pkg_verify_dependency(depnode, flags, &eflags_local); pkgdep = pkgconf_pkg_verify_dependency(client, depnode, flags, &eflags_local);
eflags |= eflags_local; eflags |= eflags_local;
if (eflags_local != PKGCONF_PKG_ERRF_OK && !(flags & PKGCONF_PKG_PKGF_SKIP_ERRORS)) if (eflags_local != PKGCONF_PKG_ERRF_OK && !(flags & PKGCONF_PKG_PKGF_SKIP_ERRORS))
@ -1118,7 +1117,7 @@ pkgconf_pkg_walk_list(pkgconf_pkg_t *parent,
pkgconf_audit_log_dependency(pkgdep, depnode); pkgconf_audit_log_dependency(pkgdep, depnode);
pkgdep->flags |= PKGCONF_PKG_PROPF_SEEN; pkgdep->flags |= PKGCONF_PKG_PROPF_SEEN;
eflags |= pkgconf_pkg_traverse(pkgdep, func, data, depth - 1, flags); eflags |= pkgconf_pkg_traverse(client, pkgdep, func, data, depth - 1, flags);
pkgdep->flags &= ~PKGCONF_PKG_PROPF_SEEN; pkgdep->flags &= ~PKGCONF_PKG_PROPF_SEEN;
pkgconf_pkg_unref(pkgdep); pkgconf_pkg_unref(pkgdep);
} }
@ -1127,7 +1126,8 @@ pkgconf_pkg_walk_list(pkgconf_pkg_t *parent,
} }
static inline unsigned int static inline unsigned int
pkgconf_pkg_walk_conflicts_list(pkgconf_pkg_t *root, pkgconf_list_t *deplist, unsigned int flags) pkgconf_pkg_walk_conflicts_list(const pkgconf_client_t *client,
pkgconf_pkg_t *root, pkgconf_list_t *deplist, unsigned int flags)
{ {
unsigned int eflags; unsigned int eflags;
pkgconf_node_t *node, *childnode; pkgconf_node_t *node, *childnode;
@ -1147,7 +1147,7 @@ pkgconf_pkg_walk_conflicts_list(pkgconf_pkg_t *root, pkgconf_list_t *deplist, un
if (*depnode->package == '\0' || strcmp(depnode->package, parentnode->package)) if (*depnode->package == '\0' || strcmp(depnode->package, parentnode->package))
continue; continue;
pkgdep = pkgconf_pkg_verify_dependency(parentnode, flags, &eflags); pkgdep = pkgconf_pkg_verify_dependency(client, parentnode, flags, &eflags);
if (eflags == PKGCONF_PKG_ERRF_OK) if (eflags == PKGCONF_PKG_ERRF_OK)
{ {
pkgconf_error("Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n", pkgconf_error("Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n",
@ -1174,7 +1174,8 @@ pkgconf_pkg_walk_conflicts_list(pkgconf_pkg_t *root, pkgconf_list_t *deplist, un
* walk the dependency graph up to maxdepth levels. -1 means infinite recursion. * walk the dependency graph up to maxdepth levels. -1 means infinite recursion.
*/ */
unsigned int unsigned int
pkgconf_pkg_traverse(pkgconf_pkg_t *root, pkgconf_pkg_traverse(const pkgconf_client_t *client,
pkgconf_pkg_t *root,
pkgconf_pkg_traverse_func_t func, pkgconf_pkg_traverse_func_t func,
void *data, void *data,
int maxdepth, int maxdepth,
@ -1189,23 +1190,23 @@ pkgconf_pkg_traverse(pkgconf_pkg_t *root,
if ((root->flags & PKGCONF_PKG_PROPF_VIRTUAL) != PKGCONF_PKG_PROPF_VIRTUAL || (flags & PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) != PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) if ((root->flags & PKGCONF_PKG_PROPF_VIRTUAL) != PKGCONF_PKG_PROPF_VIRTUAL || (flags & PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) != PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL)
{ {
if (func != NULL) if (func != NULL)
func(root, data, flags); func(client, root, data, flags);
} }
if (!(flags & PKGCONF_PKG_PKGF_SKIP_CONFLICTS)) if (!(flags & PKGCONF_PKG_PKGF_SKIP_CONFLICTS))
{ {
eflags = pkgconf_pkg_walk_conflicts_list(root, &root->conflicts, rflags); eflags = pkgconf_pkg_walk_conflicts_list(client, root, &root->conflicts, rflags);
if (eflags != PKGCONF_PKG_ERRF_OK) if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags; return eflags;
} }
eflags = pkgconf_pkg_walk_list(root, &root->requires, func, data, maxdepth, rflags); eflags = pkgconf_pkg_walk_list(client, root, &root->requires, func, data, maxdepth, rflags);
if (eflags != PKGCONF_PKG_ERRF_OK) if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags; return eflags;
if (flags & PKGCONF_PKG_PKGF_SEARCH_PRIVATE) if (flags & PKGCONF_PKG_PKGF_SEARCH_PRIVATE)
{ {
eflags = pkgconf_pkg_walk_list(root, &root->requires_private, func, data, maxdepth, rflags | PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE); eflags = pkgconf_pkg_walk_list(client, root, &root->requires_private, func, data, maxdepth, rflags | PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE);
if (eflags != PKGCONF_PKG_ERRF_OK) if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags; return eflags;
} }
@ -1214,11 +1215,12 @@ pkgconf_pkg_traverse(pkgconf_pkg_t *root,
} }
static void static void
pkgconf_pkg_cflags_collect(pkgconf_pkg_t *pkg, void *data, unsigned int flags) pkgconf_pkg_cflags_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_list_t *list = data; pkgconf_list_t *list = data;
pkgconf_node_t *node; pkgconf_node_t *node;
(void) flags; (void) flags;
(void) client;
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags.head, node)
{ {
@ -1228,11 +1230,12 @@ pkgconf_pkg_cflags_collect(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
} }
static void static void
pkgconf_pkg_cflags_private_collect(pkgconf_pkg_t *pkg, void *data, unsigned int flags) pkgconf_pkg_cflags_private_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_list_t *list = data; pkgconf_list_t *list = data;
pkgconf_node_t *node; pkgconf_node_t *node;
(void) flags; (void) flags;
(void) client;
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node)
{ {
@ -1243,17 +1246,17 @@ pkgconf_pkg_cflags_private_collect(pkgconf_pkg_t *pkg, void *data, unsigned int
} }
int int
pkgconf_pkg_cflags(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_pkg_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
eflag = pkgconf_pkg_traverse(root, pkgconf_pkg_cflags_collect, list, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_cflags_collect, list, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
pkgconf_fragment_free(list); pkgconf_fragment_free(list);
if (flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS) if (flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS)
{ {
eflag = pkgconf_pkg_traverse(root, pkgconf_pkg_cflags_private_collect, list, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_cflags_private_collect, list, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
pkgconf_fragment_free(list); pkgconf_fragment_free(list);
} }
@ -1262,11 +1265,12 @@ pkgconf_pkg_cflags(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsi
} }
static void static void
pkgconf_pkg_libs_collect(pkgconf_pkg_t *pkg, void *data, unsigned int flags) pkgconf_pkg_libs_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_list_t *list = data; pkgconf_list_t *list = data;
pkgconf_node_t *node; pkgconf_node_t *node;
(void) flags; (void) flags;
(void) client;
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node) PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node)
{ {
@ -1285,11 +1289,11 @@ pkgconf_pkg_libs_collect(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
} }
int int
pkgconf_pkg_libs(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_pkg_libs(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
eflag = pkgconf_pkg_traverse(root, pkgconf_pkg_libs_collect, list, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_libs_collect, list, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
{ {

View File

@ -30,7 +30,7 @@ pkgconf_queue_push(pkgconf_list_t *list, const char *package)
} }
bool bool
pkgconf_queue_compile(pkgconf_pkg_t *world, pkgconf_list_t *list) pkgconf_queue_compile(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
@ -39,7 +39,7 @@ pkgconf_queue_compile(pkgconf_pkg_t *world, pkgconf_list_t *list)
pkgconf_queue_t *pkgq; pkgconf_queue_t *pkgq;
pkgq = iter->data; pkgq = iter->data;
pkgconf_dependency_parse(world, &world->requires, pkgq->package); pkgconf_dependency_parse(client, world, &world->requires, pkgq->package);
} }
return (world->requires.head != NULL); return (world->requires.head != NULL);
@ -60,16 +60,16 @@ pkgconf_queue_free(pkgconf_list_t *list)
} }
static inline unsigned int static inline unsigned int
pkgconf_queue_verify(pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_queue_verify(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
if (!pkgconf_queue_compile(world, list)) if (!pkgconf_queue_compile(client, world, list))
return PKGCONF_PKG_ERRF_DEPGRAPH_BREAK; return PKGCONF_PKG_ERRF_DEPGRAPH_BREAK;
return pkgconf_pkg_verify_graph(world, maxdepth, flags); return pkgconf_pkg_verify_graph(client, world, maxdepth, flags);
} }
bool bool
pkgconf_queue_apply(pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data) pkgconf_queue_apply(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data)
{ {
pkgconf_pkg_t world = { pkgconf_pkg_t world = {
.id = "virtual:world", .id = "virtual:world",
@ -81,10 +81,10 @@ pkgconf_queue_apply(pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int m
if (!maxdepth) if (!maxdepth)
maxdepth = -1; maxdepth = -1;
if (pkgconf_queue_verify(&world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK) if (pkgconf_queue_verify(client, &world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK)
return false; return false;
if (!func(&world, data, maxdepth, flags)) if (!func(client, &world, data, maxdepth, flags))
{ {
pkgconf_pkg_free(&world); pkgconf_pkg_free(&world);
return false; return false;
@ -96,7 +96,7 @@ pkgconf_queue_apply(pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int m
} }
bool bool
pkgconf_queue_validate(pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_queue_validate(const pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
bool retval = true; bool retval = true;
pkgconf_pkg_t world = { pkgconf_pkg_t world = {
@ -109,7 +109,7 @@ pkgconf_queue_validate(pkgconf_list_t *list, int maxdepth, unsigned int flags)
if (!maxdepth) if (!maxdepth)
maxdepth = -1; maxdepth = -1;
if (pkgconf_queue_verify(&world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK) if (pkgconf_queue_verify(client, &world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK)
retval = false; retval = false;
pkgconf_pkg_free(&world); pkgconf_pkg_free(&world);

View File

@ -15,20 +15,18 @@
#include <libpkgconf/libpkgconf.h> #include <libpkgconf/libpkgconf.h>
static pkgconf_list_t pkg_global_var = PKGCONF_LIST_INITIALIZER;
void void
pkgconf_tuple_add_global(const char *key, const char *value) pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value)
{ {
pkgconf_tuple_add(&pkg_global_var, key, value, false); pkgconf_tuple_add(client, &client->global_vars, key, value, false);
} }
char * char *
pkgconf_tuple_find_global(const char *key) pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(pkg_global_var.head, node) PKGCONF_FOREACH_LIST_ENTRY(client->global_vars.head, node)
{ {
pkgconf_tuple_t *tuple = node->data; pkgconf_tuple_t *tuple = node->data;
@ -40,13 +38,13 @@ pkgconf_tuple_find_global(const char *key)
} }
void void
pkgconf_tuple_free_global(void) pkgconf_tuple_free_global(pkgconf_client_t *client)
{ {
pkgconf_tuple_free(&pkg_global_var); pkgconf_tuple_free(&client->global_vars);
} }
void void
pkgconf_tuple_define_global(const char *kv) pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv)
{ {
char *workbuf = strdup(kv); char *workbuf = strdup(kv);
char *value; char *value;
@ -56,19 +54,19 @@ pkgconf_tuple_define_global(const char *kv)
goto out; goto out;
*value++ = '\0'; *value++ = '\0';
pkgconf_tuple_add_global(workbuf, value); pkgconf_tuple_add_global(client, workbuf, value);
out: out:
free(workbuf); free(workbuf);
} }
pkgconf_tuple_t * pkgconf_tuple_t *
pkgconf_tuple_add(pkgconf_list_t *list, const char *key, const char *value, bool parse) pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key, const char *value, bool parse)
{ {
pkgconf_tuple_t *tuple = calloc(sizeof(pkgconf_tuple_t), 1); pkgconf_tuple_t *tuple = calloc(sizeof(pkgconf_tuple_t), 1);
tuple->key = strdup(key); tuple->key = strdup(key);
if (parse) if (parse)
tuple->value = pkgconf_tuple_parse(list, value); tuple->value = pkgconf_tuple_parse(client, list, value);
else else
tuple->value = strdup(value); tuple->value = strdup(value);
@ -78,12 +76,12 @@ pkgconf_tuple_add(pkgconf_list_t *list, const char *key, const char *value, bool
} }
char * char *
pkgconf_tuple_find(pkgconf_list_t *list, const char *key) pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
char *res; char *res;
if ((res = pkgconf_tuple_find_global(key)) != NULL) if ((res = pkgconf_tuple_find_global(client, key)) != NULL)
return res; return res;
PKGCONF_FOREACH_LIST_ENTRY(list->head, node) PKGCONF_FOREACH_LIST_ENTRY(list->head, node)
@ -98,7 +96,7 @@ pkgconf_tuple_find(pkgconf_list_t *list, const char *key)
} }
char * char *
pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value) pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value)
{ {
char buf[PKGCONF_BUFSIZE]; char buf[PKGCONF_BUFSIZE];
const char *ptr; const char *ptr;
@ -129,7 +127,7 @@ pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value)
} }
ptr += (pptr - ptr); ptr += (pptr - ptr);
kv = pkgconf_tuple_find_global(varname); kv = pkgconf_tuple_find_global(client, varname);
if (kv != NULL) if (kv != NULL)
{ {
strncpy(bptr, kv, PKGCONF_BUFSIZE - (bptr - buf)); strncpy(bptr, kv, PKGCONF_BUFSIZE - (bptr - buf));
@ -137,11 +135,11 @@ pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value)
} }
else else
{ {
kv = pkgconf_tuple_find(vars, varname); kv = pkgconf_tuple_find(client, vars, varname);
if (kv != NULL) if (kv != NULL)
{ {
parsekv = pkgconf_tuple_parse(vars, kv); parsekv = pkgconf_tuple_parse(client, vars, kv);
strncpy(bptr, parsekv, PKGCONF_BUFSIZE - (bptr - buf)); strncpy(bptr, parsekv, PKGCONF_BUFSIZE - (bptr - buf));
bptr += strlen(parsekv); bptr += strlen(parsekv);

114
main.c
View File

@ -52,6 +52,8 @@
static unsigned int global_traverse_flags = PKGCONF_PKG_PKGF_NONE; static unsigned int global_traverse_flags = PKGCONF_PKG_PKGF_NONE;
static pkgconf_client_t pkg_client;
static pkgconf_list_t filter_libdirs = PKGCONF_LIST_INITIALIZER; static pkgconf_list_t filter_libdirs = PKGCONF_LIST_INITIALIZER;
static pkgconf_list_t filter_includedirs = PKGCONF_LIST_INITIALIZER; static pkgconf_list_t filter_includedirs = PKGCONF_LIST_INITIALIZER;
@ -182,8 +184,9 @@ print_libs(pkgconf_list_t *list)
} }
static void static void
print_modversion(pkgconf_pkg_t *pkg, void *unused, unsigned int flags) print_modversion(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
{ {
(void) client;
(void) unused; (void) unused;
(void) flags; (void) flags;
@ -192,9 +195,10 @@ print_modversion(pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
} }
static void static void
print_variables(pkgconf_pkg_t *pkg, void *unused, unsigned int flags) print_variables(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
(void) client;
(void) unused; (void) unused;
(void) flags; (void) flags;
@ -261,7 +265,7 @@ print_provides(pkgconf_pkg_t *pkg)
} }
static bool static bool
apply_provides(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_provides(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
(void) unused; (void) unused;
@ -272,7 +276,7 @@ apply_provides(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fl
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkgconf_dependency_t *dep = iter->data; pkgconf_dependency_t *dep = iter->data;
pkg = pkgconf_pkg_verify_dependency(dep, flags, NULL); pkg = pkgconf_pkg_verify_dependency(client, dep, flags, NULL);
print_provides(pkg); print_provides(pkg);
pkgconf_pkg_free(pkg); pkgconf_pkg_free(pkg);
@ -282,9 +286,10 @@ apply_provides(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fl
} }
static void static void
print_digraph_node(pkgconf_pkg_t *pkg, void *unused, unsigned int flags) print_digraph_node(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
(void) client;
(void) unused; (void) unused;
(void) flags; (void) flags;
@ -299,7 +304,7 @@ print_digraph_node(pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
} }
static bool static bool
apply_digraph(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_digraph(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -307,7 +312,7 @@ apply_digraph(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fla
printf("edge [color=blue len=7.5 fontname=Sans fontsize=8]\n"); printf("edge [color=blue len=7.5 fontname=Sans fontsize=8]\n");
printf("node [fontname=Sans fontsize=8]\n"); printf("node [fontname=Sans fontsize=8]\n");
eflag = pkgconf_pkg_traverse(world, print_digraph_node, unused, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, world, print_digraph_node, unused, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -317,11 +322,11 @@ apply_digraph(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fla
} }
static bool static bool
apply_modversion(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_modversion(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
eflag = pkgconf_pkg_traverse(world, print_modversion, unused, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, world, print_modversion, unused, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -330,11 +335,11 @@ apply_modversion(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int
} }
static bool static bool
apply_variables(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_variables(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
eflag = pkgconf_pkg_traverse(world, print_variables, unused, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, world, print_variables, unused, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -348,13 +353,13 @@ typedef struct {
} var_request_t; } var_request_t;
static void static void
print_variable(pkgconf_pkg_t *pkg, void *data, unsigned int flags) print_variable(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
var_request_t *req = data; var_request_t *req = data;
const char *var; const char *var;
(void) flags; (void) flags;
var = pkgconf_tuple_find(&pkg->vars, req->variable); var = pkgconf_tuple_find(client, &pkg->vars, req->variable);
if (var != NULL) if (var != NULL)
{ {
if (*(req->buf) == '\0') if (*(req->buf) == '\0')
@ -380,7 +385,7 @@ print_variable(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
} }
static bool static bool
apply_variable(pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int flags) apply_variable(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -390,7 +395,7 @@ apply_variable(pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int
*req.buf = '\0'; *req.buf = '\0';
eflag = pkgconf_pkg_traverse(world, print_variable, &req, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, world, print_variable, &req, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -399,12 +404,12 @@ apply_variable(pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int
} }
static bool static bool
apply_cflags(pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags) apply_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
{ {
pkgconf_list_t *list = list_head; pkgconf_list_t *list = list_head;
int eflag; int eflag;
eflag = pkgconf_pkg_cflags(world, list, maxdepth, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE); eflag = pkgconf_pkg_cflags(client, world, list, maxdepth, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -419,12 +424,12 @@ apply_cflags(pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int f
} }
static bool static bool
apply_libs(pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags) apply_libs(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
{ {
pkgconf_list_t *list = list_head; pkgconf_list_t *list = list_head;
int eflag; int eflag;
eflag = pkgconf_pkg_libs(world, list, maxdepth, flags); eflag = pkgconf_pkg_libs(client, world, list, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -439,7 +444,7 @@ apply_libs(pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int fla
} }
static bool static bool
apply_requires(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_requires(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
(void) unused; (void) unused;
@ -450,7 +455,7 @@ apply_requires(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fl
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkgconf_dependency_t *dep = iter->data; pkgconf_dependency_t *dep = iter->data;
pkg = pkgconf_pkg_verify_dependency(dep, flags, NULL); pkg = pkgconf_pkg_verify_dependency(client, dep, flags, NULL);
print_requires(pkg); print_requires(pkg);
pkgconf_pkg_free(pkg); pkgconf_pkg_free(pkg);
@ -460,7 +465,7 @@ apply_requires(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fl
} }
static bool static bool
apply_requires_private(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_requires_private(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
(void) unused; (void) unused;
@ -471,7 +476,7 @@ apply_requires_private(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigne
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkgconf_dependency_t *dep = iter->data; pkgconf_dependency_t *dep = iter->data;
pkg = pkgconf_pkg_verify_dependency(dep, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE, NULL); pkg = pkgconf_pkg_verify_dependency(client, dep, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE, NULL);
print_requires_private(pkg); print_requires_private(pkg);
pkgconf_pkg_free(pkg); pkgconf_pkg_free(pkg);
@ -480,9 +485,10 @@ apply_requires_private(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigne
} }
static void static void
check_uninstalled(pkgconf_pkg_t *pkg, void *data, unsigned int flags) check_uninstalled(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
int *retval = data; int *retval = data;
(void) client;
(void) flags; (void) flags;
if (pkg->flags & PKGCONF_PKG_PROPF_UNINSTALLED) if (pkg->flags & PKGCONF_PKG_PROPF_UNINSTALLED)
@ -490,11 +496,11 @@ check_uninstalled(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
} }
static bool static bool
apply_uninstalled(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags) apply_uninstalled(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
eflag = pkgconf_pkg_traverse(world, check_uninstalled, data, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, world, check_uninstalled, data, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -503,10 +509,11 @@ apply_uninstalled(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int f
} }
static void static void
print_graph_node(pkgconf_pkg_t *pkg, void *data, unsigned int flags) print_graph_node(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_node_t *n; pkgconf_node_t *n;
(void) client;
(void) data; (void) data;
(void) flags; (void) flags;
@ -534,11 +541,11 @@ print_graph_node(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
} }
static bool static bool
apply_simulate(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags) apply_simulate(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
eflag = pkgconf_pkg_traverse(world, print_graph_node, data, maxdepth, flags); eflag = pkgconf_pkg_traverse(client, world, print_graph_node, data, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
return false; return false;
@ -690,6 +697,7 @@ main(int argc, char *argv[])
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
pkgconf_client_init(&pkg_client, error_handler);
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &filter_libdirs); pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &filter_libdirs);
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &filter_includedirs); pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &filter_includedirs);
@ -710,7 +718,7 @@ main(int argc, char *argv[])
maximum_traverse_depth = atoi(pkg_optarg); maximum_traverse_depth = atoi(pkg_optarg);
break; break;
case 27: case 27:
pkgconf_tuple_define_global(pkg_optarg); pkgconf_tuple_define_global(&pkg_client, pkg_optarg);
break; break;
case 28: case 28:
required_exact_module_version = pkg_optarg; required_exact_module_version = pkg_optarg;
@ -766,8 +774,6 @@ main(int argc, char *argv[])
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
pkgconf_set_error_handler(error_handler);
error_msgout = stderr; error_msgout = stderr;
if ((want_flags & PKG_ERRORS_ON_STDOUT) == PKG_ERRORS_ON_STDOUT) if ((want_flags & PKG_ERRORS_ON_STDOUT) == PKG_ERRORS_ON_STDOUT)
error_msgout = stdout; error_msgout = stdout;
@ -806,17 +812,17 @@ main(int argc, char *argv[])
want_flags |= PKG_KEEP_SYSTEM_LIBS; want_flags |= PKG_KEEP_SYSTEM_LIBS;
if ((builddir = getenv("PKG_CONFIG_TOP_BUILD_DIR")) != NULL) if ((builddir = getenv("PKG_CONFIG_TOP_BUILD_DIR")) != NULL)
pkgconf_tuple_add_global("pc_top_builddir", builddir); pkgconf_tuple_add_global(&pkg_client, "pc_top_builddir", builddir);
else else
pkgconf_tuple_add_global("pc_top_builddir", "$(top_builddir)"); pkgconf_tuple_add_global(&pkg_client, "pc_top_builddir", "$(top_builddir)");
if ((sysroot_dir = getenv("PKG_CONFIG_SYSROOT_DIR")) != NULL) if ((sysroot_dir = getenv("PKG_CONFIG_SYSROOT_DIR")) != NULL)
{ {
pkgconf_tuple_add_global("pc_sysrootdir", sysroot_dir); pkgconf_tuple_add_global(&pkg_client, "pc_sysrootdir", sysroot_dir);
global_traverse_flags |= PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX; global_traverse_flags |= PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX;
} }
else else
pkgconf_tuple_add_global("pc_sysrootdir", "/"); pkgconf_tuple_add_global(&pkg_client, "pc_sysrootdir", "/");
if (required_pkgconfig_version != NULL) if (required_pkgconfig_version != NULL)
{ {
@ -828,13 +834,13 @@ main(int argc, char *argv[])
if ((want_flags & PKG_LIST) == PKG_LIST) if ((want_flags & PKG_LIST) == PKG_LIST)
{ {
pkgconf_scan_all(NULL, print_list_entry); pkgconf_scan_all(&pkg_client, NULL, print_list_entry);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if ((want_flags & PKG_LIST_PACKAGE_NAMES) == PKG_LIST_PACKAGE_NAMES) if ((want_flags & PKG_LIST_PACKAGE_NAMES) == PKG_LIST_PACKAGE_NAMES)
{ {
pkgconf_scan_all(NULL, print_package_entry); pkgconf_scan_all(&pkg_client, NULL, print_package_entry);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -863,7 +869,7 @@ main(int argc, char *argv[])
{ {
pkgconf_dependency_t *pkgiter = node->data; pkgconf_dependency_t *pkgiter = node->data;
pkg = pkgconf_pkg_find(pkgiter->package, global_traverse_flags); pkg = pkgconf_pkg_find(&pkg_client, pkgiter->package, global_traverse_flags);
if (pkg == NULL) if (pkg == NULL)
return EXIT_FAILURE; return EXIT_FAILURE;
@ -890,7 +896,7 @@ main(int argc, char *argv[])
{ {
pkgconf_dependency_t *pkgiter = node->data; pkgconf_dependency_t *pkgiter = node->data;
pkg = pkgconf_pkg_find(pkgiter->package, global_traverse_flags); pkg = pkgconf_pkg_find(&pkg_client, pkgiter->package, global_traverse_flags);
if (pkg == NULL) if (pkg == NULL)
return EXIT_FAILURE; return EXIT_FAILURE;
@ -917,7 +923,7 @@ main(int argc, char *argv[])
{ {
pkgconf_dependency_t *pkgiter = node->data; pkgconf_dependency_t *pkgiter = node->data;
pkg = pkgconf_pkg_find(pkgiter->package, global_traverse_flags); pkg = pkgconf_pkg_find(&pkg_client, pkgiter->package, global_traverse_flags);
if (pkg == NULL) if (pkg == NULL)
return EXIT_FAILURE; return EXIT_FAILURE;
@ -972,14 +978,14 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_simulate, -1, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ERRORS, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_simulate, -1, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ERRORS, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
} }
} }
if (!pkgconf_queue_validate(&pkgq, maximum_traverse_depth, global_traverse_flags)) if (!pkgconf_queue_validate(&pkg_client, &pkgq, maximum_traverse_depth, global_traverse_flags))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -991,7 +997,7 @@ main(int argc, char *argv[])
if ((want_flags & PKG_UNINSTALLED) == PKG_UNINSTALLED) if ((want_flags & PKG_UNINSTALLED) == PKG_UNINSTALLED)
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
pkgconf_queue_apply(&pkgq, apply_uninstalled, maximum_traverse_depth, global_traverse_flags, &ret); pkgconf_queue_apply(&pkg_client, &pkgq, apply_uninstalled, maximum_traverse_depth, global_traverse_flags, &ret);
goto out; goto out;
} }
@ -999,7 +1005,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_provides, maximum_traverse_depth, global_traverse_flags, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_provides, maximum_traverse_depth, global_traverse_flags, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1010,7 +1016,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_digraph, maximum_traverse_depth, global_traverse_flags, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_digraph, maximum_traverse_depth, global_traverse_flags, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1021,7 +1027,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_modversion, 2, global_traverse_flags, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_modversion, 2, global_traverse_flags, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1032,7 +1038,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_variables, 2, global_traverse_flags, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_variables, 2, global_traverse_flags, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1043,7 +1049,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_variable, 2, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL, want_variable)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_variable, 2, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL, want_variable))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1054,7 +1060,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_requires, maximum_traverse_depth, global_traverse_flags, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_requires, maximum_traverse_depth, global_traverse_flags, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1065,7 +1071,7 @@ main(int argc, char *argv[])
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_requires_private, maximum_traverse_depth, global_traverse_flags, NULL)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_requires_private, maximum_traverse_depth, global_traverse_flags, NULL))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto out;
@ -1076,7 +1082,7 @@ main(int argc, char *argv[])
{ {
pkgconf_list_t frag_list = PKGCONF_LIST_INITIALIZER; pkgconf_list_t frag_list = PKGCONF_LIST_INITIALIZER;
if (!pkgconf_queue_apply(&pkgq, apply_cflags, maximum_traverse_depth, global_traverse_flags, &frag_list)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_cflags, maximum_traverse_depth, global_traverse_flags, &frag_list))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out_println; goto out_println;
@ -1087,7 +1093,7 @@ main(int argc, char *argv[])
{ {
pkgconf_list_t frag_list = PKGCONF_LIST_INITIALIZER; pkgconf_list_t frag_list = PKGCONF_LIST_INITIALIZER;
if (!pkgconf_queue_apply(&pkgq, apply_libs, maximum_traverse_depth, global_traverse_flags, &frag_list)) if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_libs, maximum_traverse_depth, global_traverse_flags, &frag_list))
{ {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out_println; goto out_println;
@ -1101,7 +1107,7 @@ out_println:
printf(" \n"); printf(" \n");
out: out:
pkgconf_tuple_free_global(); pkgconf_client_deinit(&pkg_client);
pkgconf_cache_free(); pkgconf_cache_free();
if (logfile_out != NULL) if (logfile_out != NULL)