libpkgconf: pkg_comparator_t becomes pkgconf_pkg_comparator_t (and so on)

pull/81/head
William Pitcock 2015-09-06 10:57:26 -05:00
parent 4410eb2c78
commit 66247fae5f
4 changed files with 45 additions and 45 deletions

View File

@ -36,7 +36,7 @@ typedef enum {
#define DEBUG_PARSE 0 #define DEBUG_PARSE 0
static inline pkgconf_dependency_t * 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) pkgconf_dependency_add(pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare)
{ {
pkgconf_dependency_t *dep; pkgconf_dependency_t *dep;
@ -86,7 +86,7 @@ void
pkgconf_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; parse_state_t state = OUTSIDE_MODULE;
pkg_comparator_t compare = PKG_ANY; pkgconf_pkg_comparator_t compare = PKG_ANY;
char cmpname[PKG_BUFSIZE]; char cmpname[PKG_BUFSIZE];
char buf[PKG_BUFSIZE]; char buf[PKG_BUFSIZE];
size_t package_sz = 0, version_sz = 0; size_t package_sz = 0, version_sz = 0;
@ -175,7 +175,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
if (!PKG_OPERATOR_CHAR(*ptr)) if (!PKG_OPERATOR_CHAR(*ptr))
{ {
state = AFTER_OPERATOR; state = AFTER_OPERATOR;
compare = pkg_comparator_lookup_by_name(cmpname); compare = pkgconf_pkg_comparator_lookup_by_name(cmpname);
} }
else else
*cnameptr++ = *ptr; *cnameptr++ = *ptr;

View File

@ -33,7 +33,7 @@ typedef enum {
PKG_NOT_EQUAL, PKG_NOT_EQUAL,
PKG_ALWAYS_MATCH, PKG_ALWAYS_MATCH,
PKG_CMP_SIZE PKG_CMP_SIZE
} pkg_comparator_t; } pkgconf_pkg_comparator_t;
typedef struct pkg_ pkg_t; typedef struct pkg_ pkg_t;
typedef struct pkgconf_dependency_ pkgconf_dependency_t; typedef struct pkgconf_dependency_ pkgconf_dependency_t;
@ -63,7 +63,7 @@ struct pkgconf_dependency_ {
pkgconf_node_t iter; pkgconf_node_t iter;
char *package; char *package;
pkg_comparator_t compare; pkgconf_pkg_comparator_t compare;
char *version; char *version;
pkg_t *parent; pkg_t *parent;
}; };
@ -142,10 +142,10 @@ unsigned int pkg_traverse(pkg_t *root, pkg_traverse_func_t func, void *data, int
unsigned int pkg_verify_graph(pkg_t *root, int depth, 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); int pkg_compare_version(const char *a, const char *b);
pkg_t *pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); pkg_t *pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkg_get_comparator(pkgconf_dependency_t *pkgdep); const char *pkgconf_pkg_get_comparator(pkgconf_dependency_t *pkgdep);
int pkg_cflags(pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags); 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); 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); pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name);
/* parse.c */ /* parse.c */
pkg_t *pkg_new_from_file(const char *path, FILE *f, unsigned int flags); pkg_t *pkg_new_from_file(const char *path, FILE *f, unsigned int flags);

View File

@ -645,14 +645,14 @@ static pkg_t pkg_config_virtual = {
}, },
}; };
typedef bool (*pkg_vercmp_res_func_t)(pkg_t *pkg, pkgconf_dependency_t *pkgdep); typedef bool (*pkgconf_vercmp_res_func_t)(pkg_t *pkg, pkgconf_dependency_t *pkgdep);
typedef struct { typedef struct {
const char *name; const char *name;
pkg_comparator_t compare; pkgconf_pkg_comparator_t compare;
} pkg_comparator_name_t; } pkgconf_pkg_comparator_name_t;
static pkg_comparator_name_t pkg_comparator_names[PKG_CMP_SIZE + 1] = { static pkgconf_pkg_comparator_name_t pkgconf_pkg_comparator_names[PKG_CMP_SIZE + 1] = {
{"<", PKG_LESS_THAN}, {"<", PKG_LESS_THAN},
{">", PKG_GREATER_THAN}, {">", PKG_GREATER_THAN},
{"<=", PKG_LESS_THAN_EQUAL}, {"<=", PKG_LESS_THAN_EQUAL},
@ -663,37 +663,37 @@ static pkg_comparator_name_t pkg_comparator_names[PKG_CMP_SIZE + 1] = {
{"???", PKG_CMP_SIZE}, {"???", PKG_CMP_SIZE},
}; };
static bool pkg_comparator_lt(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_lt(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
return (pkg_compare_version(pkg->version, pkgdep->version) < 0); return (pkg_compare_version(pkg->version, pkgdep->version) < 0);
} }
static bool pkg_comparator_gt(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_gt(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
return (pkg_compare_version(pkg->version, pkgdep->version) > 0); return (pkg_compare_version(pkg->version, pkgdep->version) > 0);
} }
static bool pkg_comparator_lte(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_lte(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
return (pkg_compare_version(pkg->version, pkgdep->version) <= 0); return (pkg_compare_version(pkg->version, pkgdep->version) <= 0);
} }
static bool pkg_comparator_gte(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_gte(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
return (pkg_compare_version(pkg->version, pkgdep->version) >= 0); return (pkg_compare_version(pkg->version, pkgdep->version) >= 0);
} }
static bool pkg_comparator_eq(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_eq(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
return (pkg_compare_version(pkg->version, pkgdep->version) == 0); return (pkg_compare_version(pkg->version, pkgdep->version) == 0);
} }
static bool pkg_comparator_ne(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_ne(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
return (pkg_compare_version(pkg->version, pkgdep->version) != 0); return (pkg_compare_version(pkg->version, pkgdep->version) != 0);
} }
static bool pkg_comparator_any(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_any(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
(void) pkg; (void) pkg;
(void) pkgdep; (void) pkgdep;
@ -701,7 +701,7 @@ static bool pkg_comparator_any(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
return true; return true;
} }
static bool pkg_comparator_unimplemented(pkg_t *pkg, pkgconf_dependency_t *pkgdep) static bool pkgconf_pkg_comparator_unimplemented(pkg_t *pkg, pkgconf_dependency_t *pkgdep)
{ {
(void) pkg; (void) pkg;
(void) pkgdep; (void) pkgdep;
@ -709,28 +709,28 @@ static bool pkg_comparator_unimplemented(pkg_t *pkg, pkgconf_dependency_t *pkgde
return false; return false;
} }
static pkg_vercmp_res_func_t pkg_comparator_impls[PKG_CMP_SIZE + 1] = { static pkgconf_vercmp_res_func_t pkgconf_pkg_comparator_impls[PKG_CMP_SIZE + 1] = {
[PKG_ANY] = pkg_comparator_any, [PKG_ANY] = pkgconf_pkg_comparator_any,
[PKG_LESS_THAN] = pkg_comparator_lt, [PKG_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKG_GREATER_THAN] = pkg_comparator_gt, [PKG_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKG_LESS_THAN_EQUAL] = pkg_comparator_lte, [PKG_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKG_GREATER_THAN_EQUAL] = pkg_comparator_gte, [PKG_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKG_EQUAL] = pkg_comparator_eq, [PKG_EQUAL] = pkgconf_pkg_comparator_eq,
[PKG_NOT_EQUAL] = pkg_comparator_ne, [PKG_NOT_EQUAL] = pkgconf_pkg_comparator_ne,
[PKG_CMP_SIZE] = pkg_comparator_unimplemented, [PKG_CMP_SIZE] = pkgconf_pkg_comparator_unimplemented,
}; };
/* /*
* pkg_get_comparator(pkgdep) * pkgconf_pkg_get_comparator(pkgdep)
* *
* returns the comparator used in a depgraph dependency node as a string. * returns the comparator used in a depgraph dependency node as a string.
*/ */
const char * const char *
pkg_get_comparator(pkgconf_dependency_t *pkgdep) pkgconf_pkg_get_comparator(pkgconf_dependency_t *pkgdep)
{ {
const pkg_comparator_name_t *i; const pkgconf_pkg_comparator_name_t *i;
for (i = pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++) for (i = pkgconf_pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++)
{ {
if (i->compare == pkgdep->compare) if (i->compare == pkgdep->compare)
return i->name; return i->name;
@ -740,20 +740,20 @@ pkg_get_comparator(pkgconf_dependency_t *pkgdep)
} }
/* /*
* pkg_comparator_lookup_by_name(name) * pkgconf_pkg_comparator_lookup_by_name(name)
* *
* look up the appropriate comparator bytecode in the comparator set (defined * look up the appropriate comparator bytecode in the comparator set (defined
* above, see pkg_comparator_names and pkg_comparator_impls). * above, see pkgconf_pkg_comparator_names and pkgconf_pkg_comparator_impls).
* *
* XXX: on error return PKG_ANY or maybe we should return PKG_CMP_SIZE which * XXX: on error return PKG_ANY or maybe we should return PKG_CMP_SIZE which
* is poisoned? * is poisoned?
*/ */
pkg_comparator_t pkgconf_pkg_comparator_t
pkg_comparator_lookup_by_name(const char *name) pkgconf_pkg_comparator_lookup_by_name(const char *name)
{ {
const pkg_comparator_name_t *i; const pkgconf_pkg_comparator_name_t *i;
for (i = pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++) for (i = pkgconf_pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++)
{ {
if (!strcmp(i->name, name)) if (!strcmp(i->name, name))
return i->compare; return i->compare;
@ -792,7 +792,7 @@ pkg_verify_dependency(pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned
if (pkg->id == NULL) if (pkg->id == NULL)
pkg->id = strdup(pkgdep->package); pkg->id = strdup(pkgdep->package);
if (pkg_comparator_impls[pkgdep->compare](pkg, pkgdep) == true) if (pkgconf_pkg_comparator_impls[pkgdep->compare](pkg, pkgdep) == true)
return pkg; return pkg;
if (eflags != NULL) if (eflags != NULL)
@ -833,11 +833,11 @@ pkg_report_graph_error(pkg_t *parent, pkg_t *pkg, pkgconf_dependency_t *node, un
else if (eflags & PKG_ERRF_PACKAGE_VER_MISMATCH) else if (eflags & PKG_ERRF_PACKAGE_VER_MISMATCH)
{ {
fprintf(error_msgout, "Package dependency requirement '%s %s %s' could not be satisfied.\n", fprintf(error_msgout, "Package dependency requirement '%s %s %s' could not be satisfied.\n",
node->package, pkg_get_comparator(node), node->version); node->package, pkgconf_pkg_get_comparator(node), node->version);
if (pkg != NULL) if (pkg != NULL)
fprintf(error_msgout, "Package '%s' has version '%s', required version is '%s %s'\n", fprintf(error_msgout, "Package '%s' has version '%s', required version is '%s %s'\n",
node->package, pkg->version, pkg_get_comparator(node), node->version); node->package, pkg->version, pkgconf_pkg_get_comparator(node), node->version);
} }
if (pkg != NULL) if (pkg != NULL)
@ -917,7 +917,7 @@ pkg_walk_conflicts_list(pkg_t *root, pkgconf_list_t *deplist, unsigned int flags
if (eflags == PKG_ERRF_OK) if (eflags == PKG_ERRF_OK)
{ {
fprintf(error_msgout, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n", 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, pkg_get_comparator(parentnode), pkgdep->version, pkgdep->realname, root->realname, parentnode->package, pkgconf_pkg_get_comparator(parentnode),
parentnode->version != NULL ? " " : "", parentnode->version != NULL ? parentnode->version : ""); parentnode->version != NULL ? " " : "", parentnode->version != NULL ? parentnode->version : "");
fprintf(error_msgout, "It may be possible to ignore this conflict and continue, try the\n"); fprintf(error_msgout, "It may be possible to ignore this conflict and continue, try the\n");
fprintf(error_msgout, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n"); fprintf(error_msgout, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");

6
main.c
View File

@ -207,7 +207,7 @@ print_requires(pkg_t *pkg)
printf("%s", dep->package); printf("%s", dep->package);
if (dep->version != NULL) if (dep->version != NULL)
printf(" %s %s", pkg_get_comparator(dep), dep->version); printf(" %s %s", pkgconf_pkg_get_comparator(dep), dep->version);
printf("\n"); printf("\n");
} }
@ -225,7 +225,7 @@ print_requires_private(pkg_t *pkg)
printf("%s", dep->package); printf("%s", dep->package);
if (dep->version != NULL) if (dep->version != NULL)
printf(" %s %s", pkg_get_comparator(dep), dep->version); printf(" %s %s", pkgconf_pkg_get_comparator(dep), dep->version);
printf("\n"); printf("\n");
} }
@ -472,7 +472,7 @@ print_graph_node(pkg_t *pkg, void *data, unsigned int flags)
if (dep->compare != PKG_ANY) if (dep->compare != PKG_ANY)
{ {
printf(" {\n"); printf(" {\n");
printf(" comparator = '%s';\n", pkg_get_comparator(dep)); printf(" comparator = '%s';\n", pkgconf_pkg_get_comparator(dep));
printf(" version = '%s';\n", dep->version); printf(" version = '%s';\n", dep->version);
printf(" };\n"); printf(" };\n");
} }