File: multicall.h

package info (click to toggle)
ifupdown-ng 0.12.1-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 964 kB
  • sloc: ansic: 3,572; sh: 980; makefile: 233
file content (79 lines) | stat: -rw-r--r-- 2,052 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * 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.
 */

#include <stdbool.h>

#ifndef IFUPDOWN_CMD_MULTICALL_H__GUARD
#define IFUPDOWN_CMD_MULTICALL_H__GUARD

#include "libifupdown/libifupdown.h"

struct if_applet;

struct if_option {
	char short_opt;
	const char *long_opt;
	const char *long_opt_desc;
	const char *desc;
	bool require_argument;
	void (*const handle)(const char *opt_arg);
};

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;
	const char *usage;
	const char *manpage;
	int (*const main)(int argc, char *argv[]);
	const struct if_option_group *groups[16];
};

extern char *argv0;
extern const struct if_applet *self_applet;
extern struct if_option_group global_option_group;

struct match_options {
	bool is_auto;
	const char *exclude_pattern;
	const char *include_pattern;
	bool pretty_print;
	bool dot;
	const char *property;
};

extern struct match_options match_opts;

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);

extern struct if_option_group match_option_group;

extern struct lif_execute_opts exec_opts;
extern struct if_option_group exec_option_group;

extern void applet_register(struct if_applet *applet);

void generic_usage(const struct if_applet *applet, int result);

#define APPLET_REGISTER(x) \
__attribute__((constructor)) static void __register_##x(void) { applet_register(&x); }

#endif