[asterisk-dev] RFC: internal CLI changes

Kevin P. Fleming kpfleming at digium.com
Tue Nov 14 15:32:39 MST 2006


Luigi Rizzo wrote:
> In the patch attached, i am trying to address the issue by putting
> all the implementation of a cli command in a single function, in a
> way that is backward compatible so that we can slowly upgrade
> commands from the old to the new format. The patch involves two
> files (include/asterisk/cli.h and main/cli.c), and there is at the
> end an example on how a new-format handler can be implemented.

I agree with the concept whole-heartedly, and would include extending it
to support telling the CLI how many (maximum) arguments the command can
take, and minimum as well, to eliminate much of the argc checking in the
command handlers.

However, I very much don't like this implementation... you've gone
through a lot of machinations to keep the command handler prototype the
way it is now, including non-obvious casting of char * to int, using
negative array indexes and other weirdness... Can you describe why you
think this is better than just changing the prototype for command
handlers to contain all the right arguments and return type, and
offering a new type of 'struct ast_cli_entry' which new handlers can
use? Granted, the codebase will have to support both old and new
structures for some time as CLI commands are upgraded, but if the
changes are straightforward, that problem won't exist for very long.


More information about the asterisk-dev mailing list