Improve.
[eruntime.git] / src / version.c
blob869461228a7ad4dc797d59a1c8c40244a1af308b
1 #include <assert.h>
2 #include <inttypes.h>
3 #include <string.h>
5 #include "eruntime/version.h"
7 /* {{{ static version_spec_t eruntime_version = { ... } */
8 version_spec_t eruntime_version =
10 .major = 0,
11 .minor = 1,
12 .patch = 0,
13 .build = 0,
14 .extra_str = "",
16 /* }}} */
18 /* {{{ int8_t eruntime_get_version() */
19 int8_t
20 eruntime_get_version (version_spec_t *vspec)
22 assert(vspec);
23 if (!vspec)
24 return -1;
26 memcpy(vspec, &eruntime_version, sizeof(*vspec));
27 return 0;
29 /* }}} */
31 /* {{{ int8_t eruntime_compare_versions() */
32 int8_t
33 eruntime_compare_versions (version_spec_t *vs_a, version_spec_t *vs_b)
35 assert(vs_a && vs_b);
36 if (!vs_a || !vs_b)
37 return -1;
39 if (vs_a->major > vs_b->major)
40 return 1;
41 else if (vs_a->major < vs_b->major)
42 return -1;
44 if (vs_a->minor > vs_b->minor)
45 return 1;
46 else if (vs_a->minor < vs_b->minor)
47 return -1;
49 if (vs_a->patch > vs_b->patch)
50 return 1;
51 else if (vs_a->patch < vs_b->patch)
52 return -1;
54 if (vs_a->build > vs_b->build)
55 return 1;
56 else if (vs_a->build < vs_b->build)
57 return -1;
60 * TODO: Add support for comparing against ->extra_str.
63 return 0;
65 /* }}} */
68 * vim: ts=8 sw=8 noet fdm=marker tw=80