]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: events - Use const event pointer for "get" functions
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 26 Apr 2020 17:15:39 +0000 (20:15 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 27 Aug 2020 06:20:16 +0000 (06:20 +0000)
src/lib/lib-event.c
src/lib/lib-event.h

index 67d1b59333115d27500990d6ed78b00c8b0f2d84..940508e391840ebe77bb791673ac981f7ef04e8f 100644 (file)
@@ -88,10 +88,11 @@ static void event_copy_parent_defaults(struct event *event,
 }
 
 static bool
-event_find_category(struct event *event, const struct event_category *category);
+event_find_category(const struct event *event,
+                   const struct event_category *category);
 
 static struct event_field *
-event_find_field_int(struct event *event, const char *key);
+event_find_field_int(const struct event *event, const char *key);
 
 static void event_set_changed(struct event *event)
 {
@@ -623,7 +624,7 @@ struct event *event_set_ptr(struct event *event, const char *key, void *value)
        return event;
 }
 
-void *event_get_ptr(struct event *event, const char *key)
+void *event_get_ptr(const struct event *event, const char *key)
 {
        const struct event_pointer *p;
 
@@ -743,7 +744,8 @@ static struct event_category *event_category_register(struct event_category *cat
 }
 
 static bool
-event_find_category(struct event *event, const struct event_category *category)
+event_find_category(const struct event *event,
+                   const struct event_category *category)
 {
        struct event_internal_category *internal = category->internal;
        struct event_category *const *categoryp;
@@ -785,7 +787,7 @@ event_add_category(struct event *event, struct event_category *category)
 }
 
 static struct event_field *
-event_find_field_int(struct event *event, const char *key)
+event_find_field_int(const struct event *event, const char *key)
 {
        struct event_field *field;
 
@@ -800,7 +802,7 @@ event_find_field_int(struct event *event, const char *key)
 }
 
 const struct event_field *
-event_find_field(struct event *event, const char *key)
+event_find_field(const struct event *event, const char *key)
 {
        const struct event_field *field = event_find_field_int(event, key);
        if (field != NULL || event->parent == NULL)
@@ -809,7 +811,7 @@ event_find_field(struct event *event, const char *key)
 }
 
 const char *
-event_find_field_str(struct event *event, const char *key)
+event_find_field_str(const struct event *event, const char *key)
 {
        const struct event_field *field;
 
@@ -922,23 +924,23 @@ void event_field_clear(struct event *event, const char *key)
        event_add_str(event, key, "");
 }
 
-struct event *event_get_parent(struct event *event)
+struct event *event_get_parent(const struct event *event)
 {
        return event->parent;
 }
 
-void event_get_create_time(struct event *event, struct timeval *tv_r)
+void event_get_create_time(const struct event *event, struct timeval *tv_r)
 {
        *tv_r = event->tv_created;
 }
 
-bool event_get_last_send_time(struct event *event, struct timeval *tv_r)
+bool event_get_last_send_time(const struct event *event, struct timeval *tv_r)
 {
        *tv_r = event->tv_last_sent;
        return tv_r->tv_sec != 0;
 }
 
-void event_get_last_duration(struct event *event, intmax_t *duration_r)
+void event_get_last_duration(const struct event *event, intmax_t *duration_r)
 {
        if (event->tv_last_sent.tv_sec == 0) {
                *duration_r = 0;
@@ -948,7 +950,7 @@ void event_get_last_duration(struct event *event, intmax_t *duration_r)
 }
 
 const struct event_field *
-event_get_fields(struct event *event, unsigned int *count_r)
+event_get_fields(const struct event *event, unsigned int *count_r)
 {
        if (!array_is_created(&event->fields)) {
                *count_r = 0;
@@ -958,7 +960,7 @@ event_get_fields(struct event *event, unsigned int *count_r)
 }
 
 struct event_category *const *
-event_get_categories(struct event *event, unsigned int *count_r)
+event_get_categories(const struct event *event, unsigned int *count_r)
 {
        if (!array_is_created(&event->categories)) {
                *count_r = 0;
index a2744c361846b4db4459927a0251d849b3455050..5bcbd3639b5f47be590d8cf3b30925af34605850 100644 (file)
@@ -247,7 +247,7 @@ enum log_type event_get_min_log_level(const struct event *event);
 struct event *event_set_ptr(struct event *event, const char *key, void *value);
 /* Return a pointer set with event_set_ptr(), or NULL if it doesn't exist.
    The pointer is looked up only from the event itself, not its parents. */
-void *event_get_ptr(struct event *event, const char *key);
+void *event_get_ptr(const struct event *event, const char *key);
 
 /* Add NULL-terminated list of categories to the event. The categories pointer
    doesn't need to stay valid afterwards, but the event_category structs
@@ -288,31 +288,32 @@ event_add_fields(struct event *event, const struct event_add_field *fields);
 void event_field_clear(struct event *event, const char *key);
 
 /* Returns the parent event, or NULL if it doesn't exist. */
-struct event *event_get_parent(struct event *event);
+struct event *event_get_parent(const struct event *event);
 /* Get the event's creation time. */
-void event_get_create_time(struct event *event, struct timeval *tv_r);
+void event_get_create_time(const struct event *event, struct timeval *tv_r);
 /* Get the time when the event was last sent. Returns TRUE if time was
    returned, FALSE if event has never been sent. */
-bool event_get_last_send_time(struct event *event, struct timeval *tv_r);
+bool event_get_last_send_time(const struct event *event, struct timeval *tv_r);
 /* Get the event duration field, calculated after event has been sent. */
-void event_get_last_duration(struct event *event, intmax_t *duration_msec_r);
+void event_get_last_duration(const struct event *event,
+                            intmax_t *duration_msec_r);
 /* Returns field for a given key, or NULL if it doesn't exist. If the key
    isn't found from the event itself, find it from parent events. */
 const struct event_field *
-event_find_field(struct event *event, const char *key);
+event_find_field(const struct event *event, const char *key);
 /* Returns the given key's value as string, or NULL if it doesn't exist.
    If the field isn't stored as a string, the result is allocated from
    data stack. */
 const char *
-event_find_field_str(struct event *event, const char *key);
+event_find_field_str(const struct event *event, const char *key);
 /* Returns all key=value fields that the event has.
    Parent events' fields aren't returned. */
 const struct event_field *
-event_get_fields(struct event *event, unsigned int *count_r);
+event_get_fields(const struct event *event, unsigned int *count_r);
 /* Return all categories that the event has.
    Parent events' categories aren't returned. */
 struct event_category *const *
-event_get_categories(struct event *event, unsigned int *count_r);
+event_get_categories(const struct event *event, unsigned int *count_r);
 
 /* Export the event into a tabescaped string, so its fields are separated
    with TABs and there are no NUL, CR or LF characters. */