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 <equinox@diac24.net>
This commit is contained in:
David Lamparter 2020-04-28 15:19:24 +02:00
parent 131879fb92
commit feb06e7a93
3 changed files with 9 additions and 1 deletions

View File

@ -239,7 +239,11 @@ struct cmd_node {
.attr = attrs, \ .attr = attrs, \
.daemon = dnum, \ .daemon = dnum, \
.name = #cmdname, \ .name = #cmdname, \
}; .xref = XREF_INIT(XREFT_DEFUN, NULL, #funcname), \
}; \
XREF_LINK(cmdname.xref); \
/* end */
#define DEFUN_CMD_FUNC_DECL(funcname) \ #define DEFUN_CMD_FUNC_DECL(funcname) \
static int funcname(const struct cmd_element *, struct vty *, int, \ static int funcname(const struct cmd_element *, struct vty *, int, \

View File

@ -31,6 +31,7 @@
#include "memory.h" #include "memory.h"
#include "vector.h" #include "vector.h"
#include "graph.h" #include "graph.h"
#include "xref.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -105,6 +106,7 @@ struct cmd_element {
struct cmd_token *[]); struct cmd_token *[]);
const char *name; /* symbol name for debugging */ const char *name; /* symbol name for debugging */
struct xref xref;
}; };
/* text for <cr> command */ /* text for <cr> command */

View File

@ -29,6 +29,8 @@ enum xref_type {
XREFT_THREADSCHED = 0x100, XREFT_THREADSCHED = 0x100,
XREFT_LOGMSG = 0x200, XREFT_LOGMSG = 0x200,
XREFT_DEFUN = 0x300,
}; };
/* struct xref is the "const" part; struct xrefdata is the writable part. */ /* struct xref is the "const" part; struct xrefdata is the writable part. */