diff options
| author | David Lamparter <equinox@diac24.net> | 2020-07-21 08:28:04 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2021-02-01 17:28:11 +0100 |
| commit | 01485adb9d07d74c0ef02f1b47cad4ce46161934 (patch) | |
| tree | 2ca1e66f04e00137d0a1d321b3f07b073ef55991 /lib/command.h | |
| parent | feb06e7a93af3642d23cad951e2eaf544025f64a (diff) | |
lib/xref: add xrefs for install_element()
Combined with the DEFUN xrefs, this means we can extract the full CLI
tree from a binary file.
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/command.h')
| -rw-r--r-- | lib/command.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/command.h b/lib/command.h index 6acaa450c2..71abb20b05 100644 --- a/lib/command.h +++ b/lib/command.h @@ -488,7 +488,29 @@ struct cmd_node { /* Prototypes. */ extern void install_node(struct cmd_node *node); extern void install_default(enum node_type); -extern void install_element(enum node_type, const struct cmd_element *); + +struct xref_install_element { + struct xref xref; + + const struct cmd_element *cmd_element; + enum node_type node_type; +}; + +#ifndef VTYSH_EXTRACT_PL +#define install_element(node_type_, cmd_element_) do { \ + static const struct xref_install_element _xref \ + __attribute__((used)) = { \ + .xref = XREF_INIT(XREFT_INSTALL_ELEMENT, NULL, \ + __func__), \ + .cmd_element = cmd_element_, \ + .node_type = node_type_, \ + }; \ + XREF_LINK(_xref.xref); \ + _install_element(node_type_, cmd_element_); \ + } while (0) +#endif + +extern void _install_element(enum node_type, const struct cmd_element *); /* known issue with uninstall_element: changes to cmd_token->attr (i.e. * deprecated/hidden) are not reversed. */ |
