]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libblkid/src/version.c
misc: Fix various typos
[thirdparty/util-linux.git] / libblkid / src / version.c
CommitLineData
a0948ffe
KZ
1/*
2 * version.c --- Return the version of the blkid library
3 *
4 * Copyright (C) 2004 Theodore Ts'o.
5 *
6 * %Begin-Header%
03915524
KZ
7 * This file may be redistributed under the terms of the GNU Lesser General
8 * Public License.
a0948ffe
KZ
9 * %End-Header%
10 */
11
fbc333fe 12#ifdef HAVE_UNISTD_H
a0948ffe
KZ
13#include <unistd.h>
14#endif
15#include <string.h>
16#include <stdio.h>
17#include <ctype.h>
18
19#include "blkid.h"
20
33b0be6d
KZ
21/* LIBBLKID_* defined in the global config.h */
22static const char *lib_version = LIBBLKID_VERSION; /* release version */
23static const char *lib_date = LIBBLKID_DATE;
a0948ffe 24
033cf439
KZ
25/**
26 * blkid_parse_version_string:
27 * @ver_string: version string (e.g. "2.16.0")
28 *
29 * Returns: release version code.
30 */
a0948ffe
KZ
31int blkid_parse_version_string(const char *ver_string)
32{
33 const char *cp;
34 int version = 0;
35
36 for (cp = ver_string; *cp; cp++) {
37 if (*cp == '.')
38 continue;
39 if (!isdigit(*cp))
40 break;
41 version = (version * 10) + (*cp - '0');
42 }
43 return version;
44}
45
33b0be6d
KZ
46/**
47 * blkid_get_library_version:
9e930041 48 * @ver_string: returns release version (!= SONAME version)
33b0be6d
KZ
49 * @date_string: returns date
50 *
488e52be 51 * Returns: release version code.
33b0be6d 52 */
a0948ffe
KZ
53int blkid_get_library_version(const char **ver_string,
54 const char **date_string)
55{
56 if (ver_string)
57 *ver_string = lib_version;
58 if (date_string)
59 *date_string = lib_date;
60
61 return blkid_parse_version_string(lib_version);
62}