clean up for configs
[oweals/gnunet.git] / src / peerinfo / gnunet-service-peerinfo.c
index d62e81eae8744b6c21971fb1fc54807ab8ed79d7..b7fa1c722f8b26dbe0dd7334ca2f1dc9b390cb6f 100644 (file)
@@ -320,11 +320,13 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
  * HELLO should be included
  *
  * @param fn name of the file
- * @param unlink_garbage if GNUNET_YES, try to remove useless files
+ * @param unlink_garbage if #GNUNET_YES, try to remove useless files
  * @param r ReadHostFileContext to store the resutl
  */
 static void
-read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *r)
+read_host_file (const char *fn,
+                int unlink_garbage,
+                struct ReadHostFileContext *r)
 {
   char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
   unsigned int size_total;
@@ -340,12 +342,12 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
   r->hello = NULL;
 
   if (GNUNET_YES != GNUNET_DISK_file_test (fn))
-  {
     return;
-  }
-
   size_total = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes from `%s'\n", size_total, fn);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Read %u bytes from `%s'\n",
+              size_total,
+              fn);
   if (size_total < sizeof (struct GNUNET_MessageHeader))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -354,7 +356,9 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
     if ( (GNUNET_YES == unlink_garbage) &&
         (0 != UNLINK (fn)) &&
         (ENOENT != errno) )
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                "unlink",
+                                fn);
     return;
   }
 
@@ -367,11 +371,15 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
       {
        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                    _("Failed to parse HELLO in file `%s': %s %u \n"),
-                   fn, "HELLO is invalid and has size of ", size_hello);
+                   fn,
+                    "HELLO is invalid and has size of ",
+                    size_hello);
        if ((GNUNET_YES == unlink_garbage) &&
            (0 != UNLINK (fn)) &&
            (ENOENT != errno) )
-         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                    "unlink",
+                                    fn);
        return;
       }
 
@@ -416,10 +424,12 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
   if (0 == left)
   {
     /* no addresses left, remove from disk */
-    if ((GNUNET_YES == unlink_garbage) && (0 != UNLINK (fn)))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+    if ( (GNUNET_YES == unlink_garbage) &&
+         (0 != UNLINK (fn)) )
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                "unlink",
+                                fn);
   }
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Found `%s' and `%s' HELLO message in file\n",
              (NULL != r->hello) ? "public" : "NO public",
@@ -446,10 +456,11 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer `%s'\n", GNUNET_i2s (identity));
     GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1,
                              GNUNET_NO);
-    entry = GNUNET_malloc (sizeof (struct HostEntry));
+    entry = GNUNET_new (struct HostEntry);
     entry->identity = *identity;
-    GNUNET_CONTAINER_multipeermap_put (hostmap, &entry->identity, entry,
-                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+    GNUNET_assert (GNUNET_OK ==
+                   GNUNET_CONTAINER_multipeermap_put (hostmap, &entry->identity, entry,
+                                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
     notify_all (entry);
     fn = get_host_filename (identity);
     if (NULL != fn)
@@ -533,18 +544,13 @@ hosts_directory_scan_callback (void *cls, const char *fullname)
 
   filename = strrchr (fullname, DIR_SEPARATOR);
   if ((NULL == filename) || (1 > strlen (filename)))
-       filename = fullname;
+    filename = fullname;
   else
     filename ++;
 
   read_host_file (fullname, dsc->remove_files, &r);
   if ( (NULL == r.hello) && (NULL == r.friend_only_hello))
-  {
-    if (GNUNET_YES == dsc->remove_files)
-      remove_garbage (fullname);
     return GNUNET_OK;
-  }
-
   if (NULL != r.friend_only_hello)
   {
     if (GNUNET_OK != GNUNET_HELLO_get_id (r.friend_only_hello, &id_friend))
@@ -575,7 +581,7 @@ hosts_directory_scan_callback (void *cls, const char *fullname)
       remove_garbage (fullname);
     return GNUNET_OK;
   }
-  if (GNUNET_OK == GNUNET_CRYPTO_ecc_public_sign_key_from_string (filename,
+  if (GNUNET_OK == GNUNET_CRYPTO_eddsa_public_key_from_string (filename,
                                                                   strlen (filename),
                                                                   &identity.public_key))
   {
@@ -654,7 +660,7 @@ update_friend_hello (const struct GNUNET_HELLO_Message *hello,
 {
   struct GNUNET_HELLO_Message * res;
   struct GNUNET_HELLO_Message * tmp;
-  struct GNUNET_CRYPTO_EccPublicSignKey pk;
+  struct GNUNET_CRYPTO_EddsaPublicKey pk;
 
   if (NULL != friend_hello)
   {