[asterisk-dev] 10787: Impossible to make optional macro arguments in AEL

Philipp Kempgen philipp.kempgen at amooma.de
Wed Jul 1 13:14:18 CDT 2009


https://issues.asterisk.org/view.php?id=10787

May I suggest to reopen that issue?
Here's an example: I have a macro
macro sip-remove-header( sipremoveheader_arg ) {
    ...
}
which calls SIPRemoveHeader() if that application exists or else
it emulates the behavior.

SIPRemoveHeader() can be called with or without an argument --
or more precisely: with an empty string as an argument.

murf: You name it: "everything is strings"
IMHO an empty string is a perfectly valid argument.
(I'm fine with implementing that as a default value for the argument
but default values are not even necessary.)

However the AEL parser does not let me call
&sip-remove-header();

("pbx_ael.c:... check_pval_item: Error: file ..., line ...:
The macro call to sip-remove-header has 0 arguments, but the macro
definition has 1 arguments")

My workaround: Trick the AEL parser by passing an empty argument:
&sip-remove-header(${});

The point is that "everything is strings" and a zero-length string
is still a string.
(IMHO strings should have to be quoted in the first place but that's
a different story.)

If there are objections then at least this e-mail serves as a
"how to pass empty/optional arguments in AEL". :-)


    Philipp Kempgen
-- 
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
Videos of the AMOOCON VoIP conference 2009 ->  http://www.amoocon.de
-- 



More information about the asterisk-dev mailing list