1 /* 2 * version.c - Return the version of the library 3 * 4 * Copyright (C) 2014 Karel Zak <kzak@redhat.com> 5 * 6 * See COPYING.libmount for the License of this software. 7 */ 8 9 /** 10 * SECTION: version-utils 11 * @title: Version functions 12 * @short_description: functions to get the library version. 13 * 14 * Note that library version is not the same thing as SONAME version. The 15 * libsmarcols uses symbols versioning and SONAME is not modified for releases. 16 * 17 * The library version and symbols version follow util-linux package versioning. 18 */ 19 20 #include <ctype.h> 21 22 #include "smartcolsP.h" 23 24 static const char *lib_version = LIBSMARTCOLS_VERSION; 25 26 /** 27 * scols_parse_version_string: 28 * @ver_string: version string (e.g "2.18.0") 29 * 30 * Returns: release version code. 31 */ scols_parse_version_string(const char * ver_string)32int scols_parse_version_string(const char *ver_string) 33 { 34 const char *cp; 35 int version = 0; 36 37 assert(ver_string); 38 39 for (cp = ver_string; *cp; cp++) { 40 if (*cp == '.') 41 continue; 42 if (!isdigit(*cp)) 43 break; 44 version = (version * 10) + (*cp - '0'); 45 } 46 return version; 47 } 48 49 /** 50 * scols_get_library_version: 51 * @ver_string: return pointer to the static library version string if not NULL 52 * 53 * Returns: release version number. 54 */ scols_get_library_version(const char ** ver_string)55int scols_get_library_version(const char **ver_string) 56 { 57 if (ver_string) 58 *ver_string = lib_version; 59 60 return scols_parse_version_string(lib_version); 61 } 62 63