summaryrefslogtreecommitdiff
path: root/src/getopt.h
blob: 965dc29003c153658d9713333d0d37b05d3647e8 (plain)
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
#ifndef GETOPT_H
#define GETOPT_H

/* include files needed by this include file */

/* macros defined by this include file */
#define no_argument       0
#define required_argument 1
#define OPTIONAL_ARG      2

/* types defined by this include file */

/* GETOPT_LONG_OPTION_T: The type of long option */
typedef struct GETOPT_LONG_OPTION_T
{
  const char *name;             /* the name of the long option */
  int has_arg;                  /* one of the above macros */
  int *flag;                    /* determines if getopt_long() returns a
                                 * value for a long option; if it is
                                 * non-NULL, 0 is returned as a function
                                 * value and the value of val is stored in
                                 * the area pointed to by flag.  Otherwise,
                                 * val is returned. */
  int val;                      /* determines the value to return if flag is
                                 * NULL. */
} GETOPT_LONG_OPTION_T;

typedef GETOPT_LONG_OPTION_T option;

#ifdef __cplusplus
extern "C"
{
#endif

  /* externally-defined variables */
  extern char *optarg;
  extern int optind;
  extern int opterr;
  extern int optopt;

  /* function prototypes */
#ifndef _AIX
  int getopt (int argc, char **argv, char *optstring);
#endif
  int getopt_long (int argc, char **argv, const char *shortopts,
                   const GETOPT_LONG_OPTION_T * longopts, int *longind);
  int getopt_long_only (int argc, char **argv, const char *shortopts,
                        const GETOPT_LONG_OPTION_T * longopts, int *longind);

#ifdef __cplusplus
};

#endif

#endif /* GETOPT_H */

/* END OF FILE getopt.h */