From feb06e7a93af3642d23cad951e2eaf544025f64a Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 28 Apr 2020 15:19:24 +0200 Subject: [PATCH] lib/xref: add xrefs for DEFUNs This allows grabbing a list of all DEFUNs and their help texts through the xref extraction mechanics. Signed-off-by: David Lamparter --- lib/command.h | 6 +++++- lib/command_graph.h | 2 ++ lib/xref.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/command.h b/lib/command.h index b002e79f09..6acaa450c2 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, \ diff --git a/lib/command_graph.h b/lib/command_graph.h index 179e104a57..09824460e6 100644 --- a/lib/command_graph.h +++ b/lib/command_graph.h @@ -31,6 +31,7 @@ #include "memory.h" #include "vector.h" #include "graph.h" +#include "xref.h" #ifdef __cplusplus extern "C" { @@ -105,6 +106,7 @@ struct cmd_element { struct cmd_token *[]); const char *name; /* symbol name for debugging */ + struct xref xref; }; /* text for command */ diff --git a/lib/xref.h b/lib/xref.h index 9b5bcffc01..29c68820fd 100644 --- a/lib/xref.h +++ b/lib/xref.h @@ -29,6 +29,8 @@ enum xref_type { XREFT_THREADSCHED = 0x100, XREFT_LOGMSG = 0x200, + + XREFT_DEFUN = 0x300, }; /* struct xref is the "const" part; struct xrefdata is the writable part. */