+ /* Eat any spaces in front of modifier */
+ for ( ; i<len; i++) {
+ if (!B_ISSPACE(str[i])) {
+ break;
+ }
+ }
+ mod_begin = i;
+ for ( ; i<len; i++) {
+ if (!B_ISALPHA(str[i])) {
+ break;
+ }
+ }
+ mod_end = i;
+ if (mod_len > (mod_end - mod_begin + 1)) {
+ mod_len = mod_end - mod_begin + 1;
+ }
+ Dmsg5(900, "str=%s: num_beg=%d num_end=%d mod_beg=%d mod_end=%d\n",
+ str, num_begin, num_end, mod_begin, mod_end);
+ bstrncpy(num, &str[num_begin], num_len);
+ bstrncpy(mod, &str[mod_begin], mod_len);
+ if (!is_a_number(num)) {
+ return false;
+ }
+ bstrncpy(str, &str[mod_end], len);
+ Dmsg2(900, "num=%s mod=%s\n", num, mod);
+
+ return true;
+}
+
+/*
+ * Convert a string duration to utime_t (64 bit seconds)
+ * Returns false: if error
+ true: if OK, and value stored in value
+ */
+bool duration_to_utime(char *str, utime_t *value)
+{
+ int i, mod_len;
+ double val, total = 0.0;
+ char mod_str[20];
+ char num_str[50];
+ /*
+ * The "n" = mins and months appears before minutes so that m maps
+ * to months. These "kludges" make it compatible with pre 1.31
+ * Baculas.
+ */
+ static const char *mod[] = {"n", "seconds", "months", "minutes", "mins",
+ "hours", "days", "weeks", "quarters", "years", NULL};
+ static const int32_t mult[] = {60, 1, 60*60*24*30, 60, 60,
+ 3600, 3600*24, 3600*24*7, 3600*24*91, 3600*24*365};