]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Added str_to_ino()
authorTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2015 20:25:12 +0000 (23:25 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2015 20:25:12 +0000 (23:25 +0300)
src/lib/strnum.c
src/lib/strnum.h

index a79ce1cbcace50e86ffbf9ed84f20acd7cb9ac49..5ed2445d349013e61fd8dc9940452f6a862240e3 100644 (file)
@@ -387,6 +387,19 @@ int str_to_pid(const char *str, pid_t *num_r)
        return 0;
 }
 
+int str_to_ino(const char *str, ino_t *num_r)
+{
+       uintmax_t l;
+
+       if (str_to_uintmax(str, &l) < 0)
+               return -1;
+
+       if (verify_xid(l, sizeof(*num_r)) < 0)
+               return -1;
+       *num_r = (ino_t)l;
+       return 0;
+}
+
 int str_to_uoff(const char *str, uoff_t *num_r)
 {
        uintmax_t l;
index 3cd5cdc1bf78da40879781db7b00894b276c53bc..58de24fdd4a4c68fcc8427574e4820971a3c7e8d 100644 (file)
@@ -161,6 +161,9 @@ int str_to_gid(const char *str, gid_t *num_r)
 int str_to_pid(const char *str, pid_t *num_r)
        ATTR_WARN_UNUSED_RESULT;
 
+int str_to_ino(const char *str, ino_t *num_r)
+       ATTR_WARN_UNUSED_RESULT;
+
 int str_to_uoff(const char *str, uoff_t *num_r)
        ATTR_WARN_UNUSED_RESULT;
 int str_parse_uoff(const char *str, uoff_t *num_r,