document options provided
[oweals/gnunet.git] / src / hello / gnunet-hello.c
index 7df8b7b83f9fbe22ac58dba61d3f6e071b021a9e..e857bde267681ca67620612ab4a49f83d660116a 100644 (file)
@@ -35,7 +35,7 @@ struct AddContext
    * Where to add.
    */
   char *buf;
-  
+
   /**
    * Maximum number of bytes left
    */
@@ -47,6 +47,8 @@ struct AddContext
   size_t ret;
 };
 
+static int address_count;
+
 
 /**
  * Add the given address with infinit expiration to the buffer.
@@ -63,13 +65,14 @@ add_to_buf (void *cls, const struct GNUNET_HELLO_Address *address,
   struct AddContext *ac = cls;
   size_t ret;
 
-  ret = GNUNET_HELLO_add_address (address, 
+  ret = GNUNET_HELLO_add_address (address,
                                  GNUNET_TIME_UNIT_FOREVER_ABS,
                                  ac->buf,
                                  ac->max);
   ac->buf += ret;
   ac->max -= ret;
-  ac->ret += ret;  
+  ac->ret += ret;
+  address_count ++;
   return GNUNET_OK;
 }
 
@@ -94,7 +97,7 @@ add_from_hello (void *cls, size_t max, void *buf)
   ac.max = max;
   ac.ret = 0;
   GNUNET_assert (NULL ==
-                GNUNET_HELLO_iterate_addresses (*orig, 
+                GNUNET_HELLO_iterate_addresses (*orig,
                                                 GNUNET_NO, &add_to_buf,
                                                 &ac));
   *orig = NULL;
@@ -108,9 +111,9 @@ main (int argc, char *argv[])
   struct GNUNET_DISK_FileHandle *fh;
   struct GNUNET_HELLO_Message *orig;
   struct GNUNET_HELLO_Message *result;
-  struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pk;
+  struct GNUNET_CRYPTO_EddsaPublicKey pk;
   uint64_t fsize;
-  int friend_only;
+  address_count = 0;
 
   GNUNET_log_setup ("gnunet-hello", "INFO", NULL);
   if (argc != 2)
@@ -142,7 +145,7 @@ main (int argc, char *argv[])
             argv[1]);
     return 1;
   }
-  fh = GNUNET_DISK_file_open (argv[1], 
+  fh = GNUNET_DISK_file_open (argv[1],
                              GNUNET_DISK_OPEN_READ,
                              GNUNET_DISK_PERM_USER_READ);
   if (NULL == fh)
@@ -155,8 +158,8 @@ main (int argc, char *argv[])
   }
   {
     char buf[fsize] GNUNET_ALIGN;
-    
-    GNUNET_assert (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;
@@ -168,14 +171,10 @@ main (int argc, char *argv[])
               argv[1]);
       return 1;
     }
-    friend_only = GNUNET_NO;
-    if (GNUNET_MESSAGE_TYPE_HELLO == GNUNET_HELLO_get_type ((struct GNUNET_MessageHeader *) orig))
-       friend_only = GNUNET_NO;
-    if (GNUNET_MESSAGE_TYPE_FRIEND_HELLO == GNUNET_HELLO_get_type ((struct GNUNET_MessageHeader *) orig))
-       friend_only = GNUNET_YES;
-    result = GNUNET_HELLO_create (&pk, &add_from_hello, &orig, friend_only);
+    result = GNUNET_HELLO_create (&pk, &add_from_hello, &orig,
+               GNUNET_HELLO_is_friend_only (orig));
     GNUNET_assert (NULL != result);
-     fh = GNUNET_DISK_file_open (argv[1], 
+     fh = GNUNET_DISK_file_open (argv[1],
                                 GNUNET_DISK_OPEN_WRITE,
                                 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
      if (NULL == fh)
@@ -201,6 +200,7 @@ main (int argc, char *argv[])
      }
     GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
   }
+  FPRINTF (stderr, _("Modified %u addresses \n"), address_count);
   return 0;
 }