5 # include <inttypes.h> /* for uintmax_t */
9 # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
10 # define PARAMS(Args) Args
12 # define PARAMS(Args) ()
16 # ifndef _STRTOL_ERROR
19 LONGINT_OK
, LONGINT_INVALID
, LONGINT_INVALID_SUFFIX_CHAR
, LONGINT_OVERFLOW
21 typedef enum strtol_error strtol_error
;
24 # define _DECLARE_XSTRTOL(name, type) \
26 name PARAMS ((const char *s, char **ptr, int base, \
27 type *val, const char *valid_suffixes));
28 _DECLARE_XSTRTOL (xstrtol
, long int)
29 _DECLARE_XSTRTOL (xstrtoul
, unsigned long int)
30 _DECLARE_XSTRTOL (xstrtoumax
, uintmax_t)
32 # define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
40 case LONGINT_INVALID: \
41 error ((Exit_code), 0, "invalid %s `%s'", \
42 (Argument_type_string), (Str)); \
45 case LONGINT_INVALID_SUFFIX_CHAR: \
46 error ((Exit_code), 0, "invalid character following %s `%s'", \
47 (Argument_type_string), (Str)); \
50 case LONGINT_OVERFLOW: \
51 error ((Exit_code), 0, "%s `%s' too large", \
52 (Argument_type_string), (Str)); \
58 # define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \
59 _STRTOL_ERROR (2, Str, Argument_type_string, Err)
61 # define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \
62 _STRTOL_ERROR (0, Str, Argument_type_string, Err)
64 #endif /* not XSTRTOL_H_ */