dovecot-2.1: liblib: Added str_to_time()

dovecot at dovecot.org dovecot at dovecot.org
Thu Dec 8 09:36:49 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/d9acfebce2c9
changeset: 13825:d9acfebce2c9
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Dec 08 09:28:54 2011 +0200
description:
liblib: Added str_to_time()

diffstat:

 src/lib/strnum.c |  11 +++++++++++
 src/lib/strnum.h |   1 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diffs (32 lines):

diff -r ad58a2d5a290 -r d9acfebce2c9 src/lib/strnum.c
--- a/src/lib/strnum.c	Thu Dec 08 07:51:28 2011 +0200
+++ b/src/lib/strnum.c	Thu Dec 08 09:28:54 2011 +0200
@@ -233,6 +233,17 @@
 	return 0;
 }
 
+int str_to_time(const char *str, time_t *num_r)
+{
+	intmax_t l;
+
+	if (str_to_intmax(str, &l) < 0)
+		return -1;
+
+	*num_r = (time_t)l;
+	return 0;
+}
+
 bool str_uint_equals(const char *str, uintmax_t num)
 {
 	uintmax_t l;
diff -r ad58a2d5a290 -r d9acfebce2c9 src/lib/strnum.h
--- a/src/lib/strnum.h	Thu Dec 08 07:51:28 2011 +0200
+++ b/src/lib/strnum.h	Thu Dec 08 09:28:54 2011 +0200
@@ -24,6 +24,7 @@
 int str_to_gid(const char *str, gid_t *num_r) ATTR_WARN_UNUSED_RESULT;
 int str_to_pid(const char *str, pid_t *num_r) ATTR_WARN_UNUSED_RESULT;
 int str_to_uoff(const char *str, uoff_t *num_r) ATTR_WARN_UNUSED_RESULT;
+int str_to_time(const char *str, time_t *num_r) ATTR_WARN_UNUSED_RESULT;
 
 /* Returns TRUE if str is a valid unsigned number that equals to num. */
 bool str_uint_equals(const char *str, uintmax_t num);


More information about the dovecot-cvs mailing list