diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-05-25 22:31:07 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-06-06 18:16:12 +0200 |
commit | 0a334343d14ee8c49f561e7e3c8def1dda93e8db (patch) | |
tree | 6a9e3a19019b7f7f4e845739d4f8d36223837389 | |
parent | vtysh: add | support (diff) | |
download | frr-0a334343d14ee8c49f561e7e3c8def1dda93e8db.tar.xz frr-0a334343d14ee8c49f561e7e3c8def1dda93e8db.zip |
*: style for | support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r-- | lib/command.c | 11 | ||||
-rw-r--r-- | lib/frrstr.c | 10 | ||||
-rw-r--r-- | lib/vector.c | 1 | ||||
-rw-r--r-- | lib/vty.c | 1 | ||||
-rw-r--r-- | vtysh/vtysh_config.c | 2 |
5 files changed, 17 insertions, 8 deletions
diff --git a/lib/command.c b/lib/command.c index c04360f28..ad0479dc9 100644 --- a/lib/command.c +++ b/lib/command.c @@ -285,7 +285,7 @@ vector cmd_make_strvec(const char *string) if (*copy == '\0' || *copy == '!' || *copy == '#') return NULL; - vector result = frrstr_split_vec(copy, " \n\r\t"); + vector result = frrstr_split_vec(copy, "\n\r\t "); for (unsigned int i = 0; i < vector_active(result); i++) { if (strlen(vector_slot(result, i)) == 0) { @@ -1163,15 +1163,15 @@ int cmd_execute_command_strict(vector vline, struct vty *vty, * The result of any processing. */ DECLARE_HOOK(cmd_execute, - (struct vty * vty, const char *cmd_in, char **cmd_out), + (struct vty *vty, const char *cmd_in, char **cmd_out), (vty, cmd_in, cmd_out)); -DEFINE_HOOK(cmd_execute, (struct vty * vty, const char *cmd_in, char **cmd_out), +DEFINE_HOOK(cmd_execute, (struct vty *vty, const char *cmd_in, char **cmd_out), (vty, cmd_in, cmd_out)); /* Hook executed after a CLI command. */ -DECLARE_KOOH(cmd_execute_done, (struct vty * vty, const char *cmd_exec), +DECLARE_KOOH(cmd_execute_done, (struct vty *vty, const char *cmd_exec), (vty, cmd_exec)); -DEFINE_KOOH(cmd_execute_done, (struct vty * vty, const char *cmd_exec), +DEFINE_KOOH(cmd_execute_done, (struct vty *vty, const char *cmd_exec), (vty, cmd_exec)); /* @@ -1198,6 +1198,7 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in, /* the remaining text should be a regexp */ char *regexp = working; bool succ = vty_set_include(vty, regexp); + if (!succ) { vty_out(vty, "%% Bad regexp '%s'", regexp); goto fail; diff --git a/lib/frrstr.c b/lib/frrstr.c index b527827b3..03368b366 100644 --- a/lib/frrstr.c +++ b/lib/frrstr.c @@ -40,6 +40,7 @@ void frrstr_split(const char *string, const char *delimiter, char ***result, *argc = 0; const char *tok = NULL; + while (copy) { tok = strsep(©, delimiter); (*result)[idx] = XSTRDUP(MTYPE_TMP, tok); @@ -50,8 +51,6 @@ void frrstr_split(const char *string, const char *delimiter, char ***result, } XFREE(MTYPE_TMP, copystart); - - return; } vector frrstr_split_vec(const char *string, const char *delimiter) @@ -62,7 +61,9 @@ vector frrstr_split_vec(const char *string, const char *delimiter) frrstr_split(string, delimiter, &result, &argc); vector v = array_to_vector((void **)result, argc); + XFREE(MTYPE_TMP, result); + return v; } @@ -85,6 +86,7 @@ char *frrstr_join(const char **parts, int argc, const char *join) for (i = 0; i < argc; i++) { size_t arglen = strlen(parts[i]); + memcpy(p, parts[i], arglen); p += arglen; if (i + 1 != argc) { @@ -115,6 +117,7 @@ char *frrstr_join_vec(vector v, const char *join) void frrstr_filter_vec(vector v, regex_t *filter) { regmatch_t ignored[1]; + for (unsigned int i = 0; i < vector_active(v); i++) { if (regexec(filter, vector_slot(v, i), 0, ignored, 0)) { XFREE(MTYPE_TMP, vector_slot(v, i)); @@ -143,9 +146,12 @@ bool begins_with(const char *str, const char *prefix) { if (!str || !prefix) return 0; + size_t lenstr = strlen(str); size_t lenprefix = strlen(prefix); + if (lenprefix > lenstr) return 0; + return strncmp(str, prefix, lenprefix) == 0; } diff --git a/lib/vector.c b/lib/vector.c index 75f6c00bd..ebac2b46e 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -192,6 +192,7 @@ void vector_to_array(vector v, void ***dest, int *argc) vector array_to_vector(void **src, int argc) { vector v = vector_init(VECTOR_MIN_SIZE); + for (int i = 0; i < argc; i++) vector_set_index(v, i, src[i]); return v; @@ -186,6 +186,7 @@ int vty_out(struct vty *vty, const char *format, ...) /* filter buffer */ if (vty->filter) { vector lines = frrstr_split_vec(buf, "\n"); + frrstr_filter_vec(lines, &vty->include); if (buf[strlen(buf) - 1] == '\n' && vector_active(lines) > 0) vector_set(lines, XSTRDUP(MTYPE_TMP, "")); diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 93210c2a7..5516d73f4 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -342,7 +342,7 @@ void vtysh_config_parse_line(void *arg, const char *line) || (I) == MPLS_NODE) /* Display configuration to file pointer. */ -void vtysh_config_dump() +void vtysh_config_dump(void) { struct listnode *node, *nnode; struct listnode *mnode, *mnnode; |