libropkg: implement package list expression parsing

This commit is contained in:
2025-08-06 22:05:35 +01:00
parent 46c6a66e44
commit f35ade11d6
3 changed files with 719 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
#ifndef ROPKG_PKG_EXPR_H_
#define ROPKG_PKG_EXPR_H_
#include <ropkg/misc.h>
#include <ropkg/status.h>
enum ropkg_pkg_expr_type {
ROPKG_PKG_EXPR_NODE_PKG,
ROPKG_PKG_EXPR_NODE_AND,
ROPKG_PKG_EXPR_NODE_OR,
ROPKG_PKG_EXPR_NODE_GROUP,
};
enum ropkg_comparison_op;
struct ropkg_version;
struct ropkg_pkg_expr;
struct ropkg_pkg_expr_pkg;
struct ropkg_pkg_expr_and;
struct ropkg_pkg_expr_or;
ROPKG_API void ropkg_pkg_expr_destroy(struct ropkg_pkg_expr *expr);
ROPKG_API b_result
ropkg_pkg_expr_parse(const char *s, struct ropkg_pkg_expr **out);
ROPKG_API enum ropkg_pkg_expr_type ropkg_pkg_expr_get_type(
const struct ropkg_pkg_expr *expr);
ROPKG_API struct ropkg_pkg_expr_pkg *ropkg_pkg_expr_pkg_create(void);
ROPKG_API const char *ropkg_pkg_expr_pkg_get_name(
const struct ropkg_pkg_expr_pkg *expr);
ROPKG_API enum ropkg_comparison_op ropkg_pkg_expr_pkg_get_version_predicate(
const struct ropkg_pkg_expr_pkg *expr);
ROPKG_API const struct ropkg_version *ropkg_pkg_expr_pkg_get_version(
const struct ropkg_pkg_expr_pkg *expr);
ROPKG_API struct ropkg_pkg_expr_and *ropkg_pkg_expr_and_create(void);
ROPKG_API const struct ropkg_pkg_expr *ropkg_pkg_expr_and_get_left_node(
const struct ropkg_pkg_expr_and *expr);
ROPKG_API const struct ropkg_pkg_expr *ropkg_pkg_expr_and_get_right_node(
const struct ropkg_pkg_expr_and *expr);
ROPKG_API struct ropkg_pkg_expr_or *ropkg_pkg_expr_or_create(void);
ROPKG_API const struct ropkg_pkg_expr *ropkg_pkg_expr_or_get_left_node(
const struct ropkg_pkg_expr_or *expr);
ROPKG_API const struct ropkg_pkg_expr *ropkg_pkg_expr_or_get_right_node(
const struct ropkg_pkg_expr_or *expr);
#endif