diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 7cddb21..fe39117 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -557,6 +557,14 @@ int iso_image_new(const char *name, IsoImage **image); */ void iso_lib_version(int *major, int *minor, int *micro); +/** + * Check if the library is ABI compatible with the given version. + * + * @return + * 1 lib is compatible, 0 is not. + */ +int iso_lib_is_compatible(int major, int minor, int micro); + /** * Creates an IsoWriteOpts for writing an image. You should set the options * desired with the correspondent setters. diff --git a/libisofs/util.c b/libisofs/util.c index 36d3830..0c7512c 100644 --- a/libisofs/util.c +++ b/libisofs/util.c @@ -1248,3 +1248,17 @@ void iso_lib_version(int *major, int *minor, int *micro) *minor = LIBISOFS_MINOR_VERSION; *micro = LIBISOFS_MICRO_VERSION; } + +int iso_lib_is_compatible(int major, int minor, int micro) +{ + int cmajor, cminor, cmicro; + + /* for now, the rule is that library is compitable if requested + * version is lower */ + iso_lib_version(&cmajor, &cminor, &cmicro); + + return cmajor > major + || (cmajor == major + && (cminor > minor + || (cminor == minor && cmicro >= micro))); +}