7a4afb160999540f9a659eb505ec9e68ba54e9a5
[platform/upstream/bash.git] / builtins / getopt.h
1 /* Declarations for getopt.
2    Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify it
5    under the terms of the GNU General Public License as published by the
6    Free Software Foundation; either version 2, or (at your option) any
7    later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.  */
17
18 /* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */
19
20 #ifndef _SH_GETOPT_H
21 #define _SH_GETOPT_H 1
22
23 #include "stdc.h"
24
25 /* For communication from `getopt' to the caller.
26    When `getopt' finds an option that takes an argument,
27    the argument value is returned here.
28    Also, when `ordering' is RETURN_IN_ORDER,
29    each non-option ARGV-element is returned here.  */
30
31 extern char *sh_optarg;
32
33 /* Index in ARGV of the next element to be scanned.
34    This is used for communication to and from the caller
35    and for communication between successive calls to `getopt'.
36
37    On entry to `getopt', zero means this is the first call; initialize.
38
39    When `getopt' returns EOF, this is the index of the first of the
40    non-option elements that the caller should itself scan.
41
42    Otherwise, `sh_optind' communicates from one call to the next
43    how much of ARGV has been scanned so far.  */
44
45 extern int sh_optind;
46
47 /* Callers store zero here to inhibit the error message `getopt' prints
48    for unrecognized options.  */
49
50 extern int sh_opterr;
51
52 /* Set to an option character which was unrecognized.  */
53
54 extern int sh_optopt;
55
56 /* Set to 1 when an unrecognized option is encountered. */
57 extern int sh_badopt;
58
59 extern int sh_getopt __P((int, char *const *, const char *));
60 extern void sh_getopt_restore_state __P((char **));
61
62 #endif /* _SH_GETOPT_H */