<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Matthew!<br>
<blockquote
cite="mid:CAN2PU+4u0rW7CspDMD00hnynBs9EWVjtAM8xJ9S-HvRkRsYccA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div><br>
</div>
<div style="">Thanks! It does need a few tweaks still, which
I'm going to try and get done next week.</div>
<div style=""><br>
</div>
<div style="">
As an FYI, we removed the JabberEvent event in Asterisk 12
for two reasons:</div>
<div style="">(1) It was spammy as all get out, and didn't
convey a lot of useful information: knowing that you
received a particular XMPP message over an AMI connection
doesn't let you do anything with it, and if you really
want that information outside of Asterisk, you should just
relay the XMPP message to an XMPP server and deal with it
there.</div>
</div>
</div>
</div>
</blockquote>
... but it is perfect to test a scanner.<br>
<blockquote
cite="mid:CAN2PU+4u0rW7CspDMD00hnynBs9EWVjtAM8xJ9S-HvRkRsYccA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div style="">(2) It isn't really AMI's job to convey
another protocol over itself. Doing so sets a rather bad
precedent (and yes, it was set for a long time, but that
doesn't mean we shouldn't correct it)</div>
</div>
</div>
</div>
</blockquote>
Yes, but a robust package must be able to deal with a lot of sh*t.<br>
<blockquote
cite="mid:CAN2PU+4u0rW7CspDMD00hnynBs9EWVjtAM8xJ9S-HvRkRsYccA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div style=""><br>
</div>
<div style="">So in 12, at least, the JabberEvent is not a
culprit in having keys with no values.</div>
</div>
</div>
</div>
</blockquote>
In that case I might write my own module that bends the rules. <span
class="moz-smiley-s1"><span> :-) </span></span>.<br>
<br>
<font color="#6600cc"><tt>...<br>
# use strong difference to exclude the trailing \r or \n
from the matched string</tt><tt><br>
</tt><tt> line = [\-_0-9A-Za-z ]+ >KEY1 @KEY3 %KEY4
@err(key_err)</tt><tt><br>
</tt><tt> ':' @SEP3 @err(sep_err)</tt><tt><br>
</tt><tt> white</tt><tt><br>
</tt><tt> ( any* -- '\r' )? >VAL1 $VAL2 %VAL4
@err(val_err)</tt><tt><br>
</tt><tt> crlf+ @CNT %RESULT
@err(term_err)</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> main := line* </tt><tt><br>
</tt><tt> ('\0' @ZERO )</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt><br>
</tt><tt> skip_line := </tt><tt><br>
</tt><tt> [^\n]* >SKIP1 $SKIP2
%SKIP4</tt><tt><br>
</tt><tt> '\n' @{ fgoto main; }</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> #write data;</tt></font><br>
<br>
Just for the the hack of it, this is the core part of my AMI
scanner. I am currently having fun with Ragel scanning these
messages. It looks a lot like flex, but it's not exactly the same.
In the background only pointers are set when things match (no
runtime lib!) and evaluated when needed. Works perfectly for cli and
gui apps. I've omitted the src of the actions when things match (but
they are simple).<br>
<br>
In case you want to allow (or somebody just did not follow the
rules) white space in front of the key this would change to:<br>
<br>
<font color="#6600cc"><tt>...<br>
# use strong difference to exclude the trailing \r or \n
from the matched string</tt><tt><br>
</tt><tt> line = </tt></font><font color="#6600cc"><tt><font
color="#6600cc"><font color="#ff0000"><b><tt>white</tt></b></font><tt><br>
</tt></font>[\-_0-9A-Za-z ]+ >KEY1
@KEY3 %KEY4 @err(key_err)</tt><tt><br>
</tt><tt> ':' @SEP3 @err(sep_err)</tt><tt><br>
</tt><tt> white</tt><tt><br>
</tt><tt> ( any* -- '\r' )? >VAL1 $VAL2 %VAL4
@err(val_err)</tt><tt><br>
</tt><tt> crlf+ @CNT %RESULT
@err(term_err)</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> main := line* </tt><tt><br>
</tt><tt> ('\0' @ZERO )</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt><br>
</tt><tt> skip_line := </tt><tt><br>
</tt><tt> [^\n]* >SKIP1 $SKIP2
%SKIP4</tt><tt><br>
</tt><tt> '\n' @{ fgoto main; }</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> #write data;</tt></font><br>
<br>
... and no backtracking at all (if you care). Error messages are
generated depending on what has been matched recently.<br>
<br>
jg<br>
</body>
</html>