libropkg: implement package version API
This commit is contained in:
57
libropkg/include/ropkg/version.h
Normal file
57
libropkg/include/ropkg/version.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef ROPKG_VERSION_H_
|
||||
#define ROPKG_VERSION_H_
|
||||
|
||||
#include <blue/core/error.h>
|
||||
#include <ropkg/misc.h>
|
||||
#include <ropkg/status.h>
|
||||
|
||||
#define ROPKG_VERSION_UPSTREAM_DIGIT_MAX 5
|
||||
|
||||
struct ropkg_version;
|
||||
|
||||
enum ropkg_comparison_op {
|
||||
ROPKG_OP_EQUAL = 0,
|
||||
ROPKG_OP_NOT_EQUAL = -1,
|
||||
ROPKG_OP_LESS_THAN = -2,
|
||||
ROPKG_OP_LESS_EQUAL = -3,
|
||||
ROPKG_OP_GREATER_THAN = 1,
|
||||
ROPKG_OP_GREATER_EQUAL = 2,
|
||||
};
|
||||
|
||||
enum ropkg_version_release_phase {
|
||||
ROPKG_VERSION_RELEASE_PHASE_ALPHA = 0,
|
||||
ROPKG_VERSION_RELEASE_PHASE_BETA,
|
||||
ROPKG_VERSION_RELEASE_PHASE_RC,
|
||||
ROPKG_VERSION_RELEASE_PHASE_RELEASE,
|
||||
};
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_version_create(struct ropkg_version **out);
|
||||
ROPKG_API void ropkg_version_destroy(struct ropkg_version *version);
|
||||
|
||||
ROPKG_API void ropkg_version_set_release_phase(
|
||||
struct ropkg_version *version,
|
||||
enum ropkg_version_release_phase phase);
|
||||
ROPKG_API void ropkg_version_set_upstream_version(
|
||||
struct ropkg_version *version,
|
||||
const unsigned int upstream_version[ROPKG_VERSION_UPSTREAM_DIGIT_MAX]);
|
||||
ROPKG_API void ropkg_version_set_version_release_phase(
|
||||
struct ropkg_version *version,
|
||||
enum ropkg_version_release_phase phase,
|
||||
unsigned int revision);
|
||||
ROPKG_API void ropkg_version_set_package_revision(
|
||||
struct ropkg_version *version,
|
||||
unsigned int revision);
|
||||
|
||||
ROPKG_API b_result
|
||||
ropkg_version_parse(struct ropkg_version *version, const char *s);
|
||||
ROPKG_API size_t ropkg_version_to_string(
|
||||
const struct ropkg_version *version,
|
||||
char *out,
|
||||
size_t max);
|
||||
|
||||
ROPKG_API bool ropkg_version_compare(
|
||||
const struct ropkg_version *left,
|
||||
const struct ropkg_version *right,
|
||||
enum ropkg_comparison_op op);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user