pkg: add pkg_comparator_lookup_by_name().

feature/tap-sh
William Pitcock 2013-02-24 07:37:20 -06:00
parent ef1f1a3a14
commit 6e4573367d
2 changed files with 24 additions and 0 deletions

23
pkg.c
View File

@ -689,6 +689,29 @@ pkg_get_comparator(pkg_dependency_t *pkgdep)
return "???"; return "???";
} }
/*
* pkg_comparator_lookup_by_name(name)
*
* look up the appropriate comparator bytecode in the comparator set (defined
* above, see pkg_comparator_names and pkg_comparator_impls).
*
* XXX: on error return PKG_ANY or maybe we should return PKG_CMP_SIZE which
* is poisoned?
*/
pkg_comparator_t
pkg_comparator_lookup_by_name(const char *name)
{
const pkg_comparator_name_t *i;
for (i = pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++)
{
if (!strcmp(i->name, name))
return i->compare;
}
return PKG_ANY;
}
/* /*
* pkg_verify_dependency(pkgdep, flags) * pkg_verify_dependency(pkgdep, flags)
* *

1
pkg.h
View File

@ -137,6 +137,7 @@ pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsig
const char *pkg_get_comparator(pkg_dependency_t *pkgdep); const char *pkg_get_comparator(pkg_dependency_t *pkgdep);
int pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags); int pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags);
int pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags); int pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags);
pkg_comparator_t pkg_comparator_lookup_by_name(const char *name);
/* parse.c */ /* parse.c */
pkg_t *pkg_new_from_file(const char *path, FILE *f); pkg_t *pkg_new_from_file(const char *path, FILE *f);