Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

xstrtol.h

Go to the documentation of this file.
00001 #ifndef XSTRTOL_H_
00002 # define XSTRTOL_H_ 1
00003 
00004 # if HAVE_INTTYPES_H
00005 #  include <inttypes.h> /* for uintmax_t */
00006 # endif
00007 
00008 # ifndef PARAMS
00009 #  if defined PROTOTYPES || (defined __STDC__ && __STDC__)
00010 #   define PARAMS(Args) Args
00011 #  else
00012 #   define PARAMS(Args) ()
00013 #  endif
00014 # endif
00015 
00016 # ifndef _STRTOL_ERROR
00017 enum strtol_error
00018   {
00019     LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW
00020   };
00021 typedef enum strtol_error strtol_error;
00022 # endif
00023 
00024 # define _DECLARE_XSTRTOL(name, type) \
00025   strtol_error \
00026     name PARAMS ((const char *s, char **ptr, int base, \
00027         type *val, const char *valid_suffixes));
00028 _DECLARE_XSTRTOL (xstrtol, long int)
00029 _DECLARE_XSTRTOL (xstrtoul, unsigned long int)
00030 _DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
00031 
00032 # define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
00033   do                          \
00034     {                         \
00035       switch ((Err))                   \
00036    {                       \
00037    case LONGINT_OK:                 \
00038      abort ();                   \
00039                            \
00040    case LONGINT_INVALID:                  \
00041      error ((Exit_code), 0, "invalid %s `%s'",        \
00042        (Argument_type_string), (Str));       \
00043      break;                   \
00044                            \
00045    case LONGINT_INVALID_SUFFIX_CHAR:            \
00046      error ((Exit_code), 0, "invalid character following %s `%s'",   \
00047        (Argument_type_string), (Str));       \
00048      break;                   \
00049                            \
00050    case LONGINT_OVERFLOW:                 \
00051      error ((Exit_code), 0, "%s `%s' too large",         \
00052        (Argument_type_string), (Str));       \
00053      break;                   \
00054    }                       \
00055     }                         \
00056   while (0)
00057 
00058 # define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err)    \
00059   _STRTOL_ERROR (2, Str, Argument_type_string, Err)
00060 
00061 # define STRTOL_FAIL_WARN(Str, Argument_type_string, Err)      \
00062   _STRTOL_ERROR (0, Str, Argument_type_string, Err)
00063 
00064 #endif /* not XSTRTOL_H_ */

Generated on Mon Apr 7 19:41:47 2003 for DuTree by doxygen1.2.18