This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20471 ) Change subject: vty/command: assign flags to CMD_ATTR_{IMMEDIATE,NODE_EXIT} ...................................................................... vty/command: assign flags to CMD_ATTR_{IMMEDIATE,NODE_EXIT} Change-Id: I77c1ef7ca4c667c769cc53c7ac65c3be5c7e1c86 Related: SYS#4937 --- M src/vty/command.c M tests/vty/vty_transcript_test.vty 2 files changed, 45 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/71/20471/1 diff --git a/src/vty/command.c b/src/vty/command.c index 60fb620..d0ac780 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -631,6 +631,19 @@ { 0, NULL } }; +/* Get a flag character for a global VTY command attribute */ +static char cmd_attr_get_flag(unsigned int attr) +{ + switch (attr) { + case CMD_ATTR_IMMEDIATE: + return '!'; + case CMD_ATTR_NODE_EXIT: + return '@'; + default: + return '.'; + } +} + /* Description of attributes shared between the lib commands */ static const char * const cmd_lib_attr_desc[32] = { /* [OSMO_LIBNAME_LIB_ATTR_ATTRNAME] = \ @@ -662,14 +675,20 @@ for (i = 0; i < ARRAY_SIZE(cmd_attr_desc) - 1; i++) { char *xml_att_desc; + char flag; if (~cmd->attr & cmd_attr_desc[i].value) continue; xml_att_desc = xml_escape(cmd_attr_desc[i].str); - print_func(data, " <attribute doc='%s' />%s", + print_func(data, " <attribute doc='%s'", xml_att_desc, newline); talloc_free(xml_att_desc); + + flag = cmd_attr_get_flag(cmd_attr_desc[i].value); + if (flag != '.') + print_func(data, " flag='%c'", flag); + print_func(data, " />%s", newline); } print_func(data, " </attributes>%s", newline); @@ -2965,9 +2984,12 @@ vty_out(vty, " Global attributes:%s", VTY_NEWLINE); for (i = 0; i < ARRAY_SIZE(cmd_attr_desc) - 1; i++) { + flag = cmd_attr_get_flag(cmd_attr_desc[i].value); desc = cmd_attr_desc[i].str; - flag = '.'; /* FIXME: no flags defined */ - vty_out(vty, " %c %s%s", flag, desc, VTY_NEWLINE); + + /* Skip attributes without flags */ + if (flag != '.') + vty_out(vty, " %c %s%s", flag, desc, VTY_NEWLINE); } } @@ -3076,11 +3098,21 @@ static const char *cmd_flag_mask(const struct cmd_element *cmd, unsigned int flag_mask) { - static char char_mask[VTY_CMD_USR_ATTR_NUM + 1]; + static char char_mask[VTY_CMD_USR_ATTR_NUM + 2 + 1]; char *ptr = &char_mask[0]; char flag_letter; unsigned int f; + /* Mutually exclusive global attributes */ + if (cmd->attr & CMD_ATTR_IMMEDIATE) + *(ptr++) = cmd_attr_get_flag(CMD_ATTR_IMMEDIATE); + else if (cmd->attr & CMD_ATTR_NODE_EXIT) + *(ptr++) = cmd_attr_get_flag(CMD_ATTR_NODE_EXIT); + else + *(ptr++) = '.'; + + *(ptr++) = ' '; + for (f = 0; f < VTY_CMD_USR_ATTR_NUM; f++) { if (~flag_mask & (1 << f)) continue; diff --git a/tests/vty/vty_transcript_test.vty b/tests/vty/vty_transcript_test.vty index 28edf29..b626f3d 100644 --- a/tests/vty/vty_transcript_test.vty +++ b/tests/vty/vty_transcript_test.vty @@ -87,10 +87,8 @@ vty_transcript_test> show vty-attributes Global attributes: - . This command is deprecated - . This command is hidden - . This command applies immediately - . This command applies on VTY node exit + ! This command applies immediately + @ This command applies on VTY node exit Library specific attributes: A This command applies on ASP restart Application specific attributes: @@ -115,10 +113,10 @@ vty_transcript_test(config-attr-test)# list with-flags ... - ... foo-immediate - ... foo-node-exit - u.. app-unbelievable - .m. app-magnificent - ..w app-wonderful - um. app-unbelievable-magnificent - u.w app-unbelievable-wonderful + ! ... foo-immediate + @ ... foo-node-exit + . u.. app-unbelievable + . .m. app-magnificent + . ..w app-wonderful + . um. app-unbelievable-magnificent + . u.w app-unbelievable-wonderful -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20471 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I77c1ef7ca4c667c769cc53c7ac65c3be5c7e1c86 Gerrit-Change-Number: 20471 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <vyanitskiy at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201007/dae3d0a9/attachment.htm>