diff options
| author | Russ White <russ@riw.us> | 2021-02-02 07:44:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-02 07:44:21 -0500 |
| commit | 8f57f7413cae483fdae4c89842ddd6b0860d1b2b (patch) | |
| tree | e55d40823268ab19e83ce7e1ea4fefaa3484edad /lib/command.h | |
| parent | b449f7dc10beb872f146c52ca6545afc4e582400 (diff) | |
| parent | acbf5146a98990850679903119d42c5dfb7cdf26 (diff) | |
Merge pull request #6766 from opensourcerouting/xref
lib: xrefs - general cross-references & unique IDs
Diffstat (limited to 'lib/command.h')
| -rw-r--r-- | lib/command.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/command.h b/lib/command.h index b002e79f09..71abb20b05 100644 --- a/lib/command.h +++ b/lib/command.h @@ -239,7 +239,11 @@ struct cmd_node { .attr = attrs, \ .daemon = dnum, \ .name = #cmdname, \ - }; + .xref = XREF_INIT(XREFT_DEFUN, NULL, #funcname), \ + }; \ + XREF_LINK(cmdname.xref); \ + /* end */ + #define DEFUN_CMD_FUNC_DECL(funcname) \ static int funcname(const struct cmd_element *, struct vty *, int, \ @@ -484,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. */ |
