~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to libblkid/src/version.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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 Public
 
8
 * License.
 
9
 * %End-Header%
 
10
 */
 
11
 
 
12
#if 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
 
 
21
/* LIBBLKID_* defined in the global config.h */
 
22
static const char *lib_version = LIBBLKID_VERSION;      /* release version */
 
23
static const char *lib_date = LIBBLKID_DATE;
 
24
 
 
25
/**
 
26
 * blkid_parse_version_string:
 
27
 * @ver_string:  version string (e.g. "2.16.0")
 
28
 *
 
29
 * Returns: release version code.
 
30
 */
 
31
int 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
 
 
46
/**
 
47
 * blkid_get_library_version:
 
48
 * @ver_string: returns relese version (!= SONAME version)
 
49
 * @date_string: returns date
 
50
 *
 
51
 * Returns: release version code.
 
52
 */
 
53
int 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
}