1 /* HERC_GETOPT.H (c) Copyright Ivan Warren, 2003                     */
2 /*              Hercules getopt interface                            */
3 
4 #if !defined(__HERC_GETOPT_H__)
5 #    define  __HERC_GETOPT_H__
6 
7 #include "hercules.h"
8 #include "getopt.h"
9 
10 #if defined(NEED_GETOPT_OPTRESET)
11   #define OPTRESET() optreset=1
12 #else
13   #define OPTRESET()
14 #endif
15 
16 #if defined(NEED_GETOPT_WRAPPER)
17 
18   // The following series of defines end up causing the source file
19   // that happens to include "herc_getopt.h" to end up calling HERC's
20   // version of getopt instead of the normal system getopt.
21 
22   #define  getopt         herc_getopt
23   #define  optarg         herc_optarg
24   #define  optind         herc_optind
25   #define  optopt         herc_optopt
26   #define  optreset       herc_optreset
27 
28   int herc_getopt(int,char * const *,const char *);
29 
30   #if defined(HAVE_GETOPT_LONG)
31     #define  getopt_long    herc_getopt_long
32     struct option; // (fwd ref)
33     int herc_getopt_long(int,char * const *,const char *,const struct option *,int *);
34   #endif
35 
36   extern char *herc_optarg;
37   extern int   herc_optind;
38   extern int   herc_opterr;
39   extern int   herc_optopt;
40   extern int   herc_optreset;
41 
42 #endif /* defined(NEED_GETOPT_WRAPPER) */
43 
44 #endif /* __HERC_GETOPT_H__ */
45