]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
plugins: push-notification: Reformat push-notification-events.c.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 1 Dec 2019 10:30:27 +0000 (11:30 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 6 Feb 2020 12:18:41 +0000 (12:18 +0000)
src/plugins/push-notification/push-notification-events.c

index 10c6ed9a23cbe701122a0034bfc4df2be0cd3549..c065d400db433da30abd90d42e17430d5b218f4f 100644 (file)
@@ -6,7 +6,6 @@
 #include "push-notification-drivers.h"
 #include "push-notification-events.h"
 
-
 ARRAY_TYPE(push_notification_event) push_notification_events;
 
 ARRAY_TYPE(push_notification_event) *push_notification_get_events(void)
@@ -17,93 +16,88 @@ ARRAY_TYPE(push_notification_event) *push_notification_get_events(void)
 static bool
 push_notification_event_find(const char *name, unsigned int *idx_r)
 {
-    unsigned int count, i;
-    const struct push_notification_event *const *events;
-
-    events = array_get(&push_notification_events, &count);
-    for (i = 0; i < count; i++) {
-        if (strcasecmp(events[i]->name, name) == 0) {
-            *idx_r = i;
-            return TRUE;
-        }
-    }
-
-    return FALSE;
+       unsigned int count, i;
+       const struct push_notification_event *const *events;
+
+       events = array_get(&push_notification_events, &count);
+       for (i = 0; i < count; i++) {
+               if (strcasecmp(events[i]->name, name) == 0) {
+                       *idx_r = i;
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
 }
 
 static const struct push_notification_event *
 push_notification_event_find_class(const char *driver)
 {
-    const struct push_notification_event *const *class_p;
-    unsigned int idx;
+       const struct push_notification_event *const *class_p;
+       unsigned int idx;
 
-    if (!push_notification_event_find(driver, &idx)) {
-        return NULL;
-    }
+       if (!push_notification_event_find(driver, &idx))
+               return NULL;
 
-    class_p = array_idx(&push_notification_events, idx);
+       class_p = array_idx(&push_notification_events, idx);
 
-    return *class_p;
+       return *class_p;
 }
 
-void
-push_notification_event_init(struct push_notification_driver_txn *dtxn,
-                             const char *event_name, void *config)
+void push_notification_event_init(struct push_notification_driver_txn *dtxn,
+                                 const char *event_name, void *config)
 {
-    const struct push_notification_event *event;
-    struct push_notification_event_config *ec;
-
-    if (!array_is_created(&dtxn->ptxn->events)) {
-        p_array_init(&dtxn->ptxn->events, dtxn->ptxn->pool, 4);
-    }
-
-    event = push_notification_event_find_class(event_name);
-    if (event != NULL) {
-        if ((config == NULL) &&
-            (event->init.default_config != NULL)) {
-            config = event->init.default_config();
-        }
-
-        ec = p_new(dtxn->ptxn->pool, struct push_notification_event_config, 1);
-        ec->config = config;
-        ec->event = event;
-
-        array_push_back(&dtxn->ptxn->events, &ec);
-    }
+       const struct push_notification_event *event;
+       struct push_notification_event_config *ec;
+
+       if (!array_is_created(&dtxn->ptxn->events))
+               p_array_init(&dtxn->ptxn->events, dtxn->ptxn->pool, 4);
+
+       event = push_notification_event_find_class(event_name);
+       if (event != NULL) {
+               if ((config == NULL) && (event->init.default_config != NULL)) {
+                       config = event->init.default_config();
+               }
+
+               ec = p_new(dtxn->ptxn->pool,
+                          struct push_notification_event_config, 1);
+               ec->config = config;
+               ec->event = event;
+
+               array_push_back(&dtxn->ptxn->events, &ec);
+       }
 }
 
-void push_notification_event_register
-(const struct push_notification_event *event)
+void push_notification_event_register(
+       const struct push_notification_event *event)
 {
-    unsigned int idx;
+       unsigned int idx;
 
-    if (!array_is_created(&push_notification_events)) {
-        i_array_init(&push_notification_events, 16);
-    }
+       if (!array_is_created(&push_notification_events))
+               i_array_init(&push_notification_events, 16);
 
-    if (push_notification_event_find(event->name, &idx)) {
-        i_panic("push_notification_event_register(%s): duplicate event",
-                event->name);
-    }
+       if (push_notification_event_find(event->name, &idx)) {
+               i_panic("push_notification_event_register(%s): duplicate event",
+                       event->name);
+       }
 
-    array_push_back(&push_notification_events, &event);
+       array_push_back(&push_notification_events, &event);
 }
 
-void push_notification_event_unregister
-(const struct push_notification_event *event)
+void push_notification_event_unregister(
+       const struct push_notification_event *event)
 {
-    unsigned int idx;
+       unsigned int idx;
 
-    if (!push_notification_event_find(event->name, &idx)) {
-        i_panic("push_notification_event_register(%s): unknown event",
-                event->name);
-    }
+       if (!push_notification_event_find(event->name, &idx)) {
+               i_panic("push_notification_event_register(%s): unknown event",
+                       event->name);
+       }
 
-    if (array_is_created(&push_notification_events)) {
-        array_delete(&push_notification_events, idx, 1);
+       if (array_is_created(&push_notification_events)) {
+               array_delete(&push_notification_events, idx, 1);
 
-        if (array_is_empty(&push_notification_events)) {
-            array_free(&push_notification_events);
-        }
-    }
+               if (array_is_empty(&push_notification_events))
+                       array_free(&push_notification_events);
+       }
 }