static bool decode_time (struct timespec *ts, char const *arg, char const *keyword) { switch (_decode_time (ts, arg, keyword)) { case decode_time_success: return true; case decode_time_bad_header: ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), keyword, arg)); return false; case decode_time_range: out_of_range_header (keyword, arg, - (uintmax_t) TYPE_MINIMUM (time_t), TYPE_MAXIMUM (time_t)); return false; } return true; }
static bool decode_time (struct timespec *ts, char const *arg, char const *keyword) { char *arg_lim; struct timespec t = decode_timespec (arg, &arg_lim, true); if (! valid_timespec (t)) { if (arg < arg_lim && !*arg_lim) out_of_range_header (keyword, arg, TYPE_MINIMUM (time_t), TYPE_MAXIMUM (time_t)); else ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), keyword, arg)); return false; } *ts = t; return true; }
static bool decode_signed_num (intmax_t *num, char const *arg, intmax_t minval, uintmax_t maxval, char const *keyword) { char *arg_lim; intmax_t u = strtosysint (arg, &arg_lim, minval, maxval); if (errno == EINVAL || *arg_lim) { ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), keyword, arg)); return false; } if (errno == ERANGE) { out_of_range_header (keyword, arg, minval, maxval); return false; } *num = u; return true; }
static bool decode_num (uintmax_t *num, char const *arg, uintmax_t maxval, char const *keyword) { uintmax_t u; char *arg_lim; if (! (ISDIGIT (*arg) && (errno = 0, u = strtoumax (arg, &arg_lim, 10), !*arg_lim))) { ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), keyword, arg)); return false; } if (! (u <= maxval && errno != ERANGE)) { out_of_range_header (keyword, arg, 0, maxval); return false; } *num = u; return true; }