po: Update German man pages translation
[dpkg.git] / lib / dpkg / version.h
blob7c3f0275e91e2f3b9c00ba4b9a0c7efed7dd16a5
1 /*
2 * libdpkg - Debian packaging suite library routines
3 * version.h - version handling routines
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2011-2014 Guillem Jover <guillem@debian.org>
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.
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.
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/>.
22 #ifndef LIBDPKG_VERSION_H
23 #define LIBDPKG_VERSION_H
25 #include <stdbool.h>
27 #include <dpkg/macros.h>
29 DPKG_BEGIN_DECLS
31 /**
32 * @defgroup version Version handling
33 * @ingroup dpkg-public
34 * @{
37 /**
38 * Data structure representing a Debian version.
40 * @see deb-version(5)
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;
51 /**
52 * Compound literal for a dpkg_version.
54 #define DPKG_VERSION_OBJECT(e, v, r) \
55 (struct dpkg_version){ .epoch = (e), .version = (v), .revision = (r) }
57 #define DPKG_VERSION_INIT \
58 DPKG_VERSION_OBJECT(0, NULL, NULL)
60 /**
61 * Enum constants for the supported relation operations that can be done
62 * on Debian versions.
64 enum DPKG_ATTR_ENUM_FLAGS dpkg_relation {
65 /** The “none” relation, sentinel value. */
66 DPKG_RELATION_NONE = 0,
67 /** Equality relation (‘=’). */
68 DPKG_RELATION_EQ = DPKG_BIT(0),
69 /** Less than relation (‘<<’). */
70 DPKG_RELATION_LT = DPKG_BIT(1),
71 /** Less than or equal to relation (‘<=’). */
72 DPKG_RELATION_LE = DPKG_RELATION_LT | DPKG_RELATION_EQ,
73 /** Greater than relation (‘>>’). */
74 DPKG_RELATION_GT = DPKG_BIT(2),
75 /** Greater than or equal to relation (‘>=’). */
76 DPKG_RELATION_GE = DPKG_RELATION_GT | DPKG_RELATION_EQ,
79 void dpkg_version_blank(struct dpkg_version *version);
80 bool dpkg_version_is_informative(const struct dpkg_version *version);
81 int dpkg_version_compare(const struct dpkg_version *a,
82 const struct dpkg_version *b);
83 bool dpkg_version_relate(const struct dpkg_version *a,
84 enum dpkg_relation rel,
85 const struct dpkg_version *b);
87 /** @} */
89 DPKG_END_DECLS
91 #endif /* LIBDPKG_VERSION_H */