[Bro-Dev] #859: to_double bif
Bro Tracker
bro at tracker.bro-ids.org
Tue Jul 24 12:04:03 PDT 2012
#859: to_double bif
------------------------+-----------------------------
Reporter: scampbell | Type: Feature Request
Status: new | Priority: Normal
Milestone: Bro2.1 | Component: Bro
Version: git/master | Keywords: bif
------------------------+-----------------------------
It would be quite useful to include a to_double bif as the new input
framework makes this sort of thing much more common when digesting logs.
sample code:
## Converts a :bro:type:`string` to a :bro:type:`double`.
##
## str: The :bro:type:`string` to convert.
##
## Returns: The :bro:type:`string` *str* as double, or 0 if *str* has
## an invalid format.
##
function to_double%(str: string%): count
%{
const char* s = str->CheckString();
char* end_s;
double d = (double) strtod(s, &end_s);
if ( s[0] == '\0' || end_s[0] != '\0' )
{
builtin_error("bad conversion to count", @ARG@[0]);
d = 0;
}
return new Val(d, TYPE_DOUBLE);
%}
--
Ticket URL: <http://tracker.bro-ids.org/bro/ticket/859>
Bro Tracker <http://tracker.bro-ids.org/bro>
Bro Issue Tracker
More information about the bro-dev
mailing list