lib-event.c revision 68f5234e8c0a79b72546e1b1013aae4b86f394a4
/* Copyright (c) 2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "lib-event-private.h"
#include "event-filter.h"
#include "array.h"
#include "llist.h"
#include "str.h"
#include "strescape.h"
#include "ioloop.h"
enum event_code {
EVENT_CODE_ALWAYS_LOG_SOURCE = 'a',
EVENT_CODE_CATEGORY = 'c',
EVENT_CODE_TV_LAST_SENT = 'l',
EVENT_CODE_SENDING_NAME = 'n',
EVENT_CODE_SOURCE = 's',
EVENT_CODE_FIELD_INTMAX = 'I',
EVENT_CODE_FIELD_STR = 'S',
EVENT_CODE_FIELD_TIMEVAL = 'T',
};
extern const struct event_passthrough event_passthrough_vfuncs;
static uint64_t event_id_counter = 0;
static struct event *last_passthrough_event(void)
{
return container_of(event_last_passthrough,
struct event, event_passthrough);
}
{
}
unsigned int source_linenum)
{
}
return event;
}
struct event_passthrough *
unsigned int source_linenum)
{
if (!parent->passthrough) {
if (event_last_passthrough != NULL) {
/* API is being used in a wrong or dangerous way */
i_panic("Can't create multiple passthrough events - finish the earlier with ->event()");
}
/* This event only intends to extend the parent event.
Use the parent's creation timestamp. */
} else {
}
return event_last_passthrough;
}
static bool
{
event_callback_t *const *callbackp;
bool ret;
T_BEGIN {
} T_END;
if (!ret) {
/* event sending was stopped */
return FALSE;
}
}
return TRUE;
}
{
return event;
}
{
/* the args are empty and not used for anything, but there doesn't seem
to be any nice and standard way of passing an initialized va_list
as a parameter without va_start(). */
}
{
return;
return;
if (last_passthrough_event() == event)
}
struct event *events_get_head(void)
{
return events;
}
{
if (current_global_event != NULL) {
if (!array_is_created(&global_event_stack))
}
return event;
}
{
if (!array_is_created(&global_event_stack) ||
array_count(&global_event_stack) == 0)
else {
unsigned int event_count;
i_assert(event_count > 0);
}
return current_global_event;
}
struct event *event_get_global(void)
{
return current_global_event;
}
static struct event *
{
/* allocate the first log prefix from the pool */
} else {
/* log prefix is being updated multiple times -
switch to system pool so we don't keep leaking memory */
else
}
return event;
}
struct event *
{
}
{
}
struct event *
{
return event;
}
struct event *
unsigned int linenum, bool literal_fname)
{
return event;
}
{
return event;
}
{
struct event_category *const *catp;
return *catp;
}
return NULL;
}
struct event_category *const *
event_get_registered_categories(unsigned int *count_r)
{
}
{
event_category_callback_t *const *callbackp;
if (category->registered)
return;
/* register parent categories first */
} T_END;
}
static bool
{
struct event_category *const *categoryp;
return TRUE;
}
return FALSE;
}
struct event *
struct event_category *const *categories)
{
for (unsigned int i = 0; categories[i] != NULL; i++) {
}
return event;
}
struct event *
{
}
static struct event_field *
{
struct event_field *field;
return NULL;
return field;
}
return NULL;
}
const struct event_field *
{
return field;
}
const char *
{
const struct event_field *field;
return NULL;
switch (field->value_type) {
}
i_unreached();
}
static struct event_field *
{
struct event_field *field;
}
return field;
}
struct event *
{
struct event_field *field;
return event;
}
struct event *
{
struct event_field *field;
return event;
}
struct event *
{
struct event_field *field;
return event;
}
struct event *
const struct event_add_field *fields)
{
else
}
return event;
}
{
}
{
}
{
}
const struct event_field *
{
*count_r = 0;
return NULL;
}
}
struct event_category *const *
{
*count_r = 0;
return NULL;
}
}
{
}
}
{
/* if the event is sent again, it needs a new name */
if (event->passthrough)
event_unref(&event);
}
static void
{
switch (field->value_type) {
break;
break;
break;
}
}
{
/* required fields: */
/* optional fields: */
}
if (event->always_log_source) {
}
}
}
struct event_category *const *catp;
}
}
const struct event_field *field;
}
}
}
{
}
{
unsigned int usecs;
*error_r = "Invalid timeval seconds parameter";
return FALSE;
}
*error_r = "Timeval missing microseconds parameter";
return FALSE;
}
*error_r = "Invalid timeval microseconds parameter";
return FALSE;
}
return TRUE;
}
const char **error_r)
{
const char *error;
/* required fields: */
*error_r = "Missing required fields";
return FALSE;
}
return FALSE;
}
args += 2;
/* optional fields: */
arg++;
switch (code) {
break;
case EVENT_CODE_CATEGORY: {
struct event_category *category =
return FALSE;
}
break;
}
case EVENT_CODE_TV_LAST_SENT:
return FALSE;
}
args++;
break;
case EVENT_CODE_SENDING_NAME:
break;
case EVENT_CODE_SOURCE:
*error_r = "Source line number missing";
return FALSE;
}
*error_r = "Invalid Source line number";
return FALSE;
}
args++;
break;
case EVENT_CODE_FIELD_INTMAX:
case EVENT_CODE_FIELD_STR:
case EVENT_CODE_FIELD_TIMEVAL: {
struct event_field *field =
*error_r = "Field value is missing";
return FALSE;
}
args++;
switch (code) {
case EVENT_CODE_FIELD_INTMAX:
"Invalid field value '%s' number for '%s'",
return FALSE;
}
break;
case EVENT_CODE_FIELD_STR:
break;
case EVENT_CODE_FIELD_TIMEVAL:
"Field '%s' value '%s': %s",
return FALSE;
}
args++;
break;
default:
i_unreached();
}
break;
}
}
args++;
}
return TRUE;
}
{
}
{
event_callback_t *const *callbackp;
return;
}
}
i_unreached();
}
{
}
{
event_category_callback_t *const *callbackp;
return;
}
}
i_unreached();
}
{
struct event_category *const *catp;
return;
}
}
i_unreached();
}
{
event_category_callback_t *const *callbackp;
if (!category->registered) {
/* it was never registered in the first place - ignore */
return;
}
} T_END;
}
static struct event_passthrough *
event_passthrough_set_append_log_prefix(const char *prefix)
{
return event_last_passthrough;
}
static struct event_passthrough *
event_passthrough_replace_log_prefix(const char *prefix)
{
return event_last_passthrough;
}
static struct event_passthrough *
event_passthrough_set_name(const char *name)
{
return event_last_passthrough;
}
static struct event_passthrough *
event_passthrough_set_source(const char *filename,
unsigned int linenum, bool literal_fname)
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event_passthrough *
{
return event_last_passthrough;
}
static struct event *event_passthrough_event(void)
{
return event;
}
const struct event_passthrough event_passthrough_vfuncs = {
};
void lib_event_init(void)
{
}
void lib_event_deinit(void)
{
i_warning("Event %p leaked (parent=%p): %s:%u",
}
}