fixing common off-by-one error with respect to maximum message size
[oweals/gnunet.git] / src / fs / gnunet-pseudonym.c
index b8bd12b35dcbe7897b8224c222d7b2a37e59c2ae..465cbdd684e992109f297a8b0ce1f0d085bcb11e 100644 (file)
@@ -205,10 +205,9 @@ post_advertising (void *cls,
                                           rating_change,
                                           &nsid))
            {
-             GNUNET_PSEUDONYM_rank (cfg,
-                                    &nsid,
-                                    delta);
-             
+             (void) GNUNET_PSEUDONYM_rank (cfg,
+                                           &nsid,
+                                           delta);           
            }
          else
            {
@@ -252,7 +251,6 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  struct GNUNET_FS_Uri *ns_uri;
   struct GNUNET_TIME_Absolute expiration;
   char *emsg;
 
@@ -262,7 +260,8 @@ run (void *cls,
                       "gnunet-pseudonym",
                       &progress_cb,
                       NULL,
-                      GNUNET_FS_FLAGS_NONE);
+                      GNUNET_FS_FLAGS_NONE,
+                      GNUNET_FS_OPTIONS_END);
   if (NULL != delete_ns)
     {
       ns = GNUNET_FS_namespace_create (h, delete_ns);
@@ -290,9 +289,6 @@ run (void *cls,
        {
          if (NULL != root_identifier)
            {
-             emsg = NULL;
-             ns_uri = GNUNET_FS_uri_sks_create (ns, root_identifier, &emsg);
-             GNUNET_assert (emsg == NULL);
              expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
              if (ksk_uri == NULL)
                {
@@ -300,72 +296,36 @@ run (void *cls,
                  ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg);
                  GNUNET_assert (NULL == emsg);
                }
-             GNUNET_FS_publish_ksk (h,
-                                    ksk_uri,
-                                    adv_metadata,
-                                    ns_uri,
-                                    expiration,
-                                    anonymity,
-                                    priority,
-                                    GNUNET_FS_PUBLISH_OPTION_NONE,
-                                    &post_advertising,
-                                    NULL);
+             GNUNET_FS_namespace_advertise (h,
+                                            ksk_uri,
+                                            ns,
+                                            adv_metadata,
+                                            anonymity,
+                                            priority,                                       
+                                            expiration,
+                                            root_identifier,
+                                            &post_advertising,
+                                            NULL);
              return;
            }
+         else
+           {
+             if (ksk_uri != NULL)
+               fprintf (stderr, _("Option `%s' ignored\n"), "-k");   
+           }
        }
     }
+  else
+    {
+      if (root_identifier != NULL) 
+       fprintf (stderr, _("Option `%s' ignored\n"), "-r");
+      if (ksk_uri != NULL)
+       fprintf (stderr, _("Option `%s' ignored\n"), "-k");   
+    }    
+    
   post_advertising (NULL, NULL, NULL);
 }
 
-/**
- * gnunet-pseudonym command line options
- */
-static struct GNUNET_GETOPT_CommandLineOption options[] = {
-  {'a', "anonymity", "LEVEL",
-   gettext_noop ("set the desired LEVEL of sender-anonymity"),
-   1, &GNUNET_GETOPT_set_uint, &anonymity},
-  {'A', "automate", NULL,
-   gettext_noop ("start a collection"),
-   0, &GNUNET_GETOPT_set_one, &start_automate},
-  {'C', "create", "NAME",
-   gettext_noop
-   ("create or advertise namespace NAME"),
-   1, &GNUNET_GETOPT_set_string, &create_ns},
-  {'D', "delete", "NAME",
-   gettext_noop
-   ("delete namespace NAME "),
-   1, &GNUNET_GETOPT_set_string, &delete_ns},
-  {'e', "end", NULL,
-   gettext_noop ("end current collection"),
-   0, &GNUNET_GETOPT_set_one, &stop_automate},
-  {'k', "keyword", "VALUE",
-  gettext_noop
-   ("add an additional keyword for the advertisment"
-    " (this option can be specified multiple times)"),
-   1, &GNUNET_FS_getopt_set_keywords, &ksk_uri},
-  {'l', "local-only", NULL,
-   gettext_noop ("print names of local namespaces"),
-   0, &GNUNET_GETOPT_set_one, &print_local_only},
-  {'m', "meta", "TYPE:VALUE",
-   gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
-   1, &GNUNET_FS_getopt_set_metadata, &adv_metadata},
-  {'p', "priority", "PRIORITY",
-   gettext_noop ("use the given PRIORITY for the advertisments"),
-   1, &GNUNET_GETOPT_set_uint, &priority},
-  {'q', "quiet", NULL,
-   gettext_noop ("do not print names of remote namespaces"),
-   0, &GNUNET_GETOPT_set_one, &no_remote_printing},
-  {'r', "root", "ID",
-   gettext_noop
-   ("specify ID of the root of the namespace"),
-   1, &GNUNET_GETOPT_set_string, &root_identifier},
-  {'s', "set-rating", "ID:VALUE",
-   gettext_noop
-   ("change rating of namespace ID by VALUE"),
-   1, &GNUNET_GETOPT_set_string, &rating_change},
-  GNUNET_GETOPT_OPTION_END
-};
-
 
 /**
  * The main function to inspect GNUnet directories.
@@ -377,6 +337,51 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
 int
 main (int argc, char *const *argv)
 {
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    {'a', "anonymity", "LEVEL",
+     gettext_noop ("set the desired LEVEL of sender-anonymity"),
+     1, &GNUNET_GETOPT_set_uint, &anonymity},
+    {'A', "automate", NULL,
+     gettext_noop ("start a collection"),
+     0, &GNUNET_GETOPT_set_one, &start_automate},
+    {'C', "create", "NAME",
+     gettext_noop
+     ("create or advertise namespace NAME"),
+     1, &GNUNET_GETOPT_set_string, &create_ns},
+    {'D', "delete", "NAME",
+     gettext_noop
+     ("delete namespace NAME "),
+     1, &GNUNET_GETOPT_set_string, &delete_ns},
+    {'e', "end", NULL,
+     gettext_noop ("end current collection"),
+     0, &GNUNET_GETOPT_set_one, &stop_automate},
+    {'k', "keyword", "VALUE",
+     gettext_noop
+     ("add an additional keyword for the advertisment"
+      " (this option can be specified multiple times)"),
+     1, &GNUNET_FS_getopt_set_keywords, &ksk_uri},
+    {'m', "meta", "TYPE:VALUE",
+     gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
+     1, &GNUNET_FS_getopt_set_metadata, &adv_metadata},
+    {'o', "only-local", NULL,
+     gettext_noop ("print names of local namespaces"),
+     0, &GNUNET_GETOPT_set_one, &print_local_only},
+    {'p', "priority", "PRIORITY",
+     gettext_noop ("use the given PRIORITY for the advertisments"),
+     1, &GNUNET_GETOPT_set_uint, &priority},
+    {'q', "quiet", NULL,
+     gettext_noop ("do not print names of remote namespaces"),
+     0, &GNUNET_GETOPT_set_one, &no_remote_printing},
+    {'r', "root", "ID",
+     gettext_noop
+     ("specify ID of the root of the namespace"),
+     1, &GNUNET_GETOPT_set_string, &root_identifier},
+    {'s', "set-rating", "ID:VALUE",
+     gettext_noop
+     ("change rating of namespace ID by VALUE"),
+     1, &GNUNET_GETOPT_set_string, &rating_change},
+    GNUNET_GETOPT_OPTION_END
+  };
   return (GNUNET_OK ==
           GNUNET_PROGRAM_run (argc,
                               argv,