Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add routine to convert string to operator.
Vsevolod Stakhov committed 10 years ago
commit 9687aec452af8dabf42eb4ca4053d3536b850634
parent 394f84c
3 files changed +39 -0
modified libpkg/pkg_deps.c
@@ -480,3 +480,39 @@ pkg_deps_formula_tostring(struct pkg_dep_formula *f)

	return (res);
}
+

+
enum pkg_dep_version_op
+
pkg_deps_string_toop(const char *in)
+
{
+
	enum pkg_dep_version_op ret = VERSION_ANY;
+
	int len;
+

+
	if (in != NULL) {
+
		len = strlen(in);
+

+
		if (len == 2) {
+
			if (memcmp(in, ">=", 2) == 0) {
+
				ret = VERSION_GE;
+
			}
+
			else if (memcmp(in, "<=", 2) == 0) {
+
				ret = VERSION_LE;
+
			}
+
			else if (memcmp(in, "!=", 2) == 0) {
+
				ret = VERSION_NOT;
+
			}
+
		}
+
		else if (len == 1) {
+
			if (*in == '>') {
+
				ret = VERSION_GT;
+
			}
+
			else if (*in == '<') {
+
				ret = VERSION_LT;
+
			}
+
			else if (*in == '!') {
+
				ret = VERSION_NOT;
+
			}
+
		}
+
	}
+

+
	return (ret);
+
}
modified libpkg/pkgdb.c
@@ -68,6 +68,7 @@
#include "private/pkg.h"
#include "private/pkgdb.h"
#include "private/utils.h"
+
#include "private/pkg_deps.h"

#include "private/db_upgrades.h"

modified libpkg/private/pkg_deps.h
@@ -81,4 +81,6 @@ void pkg_deps_formula_free(struct pkg_dep_formula *f);

char* pkg_deps_formula_tostring(struct pkg_dep_formula *f);

+
enum pkg_dep_version_op pkg_deps_string_toop(const char *in);
+

#endif /* LIBPKG_PRIVATE_PKG_DEPS_H_ */