server/telnet: fix autocomplete for jimtcl commands
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 27 May 2021 13:25:43 +0000 (15:25 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 4 Jun 2021 16:41:09 +0000 (17:41 +0100)
commitfad1eaaa42ad5a52d1d9e38b1e94ab027fad5b24
treece5fc1020f22bf2b0f6b2e63940d016b6f9a31ff
parent9e7b31479ba7100f41a5b88b32571cf765cdb3ee
server/telnet: fix autocomplete for jimtcl commands

Current autocomplete filters-out some command reported by "info
commands". One of the filter rule concerns the command's private
data.
Every command registered by OpenOCD has its 'struct command' as
private data.

By ignoring commands without private data, we loose several TCL
commands registered by jimtcl, e.g. 'foreach', 'llength'.

By assuming that every command with non-NULL private data has
'struct command' as private data, we risk at best to access
inconsistent data, at worst to trigger a segmentation fault.

Export the already available functions:
- to check if a command has been registered by OpenOCD and
- to get the private data.
While there, rename jimcmd_is_ocd_command() as
jimcmd_is_oocd_command().
Don't filter-out jimtcl commands with no private data.
Check the private data only on OpenOCD commands.

Change-Id: Ib5bf8d2bc5c12440c0cfae438f637c38724a79b7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6282
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
src/helper/command.c
src/helper/command.h
src/server/telnet_server.c