Annotation of embedaddon/lrzsz/lib/xstrtol.h, revision 1.1
1.1 ! misho 1: #ifndef _xstrtol_h_
! 2: #define _xstrtol_h_ 1
! 3:
! 4: #if STRING_TO_UNSIGNED
! 5: # define __xstrtol xstrtoul
! 6: # define __strtol strtoul
! 7: # define __unsigned unsigned
! 8: # define __ZLONG_MAX ULONG_MAX
! 9: #else
! 10: # define __xstrtol xstrtol
! 11: # define __strtol strtol
! 12: # define __unsigned /* empty */
! 13: # define __ZLONG_MAX LONG_MAX
! 14: #endif
! 15:
! 16: #undef __P
! 17: #if defined (__STDC__) && __STDC__
! 18: #define __P(x) x
! 19: #else
! 20: #define __P(x) ()
! 21: #endif
! 22:
! 23: enum strtol_error
! 24: {
! 25: LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW
! 26: };
! 27: typedef enum strtol_error strtol_error;
! 28:
! 29: strtol_error
! 30: __xstrtol __P ((const char *s, char **ptr, int base,
! 31: __unsigned long int *val, const char *valid_suffixes));
! 32:
! 33: #define _STRTOL_ERROR(exit_code, str, argument_type_string, err) \
! 34: do \
! 35: { \
! 36: switch ((err)) \
! 37: { \
! 38: case LONGINT_OK: \
! 39: abort (); \
! 40: \
! 41: case LONGINT_INVALID: \
! 42: error ((exit_code), 0, "invalid %s `%s'", \
! 43: (argument_type_string), (str)); \
! 44: break; \
! 45: \
! 46: case LONGINT_INVALID_SUFFIX_CHAR: \
! 47: error ((exit_code), 0, "invalid character following %s `%s'", \
! 48: (argument_type_string), (str)); \
! 49: break; \
! 50: \
! 51: case LONGINT_OVERFLOW: \
! 52: /* FIXME: make this message dependent on STRING_TO_UNSIGNED */\
! 53: error ((exit_code), 0, "%s `%s' larger than maximum long int",\
! 54: (argument_type_string), (str)); \
! 55: break; \
! 56: } \
! 57: } \
! 58: while (0)
! 59:
! 60: #define STRTOL_FATAL_ERROR(str, argument_type_string, err) \
! 61: _STRTOL_ERROR (2, str, argument_type_string, err)
! 62:
! 63: #define STRTOL_FAIL_WARN(str, argument_type_string, err) \
! 64: _STRTOL_ERROR (0, str, argument_type_string, err)
! 65:
! 66: #endif /* _xstrtol_h_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>