]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
liblib: Added str_to_time()
authorTimo Sirainen <tss@iki.fi>
Thu, 8 Dec 2011 07:28:54 +0000 (09:28 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 8 Dec 2011 07:28:54 +0000 (09:28 +0200)
src/lib/strnum.c
src/lib/strnum.h

index 2eb16e9ed409f559135cbab469beef52fba4b41c..1edea2cb1d7ea225178e1d882fe65c6f1e327b5c 100644 (file)
@@ -233,6 +233,17 @@ int str_to_uoff(const char *str, uoff_t *num_r)
        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;
index cd56de03f95ccf7c122d3df6084eba015403a0f2..703286da652ed1f94cbd4085c8cc7b49f77a90d3 100644 (file)
@@ -24,6 +24,7 @@ int str_to_uid(const char *str, uid_t *num_r) ATTR_WARN_UNUSED_RESULT;
 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);