- GNUNET_assert ((GNUNET_YES == GNUNET_HELLO_is_friend_only(host->friend_only_hello)));
-
- store_hello = GNUNET_NO;
- store_friend_hello = GNUNET_NO;
- fn = get_host_filename (peer);
- if ( (NULL != fn) &&
- (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) )
- {
-
- store_hello = GNUNET_NO;
- size = 0;
- cnt = 0;
- if (NULL != host->hello)
- (void) GNUNET_HELLO_iterate_addresses (host->hello,
- GNUNET_NO, &count_addresses, &cnt);
- if (cnt > 0)
- {
- store_hello = GNUNET_YES;
- size += GNUNET_HELLO_size (host->hello);
- }
- cnt = 0;
- if (NULL != host->friend_only_hello)
- (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello, GNUNET_NO,
- &count_addresses, &cnt);
- if (0 < cnt)
- {
- store_friend_hello = GNUNET_YES;
- size += GNUNET_HELLO_size (host->friend_only_hello);
- }
-
- if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello))
- {
- /* no valid addresses, don't put HELLO on disk; in fact,
- if one exists on disk, remove it */
- (void) UNLINK (fn);
- }
- else
- {
- buffer = GNUNET_malloc (size);
- pos = 0;
-
- if (GNUNET_YES == store_hello)
- {
- memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello));
- pos += GNUNET_HELLO_size (host->hello);
- }
- if (GNUNET_YES == store_friend_hello)
- {
- memcpy (&buffer[pos], host->friend_only_hello, GNUNET_HELLO_size (host->friend_only_hello));
- pos += GNUNET_HELLO_size (host->friend_only_hello);
- }
- GNUNET_assert (pos == size);
-
- if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, buffer, size,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE |
- GNUNET_DISK_PERM_GROUP_READ |
- GNUNET_DISK_PERM_OTHER_READ))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stored %s %s HELLO in %s with total size %u\n",
- (GNUNET_YES == store_friend_hello) ? "friend-only": "",
- (GNUNET_YES == store_hello) ? "public": "",
- fn, size);
- GNUNET_free (buffer);
- }
+ GNUNET_assert ((GNUNET_YES == GNUNET_HELLO_is_friend_only(host->friend_only_hello)));
+
+ fn = get_host_filename (peer);
+ if ( (NULL != fn) &&
+ (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) )
+ {
+ store_hello = GNUNET_NO;
+ size = 0;
+ cnt = 0;
+ if (NULL != host->hello)
+ (void) GNUNET_HELLO_iterate_addresses (host->hello,
+ GNUNET_NO, &count_addresses, &cnt);
+ if (cnt > 0)
+ {
+ store_hello = GNUNET_YES;
+ size += GNUNET_HELLO_size (host->hello);
+ }
+ cnt = 0;
+ if (NULL != host->friend_only_hello)
+ (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello, GNUNET_NO,
+ &count_addresses, &cnt);
+ store_friend_hello = GNUNET_NO;
+ if (0 < cnt)
+ {
+ store_friend_hello = GNUNET_YES;
+ size += GNUNET_HELLO_size (host->friend_only_hello);
+ }
+
+ if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello))
+ {
+ /* no valid addresses, don't put HELLO on disk; in fact,
+ if one exists on disk, remove it */
+ (void) UNLINK (fn);
+ }
+ else
+ {
+ buffer = GNUNET_malloc (size);
+ pos = 0;
+
+ if (GNUNET_YES == store_hello)
+ {
+ memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello));
+ pos += GNUNET_HELLO_size (host->hello);
+ }
+ if (GNUNET_YES == store_friend_hello)
+ {
+ memcpy (&buffer[pos], host->friend_only_hello, GNUNET_HELLO_size (host->friend_only_hello));
+ pos += GNUNET_HELLO_size (host->friend_only_hello);
+ }
+ GNUNET_assert (pos == size);
+
+ if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, buffer, size,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE |
+ GNUNET_DISK_PERM_GROUP_READ |
+ GNUNET_DISK_PERM_OTHER_READ))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stored %s %s HELLO in %s with total size %u\n",
+ (GNUNET_YES == store_friend_hello) ? "friend-only": "",
+ (GNUNET_YES == store_hello) ? "public": "",
+ fn, size);
+ GNUNET_free (buffer);
+ }