summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_util.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2008-03-14 22:31:57 +0000
committerkientzle <kientzle@FreeBSD.org>2008-03-14 22:31:57 +0000
commit474ea5abd8ad2fd82dfdc8707cab3058ca4dd365 (patch)
treeed7a21dbba4563b3af9187e2b437ef359e0068b1 /lib/libarchive/archive_util.c
parent495bb86033ae683e026e5205c813adf0d605b862 (diff)
downloadFreeBSD-src-474ea5abd8ad2fd82dfdc8707cab3058ca4dd365.zip
FreeBSD-src-474ea5abd8ad2fd82dfdc8707cab3058ca4dd365.tar.gz
Rework the versioning implementation and test to match the
new interface. Mark the functions that are going away in libarchive 3.0. In particular, archive_version_string() now computes the string rather than assuming that it will be created by the build infrastructure. Eventually, this will allow some simplification of the build infrastructure.
Diffstat (limited to 'lib/libarchive/archive_util.c')
-rw-r--r--lib/libarchive/archive_util.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/lib/libarchive/archive_util.c b/lib/libarchive/archive_util.c
index e80cabb..cad14f4 100644
--- a/lib/libarchive/archive_util.c
+++ b/lib/libarchive/archive_util.c
@@ -38,29 +38,71 @@ __FBSDID("$FreeBSD$");
#include "archive.h"
#include "archive_private.h"
+#include "archive_string.h"
+#if ARCHIVE_VERSION_NUMBER < 3000000
+/* These disappear in libarchive 3.0 */
+/* Deprecated. */
int
archive_api_feature(void)
{
return (ARCHIVE_API_FEATURE);
}
+/* Deprecated. */
int
archive_api_version(void)
{
return (ARCHIVE_API_VERSION);
}
+/* Deprecated synonym for archive_version_number() */
int
archive_version_stamp(void)
{
- return (ARCHIVE_VERSION_STAMP);
+ return (archive_version_number());
}
+/* Deprecated synonym for archive_version_string() */
const char *
archive_version(void)
{
- return (ARCHIVE_LIBRARY_VERSION);
+ return (archive_version_string());
+}
+#endif
+
+int
+archive_version_number(void)
+{
+ return (ARCHIVE_VERSION_NUMBER);
+}
+
+/*
+ * Format a version string of the form "libarchive x.y.z", where x, y,
+ * z are the correct parts of the version ID from
+ * archive_version_number().
+ *
+ * I used to do all of this at build time in shell scripts but that
+ * proved to be a portability headache.
+ */
+
+const char *
+archive_version_string(void)
+{
+ static char buff[128];
+ struct archive_string as;
+ int n;
+
+ if (buff[0] == '\0') {
+ n = archive_version_number();
+ memset(&as, 0, sizeof(as));
+ archive_string_sprintf(&as, "libarchive %d.%d.%d",
+ n / 1000000, (n / 1000) % 1000, n % 1000);
+ strncpy(buff, as.s, sizeof(buff));
+ buff[sizeof(buff) - 1] = '\0';
+ archive_string_free(&as);
+ }
+ return (buff);
}
int
OpenPOWER on IntegriCloud