[asterisk-dev] RFC: internal CLI changes

Luigi Rizzo rizzo at icir.org
Wed Nov 15 16:44:42 MST 2006


On Wed, Nov 15, 2006 at 02:10:57PM -0600, Kevin P. Fleming wrote:
> Luigi Rizzo wrote:
> > I am afraid the e = argv[-1] trick is probably something that we need
> > to keep for a while to help old-style handlers, but that is a relatively
> > straightforward, and hopefully sufficiently documented to avoid confusion.
> 
> Why do we need this for old style handlers? They never needed access to
> their own 'struct ast_cli_entry *' before, and if their code is updated
> to use it, then they can be converted to the new prototype as well.

well... consider that most of the breakage now is due to wrong indexes
in argc/argv checks. when you have a broken entry where you have to
replace 3-4 indexes, it is straightforward (almost mechanical) to
replace things like

	if (argc < 3) ...

with

	struct ast_cli_entry *e = (struct ast_cli_entry *)argv[-1];

	if (argc < e->args) ...

but it is slightly more time consuming to locate the usage string,
the _complete() function and the handler, put them in one place and
adapt the interface.


> Also, I don't see the value in using typedef to make types for
> 'old_cli_fn' and 'new_cli_fn'... those typedefs are only useful in
> places where you want pointers to them, you can't actually use them in
> declaring the handler functions (or even their prototypes, as far as I
> know). Unless you are planning on having a reasonable amount of code in
> cli.c that is going to be using copies of handler function pointers, the
> typedefs won't add any value.

i know, they are probably going away. I wasn't sure at the beginning
if i neede to cast back and forth.

	cheers
	luigi


More information about the asterisk-dev mailing list