Home | History | Annotate | Download | only in blkid
      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 #include "../../version.h"
     21 
     22 static const char *lib_version = E2FSPROGS_VERSION;
     23 static const char *lib_date = E2FSPROGS_DATE;
     24 
     25 int blkid_parse_version_string(const char *ver_string)
     26 {
     27 	const char *cp;
     28 	int version = 0;
     29 
     30 	for (cp = ver_string; *cp; cp++) {
     31 		if (*cp == '.')
     32 			continue;
     33 		if (!isdigit(*cp))
     34 			break;
     35 		version = (version * 10) + (*cp - '0');
     36 	}
     37 	return version;
     38 }
     39 
     40 int blkid_get_library_version(const char **ver_string,
     41 			       const char **date_string)
     42 {
     43 	if (ver_string)
     44 		*ver_string = lib_version;
     45 	if (date_string)
     46 		*date_string = lib_date;
     47 
     48 	return blkid_parse_version_string(lib_version);
     49 }
     50