-
Notifications
You must be signed in to change notification settings - Fork 0
/
semver.h
68 lines (55 loc) · 1.79 KB
/
semver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <glib.h>
#ifndef __SEMVER_H__
#define __SEMVER_H__
/*
* SEMVER VERSION
*/
typedef enum SemverVersionDifference {
SemverVersionDifference_EQUAL,
SemverVersionDifference_LESS,
SemverVersionDifference_GREATER
} SemverVersionDifference;
typedef struct SemverVersion {
unsigned int major;
unsigned int minor;
unsigned int patch;
bool is_prerelease;
char* prerelease_string;
} SemverVersion;
SemverVersion* semver_version_new(unsigned int major, unsigned int minor, unsigned int patch, bool is_prerelease, char* prerelease_string);
SemverVersion* semver_version_new_from_string(char* version_string);
void semver_version_free(SemverVersion* ver);
SemverVersion* semver_version_copy(SemverVersion* ver);
char* semver_version_to_string(SemverVersion* version);
SemverVersionDifference semver_version_compare(SemverVersion* ver1, SemverVersion* ver2);
/*
* SEMVER FILTER
*/
typedef enum SemverFilterType {
SemverFilterType_EQUAL,
SemverFilterType_EXCLUDE,
SemverFilterType_LESS_OR_EQUAL,
SemverFilterType_GREATER_OR_EQUAL
} SemverFilterType;
typedef struct SemverFilter {
SemverVersion* ver;
SemverFilterType type;
} SemverFilter;
SemverFilter* semver_filter_new(SemverVersion* ver, SemverFilterType type);
SemverFilter* semver_filter_new_from_string(char* filter_string);
char* semver_filter_to_string(SemverFilter* filter);
bool semver_filter_matches_version(SemverFilter* filter, SemverVersion* version);
/*
* SEMVER VERSION GLIST
*/
GList* semver_version_glist_apply_filters(GList* list, SemverFilter** filters);
GList* semver_version_glist_sort(GList* list);
GList* semver_version_glist_copy(GList* list);
void semver_version_glist_free(GList* list);
#endif