File: getopt.h

package info (click to toggle)
bash 4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 36,372 kB
  • sloc: ansic: 103,485; sh: 7,655; yacc: 5,214; makefile: 4,357; perl: 4,227; asm: 48; awk: 23; sed: 16
file content (82 lines) | stat: -rw-r--r-- 2,582 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* getopt.h - declarations for getopt. */

/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2008,2009 Free Software Foundation, Inc.

   This file is part of GNU Bash, the Bourne Again SHell.

   Bash is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   Bash is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
*/

/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */

#ifndef _SH_GETOPT_H
#define _SH_GETOPT_H 1

#include "stdc.h"

/* For communication from `getopt' to the caller.
   When `getopt' finds an option that takes an argument,
   the argument value is returned here.
   Also, when `ordering' is RETURN_IN_ORDER,
   each non-option ARGV-element is returned here.  */

extern char *sh_optarg;

/* Index in ARGV of the next element to be scanned.
   This is used for communication to and from the caller
   and for communication between successive calls to `getopt'.

   On entry to `getopt', zero means this is the first call; initialize.

   When `getopt' returns EOF, this is the index of the first of the
   non-option elements that the caller should itself scan.

   Otherwise, `sh_optind' communicates from one call to the next
   how much of ARGV has been scanned so far.  */

extern int sh_optind;

/* Callers store zero here to inhibit the error message `getopt' prints
   for unrecognized options.  */

extern int sh_opterr;

/* Set to an option character which was unrecognized.  */

extern int sh_optopt;

/* Set to 1 when an unrecognized option is encountered. */
extern int sh_badopt;

extern int sh_getopt __P((int, char *const *, const char *));

typedef struct sh_getopt_state
{
  char *gs_optarg;
  int gs_optind;
  int gs_curopt;
  char *gs_nextchar;
  int gs_charindex;
  int gs_flags;
} sh_getopt_state_t;

extern void sh_getopt_restore_state __P((char **));

extern sh_getopt_state_t *sh_getopt_alloc_istate __P((void));
extern void sh_getopt_dispose_istate __P((sh_getopt_state_t *));

extern sh_getopt_state_t *sh_getopt_save_istate __P((void));
extern void sh_getopt_restore_istate __P((sh_getopt_state_t *));

#endif /* _SH_GETOPT_H */