dpkg 1.21.11
version.h
Go to the documentation of this file.
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
30
44 unsigned int epoch;
46 const char *version;
48 const char *revision;
49};
50
54#define DPKG_VERSION_OBJECT(e, v, r) \
55 (struct dpkg_version){ .epoch = (e), .version = (v), .revision = (r) }
56
57#define DPKG_VERSION_INIT \
58 DPKG_VERSION_OBJECT(0, NULL, NULL)
59
77};
78
79void dpkg_version_blank(struct dpkg_version *version);
80bool dpkg_version_is_informative(const struct dpkg_version *version);
81int dpkg_version_compare(const struct dpkg_version *a,
82 const struct dpkg_version *b);
83bool dpkg_version_relate(const struct dpkg_version *a,
84 enum dpkg_relation rel,
85 const struct dpkg_version *b);
86
90
91#endif /* LIBDPKG_VERSION_H */
#define DPKG_BEGIN_DECLS
Definition: macros.h:86
#define DPKG_END_DECLS
Definition: macros.h:87
#define DPKG_BIT(n)
Return the integer value of bit n.
Definition: macros.h:125
void dpkg_version_blank(struct dpkg_version *version)
Turn the passed version into an empty version.
Definition: version.c:38
int dpkg_version_compare(const struct dpkg_version *a, const struct dpkg_version *b)
Compares two Debian versions.
Definition: version.c:140
bool dpkg_version_is_informative(const struct dpkg_version *version)
Test if a version is not empty.
Definition: version.c:54
dpkg_relation
Enum constants for the supported relation operations that can be done on Debian versions.
Definition: version.h:64
bool dpkg_version_relate(const struct dpkg_version *a, enum dpkg_relation rel, const struct dpkg_version *b)
Check if two versions have a certain relation.
Definition: version.c:172
@ DPKG_RELATION_LT
Less than relation (‘<<’).
Definition: version.h:70
@ DPKG_RELATION_EQ
Equality relation (‘=’).
Definition: version.h:68
@ DPKG_RELATION_NONE
The “none” relation, sentinel value.
Definition: version.h:66
@ DPKG_RELATION_GE
Greater than or equal to relation (‘>=’).
Definition: version.h:76
@ DPKG_RELATION_GT
Greater than relation (‘>>’).
Definition: version.h:74
@ DPKG_RELATION_LE
Less than or equal to relation (‘<=’).
Definition: version.h:72
Data structure representing a Debian version.
Definition: version.h:42
unsigned int epoch
The epoch.
Definition: version.h:44
const char * version
The upstream part of the version.
Definition: version.h:46
const char * revision
The Debian revision part of the version.
Definition: version.h:48