1*6a54128fSAndroid Build Coastguard Worker /* 2*6a54128fSAndroid Build Coastguard Worker * version.c --- Return the version of the ext2 library 3*6a54128fSAndroid Build Coastguard Worker * 4*6a54128fSAndroid Build Coastguard Worker * Copyright (C) 1997 Theodore Ts'o. 5*6a54128fSAndroid Build Coastguard Worker * 6*6a54128fSAndroid Build Coastguard Worker * %Begin-Header% 7*6a54128fSAndroid Build Coastguard Worker * This file may be redistributed under the terms of the GNU Library 8*6a54128fSAndroid Build Coastguard Worker * General Public License, version 2. 9*6a54128fSAndroid Build Coastguard Worker * %End-Header% 10*6a54128fSAndroid Build Coastguard Worker */ 11*6a54128fSAndroid Build Coastguard Worker 12*6a54128fSAndroid Build Coastguard Worker #include "config.h" 13*6a54128fSAndroid Build Coastguard Worker #if HAVE_UNISTD_H 14*6a54128fSAndroid Build Coastguard Worker #include <unistd.h> 15*6a54128fSAndroid Build Coastguard Worker #endif 16*6a54128fSAndroid Build Coastguard Worker #include <string.h> 17*6a54128fSAndroid Build Coastguard Worker #include <stdio.h> 18*6a54128fSAndroid Build Coastguard Worker #include <ctype.h> 19*6a54128fSAndroid Build Coastguard Worker 20*6a54128fSAndroid Build Coastguard Worker #include "ext2_fs.h" 21*6a54128fSAndroid Build Coastguard Worker #include "ext2fs.h" 22*6a54128fSAndroid Build Coastguard Worker 23*6a54128fSAndroid Build Coastguard Worker #include "../../version.h" 24*6a54128fSAndroid Build Coastguard Worker 25*6a54128fSAndroid Build Coastguard Worker static const char *lib_version = E2FSPROGS_VERSION; 26*6a54128fSAndroid Build Coastguard Worker static const char *lib_date = E2FSPROGS_DATE; 27*6a54128fSAndroid Build Coastguard Worker ext2fs_parse_version_string(const char * ver_string)28*6a54128fSAndroid Build Coastguard Workerint ext2fs_parse_version_string(const char *ver_string) 29*6a54128fSAndroid Build Coastguard Worker { 30*6a54128fSAndroid Build Coastguard Worker const char *cp; 31*6a54128fSAndroid Build Coastguard Worker int version = 0, dot_count = 0; 32*6a54128fSAndroid Build Coastguard Worker 33*6a54128fSAndroid Build Coastguard Worker for (cp = ver_string; *cp; cp++) { 34*6a54128fSAndroid Build Coastguard Worker if (*cp == '.') { 35*6a54128fSAndroid Build Coastguard Worker if (dot_count++) 36*6a54128fSAndroid Build Coastguard Worker break; 37*6a54128fSAndroid Build Coastguard Worker else 38*6a54128fSAndroid Build Coastguard Worker continue; 39*6a54128fSAndroid Build Coastguard Worker } 40*6a54128fSAndroid Build Coastguard Worker if (!isdigit(*cp)) 41*6a54128fSAndroid Build Coastguard Worker break; 42*6a54128fSAndroid Build Coastguard Worker version = (version * 10) + (*cp - '0'); 43*6a54128fSAndroid Build Coastguard Worker } 44*6a54128fSAndroid Build Coastguard Worker return version; 45*6a54128fSAndroid Build Coastguard Worker } 46*6a54128fSAndroid Build Coastguard Worker 47*6a54128fSAndroid Build Coastguard Worker ext2fs_get_library_version(const char ** ver_string,const char ** date_string)48*6a54128fSAndroid Build Coastguard Workerint ext2fs_get_library_version(const char **ver_string, 49*6a54128fSAndroid Build Coastguard Worker const char **date_string) 50*6a54128fSAndroid Build Coastguard Worker { 51*6a54128fSAndroid Build Coastguard Worker if (ver_string) 52*6a54128fSAndroid Build Coastguard Worker *ver_string = lib_version; 53*6a54128fSAndroid Build Coastguard Worker if (date_string) 54*6a54128fSAndroid Build Coastguard Worker *date_string = lib_date; 55*6a54128fSAndroid Build Coastguard Worker 56*6a54128fSAndroid Build Coastguard Worker return ext2fs_parse_version_string(lib_version); 57*6a54128fSAndroid Build Coastguard Worker } 58