* 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;
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,
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;
}
{
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;
}
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",
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)
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))
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))
{
{
struct GNUNET_HELLO_Message * res;
struct GNUNET_HELLO_Message * tmp;
- struct GNUNET_CRYPTO_EccPublicSignKey pk;
+ struct GNUNET_CRYPTO_EddsaPublicKey pk;
if (NULL != friend_hello)
{