pkg: add pkg_get_comparator()

feature/tap-sh
William Pitcock 2011-07-26 19:59:46 -05:00
parent 774ebc9716
commit 648c39cf8e
2 changed files with 30 additions and 0 deletions

29
pkg.c
View File

@ -142,6 +142,35 @@ pkg_compare_version(const char *a, const char *b)
return 1;
}
/*
* pkg_get_comparator(pkgdep)
*
* returns the comparator used in a depgraph dependency node as a string.
*/
const char *
pkg_get_comparator(pkg_dependency_t *pkgdep)
{
switch(pkgdep->compare)
{
case PKG_LESS_THAN:
return "<";
case PKG_GREATER_THAN:
return ">";
case PKG_LESS_THAN_EQUAL:
return "<=";
case PKG_GREATER_THAN_EQUAL:
return ">=";
case PKG_EQUAL:
return "=";
case PKG_NOT_EQUAL:
return "!=";
case PKG_ANY:
return "(any)";
}
return "???";
}
/*
* pkg_verify_dependency(pkgdep)
*

1
pkg.h
View File

@ -93,6 +93,7 @@ void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *d
void pkg_verify_graph(pkg_t *root, int depth);
int pkg_compare_version(const char *a, const char *b);
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep);
const char *pkg_get_comparator(pkg_dependency_t *pkgdep);
/* parse.c */
pkg_t *parse_file(const char *path);