uncrustify as demanded.
[oweals/gnunet.git] / src / cadet / cadet_api_get_path.c
index fcc79c3d50074b6660052bcb468449f93e35ee59..0f18014c3a3af2669b6d6a6f50b9e2f8cbeb533b 100644 (file)
@@ -16,7 +16,7 @@
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
      SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
 /**
  * @file cadet/cadet_api_get_path.c
  * @brief cadet api: client implementation of cadet service
@@ -34,9 +34,7 @@
 /**
  * Operation handle.
  */
-struct GNUNET_CADET_GetPath
-{
-
+struct GNUNET_CADET_GetPath {
   /**
    * Monitor callback
    */
@@ -71,7 +69,6 @@ struct GNUNET_CADET_GetPath
    * Peer we want information about.
    */
   struct GNUNET_PeerIdentity id;
-
 };
 
 
@@ -84,24 +81,24 @@ struct GNUNET_CADET_GetPath
  *         #GNUNET_SYSERR otherwise
  */
 static int
-check_get_path (void *cls,
-                const struct GNUNET_CADET_LocalInfoPath *message)
+check_get_path(void *cls,
+               const struct GNUNET_CADET_LocalInfoPath *message)
 {
-  size_t msize = sizeof (struct GNUNET_CADET_LocalInfoPath);
+  size_t msize = sizeof(struct GNUNET_CADET_LocalInfoPath);
   size_t esize;
 
-  (void) cls;
-  esize = ntohs (message->header.size);
+  (void)cls;
+  esize = ntohs(message->header.size);
   if (esize < msize)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  if (0 != ((esize - msize) % sizeof (struct GNUNET_PeerIdentity)))
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+    {
+      GNUNET_break(0);
+      return GNUNET_SYSERR;
+    }
+  if (0 != ((esize - msize) % sizeof(struct GNUNET_PeerIdentity)))
+    {
+      GNUNET_break(0);
+      return GNUNET_SYSERR;
+    }
   return GNUNET_OK;
 }
 
@@ -113,19 +110,19 @@ check_get_path (void *cls,
  * @param message Message itself.
  */
 static void
-handle_get_path (void *cls,
-                 const struct GNUNET_CADET_LocalInfoPath *message)
+handle_get_path(void *cls,
+                const struct GNUNET_CADET_LocalInfoPath *message)
 {
   struct GNUNET_CADET_GetPath *gp = cls;
   struct GNUNET_CADET_PeerPathDetail ppd;
 
   ppd.peer = gp->id;
-  ppd.path = (const struct GNUNET_PeerIdentity *) &message[1];
-  ppd.target_offset = ntohl (message->off);
-  ppd.path_length = (ntohs (message->header.size) - sizeof (*message))
-    / sizeof (struct GNUNET_PeerIdentity);
-  gp->path_cb (gp->path_cb_cls,
-              &ppd);
+  ppd.path = (const struct GNUNET_PeerIdentity *)&message[1];
+  ppd.target_offset = ntohl(message->off);
+  ppd.path_length = (ntohs(message->header.size) - sizeof(*message))
+                    / sizeof(struct GNUNET_PeerIdentity);
+  gp->path_cb(gp->path_cb_cls,
+              &ppd);
 }
 
 
@@ -136,15 +133,15 @@ handle_get_path (void *cls,
  * @param message Message itself.
  */
 static void
-handle_get_path_end (void *cls,
-                    const struct GNUNET_MessageHeader *message)
+handle_get_path_end(void *cls,
+                    const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_CADET_GetPath *gp = cls;
 
-  (void) message;
-  gp->path_cb (gp->path_cb_cls,
-              NULL);
-  GNUNET_CADET_get_path_cancel (gp);
+  (void)message;
+  gp->path_cb(gp->path_cb_cls,
+              NULL);
+  GNUNET_CADET_get_path_cancel(gp);
 }
 
 
@@ -154,7 +151,7 @@ handle_get_path_end (void *cls,
  * @param cls a `struct GNUNET_CADET_GetPath` operation
  */
 static void
-reconnect (void *cls);
+reconnect(void *cls);
 
 
 /**
@@ -164,18 +161,18 @@ reconnect (void *cls);
  * @param error error code from MQ
  */
 static void
-error_handler (void *cls,
-              enum GNUNET_MQ_Error error)
+error_handler(void *cls,
+              enum GNUNET_MQ_Error error)
 {
   struct GNUNET_CADET_GetPath *gp = cls;
 
-  GNUNET_MQ_destroy (gp->mq);
+  GNUNET_MQ_destroy(gp->mq);
   gp->mq = NULL;
-  gp->backoff = GNUNET_TIME_randomized_backoff (gp->backoff,
-                                               GNUNET_TIME_UNIT_MINUTES);
-  gp->reconnect_task = GNUNET_SCHEDULER_add_delayed (gp->backoff,
-                                                    &reconnect,
-                                                    gp);
+  gp->backoff = GNUNET_TIME_randomized_backoff(gp->backoff,
+                                               GNUNET_TIME_UNIT_MINUTES);
+  gp->reconnect_task = GNUNET_SCHEDULER_add_delayed(gp->backoff,
+                                                    &reconnect,
+                                                    gp);
 }
 
 
@@ -185,36 +182,36 @@ error_handler (void *cls,
  * @param cls a `struct GNUNET_CADET_GetPath` operation
  */
 static void
-reconnect (void *cls)
+reconnect(void *cls)
 {
   struct GNUNET_CADET_GetPath *gp = cls;
   struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_hd_var_size (get_path,
-                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH,
-                           struct GNUNET_CADET_LocalInfoPath,
-                           gp),
-    GNUNET_MQ_hd_fixed_size (get_path_end,
-                            GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END,
-                            struct GNUNET_MessageHeader,
-                            gp),
-    GNUNET_MQ_handler_end ()
+    GNUNET_MQ_hd_var_size(get_path,
+                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH,
+                          struct GNUNET_CADET_LocalInfoPath,
+                          gp),
+    GNUNET_MQ_hd_fixed_size(get_path_end,
+                            GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END,
+                            struct GNUNET_MessageHeader,
+                            gp),
+    GNUNET_MQ_handler_end()
   };
   struct GNUNET_CADET_RequestPathInfoMessage *msg;
   struct GNUNET_MQ_Envelope *env;
 
   gp->reconnect_task = NULL;
-  gp->mq = GNUNET_CLIENT_connect (gp->cfg,
-                                 "cadet",
-                                 handlers,
-                                 &error_handler,
-                                 gp);
+  gp->mq = GNUNET_CLIENT_connect(gp->cfg,
+                                 "cadet",
+                                 handlers,
+                                 &error_handler,
+                                 gp);
   if (NULL == gp->mq)
     return;
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH);
+  env = GNUNET_MQ_msg(msg,
+                      GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH);
   msg->peer = gp->id;
-  GNUNET_MQ_send (gp->mq,
-                  env);
+  GNUNET_MQ_send(gp->mq,
+                 env);
 }
 
 
@@ -228,29 +225,29 @@ reconnect (void *cls)
  * @return NULL on error
  */
 struct GNUNET_CADET_GetPath *
-GNUNET_CADET_get_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                      const struct GNUNET_PeerIdentity *id,
-                       GNUNET_CADET_PathCB callback,
-                       void *callback_cls)
+GNUNET_CADET_get_path(const struct GNUNET_CONFIGURATION_Handle *cfg,
+                      const struct GNUNET_PeerIdentity *id,
+                      GNUNET_CADET_PathCB callback,
+                      void *callback_cls)
 {
   struct GNUNET_CADET_GetPath *gp;
 
   if (NULL == callback)
-  {
-    GNUNET_break (0);
-    return NULL;
-  }
-  gp = GNUNET_new (struct GNUNET_CADET_GetPath);
+    {
+      GNUNET_break(0);
+      return NULL;
+    }
+  gp = GNUNET_new(struct GNUNET_CADET_GetPath);
   gp->path_cb = callback;
   gp->path_cb_cls = callback_cls;
   gp->cfg = cfg;
   gp->id = *id;
-  reconnect (gp);
+  reconnect(gp);
   if (NULL == gp->mq)
-  {
-    GNUNET_free (gp);
-    return NULL;
-  }
+    {
+      GNUNET_free(gp);
+      return NULL;
+    }
   return gp;
 }
 
@@ -262,15 +259,15 @@ GNUNET_CADET_get_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
  * @return closure from #GNUNET_CADET_get_path().
  */
 void *
-GNUNET_CADET_get_path_cancel (struct GNUNET_CADET_GetPath *gp)
+GNUNET_CADET_get_path_cancel(struct GNUNET_CADET_GetPath *gp)
 {
   void *ret = gp->path_cb_cls;
 
   if (NULL != gp->mq)
-    GNUNET_MQ_destroy (gp->mq);
+    GNUNET_MQ_destroy(gp->mq);
   if (NULL != gp->reconnect_task)
-    GNUNET_SCHEDULER_cancel (gp->reconnect_task);
-  GNUNET_free (gp);
+    GNUNET_SCHEDULER_cancel(gp->reconnect_task);
+  GNUNET_free(gp);
   return ret;
 }