summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-07 17:21:47 +0200
committerDan McGee <dan@archlinux.org>2011-10-12 21:01:25 +0200
commit5f3629bea0d4beb79c6092086b46f3d73643c76d (patch)
tree77fec7e0aa39d6bca0309d0043a68d7a9698d237
parent759f435fb91a3abf64a422b53f939a774332cd8a (diff)
downloadpacman-5f3629bea0d4beb79c6092086b46f3d73643c76d.tar.gz
pacman-5f3629bea0d4beb79c6092086b46f3d73643c76d.tar.xz
Introduce alpm_time_t type
This will always be a 64-bit signed integer rather than the variable length time_t type. Dates beyond 2038 should be fully supported in the library; the frontend still lags behind because 32-bit platforms provide no localtime64() or equivalent function to convert from an epoch value to a broken down time structure. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/add.c1
-rw-r--r--lib/libalpm/alpm.h16
-rw-r--r--lib/libalpm/be_local.c9
-rw-r--r--lib/libalpm/db.h2
-rw-r--r--lib/libalpm/dload.h2
-rw-r--r--lib/libalpm/package.c10
-rw-r--r--lib/libalpm/package.h9
-rw-r--r--lib/libalpm/util.c12
-rw-r--r--lib/libalpm/util.h3
-rw-r--r--src/pacman/callback.c1
-rw-r--r--src/pacman/package.c5
-rw-r--r--src/pacman/util.c2
12 files changed, 34 insertions, 38 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 653d2bd9..9fb3b14d 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <errno.h>
-#include <time.h>
#include <string.h>
#include <limits.h>
#include <fcntl.h>
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index a93d4e3e..9fda9406 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -27,9 +27,9 @@
extern "C" {
#endif
-#include <sys/types.h> /* for off_t */
-#include <time.h> /* for time_t */
-#include <stdarg.h> /* for va_list */
+#include <inttypes.h> /* int64_t */
+#include <sys/types.h> /* off_t */
+#include <stdarg.h> /* va_list */
#include <alpm_list.h>
@@ -44,6 +44,8 @@ extern "C" {
* @{
*/
+typedef int64_t alpm_time_t;
+
/*
* Enumerations
* These ones are used in multiple contexts, so are forward-declared.
@@ -222,8 +224,8 @@ typedef struct _alpm_pgpkey_t {
char *uid;
char *name;
char *email;
- time_t created;
- time_t expires;
+ alpm_time_t created;
+ alpm_time_t expires;
} alpm_pgpkey_t;
/** Signature result. Contains the key, status, and validity of a given
@@ -754,13 +756,13 @@ const char *alpm_pkg_get_url(alpm_pkg_t *pkg);
* @param pkg a pointer to package
* @return the timestamp of the build time
*/
-time_t alpm_pkg_get_builddate(alpm_pkg_t *pkg);
+alpm_time_t alpm_pkg_get_builddate(alpm_pkg_t *pkg);
/** Returns the install timestamp of the package.
* @param pkg a pointer to package
* @return the timestamp of the install time
*/
-time_t alpm_pkg_get_installdate(alpm_pkg_t *pkg);
+alpm_time_t alpm_pkg_get_installdate(alpm_pkg_t *pkg);
/** Returns the packager's name.
* @param pkg a pointer to package
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 56cf38bb..21d27481 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -28,7 +28,6 @@
#include <stdint.h> /* intmax_t */
#include <sys/stat.h>
#include <dirent.h>
-#include <time.h>
#include <limits.h> /* PATH_MAX */
/* libalpm */
@@ -69,13 +68,13 @@ static const char *_cache_get_url(alpm_pkg_t *pkg)
return pkg->url;
}
-static time_t _cache_get_builddate(alpm_pkg_t *pkg)
+static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, 0);
return pkg->builddate;
}
-static time_t _cache_get_installdate(alpm_pkg_t *pkg)
+static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, 0);
return pkg->installdate;
@@ -794,11 +793,11 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
}
if(info->builddate) {
fprintf(fp, "%%BUILDDATE%%\n"
- "%ld\n\n", info->builddate);
+ "%jd\n\n", (intmax_t)info->builddate);
}
if(info->installdate) {
fprintf(fp, "%%INSTALLDATE%%\n"
- "%ld\n\n", info->installdate);
+ "%jd\n\n", (intmax_t)info->installdate);
}
if(info->packager) {
fprintf(fp, "%%PACKAGER%%\n"
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 224bfbeb..a1249d3e 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -22,8 +22,6 @@
#ifndef _ALPM_DB_H
#define _ALPM_DB_H
-#include <time.h>
-
/* libarchive */
#include <archive.h>
#include <archive_entry.h>
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 5442c0e2..57a69f93 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -23,8 +23,6 @@
#include "alpm_list.h"
#include "alpm.h"
-#include <time.h>
-
struct dload_payload {
alpm_handle_t *handle;
const char *tempfile_openmode;
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a5ff238f..0b0bf6e4 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -87,12 +87,12 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
* populated package structures. */
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
-static time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
-static time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; }
+static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
+static alpm_time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; }
static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager; }
static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; }
static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; }
-static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
+static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; }
static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; }
@@ -200,14 +200,14 @@ const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
return pkg->ops->get_url(pkg);
}
-time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
+alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
return pkg->ops->get_builddate(pkg);
}
-time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
+alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index eff7d898..82a83264 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -27,7 +27,6 @@
#include "config.h" /* ensure off_t is correct length */
#include <sys/types.h> /* off_t */
-#include <time.h> /* time_t */
#include "alpm.h"
#include "backup.h"
@@ -44,8 +43,8 @@
struct pkg_operations {
const char *(*get_desc) (alpm_pkg_t *);
const char *(*get_url) (alpm_pkg_t *);
- time_t (*get_builddate) (alpm_pkg_t *);
- time_t (*get_installdate) (alpm_pkg_t *);
+ alpm_time_t (*get_builddate) (alpm_pkg_t *);
+ alpm_time_t (*get_installdate) (alpm_pkg_t *);
const char *(*get_packager) (alpm_pkg_t *);
const char *(*get_arch) (alpm_pkg_t *);
off_t (*get_isize) (alpm_pkg_t *);
@@ -89,8 +88,8 @@ struct __alpm_pkg_t {
char *base64_sig;
char *arch;
- time_t builddate;
- time_t installdate;
+ alpm_time_t builddate;
+ alpm_time_t installdate;
off_t size;
off_t isize;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 243978cd..d723aee2 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -1107,7 +1107,7 @@ off_t _alpm_strtoofft(const char *line)
return (off_t)result;
}
-time_t _alpm_parsedate(const char *line)
+alpm_time_t _alpm_parsedate(const char *line)
{
char *end;
long long result;
@@ -1120,24 +1120,24 @@ time_t _alpm_parsedate(const char *line)
setlocale(LC_TIME, "C");
strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm);
setlocale(LC_TIME, "");
- return mktime(&tmp_tm);
+ return (alpm_time_t)mktime(&tmp_tm);
}
result = strtoll(line, &end, 10);
if (result == 0 && end == line) {
/* line was not a number */
errno = EINVAL;
- return (time_t)0;
+ return 0;
} else if (errno == ERANGE) {
/* line does not fit in long long */
- return (time_t)0;
+ return 0;
} else if (*end) {
/* line began with a number but has junk left over at the end */
errno = EINVAL;
- return (time_t)0;
+ return 0;
}
- return (time_t)result;
+ return (alpm_time_t)result;
}
/**
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 2a2d3a93..017bf518 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -35,7 +35,6 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h> /* size_t */
-#include <time.h>
#include <sys/stat.h> /* struct stat */
#include <archive.h> /* struct archive */
#include <math.h> /* fabs */
@@ -120,7 +119,7 @@ int _alpm_splitname(const char *target, char **name, char **version,
unsigned long *name_hash);
unsigned long _alpm_hash_sdbm(const char *str);
off_t _alpm_strtoofft(const char *line);
-time_t _alpm_parsedate(const char *line);
+alpm_time_t _alpm_parsedate(const char *line);
int _alpm_raw_cmp(const char *first, const char *second);
int _alpm_raw_ncmp(const char *first, const char *second, size_t max);
int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int amode);
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 3ba07b0c..f62d4449 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <sys/time.h>
#include <sys/types.h> /* off_t */
+#include <time.h>
#include <unistd.h>
#include <wchar.h>
#include <limits.h> /* UINT_MAX */
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 6a312f9a..84696280 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <limits.h>
#include <errno.h>
+#include <time.h>
#include <alpm.h>
#include <alpm_list.h>
@@ -74,11 +75,11 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
from = alpm_pkg_get_origin(pkg);
/* set variables here, do all output below */
- bdate = alpm_pkg_get_builddate(pkg);
+ bdate = (time_t)alpm_pkg_get_builddate(pkg);
if(bdate) {
strftime(bdatestr, 50, "%c", localtime(&bdate));
}
- idate = alpm_pkg_get_installdate(pkg);
+ idate = (time_t)alpm_pkg_get_installdate(pkg);
if(idate) {
strftime(idatestr, 50, "%c", localtime(&idate));
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 79fb54dc..ae9f881a 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -23,7 +23,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <sys/time.h>
+#include <time.h>
#include <stdio.h>
#include <stdlib.h>