The simple_filter macro must accept the two different levels of
contexts. In the same way, it should also accept the log level, and
therefore replace the now removed simple_filter_log_level macro.
Threads are a bad idea because for now the filter API is not guaranteed
to be state-less. The interface is now synchronous, which should be
enough for most filters.
The refactoring brought other changes, the most important being the
concept of modular input sources and output destination and the complete
rewrite of the procedural macro.
The main goal of events/reports is to update a context object, which
will be used in filters to generate a response. It is now possible to
use any object implementing both Clone and Default as a context object.
It is also possible to define no context at all.
Many filters requires to keep a state within a session. Although it not
currently possible to do so, the callback now accept a mutable object of
type NoContext. This is the first step, the next one will be to accept
any type that implements both Clone and Default.
An other step will be to allow the user to define different callback
parameters depending on his/her needs.
The construction of an EventHandler object should not be directly done
by the client. Instead, it is easier to use procedural macro to
automatize the process, hence exposing a nice and simple interface. Such
use of procedural macros requires to crate an additional crate.
The timestamp comes from OpenBSD's struct timeval, which defines the
number of seconds as a time_t (i64) and the number of micro-seconds as a
suseconds_t (long, hence i64 too). They are separated by a dot.
https://man.openbsd.org/gettimeofday.2
The latest OpenSMTPD draft added the timeout event, it therefore has
been added to the parser. As shown in the new sessions examples, the
timestamp format changed and the parameters are also optional.
The previous design did not handled errors correctly and was kind of
spaghetti code. With the new one, the reader and the dispatcher are
clearly separated. The filter will only exit on an error from the reader
or if EOF has been reached, any other error is displayed but does not
exit the filter, which is required by the API. If the filter must exit,
all threads are gracefully stopped.