summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-11-20 19:02:34 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-11-21 16:25:30 +0100
commitb251f9e8857fba284f515061ac62013519997e30 (patch)
tree8cb3501b8cb32e43496e56dd76446ba7559c7eed /ffi
parent13c437470cc7377d7b761b5bb9b8d4efb0ba385e (diff)
openpgp: Replace time crate with std::time.
- In sq and sqv, use chrono to interface with the user. - Fixes #341.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/Cargo.toml1
-rw-r--r--ffi/include/sequoia/store.h8
-rw-r--r--ffi/src/lib.rs2
-rw-r--r--ffi/src/store.rs23
4 files changed, 17 insertions, 17 deletions
diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml
index 4ca1ba41..10b80a26 100644
--- a/ffi/Cargo.toml
+++ b/ffi/Cargo.toml
@@ -33,7 +33,6 @@ libc = "0.2.33"
memsec = "0.5.6"
native-tls = "0.2.0"
nettle = "5.0"
-time = "0.1.40"
tokio-core = "0.1"
[dev-dependencies]
diff --git a/ffi/include/sequoia/store.h b/ffi/include/sequoia/store.h
index 50abc67a..38eb04d0 100644
--- a/ffi/include/sequoia/store.h
+++ b/ffi/include/sequoia/store.h
@@ -119,12 +119,12 @@ struct sq_stamps {
/*/
/// Records the time when this has been used first.
/*/
- uint64_t first;
+ time_t first;
/*/
/// Records the time when this has been used last.
/*/
- uint64_t last;
+ time_t last;
};
/*/
@@ -134,12 +134,12 @@ struct sq_stats {
/*/
/// Records the time this item was created.
/*/
- uint64_t created;
+ time_t created;
/*/
/// Records the time this item was last updated.
/*/
- uint64_t updated;
+ time_t updated;
/*/
/// Records counters and timestamps of encryptions.
diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs
index bc864f76..92cfab0d 100644
--- a/ffi/src/lib.rs
+++ b/ffi/src/lib.rs
@@ -140,6 +140,8 @@ pub(crate) use crate::openpgp::{
MoveIntoRaw,
MoveResultIntoRaw,
Maybe,
+ maybe_time,
+ to_time_t,
};
/* Error handling with implicit context. */
diff --git a/ffi/src/store.rs b/ffi/src/store.rs
index abf47962..8f273258 100644
--- a/ffi/src/store.rs
+++ b/ffi/src/store.rs
@@ -42,6 +42,7 @@ use crate::RefRaw;
use crate::MoveIntoRaw;
use crate::MoveResultIntoRaw;
use crate::Maybe;
+use crate::to_time_t;
/// Lists all mappings with the given prefix.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
@@ -159,7 +160,7 @@ fn sq_log_iter_next(iter: *mut LogIter) -> *mut Log {
};
box_raw!(Log{
- timestamp: e.timestamp.sec as u64,
+ timestamp: to_time_t(e.timestamp),
mapping: maybe_box_raw!(e.mapping),
binding: maybe_box_raw!(e.binding),
key: maybe_box_raw!(e.key),
@@ -572,20 +573,18 @@ pub struct Stamps {
pub count: u64,
/// Records the time when this has been used first.
- pub first: u64,
+ pub first: libc::time_t,
/// Records the time when this has been used last.
- pub last: u64,
+ pub last: libc::time_t,
}
impl Stamps {
fn new(s: &sequoia_store::Stamps) -> Stamps {
Stamps{
count: s.count as u64,
- first: s.first.map(|t| t.sec).unwrap_or(0)
- as u64,
- last: s.last.map(|t| t.sec).unwrap_or(0)
- as u64,
+ first: to_time_t(s.first),
+ last: to_time_t(s.last),
}
}
}
@@ -598,10 +597,10 @@ impl Stamps {
#[repr(C)]
pub struct Stats {
/// Records the time this item was created.
- pub created: u64,
+ pub created: libc::time_t,
/// Records the time this item was last updated.
- pub updated: u64,
+ pub updated: libc::time_t,
/// Records counters and timestamps of encryptions.
pub encryption: Stamps,
@@ -613,8 +612,8 @@ pub struct Stats {
impl Stats {
fn new(s: sequoia_store::Stats) -> Stats {
Stats {
- created: s.created.map(|t| t.sec).unwrap_or(0) as u64,
- updated: s.updated.map(|t| t.sec).unwrap_or(0) as u64,
+ created: to_time_t(s.created),
+ updated: to_time_t(s.updated),
encryption: Stamps::new(&s.encryption),
verification: Stamps::new(&s.verification),
}
@@ -625,7 +624,7 @@ impl Stats {
#[repr(C)]
pub struct Log {
/// Records the time of the entry.
- pub timestamp: u64,
+ pub timestamp: libc::time_t,
/// Relates the entry to a mapping.
///