]> git.cworth.org Git - tar/blob - gnu/xstrtol.h
upstream: Fix extraction of device nodes.
[tar] / gnu / xstrtol.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A more useful interface to strtol.
4
5    Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2010 Free Software
6    Foundation, Inc.
7
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21 #ifndef XSTRTOL_H_
22 # define XSTRTOL_H_ 1
23
24 # include <getopt.h>
25 # include <inttypes.h>
26
27 # ifndef _STRTOL_ERROR
28 enum strtol_error
29   {
30     LONGINT_OK = 0,
31
32     /* These two values can be ORed together, to indicate that both
33        errors occurred.  */
34     LONGINT_OVERFLOW = 1,
35     LONGINT_INVALID_SUFFIX_CHAR = 2,
36
37     LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR
38                                                  | LONGINT_OVERFLOW),
39     LONGINT_INVALID = 4
40   };
41 typedef enum strtol_error strtol_error;
42 # endif
43
44 # define _DECLARE_XSTRTOL(name, type) \
45   strtol_error name (const char *, char **, int, type *, const char *);
46 _DECLARE_XSTRTOL (xstrtol, long int)
47 _DECLARE_XSTRTOL (xstrtoul, unsigned long int)
48 _DECLARE_XSTRTOL (xstrtoimax, intmax_t)
49 _DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
50
51 #if HAVE_LONG_LONG_INT
52 _DECLARE_XSTRTOL (xstrtoll, long long int)
53 _DECLARE_XSTRTOL (xstrtoull, unsigned long long int)
54 #endif
55
56 #ifndef __attribute__
57 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
58 #  define __attribute__(x)
59 # endif
60 #endif
61
62 #ifndef ATTRIBUTE_NORETURN
63 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
64 #endif
65
66 /* Report an error for an invalid integer in an option argument.
67
68    ERR is the error code returned by one of the xstrto* functions.
69
70    Use OPT_IDX to decide whether to print the short option string "C"
71    or "-C" or a long option string derived from LONG_OPTION.  OPT_IDX
72    is -2 if the short option "C" was used, without any leading "-"; it
73    is -1 if the short option "-C" was used; otherwise it is an index
74    into LONG_OPTIONS, which should have a name preceded by two '-'
75    characters.
76
77    ARG is the option-argument containing the integer.
78
79    After reporting an error, exit with a failure status.  */
80
81 void xstrtol_fatal (enum strtol_error,
82                     int, char, struct option const *,
83                     char const *) ATTRIBUTE_NORETURN;
84
85 #endif /* not XSTRTOL_H_ */