Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * libdpkg - Debian packaging suite library routines | |
3 | * version.h - version handling routines | |
4 | * | |
5 | * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk> | |
6 | * Copyright © 2011-2014 Guillem Jover <guillem@debian.org> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
20 | */ | |
21 | ||
22 | #ifndef LIBDPKG_VERSION_H | |
23 | #define LIBDPKG_VERSION_H | |
24 | ||
25 | #include <stdbool.h> | |
26 | ||
27 | #include <dpkg/macros.h> | |
28 | ||
29 | DPKG_BEGIN_DECLS | |
30 | ||
31 | /** | |
32 | * @defgroup version Version handling | |
33 | * @ingroup dpkg-public | |
34 | * @{ | |
35 | */ | |
36 | ||
37 | /** | |
38 | * Data structure representing a Debian version. | |
39 | * | |
40 | * @see deb-version(5) | |
41 | */ | |
42 | struct dpkg_version { | |
43 | /** The epoch. It will be zero if no epoch is present. */ | |
44 | unsigned int epoch; | |
45 | /** The upstream part of the version. */ | |
46 | const char *version; | |
47 | /** The Debian revision part of the version. */ | |
48 | const char *revision; | |
49 | }; | |
50 | ||
51 | /** | |
52 | * Compound literal for a dpkg_version. | |
53 | */ | |
54 | #define DPKG_VERSION_OBJECT(e, v, r) \ | |
55 | (struct dpkg_version){ .epoch = (e), .version = (v), .revision = (r) } | |
56 | ||
57 | /** | |
58 | * Enum constants for the supported relation operations that can be done | |
59 | * on Debian versions. | |
60 | */ | |
61 | enum dpkg_relation { | |
62 | /** The “none” relation, sentinel value. */ | |
63 | DPKG_RELATION_NONE = 0, | |
64 | /** Equality relation (‘=’). */ | |
65 | DPKG_RELATION_EQ = DPKG_BIT(0), | |
66 | /** Less than relation (‘<<’). */ | |
67 | DPKG_RELATION_LT = DPKG_BIT(1), | |
68 | /** Less than or equal to relation (‘<=’). */ | |
69 | DPKG_RELATION_LE = DPKG_RELATION_LT | DPKG_RELATION_EQ, | |
70 | /** Greater than relation (‘>>’). */ | |
71 | DPKG_RELATION_GT = DPKG_BIT(2), | |
72 | /** Greater than or equal to relation (‘>=’). */ | |
73 | DPKG_RELATION_GE = DPKG_RELATION_GT | DPKG_RELATION_EQ, | |
74 | }; | |
75 | ||
76 | void dpkg_version_blank(struct dpkg_version *version); | |
77 | bool dpkg_version_is_informative(const struct dpkg_version *version); | |
78 | int dpkg_version_compare(const struct dpkg_version *a, | |
79 | const struct dpkg_version *b); | |
80 | bool dpkg_version_relate(const struct dpkg_version *a, | |
81 | enum dpkg_relation rel, | |
82 | const struct dpkg_version *b); | |
83 | ||
84 | /** @} */ | |
85 | ||
86 | DPKG_END_DECLS | |
87 | ||
88 | #endif /* LIBDPKG_VERSION_H */ |