Debian Codegraph @

tipc/cmdl.h

raw
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * cmdl.h Framework for handling command line options.
4 *
5 * Authors: Richard Alpe <[email protected]>
6 */
7
8 #ifndef _TIPC_CMDL_H
9 #define _TIPC_CMDL_H
10
11 #include <libmnl/libmnl.h>
12
13 extern int help_flag;
14
15 enum {
16 OPT_KEY = (1 << 0),
17 OPT_KEYVAL = (1 << 1),
18 };
19
20 struct cmdl {
21 int optind;
22 int argc;
23 char **argv;
24 };
25
26 struct tipc_sup_media {
27 char *media;
28 char *identifier;
29 void (*help)(struct cmdl *cmdl, char *media);
30 };
31
32 struct cmd {
33 const char *cmd;
34 int (*func)(struct nlmsghdr *nlh, const struct cmd *cmd,
35 struct cmdl *cmdl, void *data);
36 void (*help)(struct cmdl *cmdl);
37 };
38
39 struct opt {
40 const char *key;
41 uint16_t flag;
42 char *val;
43 };
44
45 struct opt *find_opt(struct opt *opts, char *str);
46 struct opt *get_opt(struct opt *opts, char *key);
47 bool has_opt(struct opt *opts, char *key);
48 int parse_opts(struct opt *opts, struct cmdl *cmdl);
49 char *shift_cmdl(struct cmdl *cmdl);
50
51 int run_cmd(struct nlmsghdr *nlh, const struct cmd *caller,
52 const struct cmd *cmds, struct cmdl *cmdl, void *data);
53
54 #endif