#include #include "foodopts.h" int get_foodopt(int argc, char *const argv[], const char *optstring, const struct foodoption *longopts, int *longindex) { return getopt_long(argc, argv, optstring, (struct option *)longopts, longindex); } void foodopt_help(char * argv0, const struct foodoption *longopts) { fprintf(stderr, "%s [OPTION ...] FILE ...\n", argv0); fprintf(stderr, "\nOPTIONS:\n"); int i = 0; while ((longopts[i].name) && (longopts[i].val)) { fprintf(stderr, "-%c, --%s%s%s: %s\n", longopts[i].val, longopts[i].name, longopts[i].has_arg == required_argument ? " " : "", longopts[i].has_arg == required_argument ? longopts[i].arg : "", longopts[i].help); i++; } }