From c48a83413a6bfd9a6f3012c45f0c9bbfd3097ae1 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 24 Jul 2004 20:08:26 +0000 Subject: [PATCH] Add some functions to query basic facts about the library: archive_version: Returns a text string, e.g., "libarchive 1.00.000" archive_api_version: Returns the SHLIB major version archive_api_feature: Returns a feature number useful for answering questions such as "Is this recent enough to do XXX?" The last two also have macros defined in archive.h, so you can compare the compile-time and run-time environments. (In particular, you can compare ARCHIVE_API_VERSION to archive_api_version() to detect library version mismatches.) With these in hand, it will soon be time to turn on the shared-library version of libarchive... stay tuned. --- lib/libarchive/archive.h | 30 ++++++++++++++++++++++++------ lib/libarchive/archive.h.in | 30 ++++++++++++++++++++++++------ lib/libarchive/archive_util.c | 18 ++++++++++++++++++ 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/lib/libarchive/archive.h b/lib/libarchive/archive.h index 6f052f9e1c37..d374eeccbbd3 100644 --- a/lib/libarchive/archive.h +++ b/lib/libarchive/archive.h @@ -29,6 +29,27 @@ #ifndef ARCHIVE_H_INCLUDED #define ARCHIVE_H_INCLUDED +/* + * If ARCHIVE_API_VERSION != archive_api_version(), then the library you + * were linked with is using an incompatible API. This is almost + * certainly a fatal problem. + * + * ARCHIVE_API_FEATURE is incremented with each significant feature + * addition, so you can test (at compile or run time) if a particular + * feature is implemented. It's no big deal if ARCHIVE_API_FEATURE != + * archive_api_feature(), as long as both are high enough to include + * the features you're relying on. Specific values of FEATURE are + * documented here: + * + * 1 - Version test is available. + */ +#define ARCHIVE_API_VERSION 1 +int archive_api_version(void); +#define ARCHIVE_API_FEATURE 1 +int archive_api_feature(void); +/* Textual name/version of the library. */ +const char * archive_version(void); + #include /* Linux requires this for off_t */ #include /* For int64_t */ #include /* For ssize_t and size_t */ @@ -47,9 +68,9 @@ struct archive_entry; */ #define ARCHIVE_EOF 1 /* Found end of archive. */ #define ARCHIVE_OK 0 /* Operation was successful. */ -#define ARCHIVE_WARN (-1) /* Sucess, but minor problem. */ -#define ARCHIVE_RETRY (-2) /* Retry might succeed. */ -#define ARCHIVE_FATAL (-3) /* No more operations are possible. */ +#define ARCHIVE_RETRY (-10) /* Retry might succeed. */ +#define ARCHIVE_WARN (-20) /* Partial sucess. */ +#define ARCHIVE_FATAL (-30) /* No more operations are possible. */ /* * As far as possible, archive_errno returns standard platform errno codes. @@ -283,9 +304,6 @@ int archive_errno(struct archive *); const char *archive_error_string(struct archive *); const char *archive_format_name(struct archive *); int archive_format(struct archive *); -/* void archive_set_errno(struct archive *, int); */ -/* void archive_error_printf(struct archive *, const char *fmt, ...); */ - void archive_set_error(struct archive *, int _err, const char *fmt, ...); #endif /* !ARCHIVE_H_INCLUDED */ diff --git a/lib/libarchive/archive.h.in b/lib/libarchive/archive.h.in index 6f052f9e1c37..d374eeccbbd3 100644 --- a/lib/libarchive/archive.h.in +++ b/lib/libarchive/archive.h.in @@ -29,6 +29,27 @@ #ifndef ARCHIVE_H_INCLUDED #define ARCHIVE_H_INCLUDED +/* + * If ARCHIVE_API_VERSION != archive_api_version(), then the library you + * were linked with is using an incompatible API. This is almost + * certainly a fatal problem. + * + * ARCHIVE_API_FEATURE is incremented with each significant feature + * addition, so you can test (at compile or run time) if a particular + * feature is implemented. It's no big deal if ARCHIVE_API_FEATURE != + * archive_api_feature(), as long as both are high enough to include + * the features you're relying on. Specific values of FEATURE are + * documented here: + * + * 1 - Version test is available. + */ +#define ARCHIVE_API_VERSION 1 +int archive_api_version(void); +#define ARCHIVE_API_FEATURE 1 +int archive_api_feature(void); +/* Textual name/version of the library. */ +const char * archive_version(void); + #include /* Linux requires this for off_t */ #include /* For int64_t */ #include /* For ssize_t and size_t */ @@ -47,9 +68,9 @@ struct archive_entry; */ #define ARCHIVE_EOF 1 /* Found end of archive. */ #define ARCHIVE_OK 0 /* Operation was successful. */ -#define ARCHIVE_WARN (-1) /* Sucess, but minor problem. */ -#define ARCHIVE_RETRY (-2) /* Retry might succeed. */ -#define ARCHIVE_FATAL (-3) /* No more operations are possible. */ +#define ARCHIVE_RETRY (-10) /* Retry might succeed. */ +#define ARCHIVE_WARN (-20) /* Partial sucess. */ +#define ARCHIVE_FATAL (-30) /* No more operations are possible. */ /* * As far as possible, archive_errno returns standard platform errno codes. @@ -283,9 +304,6 @@ int archive_errno(struct archive *); const char *archive_error_string(struct archive *); const char *archive_format_name(struct archive *); int archive_format(struct archive *); -/* void archive_set_errno(struct archive *, int); */ -/* void archive_error_printf(struct archive *, const char *fmt, ...); */ - void archive_set_error(struct archive *, int _err, const char *fmt, ...); #endif /* !ARCHIVE_H_INCLUDED */ diff --git a/lib/libarchive/archive_util.c b/lib/libarchive/archive_util.c index 065a8fe40d4b..2a44498e3c78 100644 --- a/lib/libarchive/archive_util.c +++ b/lib/libarchive/archive_util.c @@ -34,6 +34,24 @@ __FBSDID("$FreeBSD$"); #include "archive.h" #include "archive_private.h" +int +archive_api_feature(void) +{ + return (ARCHIVE_API_FEATURE); +} + +int +archive_api_version(void) +{ + return (ARCHIVE_API_VERSION); +} + +const char * +archive_version(void) +{ + return (PACKAGE_NAME " " PACKAGE_VERSION); +} + int archive_errno(struct archive *a) {