+/* --- @strtotime@ --- *
+ *
+ * Arguments: @const char *p@ = pointer to string
+ * @struct timeval *tv@ = where to put the result
+ *
+ * Returns: ---
+ *
+ * Use: Converts a string representation of a duration into an
+ * internal version. Understands various time units.
+ */
+
+static void strtotime(const char *p, struct timeval *tv)
+{
+ char *q = (/*unconst*/ char *)p;
+ double t, i, f;
+
+ while (isspace((unsigned char)*q)) q++;
+ t = strtod(q, &q);
+ while (isspace((unsigned char)*q)) q++;
+ switch (*q) {
+ case 'd': case 'D': t *= 24;
+ case 'h': case 'H': t *= 60;
+ case 'm': case 'M': t *= 60;
+ case 's': case 'S':
+ q++;
+ while (isspace((unsigned char)*q)) q++;
+ }
+ if (*q) die(253, "bad time value `%s'", p);
+ f = modf(t, &i);
+ tv->tv_sec = i;
+ tv->tv_usec = f * 1000000;
+}
+