2020-07-24 09:07:19 +00:00
|
|
|
/*
|
|
|
|
* cmd/multicall.h
|
|
|
|
* Purpose: structures for multicall frontend
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020 Ariadne Conill <ariadne@dereferenced.org>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* This software is provided 'as is' and without any warranty, express or
|
|
|
|
* implied. In no event shall the authors be liable for any damages arising
|
|
|
|
* from the use of this software.
|
|
|
|
*/
|
|
|
|
|
2020-08-12 04:07:32 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2020-07-24 09:07:19 +00:00
|
|
|
#ifndef IFUPDOWN_CMD_MULTICALL_H__GUARD
|
|
|
|
#define IFUPDOWN_CMD_MULTICALL_H__GUARD
|
|
|
|
|
|
|
|
#include "libifupdown/libifupdown.h"
|
|
|
|
|
2020-08-12 04:07:32 +00:00
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
|
|
|
|
|
|
|
|
struct if_applet;
|
|
|
|
|
|
|
|
struct if_option {
|
|
|
|
char short_opt;
|
|
|
|
const char *long_opt;
|
2020-08-12 04:37:36 +00:00
|
|
|
const char *long_opt_desc;
|
2020-08-12 04:07:32 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2020-07-24 09:07:19 +00:00
|
|
|
struct if_applet {
|
|
|
|
const char *name;
|
2020-08-12 04:07:32 +00:00
|
|
|
const char *desc;
|
2020-07-24 09:07:19 +00:00
|
|
|
int (*const main)(int argc, char *argv[]);
|
2020-08-12 02:44:04 +00:00
|
|
|
void (*const usage)(int status);
|
2020-08-12 04:07:32 +00:00
|
|
|
const struct if_option_group *groups[4];
|
2020-07-24 09:07:19 +00:00
|
|
|
};
|
|
|
|
|
2020-07-24 10:52:15 +00:00
|
|
|
extern char *argv0;
|
2020-08-12 04:37:36 +00:00
|
|
|
extern const struct if_applet *self_applet;
|
2020-08-12 04:07:32 +00:00
|
|
|
extern struct if_option_group global_option_group;
|
2020-07-24 10:52:15 +00:00
|
|
|
|
2020-08-12 04:12:37 +00:00
|
|
|
struct match_options {
|
|
|
|
bool is_auto;
|
2020-08-12 04:37:36 +00:00
|
|
|
const char *exclude_pattern;
|
|
|
|
const char *include_pattern;
|
2020-08-12 04:12:37 +00:00
|
|
|
bool pretty_print;
|
|
|
|
bool dot;
|
2020-08-12 04:37:36 +00:00
|
|
|
const char *property;
|
2020-08-12 04:12:37 +00:00
|
|
|
};
|
|
|
|
|
2020-08-12 04:37:36 +00:00
|
|
|
extern struct match_options match_opts;
|
|
|
|
|
2020-08-12 04:15:52 +00:00
|
|
|
extern void process_options(const struct if_applet *applet, int argc, char *argv[]);
|
|
|
|
extern const struct if_option *lookup_option(const struct if_applet *applet, int opt);
|
|
|
|
|
2020-08-12 04:37:36 +00:00
|
|
|
extern struct if_option_group match_option_group;
|
|
|
|
|
2020-07-24 09:07:19 +00:00
|
|
|
#endif
|