diff options
author | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-12-04 10:34:02 -0500 |
---|---|---|
committer | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-12-04 10:34:02 -0500 |
commit | e797efeb476b9773b79b8ab36a70f070adfcc976 (patch) | |
tree | c0abb427342964a868aa229882f53d658611b93e | |
parent | c46ee83921d88e9d52bbf11df13835604472b970 (diff) | |
download | gmime-e797efeb476b9773b79b8ab36a70f070adfcc976.tar.gz |
Added g_mime_[certificate,signature]_get_[created,expires]64()
Returns a 64bit representation of the timestamps.
Fixes issue #68
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | gmime/gmime-certificate.c | 44 | ||||
-rw-r--r-- | gmime/gmime-certificate.h | 2 | ||||
-rw-r--r-- | gmime/gmime-signature.c | 44 | ||||
-rw-r--r-- | gmime/gmime-signature.h | 2 |
5 files changed, 89 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 4c795048..34751577 100644 --- a/configure.ac +++ b/configure.ac @@ -474,6 +474,7 @@ CFLAGS="$CFLAGS $LFS_CFLAGS" AC_CHECK_SIZEOF(ssize_t) AC_CHECK_SIZEOF(size_t) AC_CHECK_SIZEOF(off_t) +AC_CHECK_SIZEOF(time_t) CFLAGS="$CFLAGS_save" dnl Check for some network functions diff --git a/gmime/gmime-certificate.c b/gmime/gmime-certificate.c index f7d86e01..b3c2f5f2 100644 --- a/gmime/gmime-certificate.c +++ b/gmime/gmime-certificate.c @@ -557,11 +557,31 @@ g_mime_certificate_get_created (GMimeCertificate *cert) /** + * g_mime_certificate_get_created64: + * @cert: a #GMimeCertificate + * + * Get the creation date of the certificate's key. + * + * Returns: the creation date of the certificate's key or %-1 if unknown. + **/ +gint64 +g_mime_certificate_get_created64 (GMimeCertificate *cert) +{ + g_return_val_if_fail (GMIME_IS_CERTIFICATE (cert), -1); + + if (cert->created == (time_t) -1) + return -1; + + return (gint64) ((unsigned long) cert->created); +} + + +/** * g_mime_certificate_set_expires: * @cert: a #GMimeCertificate * @expires: expiration date * - * Set the expiration date of the certificate's key. + * Set the expiration date of the certificate's key. A value of %0 means the certificate never expires. **/ void g_mime_certificate_set_expires (GMimeCertificate *cert, time_t expires) @@ -576,7 +596,7 @@ g_mime_certificate_set_expires (GMimeCertificate *cert, time_t expires) * g_mime_certificate_get_expires: * @cert: a #GMimeCertificate * - * Get the expiration date of the certificate's key. + * Get the expiration date of the certificate's key. A value of %0 means the certificate never expires. * * Returns: the expiration date of the certificate's key or %-1 if unknown. **/ @@ -589,6 +609,26 @@ g_mime_certificate_get_expires (GMimeCertificate *cert) } +/** + * g_mime_certificate_get_expires64: + * @cert: a #GMimeCertificate + * + * Get the expiration date of the certificate's key. A value of %0 means the certificate never expires. + * + * Returns: the expiration date of the certificate's key or %-1 if unknown. + **/ +gint64 +g_mime_certificate_get_expires64 (GMimeCertificate *cert) +{ + g_return_val_if_fail (GMIME_IS_CERTIFICATE (cert), -1); + + if (cert->expires == (time_t) -1) + return -1; + + return (gint64) ((unsigned long) cert->expires); +} + + static void g_mime_certificate_list_class_init (GMimeCertificateListClass *klass); static void g_mime_certificate_list_init (GMimeCertificateList *list, GMimeCertificateListClass *klass); static void g_mime_certificate_list_finalize (GObject *object); diff --git a/gmime/gmime-certificate.h b/gmime/gmime-certificate.h index c5070784..bccd4dc6 100644 --- a/gmime/gmime-certificate.h +++ b/gmime/gmime-certificate.h @@ -263,9 +263,11 @@ GMimeValidity g_mime_certificate_get_id_validity (GMimeCertificate *cert); void g_mime_certificate_set_created (GMimeCertificate *cert, time_t created); time_t g_mime_certificate_get_created (GMimeCertificate *cert); +gint64 g_mime_certificate_get_created64 (GMimeCertificate *cert); void g_mime_certificate_set_expires (GMimeCertificate *cert, time_t expires); time_t g_mime_certificate_get_expires (GMimeCertificate *cert); +gint64 g_mime_certificate_get_expires64 (GMimeCertificate *cert); /** diff --git a/gmime/gmime-signature.c b/gmime/gmime-signature.c index f0239af8..c5abaed2 100644 --- a/gmime/gmime-signature.c +++ b/gmime/gmime-signature.c @@ -225,11 +225,31 @@ g_mime_signature_get_created (GMimeSignature *sig) /** + * g_mime_signature_get_created64: + * @sig: a #GMimeSignature + * + * Get the creation date of the signature. + * + * Returns: the creation date of the signature or %-1 if unknown. + **/ +gint64 +g_mime_signature_get_created64 (GMimeSignature *sig) +{ + g_return_val_if_fail (GMIME_IS_SIGNATURE (sig), -1); + + if (sig->created == (time_t) -1) + return -1; + + return (gint64) ((unsigned long) sig->created); +} + + +/** * g_mime_signature_set_expires: * @sig: a #GMimeSignature * @expires: expiration date * - * Set the expiration date of the signature. + * Set the expiration date of the signature. A value of %0 means the signature never expires. **/ void g_mime_signature_set_expires (GMimeSignature *sig, time_t expires) @@ -244,7 +264,7 @@ g_mime_signature_set_expires (GMimeSignature *sig, time_t expires) * g_mime_signature_get_expires: * @sig: a #GMimeSignature * - * Get the expiration date of the signature. + * Get the expiration date of the signature. A value of %0 means the signature never expires. * * Returns: the expiration date of the signature or %-1 if unknown. **/ @@ -257,6 +277,26 @@ g_mime_signature_get_expires (GMimeSignature *sig) } +/** + * g_mime_signature_get_expires64: + * @sig: a #GMimeSignature + * + * Get the expiration date of the signature. A value of %0 means the signature never expires. + * + * Returns: the expiration date of the signature or %-1 if unknown. + **/ +gint64 +g_mime_signature_get_expires64 (GMimeSignature *sig) +{ + g_return_val_if_fail (GMIME_IS_SIGNATURE (sig), -1); + + if (sig->expires == (time_t) -1) + return -1; + + return (gint64) ((unsigned long) sig->expires); +} + + static void g_mime_signature_list_class_init (GMimeSignatureListClass *klass); static void g_mime_signature_list_init (GMimeSignatureList *list, GMimeSignatureListClass *klass); static void g_mime_signature_list_finalize (GObject *object); diff --git a/gmime/gmime-signature.h b/gmime/gmime-signature.h index 712d5a47..506680cf 100644 --- a/gmime/gmime-signature.h +++ b/gmime/gmime-signature.h @@ -127,9 +127,11 @@ GMimeSignatureStatus g_mime_signature_get_status (GMimeSignature *sig); void g_mime_signature_set_created (GMimeSignature *sig, time_t created); time_t g_mime_signature_get_created (GMimeSignature *sig); +gint64 g_mime_signature_get_created64 (GMimeSignature *sig); void g_mime_signature_set_expires (GMimeSignature *sig, time_t expires); time_t g_mime_signature_get_expires (GMimeSignature *sig); +gint64 g_mime_signature_get_expires64 (GMimeSignature *sig); /** |