actf 0.0.1
An acute CTF reader
Loading...
Searching...
No Matches
/home/adwe/code/actf/event_generator.h File Reference

Event generator API. More...

#include <stdint.h>
#include "event.h"

Go to the source code of this file.

Data Structures

struct  actf_event_generator
 An event generator. More...

Macros

#define ACTF_DEFAULT_EVS_CAP   64
 The default capacity of an event array.

Typedefs

typedef int(* actf_event_generate) (void *self, actf_event ***evs, size_t *evs_len)
 Generate events.
typedef int(* actf_seek_ns_from_origin) (void *self, int64_t tstamp)
 Seek to the specified timestamp in the event stream.
typedef const char *(* actf_last_error) (void *self)
 Get the last error message of a generator function.

Functions

actf_event ** actf_event_arr_alloc (size_t evs_cap)
 Allocate an event array with provided capacity.
void actf_event_arr_free (actf_event **evs)
 Free an event array.

Detailed Description

Event generator API.

Event generators are the basic building blocks of actf that are hooked together to produce events, combine generators or perform filtering on events.

Macro Definition Documentation

◆ ACTF_DEFAULT_EVS_CAP

#define ACTF_DEFAULT_EVS_CAP   64

The default capacity of an event array.

Napkin math for 32 data stream files:

  • 40 bytes per actf_fld
  • 16 fields per message allocated up front
  • 40 * 16 = 640 bytes per event allocated per data stream file
  • 640 * 32 data stream = 20480 bytes per event for 32 data stream files
  • 20480 * 64 = 1310720 bytes = 1280 K = 1.25 M total for 32 data stream files each having 64 events per buffer

Typedef Documentation

◆ actf_event_generate

typedef int(* actf_event_generate) (void *self, actf_event ***evs, size_t *evs_len)

Generate events.

A generator will write events up to its event capacity and provide a pointer to the array holding them. An actf_event_generate() must not return both events and an error code. On error, any valid events should be returned and then on the next call, the error is returned.

The generator owns the events and any returned events (or their fields) are invalid after the next actf_event_generate() call.

Parameters
selfthe generator's self parameter
evsa pointer to be populated with an event array
evs_lena pointer to be populated with the number of events in the event array
Returns
ACTF_OK on success or an error code. On error, see actf_last_error().

◆ actf_seek_ns_from_origin

typedef int(* actf_seek_ns_from_origin) (void *self, int64_t tstamp)

Seek to the specified timestamp in the event stream.

Any events previously returned by an actf_event_generate() are invalid after calling this.

Parameters
selfthe generator's self parameter
tstampthe nanosecond from origin timestamp to seek to
Returns
ACTF_OK on success or an error code. On error, see actf_last_error().

◆ actf_last_error

typedef const char *(* actf_last_error) (void *self)

Get the last error message of a generator function.

A failing generator function can store the most recent error and return it through this function. The returned string is handled internally, should not be freed, and might be overwritten or freed on subsequent API calls.

Parameters
selfthe generator's self parameter
Returns
the last error message or NULL

Function Documentation

◆ actf_event_arr_alloc()

actf_event ** actf_event_arr_alloc ( size_t evs_cap)

Allocate an event array with provided capacity.

Parameters
evs_capthe event capacity
Returns
an event array or NULL with errno set. A returned array should be freed with actf_event_arr_free().

◆ actf_event_arr_free()

void actf_event_arr_free ( actf_event ** evs)

Free an event array.

Parameters
evsthe event array