summaryrefslogtreecommitdiff
path: root/src/hello/gnunet-hello.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hello/gnunet-hello.c')
-rw-r--r--src/hello/gnunet-hello.c124
1 files changed, 56 insertions, 68 deletions
diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c
index 0b176ac79..612b5110a 100644
--- a/src/hello/gnunet-hello.c
+++ b/src/hello/gnunet-hello.c
@@ -67,13 +67,13 @@ add_to_buf (void *cls,
size_t ret;
ret = GNUNET_HELLO_add_address (address,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- ac->buf,
- ac->max);
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ ac->buf,
+ ac->max);
ac->buf += ret;
ac->max -= ret;
ac->ret += ret;
- address_count ++;
+ address_count++;
return GNUNET_OK;
}
@@ -87,9 +87,7 @@ add_to_buf (void *cls,
* @return number of bytes added, 0 to terminate
*/
static ssize_t
-add_from_hello (void *cls,
- size_t max,
- void *buf)
+add_from_hello (void *cls, size_t max, void *buf)
{
struct GNUNET_HELLO_Message **orig = cls;
struct AddContext ac;
@@ -99,10 +97,9 @@ add_from_hello (void *cls,
ac.buf = buf;
ac.max = max;
ac.ret = 0;
- GNUNET_assert (NULL ==
- GNUNET_HELLO_iterate_addresses (*orig,
- GNUNET_NO, &add_to_buf,
- &ac));
+ GNUNET_assert (
+ NULL ==
+ GNUNET_HELLO_iterate_addresses (*orig, GNUNET_NO, &add_to_buf, &ac));
*orig = NULL;
return ac.ret;
}
@@ -121,67 +118,58 @@ main (int argc, char *argv[])
GNUNET_log_setup ("gnunet-hello", "INFO", NULL);
if (argc != 2)
{
- FPRINTF (stderr,
- "%s",
- _("Call with name of HELLO file to modify.\n"));
+ fprintf (stderr, "%s", _ ("Call with name of HELLO file to modify.\n"));
return 1;
}
- if (GNUNET_OK != GNUNET_DISK_file_size (argv[1], &fsize, GNUNET_YES, GNUNET_YES))
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (argv[1], &fsize, GNUNET_YES, GNUNET_YES))
{
- FPRINTF (stderr,
- _("Error accessing file `%s': %s\n"),
- argv[1],
- STRERROR (errno));
+ fprintf (stderr,
+ _ ("Error accessing file `%s': %s\n"),
+ argv[1],
+ strerror (errno));
return 1;
}
if (fsize > 65536)
{
- FPRINTF (stderr,
- _("File `%s' is too big to be a HELLO\n"),
- argv[1]);
+ fprintf (stderr, _ ("File `%s' is too big to be a HELLO\n"), argv[1]);
return 1;
}
if (fsize < sizeof (struct GNUNET_MessageHeader))
{
- FPRINTF (stderr,
- _("File `%s' is too small to be a HELLO\n"),
- argv[1]);
+ fprintf (stderr, _ ("File `%s' is too small to be a HELLO\n"), argv[1]);
return 1;
}
fh = GNUNET_DISK_file_open (argv[1],
- GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_USER_READ);
+ GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_USER_READ);
if (NULL == fh)
{
- FPRINTF (stderr,
- _("Error opening file `%s': %s\n"),
- argv[1],
- STRERROR (errno));
+ fprintf (stderr,
+ _ ("Error opening file `%s': %s\n"),
+ argv[1],
+ strerror (errno));
return 1;
}
{
char buf[fsize] GNUNET_ALIGN;
- GNUNET_assert (fsize ==
- GNUNET_DISK_file_read (fh, buf, fsize));
+ GNUNET_assert (fsize == GNUNET_DISK_file_read (fh, buf, fsize));
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
orig = (struct GNUNET_HELLO_Message *) buf;
- if ( (fsize < GNUNET_HELLO_size (orig)) ||
- (GNUNET_OK != GNUNET_HELLO_get_id (orig,
- &pid)) )
+ if ((fsize < GNUNET_HELLO_size (orig)) ||
+ (GNUNET_OK != GNUNET_HELLO_get_id (orig, &pid)))
{
- FPRINTF (stderr,
- _("Did not find well-formed HELLO in file `%s'\n"),
- argv[1]);
+ fprintf (stderr,
+ _ ("Did not find well-formed HELLO in file `%s'\n"),
+ argv[1]);
return 1;
}
{
char *pids;
pids = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid.public_key);
- fprintf (stdout,
- "Processing HELLO for peer `%s'\n",
- pids);
+ fprintf (stdout, "Processing HELLO for peer `%s'\n", pids);
GNUNET_free (pids);
}
result = GNUNET_HELLO_create (&pid.public_key,
@@ -189,34 +177,34 @@ main (int argc, char *argv[])
&orig,
GNUNET_HELLO_is_friend_only (orig));
GNUNET_assert (NULL != result);
- fh = GNUNET_DISK_file_open (argv[1],
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE,
- GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
- if (NULL == fh)
- {
- FPRINTF (stderr,
- _("Error opening file `%s': %s\n"),
- argv[1],
- STRERROR (errno));
- GNUNET_free (result);
- return 1;
- }
- fsize = GNUNET_HELLO_size (result);
- if (fsize != GNUNET_DISK_file_write (fh,
- result,
- fsize))
- {
- FPRINTF (stderr,
- _("Error writing HELLO to file `%s': %s\n"),
- argv[1],
- STRERROR (errno));
- (void) GNUNET_DISK_file_close (fh);
- return 1;
- }
+ fh =
+ GNUNET_DISK_file_open (argv[1],
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == fh)
+ {
+ fprintf (stderr,
+ _ ("Error opening file `%s': %s\n"),
+ argv[1],
+ strerror (errno));
+ GNUNET_free (result);
+ return 1;
+ }
+ fsize = GNUNET_HELLO_size (result);
+ if (fsize != GNUNET_DISK_file_write (fh, result, fsize))
+ {
+ fprintf (stderr,
+ _ ("Error writing HELLO to file `%s': %s\n"),
+ argv[1],
+ strerror (errno));
+ (void) GNUNET_DISK_file_close (fh);
+ return 1;
+ }
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
}
- FPRINTF (stderr,
- _("Modified %u addresses, wrote %u bytes\n"),
+ fprintf (stderr,
+ _ ("Modified %u addresses, wrote %u bytes\n"),
address_count,
(unsigned int) fsize);
return 0;