]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Remove dev_t and time_t from public API in 4.0 (#2392)
authorljdarj <ljd@luigiscorner.mu>
Sat, 25 Jan 2025 18:14:42 +0000 (19:14 +0100)
committerGitHub <noreply@github.com>
Sat, 25 Jan 2025 18:14:42 +0000 (10:14 -0800)
Removing dev_t and time_t from the public include files from 4.0 on and
updating some tests in consequence.

Fixes #2279 .

libarchive/archive.h
libarchive/archive_entry.c
libarchive/archive_entry.h

index 0dfb02f9dc4b0171644fdb1ca5608b16f72418b7..2067fa80d920ee363871489b94ac66e8f9942dbc 100644 (file)
 #include <sys/stat.h>
 #include <stddef.h>  /* for wchar_t */
 #include <stdio.h> /* For FILE * */
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* time_t is slated to be removed from public includes in 4.0 */
 #include <time.h> /* For time_t */
+#endif
 
 /*
  * Note: archive.h is for use outside of libarchive; the configuration
@@ -94,6 +97,22 @@ typedef ssize_t la_ssize_t;
 # endif
 #endif
 
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* Use the platform types for time_t */
+#define __LA_TIME_T time_t
+#else
+/* Use 64-bytes integer types for time_t */
+#define __LA_TIME_T la_int64_t
+#endif
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* Use the platform types for dev_t */
+#define __LA_DEV_T dev_t
+#else
+/* Use 64-bytes integer types for dev_t */
+#define __LA_DEV_T la_int64_t
+#endif
+
 /* Large file support for Android */
 #if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
 #include "android_lf.h"
index 4ebfc5fa6323b8dbcb2f8be9d4b2858135733eb3..f20bb2efc7002f012741015ef0a7dbce678986cf 100644 (file)
@@ -275,7 +275,7 @@ archive_entry_new2(struct archive *a)
  * Functions for reading fields from an archive_entry.
  */
 
-time_t
+__LA_TIME_T
 archive_entry_atime(struct archive_entry *entry)
 {
        return (entry->ae_stat.aest_atime);
@@ -293,7 +293,7 @@ archive_entry_atime_is_set(struct archive_entry *entry)
        return (entry->ae_set & AE_SET_ATIME);
 }
 
-time_t
+__LA_TIME_T
 archive_entry_birthtime(struct archive_entry *entry)
 {
        return (entry->ae_stat.aest_birthtime);
@@ -311,7 +311,7 @@ archive_entry_birthtime_is_set(struct archive_entry *entry)
        return (entry->ae_set & AE_SET_BIRTHTIME);
 }
 
-time_t
+__LA_TIME_T
 archive_entry_ctime(struct archive_entry *entry)
 {
        return (entry->ae_stat.aest_ctime);
@@ -329,7 +329,7 @@ archive_entry_ctime_nsec(struct archive_entry *entry)
        return (entry->ae_stat.aest_ctime_nsec);
 }
 
-dev_t
+__LA_DEV_T
 archive_entry_dev(struct archive_entry *entry)
 {
        if (entry->ae_stat.aest_dev_is_broken_down)
@@ -345,7 +345,7 @@ archive_entry_dev_is_set(struct archive_entry *entry)
        return (entry->ae_set & AE_SET_DEV);
 }
 
-dev_t
+__LA_DEV_T
 archive_entry_devmajor(struct archive_entry *entry)
 {
        if (entry->ae_stat.aest_dev_is_broken_down)
@@ -354,7 +354,7 @@ archive_entry_devmajor(struct archive_entry *entry)
                return major(entry->ae_stat.aest_dev);
 }
 
-dev_t
+__LA_DEV_T
 archive_entry_devminor(struct archive_entry *entry)
 {
        if (entry->ae_stat.aest_dev_is_broken_down)
@@ -568,7 +568,7 @@ archive_entry_mode(struct archive_entry *entry)
        return (entry->acl.mode);
 }
 
-time_t
+__LA_TIME_T
 archive_entry_mtime(struct archive_entry *entry)
 {
        return (entry->ae_stat.aest_mtime);
@@ -667,7 +667,7 @@ archive_entry_rdev_is_set(struct archive_entry *entry)
        return (entry->ae_set & AE_SET_RDEV);
 }
 
-dev_t
+__LA_DEV_T
 archive_entry_rdev(struct archive_entry *entry)
 {
        if (archive_entry_rdev_is_set(entry)) {
@@ -681,7 +681,7 @@ archive_entry_rdev(struct archive_entry *entry)
        }
 }
 
-dev_t
+__LA_DEV_T
 archive_entry_rdevmajor(struct archive_entry *entry)
 {
        if (archive_entry_rdev_is_set(entry)) {
@@ -694,7 +694,7 @@ archive_entry_rdevmajor(struct archive_entry *entry)
        }
 }
 
-dev_t
+__LA_DEV_T
 archive_entry_rdevminor(struct archive_entry *entry)
 {
        if (archive_entry_rdev_is_set(entry)) {
@@ -1088,7 +1088,7 @@ _archive_entry_copy_hardlink_l(struct archive_entry *entry,
 }
 
 void
-archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns)
+archive_entry_set_atime(struct archive_entry *entry, __LA_TIME_T t, long ns)
 {
        FIX_NS(t, ns);
        entry->stat_valid = 0;
@@ -1105,7 +1105,7 @@ archive_entry_unset_atime(struct archive_entry *entry)
 }
 
 void
-archive_entry_set_birthtime(struct archive_entry *entry, time_t t, long ns)
+archive_entry_set_birthtime(struct archive_entry *entry, __LA_TIME_T t, long ns)
 {
        FIX_NS(t, ns);
        entry->stat_valid = 0;
@@ -1122,7 +1122,7 @@ archive_entry_unset_birthtime(struct archive_entry *entry)
 }
 
 void
-archive_entry_set_ctime(struct archive_entry *entry, time_t t, long ns)
+archive_entry_set_ctime(struct archive_entry *entry, __LA_TIME_T t, long ns)
 {
        FIX_NS(t, ns);
        entry->stat_valid = 0;
@@ -1139,7 +1139,7 @@ archive_entry_unset_ctime(struct archive_entry *entry)
 }
 
 void
-archive_entry_set_dev(struct archive_entry *entry, dev_t d)
+archive_entry_set_dev(struct archive_entry *entry, __LA_DEV_T d)
 {
        entry->stat_valid = 0;
        entry->ae_set |= AE_SET_DEV;
@@ -1148,7 +1148,7 @@ archive_entry_set_dev(struct archive_entry *entry, dev_t d)
 }
 
 void
-archive_entry_set_devmajor(struct archive_entry *entry, dev_t m)
+archive_entry_set_devmajor(struct archive_entry *entry, __LA_DEV_T m)
 {
        entry->stat_valid = 0;
        entry->ae_set |= AE_SET_DEV;
@@ -1157,7 +1157,7 @@ archive_entry_set_devmajor(struct archive_entry *entry, dev_t m)
 }
 
 void
-archive_entry_set_devminor(struct archive_entry *entry, dev_t m)
+archive_entry_set_devminor(struct archive_entry *entry, __LA_DEV_T m)
 {
        entry->stat_valid = 0;
        entry->ae_set |= AE_SET_DEV;
@@ -1243,7 +1243,7 @@ archive_entry_set_mode(struct archive_entry *entry, mode_t m)
 }
 
 void
-archive_entry_set_mtime(struct archive_entry *entry, time_t t, long ns)
+archive_entry_set_mtime(struct archive_entry *entry, __LA_TIME_T t, long ns)
 {
        FIX_NS(t, ns);
        entry->stat_valid = 0;
@@ -1319,7 +1319,7 @@ archive_entry_set_perm(struct archive_entry *entry, mode_t p)
 }
 
 void
-archive_entry_set_rdev(struct archive_entry *entry, dev_t m)
+archive_entry_set_rdev(struct archive_entry *entry, __LA_DEV_T m)
 {
        entry->stat_valid = 0;
        entry->ae_stat.aest_rdev = m;
@@ -1330,7 +1330,7 @@ archive_entry_set_rdev(struct archive_entry *entry, dev_t m)
 }
 
 void
-archive_entry_set_rdevmajor(struct archive_entry *entry, dev_t m)
+archive_entry_set_rdevmajor(struct archive_entry *entry, __LA_DEV_T m)
 {
        entry->stat_valid = 0;
        entry->ae_stat.aest_rdev_is_broken_down = 1;
@@ -1340,7 +1340,7 @@ archive_entry_set_rdevmajor(struct archive_entry *entry, dev_t m)
 }
 
 void
-archive_entry_set_rdevminor(struct archive_entry *entry, dev_t m)
+archive_entry_set_rdevminor(struct archive_entry *entry, __LA_DEV_T m)
 {
        entry->stat_valid = 0;
        entry->ae_stat.aest_rdev_is_broken_down = 1;
index 079233c275650644a1e3e2bd612a3b4467f63524..8a3215dccef11c9fc243a81d67cfe521c6a41756 100644 (file)
 #include <sys/types.h>
 #include <stddef.h>  /* for wchar_t */
 #include <stdint.h>
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* time_t is slated to be removed from public includes in 4.0 */
 #include <time.h>
+#endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include <windows.h>
@@ -96,6 +99,22 @@ typedef ssize_t la_ssize_t;
 # define       __LA_MODE_T     mode_t
 #endif
 
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* Use the platform types for time_t */
+#define __LA_TIME_T time_t
+#else
+/* Use 64-bytes integer types for time_t */
+#define __LA_TIME_T la_int64_t
+#endif
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* Use the platform types for dev_t */
+#define __LA_DEV_T dev_t
+#else
+/* Use 64-bytes integer types for dev_t */
+#define __LA_DEV_T la_int64_t
+#endif
+
 /* Large file support for Android */
 #if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
 #include "android_lf.h"
@@ -236,19 +255,19 @@ __LA_DECL struct archive_entry    *archive_entry_new2(struct archive *);
  * also return NULL when implicit character set conversions fail.
  * This is usually what you want.
  */
-__LA_DECL time_t        archive_entry_atime(struct archive_entry *);
+__LA_DECL __LA_TIME_T   archive_entry_atime(struct archive_entry *);
 __LA_DECL long          archive_entry_atime_nsec(struct archive_entry *);
 __LA_DECL int           archive_entry_atime_is_set(struct archive_entry *);
-__LA_DECL time_t        archive_entry_birthtime(struct archive_entry *);
+__LA_DECL __LA_TIME_T   archive_entry_birthtime(struct archive_entry *);
 __LA_DECL long          archive_entry_birthtime_nsec(struct archive_entry *);
 __LA_DECL int           archive_entry_birthtime_is_set(struct archive_entry *);
-__LA_DECL time_t        archive_entry_ctime(struct archive_entry *);
+__LA_DECL __LA_TIME_T   archive_entry_ctime(struct archive_entry *);
 __LA_DECL long          archive_entry_ctime_nsec(struct archive_entry *);
 __LA_DECL int           archive_entry_ctime_is_set(struct archive_entry *);
-__LA_DECL dev_t                 archive_entry_dev(struct archive_entry *);
+__LA_DECL __LA_DEV_T            archive_entry_dev(struct archive_entry *);
 __LA_DECL int           archive_entry_dev_is_set(struct archive_entry *);
-__LA_DECL dev_t                 archive_entry_devmajor(struct archive_entry *);
-__LA_DECL dev_t                 archive_entry_devminor(struct archive_entry *);
+__LA_DECL __LA_DEV_T            archive_entry_devmajor(struct archive_entry *);
+__LA_DECL __LA_DEV_T            archive_entry_devminor(struct archive_entry *);
 __LA_DECL __LA_MODE_T   archive_entry_filetype(struct archive_entry *);
 __LA_DECL int           archive_entry_filetype_is_set(struct archive_entry *);
 __LA_DECL void          archive_entry_fflags(struct archive_entry *,
@@ -279,9 +298,9 @@ __LA_DECL const wchar_t     *archive_entry_pathname_w(struct archive_entry *);
 __LA_DECL __LA_MODE_T   archive_entry_perm(struct archive_entry *);
 __LA_DECL int           archive_entry_perm_is_set(struct archive_entry *);
 __LA_DECL int           archive_entry_rdev_is_set(struct archive_entry *);
-__LA_DECL dev_t                 archive_entry_rdev(struct archive_entry *);
-__LA_DECL dev_t                 archive_entry_rdevmajor(struct archive_entry *);
-__LA_DECL dev_t                 archive_entry_rdevminor(struct archive_entry *);
+__LA_DECL __LA_DEV_T            archive_entry_rdev(struct archive_entry *);
+__LA_DECL __LA_DEV_T            archive_entry_rdevmajor(struct archive_entry *);
+__LA_DECL __LA_DEV_T            archive_entry_rdevminor(struct archive_entry *);
 __LA_DECL const char   *archive_entry_sourcepath(struct archive_entry *);
 __LA_DECL const wchar_t        *archive_entry_sourcepath_w(struct archive_entry *);
 __LA_DECL la_int64_t    archive_entry_size(struct archive_entry *);
@@ -310,18 +329,18 @@ __LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
  * always copied.
  */
 
-__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_set_atime(struct archive_entry *, __LA_TIME_T, long);
 __LA_DECL void  archive_entry_unset_atime(struct archive_entry *);
 #if defined(_WIN32) && !defined(__CYGWIN__)
 __LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
 #endif
-__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, __LA_TIME_T, long);
 __LA_DECL void  archive_entry_unset_birthtime(struct archive_entry *);
-__LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_set_ctime(struct archive_entry *, __LA_TIME_T, long);
 __LA_DECL void  archive_entry_unset_ctime(struct archive_entry *);
-__LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t);
-__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t);
-__LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t);
+__LA_DECL void archive_entry_set_dev(struct archive_entry *, __LA_DEV_T);
+__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, __LA_DEV_T);
+__LA_DECL void archive_entry_set_devminor(struct archive_entry *, __LA_DEV_T);
 __LA_DECL void archive_entry_set_filetype(struct archive_entry *, unsigned int);
 __LA_DECL void archive_entry_set_fflags(struct archive_entry *,
            unsigned long /* set */, unsigned long /* clear */);
@@ -352,7 +371,7 @@ __LA_DECL void      archive_entry_copy_link(struct archive_entry *, const char *);
 __LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
 __LA_DECL int  archive_entry_update_link_utf8(struct archive_entry *, const char *);
 __LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);
-__LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_set_mtime(struct archive_entry *, __LA_TIME_T, long);
 __LA_DECL void  archive_entry_unset_mtime(struct archive_entry *);
 __LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);
 __LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);
@@ -361,9 +380,9 @@ __LA_DECL void      archive_entry_copy_pathname(struct archive_entry *, const char *)
 __LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);
 __LA_DECL int  archive_entry_update_pathname_utf8(struct archive_entry *, const char *);
 __LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
-__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
-__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
-__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
+__LA_DECL void archive_entry_set_rdev(struct archive_entry *, __LA_DEV_T);
+__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, __LA_DEV_T);
+__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, __LA_DEV_T);
 __LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t);
 __LA_DECL void archive_entry_unset_size(struct archive_entry *);
 __LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);