Blame lib/xstrtol.h

Packit Service fdd496
/* A more useful interface to strtol.
Packit Service fdd496
Packit Service fdd496
   Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2017 Free Software
Packit Service fdd496
   Foundation, Inc.
Packit Service fdd496
Packit Service fdd496
   This program is free software: you can redistribute it and/or modify
Packit Service fdd496
   it under the terms of the GNU General Public License as published by
Packit Service fdd496
   the Free Software Foundation; either version 3 of the License, or
Packit Service fdd496
   (at your option) any later version.
Packit Service fdd496
Packit Service fdd496
   This program is distributed in the hope that it will be useful,
Packit Service fdd496
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fdd496
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service fdd496
   GNU General Public License for more details.
Packit Service fdd496
Packit Service fdd496
   You should have received a copy of the GNU General Public License
Packit Service fdd496
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit Service fdd496
Packit Service fdd496
#ifndef XSTRTOL_H_
Packit Service fdd496
# define XSTRTOL_H_ 1
Packit Service fdd496
Packit Service fdd496
# include <getopt.h>
Packit Service fdd496
# include <inttypes.h>
Packit Service fdd496
Packit Service fdd496
# ifndef _STRTOL_ERROR
Packit Service fdd496
enum strtol_error
Packit Service fdd496
  {
Packit Service fdd496
    LONGINT_OK = 0,
Packit Service fdd496
Packit Service fdd496
    /* These two values can be ORed together, to indicate that both
Packit Service fdd496
       errors occurred.  */
Packit Service fdd496
    LONGINT_OVERFLOW = 1,
Packit Service fdd496
    LONGINT_INVALID_SUFFIX_CHAR = 2,
Packit Service fdd496
Packit Service fdd496
    LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR
Packit Service fdd496
                                                 | LONGINT_OVERFLOW),
Packit Service fdd496
    LONGINT_INVALID = 4
Packit Service fdd496
  };
Packit Service fdd496
typedef enum strtol_error strtol_error;
Packit Service fdd496
# endif
Packit Service fdd496
Packit Service fdd496
# define _DECLARE_XSTRTOL(name, type) \
Packit Service fdd496
  strtol_error name (const char *, char **, int, type *, const char *);
Packit Service fdd496
_DECLARE_XSTRTOL (xstrtol, long int)
Packit Service fdd496
_DECLARE_XSTRTOL (xstrtoul, unsigned long int)
Packit Service fdd496
_DECLARE_XSTRTOL (xstrtoimax, intmax_t)
Packit Service fdd496
_DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
Packit Service fdd496
Packit Service fdd496
#if HAVE_LONG_LONG_INT
Packit Service fdd496
_DECLARE_XSTRTOL (xstrtoll, long long int)
Packit Service fdd496
_DECLARE_XSTRTOL (xstrtoull, unsigned long long int)
Packit Service fdd496
#endif
Packit Service fdd496
Packit Service fdd496
/* Report an error for an invalid integer in an option argument.
Packit Service fdd496
Packit Service fdd496
   ERR is the error code returned by one of the xstrto* functions.
Packit Service fdd496
Packit Service fdd496
   Use OPT_IDX to decide whether to print the short option string "C"
Packit Service fdd496
   or "-C" or a long option string derived from LONG_OPTION.  OPT_IDX
Packit Service fdd496
   is -2 if the short option "C" was used, without any leading "-"; it
Packit Service fdd496
   is -1 if the short option "-C" was used; otherwise it is an index
Packit Service fdd496
   into LONG_OPTIONS, which should have a name preceded by two '-'
Packit Service fdd496
   characters.
Packit Service fdd496
Packit Service fdd496
   ARG is the option-argument containing the integer.
Packit Service fdd496
Packit Service fdd496
   After reporting an error, exit with a failure status.  */
Packit Service fdd496
Packit Service fdd496
_Noreturn void xstrtol_fatal (enum strtol_error,
Packit Service fdd496
                              int, char, struct option const *,
Packit Service fdd496
                              char const *);
Packit Service fdd496
Packit Service fdd496
#endif /* not XSTRTOL_H_ */