More W32 resolver workarounds
[oweals/gnunet.git] / src / dht / gnunet-service-dht_neighbours.c
index 9085757359836b2235bce8012637666efbc56648..d89f26685b3cf51c6b9cdb848e03d85caa3d428e 100644 (file)
@@ -313,7 +313,7 @@ struct PeerInfo
   struct PeerInfo *prev;
 
   /**
-   * Count of outstanding messages for peer. 
+   * Count of outstanding messages for peer.
    */
   unsigned int pending_count;
 
@@ -438,7 +438,7 @@ static struct GNUNET_HashCode my_identity_hash;
 /**
  * Handle to CORE.
  */
-static struct GNUNET_CORE_Handle *coreAPI;
+static struct GNUNET_CORE_Handle *core_api;
 
 /**
  * Handle to ATS.
@@ -553,8 +553,8 @@ struct BloomConstructorContext
  * @return #GNUNET_YES (we should continue to iterate)
  */
 static int
-add_known_to_bloom (void *cls, 
-                   const struct GNUNET_PeerIdentity *key, 
+add_known_to_bloom (void *cls,
+                   const struct GNUNET_PeerIdentity *key,
                    void *value)
 {
   struct BloomConstructorContext *ctx = cls;
@@ -649,7 +649,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
   /* Check for connect to self message */
   if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
     return;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Connected to %s\n",
               GNUNET_i2s (peer));
   if (GNUNET_YES ==
@@ -666,7 +666,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
                      &phash);
   peer_bucket = find_bucket (&phash);
   GNUNET_assert ((peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS));
-  ret = GNUNET_malloc (sizeof (struct PeerInfo));
+  ret = GNUNET_new (struct PeerInfo);
 #if 0
   ret->latency = latency;
   ret->distance = distance;
@@ -714,7 +714,7 @@ handle_core_disconnect (void *cls,
   /* Check for disconnect from self message */
   if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
     return;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Disconnected %s\n",
               GNUNET_i2s (peer));
   to_remove =
@@ -801,7 +801,7 @@ core_transmit_notify (void *cls, size_t size, void *buf)
   if (buf == NULL)
   {
     peer->th =
-        GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO,
+        GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
                                            pending->importance,
                                            GNUNET_TIME_absolute_get_remaining
                                            (pending->timeout), &peer->id,
@@ -827,7 +827,7 @@ core_transmit_notify (void *cls, size_t size, void *buf)
   if (peer->head != NULL)
   {
     peer->th =
-        GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO,
+        GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
                                            pending->importance,
                                            GNUNET_TIME_absolute_get_remaining
                                            (pending->timeout), &peer->id, msize,
@@ -857,7 +857,7 @@ process_peer_queue (struct PeerInfo *peer)
                             ("# Bytes of bandwidth requested from core"),
                             ntohs (pending->msg->size), GNUNET_NO);
   peer->th =
-      GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO,
+      GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
                                          pending->importance,
                                          GNUNET_TIME_absolute_get_remaining
                                          (pending->timeout), &peer->id,
@@ -919,14 +919,14 @@ get_forward_count (uint32_t hop_count, uint32_t target_replication)
  * Differences in the lower bits must count stronger than differences
  * in the higher bits.
  *
- * @param target 
+ * @param target
  * @param have
  * @return 0 if have==target, otherwise a number
  *           that is larger as the distance between
  *           the two hash codes increases
  */
 static unsigned int
-get_distance (const struct GNUNET_HashCode *target, 
+get_distance (const struct GNUNET_HashCode *target,
              const struct GNUNET_HashCode *have)
 {
   unsigned int bucket;
@@ -1197,7 +1197,7 @@ get_target_peers (const struct GNUNET_HashCode *key,
   struct GNUNET_HashCode nhash;
 
   GNUNET_assert (NULL != bloom);
-  ret = get_forward_count (hop_count, target_replication);  
+  ret = get_forward_count (hop_count, target_replication);
   if (0 == ret)
   {
     *targets = NULL;
@@ -1231,7 +1231,7 @@ get_target_peers (const struct GNUNET_HashCode *key,
   *targets = rtargets;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Forwarding query `%s' to %u peers (goal was %u peers)\n",
-             GNUNET_h2s (key), 
+             GNUNET_h2s (key),
              off,
              ret);
   return off;
@@ -1601,7 +1601,7 @@ core_init (void *cls,
  *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-handle_dht_p2p_put (void *cls, 
+handle_dht_p2p_put (void *cls,
                    const struct GNUNET_PeerIdentity *peer,
                     const struct GNUNET_MessageHeader *message)
 {
@@ -1654,7 +1654,7 @@ handle_dht_p2p_put (void *cls,
 
     tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
     LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
-                 "XDHT PUT %s: %s->%s (%u, %u=>%u)\n", 
+                 "XDHT PUT %s: %s->%s (%u, %u=>%u)\n",
                  GNUNET_h2s (&put->key), GNUNET_i2s (peer), tmp,
                  ntohl(put->hop_count),
                  GNUNET_CRYPTO_hash_matching_bits (&phash, &put->key),
@@ -1913,7 +1913,7 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
 
     tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
     LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
-                 "XDHT GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n", 
+                 "XDHT GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n",
                  GNUNET_h2s (&get->key), GNUNET_i2s (peer), tmp,
                  ntohl(get->hop_count),
                  GNUNET_CRYPTO_hash_matching_bits (&phash, &get->key),
@@ -2059,7 +2059,7 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
     char *tmp;
 
     tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
-    LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT RESULT %s: %s->%s (%u)\n", 
+    LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT RESULT %s: %s->%s (%u)\n",
                  GNUNET_h2s (&prm->key), GNUNET_i2s (peer), tmp,
                  get_path_length + 1);
     GNUNET_free (tmp);
@@ -2132,10 +2132,10 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
       struct GNUNET_PeerIdentity xput_path[get_path_length + 1 + put_path_length];
 
       memcpy (xput_path, put_path, put_path_length * sizeof (struct GNUNET_PeerIdentity));
-      memcpy (&xput_path[put_path_length], 
-             xget_path, 
+      memcpy (&xput_path[put_path_length],
+             xget_path,
              get_path_length * sizeof (struct GNUNET_PeerIdentity));
-      
+
       GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
                                &prm->key,
                                get_path_length + put_path_length, xput_path,
@@ -2179,11 +2179,11 @@ GDS_NEIGHBOURS_init ()
   log_route_details_stderr =
     (NULL != getenv("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO;
   atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL);
-  coreAPI =
+  core_api =
       GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect,
                            &handle_core_disconnect, NULL, GNUNET_NO, NULL,
                            GNUNET_NO, core_handlers);
-  if (coreAPI == NULL)
+  if (core_api == NULL)
     return GNUNET_SYSERR;
   all_known_peers = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO);
   return GNUNET_OK;
@@ -2196,10 +2196,10 @@ GDS_NEIGHBOURS_init ()
 void
 GDS_NEIGHBOURS_done ()
 {
-  if (NULL == coreAPI)
+  if (NULL == core_api)
     return;
-  GNUNET_CORE_disconnect (coreAPI);
-  coreAPI = NULL;
+  GNUNET_CORE_disconnect (core_api);
+  core_api = NULL;
   GNUNET_ATS_performance_done (atsAPI);
   atsAPI = NULL;
   GNUNET_assert (0 == GNUNET_CONTAINER_multipeermap_size (all_known_peers));
@@ -2214,7 +2214,7 @@ GDS_NEIGHBOURS_done ()
 
 /**
  * Get the ID of the local node.
- * 
+ *
  * @return identity of the local node
  */
 struct GNUNET_PeerIdentity *