libsemver/include/semver.h

105 lines
1.7 KiB
C
Raw Normal View History

2024-02-10 00:48:59 -05:00
#include "epoch.h"
#include <stdint.h>
#define u128 __uint128_t
typedef struct {
2024-02-10 19:11:35 -05:00
uint16_t major;
2024-02-10 00:48:59 -05:00
} __Simple;
typedef struct {
2024-02-10 19:11:35 -05:00
uint16_t major;
uint16_t minor;
2024-02-10 00:48:59 -05:00
} __Rapid;
typedef struct {
2024-02-10 19:11:35 -05:00
uint16_t major;
uint16_t minor;
uint16_t patch;
2024-02-10 00:48:59 -05:00
} __SemVer;
typedef struct {
2024-02-10 19:11:35 -05:00
uint16_t major;
uint16_t minor;
uint16_t patch;
uint16_t build;
2024-02-10 00:48:59 -05:00
} __Extended;
typedef enum {
2024-02-10 19:11:35 -05:00
Simple,
Rapid,
SemVer,
Extended,
2024-02-10 00:48:59 -05:00
} VersionKindTag;
typedef struct {
2024-02-10 19:11:35 -05:00
char hash[7];
DateTime dt;
2024-02-10 00:48:59 -05:00
} GitRevision;
typedef enum {
2024-02-10 19:11:35 -05:00
Alpha,
Beta,
ReleaseCandidate,
GitRev,
PRNone,
2024-02-10 00:48:59 -05:00
} PreReleaseTag;
typedef enum {
2024-02-10 19:11:35 -05:00
any,
arm,
arm64,
loongson,
mips32,
mips64,
powerepc,
powerpc64,
riscv64,
s390x,
sparc,
sparc64,
x86,
x86_64,
2024-02-10 00:48:59 -05:00
} Arch;
typedef struct {
2024-02-10 19:11:35 -05:00
PreReleaseTag pr_tag;
union {
uint16_t alpha;
uint16_t beta;
uint16_t rc;
GitRevision *git;
};
} PreRelease;
typedef struct {
VersionKindTag vk_tag;
union {
__Simple simple;
__Rapid rapid;
__SemVer semver;
__Extended extended;
} vk_data;
PreReleaseTag pr_tag;
union {
uint16_t alpha;
uint16_t beta;
uint16_t rc;
GitRevision *git;
} pr_data;
Arch arch;
2024-02-10 00:48:59 -05:00
} Version;
typedef enum {
2024-02-10 19:11:35 -05:00
CompGreater,
CompEqual,
CompLess,
CompNone,
2024-02-10 00:48:59 -05:00
} Comparison;
2024-02-10 19:11:35 -05:00
u128 u128FromVersion(Version *self);
Comparison compareVersion (Version *self, Version *other);
int parseVersion (Version *self, const char *s);
char *versionToString(Version *self);