]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - libmount/src/version.c
2 * version.c - Return the version of the blkid library
4 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
5 * [Based on libblkid/version.c by Theodore Ts'o]
7 * See COPYING.libmount for the License of this software.
12 * @title: Version functions
13 * @short_description: functions to get library version.
20 static const char *lib_version
= LIBMOUNT_VERSION
;
21 static const char *lib_features
[] = {
22 #ifdef HAVE_LIBSELINUX
25 #ifdef CONFIG_LIBMOUNT_DEBUG
28 #ifdef CONFIG_LIBMOUNT_ASSERT
35 * mnt_parse_version_string:
36 * @ver_string: version string (e.g "2.18.0")
38 * Returns: release version code.
40 int mnt_parse_version_string(const char *ver_string
)
47 for (cp
= ver_string
; *cp
; cp
++) {
52 version
= (version
* 10) + (*cp
- '0');
58 * mnt_get_library_version:
59 * @ver_string: return pointer to the static library version string if not NULL
61 * Returns: release version number.
63 int mnt_get_library_version(const char **ver_string
)
66 *ver_string
= lib_version
;
68 return mnt_parse_version_string(lib_version
);
72 * mnt_get_library_features:
73 * @features: returns pointer to the static array of strings, the array is
76 * Returns: number of items in the features array not including the last NULL,
77 * or less then zero in case of error
82 * const char *features;
84 * mnt_get_library_features(&features);
85 * while (features && *features)
86 * printf("%s\n", *features++);
91 int mnt_get_library_features(const char ***features
)
96 *features
= lib_features
;
97 return ARRAY_SIZE(lib_features
) - 1;
101 int test_version(struct libmnt_test
*ts
, int argc
, char *argv
[])
104 const char **features
;
106 mnt_get_library_version(&ver
);
108 printf("Library version: %s\n", ver
);
109 printf("Library API version: " LIBMOUNT_VERSION
"\n");
110 printf("Library features:");
112 mnt_get_library_features(&features
);
113 while (features
&& *features
)
114 printf(" %s", *features
++);
116 if (mnt_get_library_version(NULL
) ==
117 mnt_parse_version_string(LIBMOUNT_VERSION
))
123 int main(int argc
, char *argv
[])
125 struct libmnt_test ts
[] = {
126 { "--print", test_version
, "print versions" },
130 return mnt_run_test(ts
, argc
, argv
);