multicall: add support for unified option handling

This commit is contained in:
Ariadne Conill 2020-08-11 22:07:32 -06:00
parent ebd04cafda
commit b481db6c20
2 changed files with 164 additions and 2 deletions

View file

@ -13,17 +13,40 @@
* from the use of this software.
*/
#include <stdbool.h>
#ifndef IFUPDOWN_CMD_MULTICALL_H__GUARD
#define IFUPDOWN_CMD_MULTICALL_H__GUARD
#include "libifupdown/libifupdown.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
struct if_applet;
struct if_option {
char short_opt;
const char *long_opt;
const char *desc;
bool require_argument;
void (*const handle)(int short_opt, const struct if_option *opt, const char *opt_arg, const struct if_applet *applet);
};
struct if_option_group {
const char *desc;
size_t group_size;
const struct if_option *group;
};
struct if_applet {
const char *name;
const char *desc;
int (*const main)(int argc, char *argv[]);
void (*const usage)(int status);
const struct if_option_group *groups[4];
};
extern char *argv0;
extern struct if_option_group global_option_group;
#endif