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.
This commit is contained in:
Tim Kientzle 2004-07-24 20:08:26 +00:00
parent db7edb3137
commit c48a83413a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132609
3 changed files with 66 additions and 12 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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)
{