mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +00:00
many helper functions
This commit is contained in:
parent
3654060246
commit
d7a3b85fcd
6 changed files with 245 additions and 31 deletions
|
@ -32,4 +32,35 @@ bool InputReader::Init(string arg_source, int arg_num_fields,
|
|||
|
||||
void InputReader::Finish() {
|
||||
DoFinish();
|
||||
}
|
||||
}
|
||||
|
||||
bool InputReader::Update() {
|
||||
return DoUpdate();
|
||||
}
|
||||
|
||||
// stolen from logwriter
|
||||
const char* InputReader::Fmt(const char* format, ...)
|
||||
{
|
||||
if ( ! buf )
|
||||
buf = (char*) malloc(buf_len);
|
||||
|
||||
va_list al;
|
||||
va_start(al, format);
|
||||
int n = safe_vsnprintf(buf, buf_len, format, al);
|
||||
va_end(al);
|
||||
|
||||
if ( (unsigned int) n >= buf_len )
|
||||
{ // Not enough room, grow the buffer.
|
||||
buf_len = n + 32;
|
||||
buf = (char*) realloc(buf, buf_len);
|
||||
|
||||
// Is it portable to restart?
|
||||
va_start(al, format);
|
||||
n = safe_vsnprintf(buf, buf_len, format, al);
|
||||
va_end(al);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue