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