diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-07-24 20:08:26 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-07-24 20:08:26 +0000 |
commit | 93e4420b8b4fd63660b92f1612c9bbe60a702635 (patch) | |
tree | 1de9ff5108371560466849f34343c7c458f6f45f /lib/libarchive | |
parent | fca95b696edc3d1a61a7be1a59769f70697d5501 (diff) | |
download | FreeBSD-src-93e4420b8b4fd63660b92f1612c9bbe60a702635.zip FreeBSD-src-93e4420b8b4fd63660b92f1612c9bbe60a702635.tar.gz |
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.
Diffstat (limited to 'lib/libarchive')
-rw-r--r-- | lib/libarchive/archive.h | 30 | ||||
-rw-r--r-- | lib/libarchive/archive.h.in | 30 | ||||
-rw-r--r-- | 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 6f052f9..d374eec 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 <sys/types.h> /* Linux requires this for off_t */ #include <inttypes.h> /* For int64_t */ #include <unistd.h> /* 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 6f052f9..d374eec 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 <sys/types.h> /* Linux requires this for off_t */ #include <inttypes.h> /* For int64_t */ #include <unistd.h> /* 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 065a8fe..2a44498 100644 --- a/lib/libarchive/archive_util.c +++ b/lib/libarchive/archive_util.c @@ -35,6 +35,24 @@ __FBSDID("$FreeBSD$"); #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) { return (a->archive_error_number); |