chiark / gitweb /
align: Add trivial manpage.
[mLib] / versioncmp.h
CommitLineData
0683223a
MW
1/* -*-c-*-
2 *
3 * $Id$
4 *
5 * Compare version numbers using the Debian algorithm
6 *
7 * (c) 2007 Straylight/Edgeware
8 */
9
d4efbcd9 10/*----- Licensing notice --------------------------------------------------*
0683223a
MW
11 *
12 * This file is part of the mLib utilities library.
13 *
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
d4efbcd9 18 *
0683223a
MW
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
d4efbcd9 23 *
0683223a
MW
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30#ifndef MLIB_VERSIONCMP_H
31#define MLIB_VERSIONCMP_H
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37/*----- Functions provided ------------------------------------------------*/
38
39/* --- @versioncmp@ --- *
40 *
41 * Arguments: @const char *va, *vb@ = two version strings
42 *
43 * Returns: Less than, equal to, or greater than zero, according to
44 * whether @va@ is less than, equal to, or greater than @vb@.
45 *
46 * Use: Compares version number strings.
47 *
48 * The algorithm is an extension of the Debian version
49 * comparison algorithm. A version number consists of three
50 * components:
51 *
52 * [EPOCH :] MAIN [- SUB]
53 *
54 * The MAIN part may contain colons or hyphens if there is an
55 * EPOCH or SUB, respectively. Version strings are compared
56 * componentwise: first epochs, then main parts, and finally
57 * subparts.
58 *
59 * The component comparison is done as follows. First, the
60 * initial subsequence of nondigit characters is extracted from
61 * each string, and these are compared lexicographically, using
62 * ASCII ordering, except that letters precede non-letters. If
63 * both are the same, an initial sequence of digits is extracted
64 * from the remaining parts of the version strings, and these
65 * are compared numerically (an empty sequence being considered
66 * to have the value zero). This process is repeated until we
67 * have a winner or until both strings are exhausted.
68 */
69
70extern int versioncmp(const char */*va*/, const char */*vb*/);
71
72/*----- That's all, folks -------------------------------------------------*/
73
74#ifdef __cplusplus
75 }
76#endif
77
78#endif