ifconfig: add glue for specifying functions taking static string parameter
Reviewed by: hselasky, jhb, kp Sponsored by: NVIDIA Networking MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D32551
This commit is contained in:
parent
7aecd12d9c
commit
42d5cb0927
@ -991,6 +991,8 @@ top:
|
||||
p->c_name);
|
||||
p->c_u.c_func2(argv[1], argv[2], s, afp);
|
||||
argc -= 2, argv += 2;
|
||||
} else if (p->c_parameter == SPARAM && p->c_u.c_func3) {
|
||||
p->c_u.c_func3(*argv, p->c_sparameter, s, afp);
|
||||
} else if (p->c_u.c_func)
|
||||
p->c_u.c_func(*argv, p->c_parameter, s, afp);
|
||||
argc--, argv++;
|
||||
|
@ -48,6 +48,8 @@ struct cmd;
|
||||
typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp);
|
||||
typedef void c_func2(const char *arg1, const char *arg2, int s,
|
||||
const struct afswtch *afp);
|
||||
typedef void c_func3(const char *cmd, const char *arg, int s,
|
||||
const struct afswtch *afp);
|
||||
|
||||
struct cmd {
|
||||
const char *c_name;
|
||||
@ -55,9 +57,12 @@ struct cmd {
|
||||
#define NEXTARG 0xffffff /* has following arg */
|
||||
#define NEXTARG2 0xfffffe /* has 2 following args */
|
||||
#define OPTARG 0xfffffd /* has optional following arg */
|
||||
#define SPARAM 0xfffffc /* parameter is string c_sparameter */
|
||||
const char *c_sparameter;
|
||||
union {
|
||||
c_func *c_func;
|
||||
c_func2 *c_func2;
|
||||
c_func3 *c_func3;
|
||||
} c_u;
|
||||
int c_iscloneop;
|
||||
struct cmd *c_next;
|
||||
@ -81,7 +86,7 @@ void callback_register(callback_func *, void *);
|
||||
.c_parameter = (param), \
|
||||
.c_u = { .c_func = (func) }, \
|
||||
.c_iscloneop = 0, \
|
||||
.c_next = NULL,
|
||||
.c_next = NULL, \
|
||||
}
|
||||
#define DEF_CMD_ARG(name, func) { \
|
||||
.c_name = (name), \
|
||||
@ -104,6 +109,14 @@ void callback_register(callback_func *, void *);
|
||||
.c_iscloneop = 0, \
|
||||
.c_next = NULL, \
|
||||
}
|
||||
#define DEF_CMD_SARG(name, sparam, func) { \
|
||||
.c_name = (name), \
|
||||
.c_parameter = SPARAM, \
|
||||
.c_sparameter = (sparam), \
|
||||
.c_u = { .c_func3 = (func) }, \
|
||||
.c_iscloneop = 0, \
|
||||
.c_next = NULL, \
|
||||
}
|
||||
#define DEF_CLONE_CMD(name, param, func) { \
|
||||
.c_name = (name), \
|
||||
.c_parameter = (param), \
|
||||
|
Loading…
x
Reference in New Issue
Block a user