libpkgconf: clean up PKG_ERRF and PKGF_ defines

feature/tap-sh
William Pitcock 2015-09-06 11:45:00 -05:00
parent 50cf8db086
commit 06a45f1b62
5 changed files with 70 additions and 70 deletions

View File

@ -21,7 +21,7 @@ pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
char mungebuf[PKGCONF_BUFSIZE];
char *sysroot_dir;
if (!(flags & PKGF_MUNGE_SYSROOT_PREFIX))
if (!(flags & PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX))
return strdup(source);
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir");

View File

@ -107,23 +107,23 @@ struct pkgconf_pkg_ {
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))
#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
#define PKGF_NONE 0x000
#define PKGF_SEARCH_PRIVATE 0x001
#define PKGF_ENV_ONLY 0x002
#define PKGF_NO_UNINSTALLED 0x004
#define PKGF_SKIP_ROOT_VIRTUAL 0x008
#define PKGF_MERGE_PRIVATE_FRAGMENTS 0x010
#define PKGF_SKIP_CONFLICTS 0x020
#define PKGF_NO_CACHE 0x040
#define PKGF_MUNGE_SYSROOT_PREFIX 0x080
#define PKGF_SKIP_ERRORS 0x100
#define PKGF_ITER_PKG_IS_PRIVATE 0x200
#define PKGCONF_PKG_PKGF_NONE 0x000
#define PKGCONF_PKG_PKGF_SEARCH_PRIVATE 0x001
#define PKGCONF_PKG_PKGF_ENV_ONLY 0x002
#define PKGCONF_PKG_PKGF_NO_UNINSTALLED 0x004
#define PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL 0x008
#define PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS 0x010
#define PKGCONF_PKG_PKGF_SKIP_CONFLICTS 0x020
#define PKGCONF_PKG_PKGF_NO_CACHE 0x040
#define PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX 0x080
#define PKGCONF_PKG_PKGF_SKIP_ERRORS 0x100
#define PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE 0x200
#define PKG_ERRF_OK 0x0
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
#define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2
#define PKG_ERRF_PACKAGE_CONFLICT 0x4
#define PKG_ERRF_DEPGRAPH_BREAK 0x8
#define PKGCONF_PKG_ERRF_OK 0x0
#define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1
#define PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH 0x2
#define PKGCONF_PKG_ERRF_PACKAGE_CONFLICT 0x4
#define PKGCONF_PKG_ERRF_DEPGRAPH_BREAK 0x8
typedef void (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg);
typedef void (*pkgconf_pkg_traverse_func_t)(pkgconf_pkg_t *pkg, void *data, unsigned int flags);

View File

@ -158,7 +158,7 @@ pkgconf_pkg_dir_list_build(unsigned int flags)
if (env_path)
path_split(env_path, &pkg_dir_list);
if (!(flags & PKGF_ENV_ONLY))
if (!(flags & PKGCONF_PKG_PKGF_ENV_ONLY))
{
env_path = get_pkgconfig_path();
path_split(env_path, &pkg_dir_list);
@ -324,7 +324,7 @@ pkgconf_pkg_try_specific_path(const char *path, const char *name, unsigned int f
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path, name);
snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s/%s-uninstalled" PKG_CONFIG_EXT, path, name);
if (!(flags & 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->flags |= PKGCONF_PKG_PROPF_UNINSTALLED;
@ -452,7 +452,7 @@ pkgconf_pkg_find(const char *name, unsigned int flags)
}
/* check cache */
if (!(flags & PKGF_NO_CACHE))
if (!(flags & PKGCONF_PKG_PKGF_NO_CACHE))
{
if ((pkg = pkgconf_cache_lookup(name)) != NULL)
{
@ -754,7 +754,7 @@ pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags,
pkgconf_pkg_t *pkg = &pkg_config_virtual;
if (eflags != NULL)
*eflags = PKG_ERRF_OK;
*eflags = PKGCONF_PKG_ERRF_OK;
/* pkg-config package name is special cased. */
if (strcasecmp(pkgdep->package, "pkg-config"))
@ -763,7 +763,7 @@ pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags,
if (pkg == NULL)
{
if (eflags != NULL)
*eflags |= PKG_ERRF_PACKAGE_NOT_FOUND;
*eflags |= PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND;
return NULL;
}
@ -776,7 +776,7 @@ pkgconf_pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags,
return pkg;
if (eflags != NULL)
*eflags |= PKG_ERRF_PACKAGE_VER_MISMATCH;
*eflags |= PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH;
return pkg;
}
@ -798,7 +798,7 @@ pkgconf_pkg_report_graph_error(pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgcon
{
static bool already_sent_notice = false;
if (eflags & PKG_ERRF_PACKAGE_NOT_FOUND)
if (eflags & PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND)
{
if (!already_sent_notice)
{
@ -810,7 +810,7 @@ pkgconf_pkg_report_graph_error(pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgcon
fprintf(error_msgout, "Package '%s', required by '%s', not found\n", node->package, parent->id);
}
else if (eflags & PKG_ERRF_PACKAGE_VER_MISMATCH)
else if (eflags & PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH)
{
fprintf(error_msgout, "Package dependency requirement '%s %s %s' could not be satisfied.\n",
node->package, pkgconf_pkg_get_comparator(node), node->version);
@ -834,12 +834,12 @@ pkgconf_pkg_walk_list(pkgconf_pkg_t *parent,
int depth,
unsigned int flags)
{
unsigned int eflags = PKG_ERRF_OK;
unsigned int eflags = PKGCONF_PKG_ERRF_OK;
pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(deplist->head, node)
{
unsigned int eflags_local = PKG_ERRF_OK;
unsigned int eflags_local = PKGCONF_PKG_ERRF_OK;
pkgconf_dependency_t *depnode = node->data;
pkgconf_pkg_t *pkgdep;
@ -849,7 +849,7 @@ pkgconf_pkg_walk_list(pkgconf_pkg_t *parent,
pkgdep = pkgconf_pkg_verify_dependency(depnode, flags, &eflags_local);
eflags |= eflags_local;
if (eflags_local != PKG_ERRF_OK && !(flags & PKGF_SKIP_ERRORS))
if (eflags_local != PKGCONF_PKG_ERRF_OK && !(flags & PKGCONF_PKG_PKGF_SKIP_ERRORS))
{
pkgconf_pkg_report_graph_error(parent, pkgdep, depnode, eflags_local);
continue;
@ -894,7 +894,7 @@ pkgconf_pkg_walk_conflicts_list(pkgconf_pkg_t *root, pkgconf_list_t *deplist, un
continue;
pkgdep = pkgconf_pkg_verify_dependency(parentnode, flags, &eflags);
if (eflags == PKG_ERRF_OK)
if (eflags == PKGCONF_PKG_ERRF_OK)
{
fprintf(error_msgout, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n",
pkgdep->version, pkgdep->realname, root->realname, parentnode->package, pkgconf_pkg_get_comparator(parentnode),
@ -904,14 +904,14 @@ pkgconf_pkg_walk_conflicts_list(pkgconf_pkg_t *root, pkgconf_list_t *deplist, un
pkgconf_pkg_unref(pkgdep);
return PKG_ERRF_PACKAGE_CONFLICT;
return PKGCONF_PKG_ERRF_PACKAGE_CONFLICT;
}
pkgconf_pkg_unref(pkgdep);
}
}
return PKG_ERRF_OK;
return PKGCONF_PKG_ERRF_OK;
}
/*
@ -926,33 +926,33 @@ pkgconf_pkg_traverse(pkgconf_pkg_t *root,
int maxdepth,
unsigned int flags)
{
unsigned int rflags = flags & ~PKGF_SKIP_ROOT_VIRTUAL;
unsigned int eflags = PKG_ERRF_OK;
unsigned int rflags = flags & ~PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL;
unsigned int eflags = PKGCONF_PKG_ERRF_OK;
if (maxdepth == 0)
return eflags;
if ((root->flags & PKGCONF_PKG_PROPF_VIRTUAL) != PKGCONF_PKG_PROPF_VIRTUAL || (flags & PKGF_SKIP_ROOT_VIRTUAL) != 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)
func(root, data, flags);
}
if (!(flags & PKGF_SKIP_CONFLICTS))
if (!(flags & PKGCONF_PKG_PKGF_SKIP_CONFLICTS))
{
eflags = pkgconf_pkg_walk_conflicts_list(root, &root->conflicts, rflags);
if (eflags != PKG_ERRF_OK)
if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags;
}
eflags = pkgconf_pkg_walk_list(root, &root->requires, func, data, maxdepth, rflags);
if (eflags != PKG_ERRF_OK)
if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags;
if (flags & PKGF_SEARCH_PRIVATE)
if (flags & PKGCONF_PKG_PKGF_SEARCH_PRIVATE)
{
eflags = pkgconf_pkg_walk_list(root, &root->requires_private, func, data, maxdepth, rflags | PKGF_ITER_PKG_IS_PRIVATE);
if (eflags != PKG_ERRF_OK)
eflags = pkgconf_pkg_walk_list(root, &root->requires_private, func, data, maxdepth, rflags | PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE);
if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags;
}
@ -994,13 +994,13 @@ pkgconf_pkg_cflags(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsi
int eflag;
eflag = pkgconf_pkg_traverse(root, pkgconf_pkg_cflags_collect, list, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
pkgconf_fragment_free(list);
if (flags & 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);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
pkgconf_fragment_free(list);
}
@ -1017,10 +1017,10 @@ pkgconf_pkg_libs_collect(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node)
{
pkgconf_fragment_t *frag = node->data;
pkgconf_fragment_copy(list, frag, flags, (flags & PKGF_ITER_PKG_IS_PRIVATE) != 0);
pkgconf_fragment_copy(list, frag, flags, (flags & PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE) != 0);
}
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
if (flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS)
{
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs_private.head, node)
{
@ -1037,7 +1037,7 @@ pkgconf_pkg_libs(pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsign
eflag = pkgconf_pkg_traverse(root, pkgconf_pkg_libs_collect, list, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
{
pkgconf_fragment_free(list);
return eflag;

View File

@ -63,7 +63,7 @@ static inline unsigned int
pkgconf_queue_verify(pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{
if (!pkgconf_queue_compile(world, list))
return PKG_ERRF_DEPGRAPH_BREAK;
return PKGCONF_PKG_ERRF_DEPGRAPH_BREAK;
return pkgconf_pkg_verify_graph(world, maxdepth, flags);
}
@ -81,7 +81,7 @@ pkgconf_queue_apply(pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int m
if (!maxdepth)
maxdepth = -1;
if (pkgconf_queue_verify(&world, list, maxdepth, flags) != PKG_ERRF_OK)
if (pkgconf_queue_verify(&world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK)
return false;
if (!func(&world, data, maxdepth, flags))
@ -109,7 +109,7 @@ pkgconf_queue_validate(pkgconf_list_t *list, int maxdepth, unsigned int flags)
if (!maxdepth)
maxdepth = -1;
if (pkgconf_queue_verify(&world, list, maxdepth, flags) != PKG_ERRF_OK)
if (pkgconf_queue_verify(&world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK)
retval = false;
pkgconf_pkg_free(&world);

42
main.c
View File

@ -48,7 +48,7 @@
#define PKG_VALIDATE (uint64_t)(1<<30)
#define PKG_LIST_PACKAGE_NAMES (uint64_t)(1<<31)
static unsigned int global_traverse_flags = PKGF_NONE;
static unsigned int global_traverse_flags = PKGCONF_PKG_PKGF_NONE;
static uint64_t want_flags;
static int maximum_traverse_depth = 2000;
@ -259,7 +259,7 @@ apply_digraph(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int fla
eflag = pkgconf_pkg_traverse(world, print_digraph_node, unused, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
printf("}\n");
@ -273,7 +273,7 @@ apply_modversion(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int
eflag = pkgconf_pkg_traverse(world, print_modversion, unused, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
return true;
@ -286,7 +286,7 @@ apply_variables(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int f
eflag = pkgconf_pkg_traverse(world, print_variables, unused, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
return true;
@ -311,7 +311,7 @@ print_variable(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{
memset(req->buf, 0, sizeof(req->buf));
if (*var == '/' && (flags & PKGF_MUNGE_SYSROOT_PREFIX) &&
if (*var == '/' && (flags & PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX) &&
(sysroot_dir != NULL && strncmp(var, sysroot_dir, strlen(sysroot_dir))))
strlcat(req->buf, sysroot_dir, sizeof(req->buf));
@ -321,7 +321,7 @@ print_variable(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
strlcat(req->buf, " ", sizeof(req->buf));
if (*var == '/' && (flags & PKGF_MUNGE_SYSROOT_PREFIX) &&
if (*var == '/' && (flags & PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX) &&
(sysroot_dir != NULL && strncmp(var, sysroot_dir, strlen(sysroot_dir))))
strlcat(req->buf, sysroot_dir, sizeof(req->buf));
@ -341,7 +341,7 @@ apply_variable(pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int
*req.buf = '\0';
eflag = pkgconf_pkg_traverse(world, print_variable, &req, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
printf("%s\n", req.buf);
@ -354,8 +354,8 @@ apply_cflags(pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int f
pkgconf_list_t *list = list_head;
int eflag;
eflag = pkgconf_pkg_cflags(world, list, maxdepth, flags | PKGF_SEARCH_PRIVATE);
if (eflag != PKG_ERRF_OK)
eflag = pkgconf_pkg_cflags(world, list, maxdepth, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE);
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
if (list->head == NULL)
@ -375,7 +375,7 @@ apply_libs(pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int fla
int eflag;
eflag = pkgconf_pkg_libs(world, list, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
if (list->head == NULL)
@ -421,7 +421,7 @@ apply_requires_private(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigne
pkgconf_pkg_t *pkg;
pkgconf_dependency_t *dep = iter->data;
pkg = pkgconf_pkg_verify_dependency(dep, flags | PKGF_SEARCH_PRIVATE, NULL);
pkg = pkgconf_pkg_verify_dependency(dep, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE, NULL);
print_requires_private(pkg);
pkgconf_pkg_free(pkg);
@ -446,7 +446,7 @@ apply_uninstalled(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int f
eflag = pkgconf_pkg_traverse(world, check_uninstalled, data, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
return true;
@ -490,7 +490,7 @@ apply_simulate(pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flag
eflag = pkgconf_pkg_traverse(world, print_graph_node, data, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
return true;
@ -698,19 +698,19 @@ main(int argc, char *argv[])
error_msgout = fopen(PATH_DEV_NULL, "w");
if ((want_flags & PKG_IGNORE_CONFLICTS) == PKG_IGNORE_CONFLICTS || getenv("PKG_CONFIG_IGNORE_CONFLICTS") != NULL)
global_traverse_flags |= PKGF_SKIP_CONFLICTS;
global_traverse_flags |= PKGCONF_PKG_PKGF_SKIP_CONFLICTS;
if ((want_flags & PKG_STATIC) == PKG_STATIC)
global_traverse_flags |= (PKGF_SEARCH_PRIVATE | PKGF_MERGE_PRIVATE_FRAGMENTS);
global_traverse_flags |= (PKGCONF_PKG_PKGF_SEARCH_PRIVATE | PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS);
if ((want_flags & PKG_ENV_ONLY) == PKG_ENV_ONLY)
global_traverse_flags |= PKGF_ENV_ONLY;
global_traverse_flags |= PKGCONF_PKG_PKGF_ENV_ONLY;
if ((want_flags & PKG_NO_CACHE) == PKG_NO_CACHE)
global_traverse_flags |= PKGF_NO_CACHE;
global_traverse_flags |= PKGCONF_PKG_PKGF_NO_CACHE;
if ((want_flags & PKG_NO_UNINSTALLED) == PKG_NO_UNINSTALLED || getenv("PKG_CONFIG_DISABLE_UNINSTALLED") != NULL)
global_traverse_flags |= PKGF_NO_UNINSTALLED;
global_traverse_flags |= PKGCONF_PKG_PKGF_NO_UNINSTALLED;
if (getenv("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS") != NULL)
want_flags |= PKG_KEEP_SYSTEM_CFLAGS;
@ -726,7 +726,7 @@ main(int argc, char *argv[])
if ((sysroot_dir = getenv("PKG_CONFIG_SYSROOT_DIR")) != NULL)
{
pkgconf_tuple_add_global("pc_sysrootdir", sysroot_dir);
global_traverse_flags |= PKGF_MUNGE_SYSROOT_PREFIX;
global_traverse_flags |= PKGCONF_PKG_PKGF_MUNGE_SYSROOT_PREFIX;
}
else
pkgconf_tuple_add_global("pc_sysrootdir", "/");
@ -876,7 +876,7 @@ main(int argc, char *argv[])
{
want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_simulate, -1, global_traverse_flags | PKGF_SKIP_ERRORS, NULL))
if (!pkgconf_queue_apply(&pkgq, apply_simulate, -1, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ERRORS, NULL))
{
ret = EXIT_FAILURE;
goto out;
@ -944,7 +944,7 @@ main(int argc, char *argv[])
{
want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkgq, apply_variable, 2, global_traverse_flags | PKGF_SKIP_ROOT_VIRTUAL, want_variable))
if (!pkgconf_queue_apply(&pkgq, apply_variable, 2, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL, want_variable))
{
ret = EXIT_FAILURE;
goto out;