mirror of https://github.com/vitalif/e2fsprogs
Add functions which allow an application program to do a run-time query
of the version of the blkid library.bitmap-optimize
parent
f923bf2a81
commit
32923fa402
|
@ -1,5 +1,7 @@
|
|||
2005-01-26 Theodore Ts'o <tytso@mit.edu>
|
||||
|
||||
* version.c: Add functions to query the version of the blkid library.
|
||||
|
||||
* blkid.pc.in: Add pkg-config files.
|
||||
|
||||
2005-01-25 Theodore Ts'o <tytso@mit.edu>
|
||||
|
|
|
@ -19,11 +19,12 @@ all::
|
|||
SMANPAGES= libblkid.3
|
||||
|
||||
OBJS= cache.o dev.o devname.o devno.o getsize.o llseek.o probe.o \
|
||||
read.o resolve.o save.o tag.o
|
||||
read.o resolve.o save.o tag.o version.o
|
||||
|
||||
SRCS= $(srcdir)/cache.c $(srcdir)/dev.c $(srcdir)/devname.c $(srcdir)/devno.c \
|
||||
$(srcdir)/getsize.c $(srcdir)/llseek.c $(srcdir)/probe.c \
|
||||
$(srcdir)/read.c $(srcdir)/resolve.c $(srcdir)/save.c $(srcdir)/tag.c
|
||||
$(srcdir)/read.c $(srcdir)/resolve.c $(srcdir)/save.c $(srcdir)/tag.c \
|
||||
$(srcdir)/version.c
|
||||
|
||||
HFILES= blkid.h
|
||||
HFILES_IN= blkid_types.h
|
||||
|
@ -194,3 +195,5 @@ save.o: $(srcdir)/save.c $(srcdir)/blkidP.h $(srcdir)/blkid.h \
|
|||
$(top_builddir)/lib/blkid/blkid_types.h $(srcdir)/list.h
|
||||
tag.o: $(srcdir)/tag.c $(srcdir)/blkidP.h $(srcdir)/blkid.h \
|
||||
$(top_builddir)/lib/blkid/blkid_types.h $(srcdir)/list.h
|
||||
version.o: $(srcdir)/version.c $(srcdir)/blkid.h \
|
||||
$(top_builddir)/lib/blkid/blkid_types.h $(top_srcdir)/version.h
|
||||
|
|
|
@ -92,6 +92,11 @@ extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
|
|||
extern int blkid_parse_tag_string(const char *token, char **ret_type,
|
||||
char **ret_val);
|
||||
|
||||
/* version.c */
|
||||
extern int blkid_parse_version_string(const char *ver_string);
|
||||
extern int blkid_get_library_version(const char **ver_string,
|
||||
const char **date_string);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* version.c --- Return the version of the blkid library
|
||||
*
|
||||
* Copyright (C) 2004 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "blkid.h"
|
||||
#include "../../version.h"
|
||||
|
||||
static const char *lib_version = E2FSPROGS_VERSION;
|
||||
static const char *lib_date = E2FSPROGS_DATE;
|
||||
|
||||
int blkid_parse_version_string(const char *ver_string)
|
||||
{
|
||||
const char *cp;
|
||||
int version = 0;
|
||||
|
||||
for (cp = ver_string; *cp; cp++) {
|
||||
if (*cp == '.')
|
||||
continue;
|
||||
if (!isdigit(*cp))
|
||||
break;
|
||||
version = (version * 10) + (*cp - '0');
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
int blkid_get_library_version(const char **ver_string,
|
||||
const char **date_string)
|
||||
{
|
||||
if (ver_string)
|
||||
*ver_string = lib_version;
|
||||
if (date_string)
|
||||
*date_string = lib_date;
|
||||
|
||||
return blkid_parse_version_string(lib_version);
|
||||
}
|
Loading…
Reference in New Issue