summaryrefslogtreecommitdiffstats
path: root/include/cli_classic.h
blob: e651cc636a2cb4d5ab380d5251a4c0fa8c7b0eee (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
/*
 * This file is part of the flashrom project.
 *
 * This program 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 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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.
 */

#ifndef CLI_CLASSIC_H
#define CLI_CLASSIC_H

#if __has_include(<getopt.h>)
#include <getopt.h>
#else

#define	no_argument		0
#define required_argument	1
#define optional_argument	2

extern char *optarg;
extern int optind, opterr, optopt;

struct option {
  const char *name;
  int has_arg;
  int *flag;
  int val;
};

int getopt (int argc, char *const *argv, const char *shortopts);
int getopt_long (int argc, char *const *argv, const char *shortopts,
			const struct option *longopts, int *longind);
int getopt_long_only (int argc, char *const *argv, const char *shortopts,
			const struct option *longopts, int *longind);

#endif /* __has_include() */
#endif /* CLI_CLASSIC_H */