1f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe/*
2f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe * cmdl.h	Framework for handling command line options.
3f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe *
4f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe *		This program is free software; you can redistribute it and/or
5f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe *		modify it under the terms of the GNU General Public License
6f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe *		as published by the Free Software Foundation; either version
7f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe *		2 of the License, or (at your option) any later version.
8f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe *
9f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe * Authors:	Richard Alpe <richard.alpe@ericsson.com>
10f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe */
11f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
12f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe#ifndef _TIPC_CMDL_H
13f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe#define _TIPC_CMDL_H
14f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
15f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe#include <libmnl/libmnl.h>
16f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
17f043759dd492897513d5aa057427bcdab8592d4bRichard Alpeextern int help_flag;
18f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
19f043759dd492897513d5aa057427bcdab8592d4bRichard Alpestruct cmdl {
20f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	int optind;
21f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	int argc;
22f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	char **argv;
23f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe};
24f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
25f043759dd492897513d5aa057427bcdab8592d4bRichard Alpestruct cmd {
26f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	const char *cmd;
27f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	int (*func)(struct nlmsghdr *nlh, const struct cmd *cmd,
28f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe		    struct cmdl *cmdl, void *data);
29f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	void (*help)(struct cmdl *cmdl);
30f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe};
31f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
32f043759dd492897513d5aa057427bcdab8592d4bRichard Alpestruct opt {
33f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	const char *key;
34f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	char *val;
35f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe};
36f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
37f043759dd492897513d5aa057427bcdab8592d4bRichard Alpestruct opt *get_opt(struct opt *opts, char *key);
38f043759dd492897513d5aa057427bcdab8592d4bRichard Alpeint parse_opts(struct opt *opts, struct cmdl *cmdl);
39f043759dd492897513d5aa057427bcdab8592d4bRichard Alpechar *shift_cmdl(struct cmdl *cmdl);
40f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
41f043759dd492897513d5aa057427bcdab8592d4bRichard Alpeint run_cmd(struct nlmsghdr *nlh, const struct cmd *caller,
42f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe	    const struct cmd *cmds, struct cmdl *cmdl, void *data);
43f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
44f043759dd492897513d5aa057427bcdab8592d4bRichard Alpeconst struct cmd *find_cmd(const struct cmd *cmds, char *str);
45f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe
46f043759dd492897513d5aa057427bcdab8592d4bRichard Alpe#endif
47