summaryrefslogtreecommitdiffstats
path: root/src/foodopts.h
blob: c8b0686f0ef8f0d7cdfb579cf866d45ea0d8d1ed (plain) (blame)
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
#ifndef __FOODOPTS_H
#define __FOODOPTS_H

#include <getopt.h>

/**
 * This is a wrapper on getopt.h, specifically 
 * 
 * It provides a unified interface for defining
 * cli options, printing the help, and looping though
 * the parsing results.
 *
 */
struct foodoption {
  const char *name;
  int has_arg;
  int *flag;
  int val;
  /* Extra values */
  const char *help;
  const char *arg;
};

int
get_foodopt(int argc, char *const argv[],
            const char *optstring,
            const struct foodoption *longopts,
            int *longindex);

void
foodopt_help(char * argv0,
             const struct foodoption *longopts);


#endif /* __FOODOPTS_H */