libsemver/include/semver.h

91 lines
1.5 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 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 23:18:06 -05:00
PreReleaseTag tag;
2024-02-10 19:11:35 -05:00
union {
uint16_t alpha;
uint16_t beta;
uint16_t rc;
2024-02-10 23:18:06 -05:00
GitRevision git;
2024-02-10 19:11:35 -05:00
};
} PreRelease;
typedef struct {
2024-02-10 23:18:06 -05:00
VersionKindTag vk_tag;
2024-02-10 19:11:35 -05:00
union {
2024-02-10 23:18:06 -05:00
struct {
uint16_t major;
} simple;
struct {
uint16_t major;
uint16_t minor;
} rapid;
struct {
uint16_t major;
uint16_t minor;
uint16_t patch;
} semver;
struct {
uint16_t major;
uint16_t minor;
uint16_t patch;
uint16_t build;
} extended;
};
PreRelease pr;
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);