summaryrefslogblamecommitdiffstats
path: root/src/foodopts.h
blob: 06349a1204f60b8fd3c174a398852200002eb631 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                     







                    
                       







                                              



                                                


                                                


                         
#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;
  const char *category;
};

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

const char *
get_argument(const char opt,
             const struct foodoption *longopts);

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


#endif /* __FOODOPTS_H */