[1.5] Create a new cmake option to choose between convienient copy of getopt and...
[openjpeg.git] / applications / common / opj_getopt.h
1 /* last review : october 29th, 2002 */
2
3 #include "opj_config.h"
4
5 #ifndef _GETOPT_H_
6 #define _GETOPT_H_
7
8 typedef struct opj_option
9 {
10         const char *name;
11         int has_arg;
12         int *flag;
13         int val;
14 } opj_option_t;
15
16 #define NO_ARG  0
17 #define REQ_ARG 1
18 #define OPT_ARG 2
19
20 #ifdef USE_SYSTEM_GETOPT
21 #include <getopt.h>
22
23 #define opj_opterr opterr
24 #define opj_optind optind
25 #define opj_optopt optopt
26 #define opj_optreset optreset
27 #define opj_optarg optarg
28
29 #define opj_getopt getopt
30 #define opj_getopt_long getopt_long
31
32 #else
33 extern int opj_opterr;
34 extern int opj_optind;
35 extern int opj_optopt;
36 extern int opj_optreset;
37 extern char *opj_optarg;
38
39 extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
40 extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
41                         const opj_option_t *longopts, int totlen);
42 extern void reset_options_reading(void);
43
44 #endif /* USE_SYSTEM_GETOPT */
45 #endif                          /* _GETOPT_H_ */