libpkgconf: move pkg_dependency to pkgconf_dependency namespace
parent
cc2dcc1f5d
commit
1ee18d0e69
|
@ -16,7 +16,7 @@
|
|||
#include <libpkgconf/libpkgconf.h>
|
||||
|
||||
/*
|
||||
* pkg_dependency_parse(pkg, depends)
|
||||
* pkgconf_dependency_parse(pkg, depends)
|
||||
*
|
||||
* Add requirements to a .pc file.
|
||||
* Commas are counted as whitespace, as to allow:
|
||||
|
@ -35,12 +35,12 @@ typedef enum {
|
|||
|
||||
#define DEBUG_PARSE 0
|
||||
|
||||
static inline pkg_dependency_t *
|
||||
pkg_dependency_add(pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkg_comparator_t compare)
|
||||
static inline pkgconf_dependency_t *
|
||||
pkgconf_dependency_add(pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkg_comparator_t compare)
|
||||
{
|
||||
pkg_dependency_t *dep;
|
||||
pkgconf_dependency_t *dep;
|
||||
|
||||
dep = calloc(sizeof(pkg_dependency_t), 1);
|
||||
dep = calloc(sizeof(pkgconf_dependency_t), 1);
|
||||
dep->package = strndup(package, package_sz);
|
||||
|
||||
if (version_sz != 0)
|
||||
|
@ -58,19 +58,19 @@ pkg_dependency_add(pkgconf_list_t *list, const char *package, size_t package_sz,
|
|||
}
|
||||
|
||||
void
|
||||
pkg_dependency_append(pkgconf_list_t *list, pkg_dependency_t *tail)
|
||||
pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail)
|
||||
{
|
||||
pkgconf_node_insert_tail(&tail->iter, tail, list);
|
||||
}
|
||||
|
||||
void
|
||||
pkg_dependency_free(pkgconf_list_t *list)
|
||||
pkgconf_dependency_free(pkgconf_list_t *list)
|
||||
{
|
||||
pkgconf_node_t *node, *next;
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node)
|
||||
{
|
||||
pkg_dependency_t *dep = node->data;
|
||||
pkgconf_dependency_t *dep = node->data;
|
||||
|
||||
if (dep->package != NULL)
|
||||
free(dep->package);
|
||||
|
@ -83,7 +83,7 @@ pkg_dependency_free(pkgconf_list_t *list)
|
|||
}
|
||||
|
||||
void
|
||||
pkg_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
|
||||
pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
|
||||
{
|
||||
parse_state_t state = OUTSIDE_MODULE;
|
||||
pkg_comparator_t compare = PKG_ANY;
|
||||
|
@ -153,7 +153,7 @@ pkg_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
|
|||
|
||||
if (state == OUTSIDE_MODULE)
|
||||
{
|
||||
pkg_dependency_add(deplist_head, package, package_sz, NULL, 0, compare);
|
||||
pkgconf_dependency_add(deplist_head, package, package_sz, NULL, 0, compare);
|
||||
|
||||
compare = PKG_ANY;
|
||||
package_sz = 0;
|
||||
|
@ -204,7 +204,7 @@ pkg_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
|
|||
#if DEBUG_PARSE
|
||||
fprintf(error_msgout, "Found version: %s\n", version);
|
||||
#endif
|
||||
pkg_dependency_add(deplist_head, package, package_sz, version, version_sz, compare);
|
||||
pkgconf_dependency_add(deplist_head, package, package_sz, version, version_sz, compare);
|
||||
|
||||
compare = PKG_ANY;
|
||||
cnameptr = cmpname;
|
||||
|
@ -223,10 +223,10 @@ pkg_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
|
|||
}
|
||||
|
||||
void
|
||||
pkg_dependency_parse(pkg_t *pkg, pkgconf_list_t *deplist, const char *depends)
|
||||
pkgconf_dependency_parse(pkg_t *pkg, pkgconf_list_t *deplist, const char *depends)
|
||||
{
|
||||
char *kvdepends = pkg_tuple_parse(&pkg->vars, depends);
|
||||
|
||||
pkg_dependency_parse_str(deplist, kvdepends);
|
||||
pkgconf_dependency_parse_str(deplist, kvdepends);
|
||||
free(kvdepends);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef enum {
|
|||
} pkg_comparator_t;
|
||||
|
||||
typedef struct pkg_ pkg_t;
|
||||
typedef struct pkg_dependency_ pkg_dependency_t;
|
||||
typedef struct pkgconf_dependency_ pkgconf_dependency_t;
|
||||
typedef struct pkg_tuple_ pkg_tuple_t;
|
||||
typedef struct pkg_fragment_ pkg_fragment_t;
|
||||
|
||||
|
@ -59,7 +59,7 @@ struct pkg_fragment_ {
|
|||
char *data;
|
||||
};
|
||||
|
||||
struct pkg_dependency_ {
|
||||
struct pkgconf_dependency_ {
|
||||
pkgconf_node_t iter;
|
||||
|
||||
char *package;
|
||||
|
@ -141,18 +141,18 @@ void pkg_scan_all(pkg_iteration_func_t func);
|
|||
unsigned int pkg_traverse(pkg_t *root, pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
|
||||
unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);
|
||||
int pkg_compare_version(const char *a, const char *b);
|
||||
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
|
||||
const char *pkg_get_comparator(pkg_dependency_t *pkgdep);
|
||||
pkg_t *pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
|
||||
const char *pkg_get_comparator(pkgconf_dependency_t *pkgdep);
|
||||
int pkg_cflags(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
|
||||
int pkg_libs(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
|
||||
pkg_comparator_t pkg_comparator_lookup_by_name(const char *name);
|
||||
|
||||
/* parse.c */
|
||||
pkg_t *pkg_new_from_file(const char *path, FILE *f, unsigned int flags);
|
||||
void pkg_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends);
|
||||
void pkg_dependency_parse(pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
|
||||
void pkg_dependency_append(pkgconf_list_t *list, pkg_dependency_t *tail);
|
||||
void pkg_dependency_free(pkgconf_list_t *list);
|
||||
void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends);
|
||||
void pkgconf_dependency_parse(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_free(pkgconf_list_t *list);
|
||||
|
||||
/* argvsplit.c */
|
||||
int pkg_argv_split(const char *src, int *argc, char ***argv);
|
||||
|
|
|
@ -257,11 +257,11 @@ pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
|
|||
else if (!strcasecmp(key, "LIBS.private"))
|
||||
pkg_fragment_parse(&pkg->libs_private, &pkg->vars, value, flags);
|
||||
else if (!strcmp(key, "Requires"))
|
||||
pkg_dependency_parse(pkg, &pkg->requires, value);
|
||||
pkgconf_dependency_parse(pkg, &pkg->requires, value);
|
||||
else if (!strcmp(key, "Requires.private"))
|
||||
pkg_dependency_parse(pkg, &pkg->requires_private, value);
|
||||
pkgconf_dependency_parse(pkg, &pkg->requires_private, value);
|
||||
else if (!strcmp(key, "Conflicts"))
|
||||
pkg_dependency_parse(pkg, &pkg->conflicts, value);
|
||||
pkgconf_dependency_parse(pkg, &pkg->conflicts, value);
|
||||
break;
|
||||
case '=':
|
||||
pkg_tuple_add(&pkg->vars, key, value);
|
||||
|
@ -283,9 +283,9 @@ pkg_free(pkg_t *pkg)
|
|||
|
||||
pkg_cache_remove(pkg);
|
||||
|
||||
pkg_dependency_free(&pkg->requires);
|
||||
pkg_dependency_free(&pkg->requires_private);
|
||||
pkg_dependency_free(&pkg->conflicts);
|
||||
pkgconf_dependency_free(&pkg->requires);
|
||||
pkgconf_dependency_free(&pkg->requires_private);
|
||||
pkgconf_dependency_free(&pkg->conflicts);
|
||||
|
||||
pkg_fragment_free(&pkg->cflags);
|
||||
pkg_fragment_free(&pkg->cflags_private);
|
||||
|
@ -645,7 +645,7 @@ static pkg_t pkg_config_virtual = {
|
|||
},
|
||||
};
|
||||
|
||||
typedef bool (*pkg_vercmp_res_func_t)(pkg_t *pkg, pkg_dependency_t *pkgdep);
|
||||
typedef bool (*pkg_vercmp_res_func_t)(pkg_t *pkg, pkgconf_dependency_t *pkgdep);
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
@ -663,37 +663,37 @@ static pkg_comparator_name_t pkg_comparator_names[PKG_CMP_SIZE + 1] = {
|
|||
{"???", PKG_CMP_SIZE},
|
||||
};
|
||||
|
||||
static bool pkg_comparator_lt(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_lt(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
return (pkg_compare_version(pkg->version, pkgdep->version) < 0);
|
||||
}
|
||||
|
||||
static bool pkg_comparator_gt(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_gt(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
return (pkg_compare_version(pkg->version, pkgdep->version) > 0);
|
||||
}
|
||||
|
||||
static bool pkg_comparator_lte(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_lte(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
return (pkg_compare_version(pkg->version, pkgdep->version) <= 0);
|
||||
}
|
||||
|
||||
static bool pkg_comparator_gte(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_gte(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
return (pkg_compare_version(pkg->version, pkgdep->version) >= 0);
|
||||
}
|
||||
|
||||
static bool pkg_comparator_eq(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_eq(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
return (pkg_compare_version(pkg->version, pkgdep->version) == 0);
|
||||
}
|
||||
|
||||
static bool pkg_comparator_ne(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_ne(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
return (pkg_compare_version(pkg->version, pkgdep->version) != 0);
|
||||
}
|
||||
|
||||
static bool pkg_comparator_any(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_any(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
(void) pkg;
|
||||
(void) pkgdep;
|
||||
|
@ -701,7 +701,7 @@ static bool pkg_comparator_any(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool pkg_comparator_unimplemented(pkg_t *pkg, pkg_dependency_t *pkgdep)
|
||||
static bool pkg_comparator_unimplemented(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
(void) pkg;
|
||||
(void) pkgdep;
|
||||
|
@ -726,7 +726,7 @@ static pkg_vercmp_res_func_t pkg_comparator_impls[PKG_CMP_SIZE + 1] = {
|
|||
* returns the comparator used in a depgraph dependency node as a string.
|
||||
*/
|
||||
const char *
|
||||
pkg_get_comparator(pkg_dependency_t *pkgdep)
|
||||
pkg_get_comparator(pkgconf_dependency_t *pkgdep)
|
||||
{
|
||||
const pkg_comparator_name_t *i;
|
||||
|
||||
|
@ -765,11 +765,11 @@ pkg_comparator_lookup_by_name(const char *name)
|
|||
/*
|
||||
* pkg_verify_dependency(pkgdep, flags)
|
||||
*
|
||||
* verify a pkg_dependency_t node in the depgraph. if the dependency is solvable,
|
||||
* verify a pkgconf_dependency_t node in the depgraph. if the dependency is solvable,
|
||||
* return the appropriate pkg_t object, else NULL.
|
||||
*/
|
||||
pkg_t *
|
||||
pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags)
|
||||
pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags)
|
||||
{
|
||||
pkg_t *pkg = &pkg_config_virtual;
|
||||
|
||||
|
@ -814,7 +814,7 @@ pkg_verify_graph(pkg_t *root, int depth, unsigned int flags)
|
|||
}
|
||||
|
||||
static unsigned int
|
||||
pkg_report_graph_error(pkg_t *parent, pkg_t *pkg, pkg_dependency_t *node, unsigned int eflags)
|
||||
pkg_report_graph_error(pkg_t *parent, pkg_t *pkg, pkgconf_dependency_t *node, unsigned int eflags)
|
||||
{
|
||||
static bool already_sent_notice = false;
|
||||
|
||||
|
@ -860,7 +860,7 @@ pkg_walk_list(pkg_t *parent,
|
|||
PKGCONF_FOREACH_LIST_ENTRY(deplist->head, node)
|
||||
{
|
||||
unsigned int eflags_local = PKG_ERRF_OK;
|
||||
pkg_dependency_t *depnode = node->data;
|
||||
pkgconf_dependency_t *depnode = node->data;
|
||||
pkg_t *pkgdep;
|
||||
|
||||
if (*depnode->package == '\0')
|
||||
|
@ -900,7 +900,7 @@ pkg_walk_conflicts_list(pkg_t *root, pkgconf_list_t *deplist, unsigned int flags
|
|||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(deplist->head, node)
|
||||
{
|
||||
pkg_dependency_t *parentnode = node->data;
|
||||
pkgconf_dependency_t *parentnode = node->data;
|
||||
|
||||
if (*parentnode->package == '\0')
|
||||
continue;
|
||||
|
@ -908,7 +908,7 @@ pkg_walk_conflicts_list(pkg_t *root, pkgconf_list_t *deplist, unsigned int flags
|
|||
PKGCONF_FOREACH_LIST_ENTRY(root->requires.head, childnode)
|
||||
{
|
||||
pkg_t *pkgdep;
|
||||
pkg_dependency_t *depnode = childnode->data;
|
||||
pkgconf_dependency_t *depnode = childnode->data;
|
||||
|
||||
if (*depnode->package == '\0' || strcmp(depnode->package, parentnode->package))
|
||||
continue;
|
||||
|
|
|
@ -39,7 +39,7 @@ pkg_queue_compile(pkg_t *world, pkgconf_list_t *list)
|
|||
pkg_queue_t *pkgq;
|
||||
|
||||
pkgq = iter->data;
|
||||
pkg_dependency_parse(world, &world->requires, pkgq->package);
|
||||
pkgconf_dependency_parse(world, &world->requires, pkgq->package);
|
||||
}
|
||||
|
||||
return (world->requires.head != NULL);
|
||||
|
|
24
main.c
24
main.c
|
@ -202,7 +202,7 @@ print_requires(pkg_t *pkg)
|
|||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->requires.head, node)
|
||||
{
|
||||
pkg_dependency_t *dep = node->data;
|
||||
pkgconf_dependency_t *dep = node->data;
|
||||
|
||||
printf("%s", dep->package);
|
||||
|
||||
|
@ -220,7 +220,7 @@ print_requires_private(pkg_t *pkg)
|
|||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->requires_private.head, node)
|
||||
{
|
||||
pkg_dependency_t *dep = node->data;
|
||||
pkgconf_dependency_t *dep = node->data;
|
||||
|
||||
printf("%s", dep->package);
|
||||
|
||||
|
@ -242,7 +242,7 @@ print_digraph_node(pkg_t *pkg, void *unused, unsigned int flags)
|
|||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->requires.head, node)
|
||||
{
|
||||
pkg_dependency_t *dep = node->data;
|
||||
pkgconf_dependency_t *dep = node->data;
|
||||
|
||||
printf("\"%s\" -- \"%s\" [fontname=Sans fontsize=8]\n", dep->package, pkg->id);
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ apply_requires(pkg_t *world, void *unused, int maxdepth, unsigned int flags)
|
|||
PKGCONF_FOREACH_LIST_ENTRY(world->requires.head, iter)
|
||||
{
|
||||
pkg_t *pkg;
|
||||
pkg_dependency_t *dep = iter->data;
|
||||
pkgconf_dependency_t *dep = iter->data;
|
||||
|
||||
pkg = pkg_verify_dependency(dep, flags, NULL);
|
||||
print_requires(pkg);
|
||||
|
@ -419,7 +419,7 @@ apply_requires_private(pkg_t *world, void *unused, int maxdepth, unsigned int fl
|
|||
PKGCONF_FOREACH_LIST_ENTRY(world->requires.head, iter)
|
||||
{
|
||||
pkg_t *pkg;
|
||||
pkg_dependency_t *dep = iter->data;
|
||||
pkgconf_dependency_t *dep = iter->data;
|
||||
|
||||
pkg = pkg_verify_dependency(dep, flags | PKGF_SEARCH_PRIVATE, NULL);
|
||||
print_requires_private(pkg);
|
||||
|
@ -467,7 +467,7 @@ print_graph_node(pkg_t *pkg, void *data, unsigned int flags)
|
|||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->requires.head, n)
|
||||
{
|
||||
pkg_dependency_t *dep = n->data;
|
||||
pkgconf_dependency_t *dep = n->data;
|
||||
printf(" dependency '%s'", dep->package);
|
||||
if (dep->compare != PKG_ANY)
|
||||
{
|
||||
|
@ -759,13 +759,13 @@ main(int argc, char *argv[])
|
|||
|
||||
while (argv[pkg_optind])
|
||||
{
|
||||
pkg_dependency_parse_str(&deplist, argv[pkg_optind]);
|
||||
pkgconf_dependency_parse_str(&deplist, argv[pkg_optind]);
|
||||
pkg_optind++;
|
||||
}
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(deplist.head, node)
|
||||
{
|
||||
pkg_dependency_t *pkgiter = node->data;
|
||||
pkgconf_dependency_t *pkgiter = node->data;
|
||||
|
||||
pkg = pkg_find(pkgiter->package, global_traverse_flags);
|
||||
if (pkg == NULL)
|
||||
|
@ -786,13 +786,13 @@ main(int argc, char *argv[])
|
|||
|
||||
while (argv[pkg_optind])
|
||||
{
|
||||
pkg_dependency_parse_str(&deplist, argv[pkg_optind]);
|
||||
pkgconf_dependency_parse_str(&deplist, argv[pkg_optind]);
|
||||
pkg_optind++;
|
||||
}
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(deplist.head, node)
|
||||
{
|
||||
pkg_dependency_t *pkgiter = node->data;
|
||||
pkgconf_dependency_t *pkgiter = node->data;
|
||||
|
||||
pkg = pkg_find(pkgiter->package, global_traverse_flags);
|
||||
if (pkg == NULL)
|
||||
|
@ -813,13 +813,13 @@ main(int argc, char *argv[])
|
|||
|
||||
while (argv[pkg_optind])
|
||||
{
|
||||
pkg_dependency_parse_str(&deplist, argv[pkg_optind]);
|
||||
pkgconf_dependency_parse_str(&deplist, argv[pkg_optind]);
|
||||
pkg_optind++;
|
||||
}
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(deplist.head, node)
|
||||
{
|
||||
pkg_dependency_t *pkgiter = node->data;
|
||||
pkgconf_dependency_t *pkgiter = node->data;
|
||||
|
||||
pkg = pkg_find(pkgiter->package, global_traverse_flags);
|
||||
if (pkg == NULL)
|
||||
|
|
Loading…
Reference in New Issue