-bringing copyright tags up to FSF standard
[oweals/gnunet.git] / src / namestore / gnunet-namestore.c
index 8c8c7660e5677c3a882115f46d47182365a858d1..62846df922512320c5d026a2546b7776c7931c7d 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2012, 2013, 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2013, 2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -109,11 +109,6 @@ static int is_public;
  */
 static int is_shadow;
 
-/**
- * Is record pending approval (#GNUNET_GNSRECORD_RF_PENDING)
- */
-static int is_pending;
-
 /**
  * Queue entry for the 'del' operation.
  */
@@ -414,13 +409,12 @@ display_record (void *cls,
       ets = GNUNET_STRINGS_absolute_time_to_string (at);
     }
     FPRINTF (stdout,
-            "\t%s: %s (%s)\t%s\t%s\t%s\n",
+            "\t%s: %s (%s)\t%s\t%s\n",
             typestring,
             s,
              ets,
              (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" : "PUBLIC",
-             (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" : "",
-             (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) ? "PENDING" : "");
+             (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" : "");
     GNUNET_free (s);
   }
   FPRINTF (stdout, "%s", "\n");
@@ -493,6 +487,7 @@ get_existing_record (void *cls,
                rec_name);
       ret = 1;
       test_finished ();
+      return;
     case GNUNET_GNSRECORD_TYPE_GNS2DNS:
       fprintf (stderr,
                _("A %s record exists already under `%s', no other records can be added.\n"),
@@ -501,18 +496,46 @@ get_existing_record (void *cls,
       ret = 1;
       test_finished ();
       return;
-    case GNUNET_DNSPARSER_TYPE_NS:
-      if ( (GNUNET_DNSPARSER_TYPE_A == type) ||
-          (GNUNET_DNSPARSER_TYPE_AAAA == type) )
-       break;
+    }
+  }
+  switch (type)
+  {
+  case GNUNET_DNSPARSER_TYPE_CNAME:
+    if (0 != rd_count)
+    {
       fprintf (stderr,
-               _("A %s record exists already under `%s', only A/AAAA records can be added.\n"),
-               "NS",
-               rec_name);
+               _("Records already exist under `%s', cannot add `%s' record.\n"),
+               rec_name,
+               "CNAME");
+      ret = 1;
+      test_finished ();
+      return;
+    }
+    break;
+  case GNUNET_GNSRECORD_TYPE_PKEY:
+    if (0 != rd_count)
+    {
+      fprintf (stderr,
+               _("Records already exist under `%s', cannot add `%s' record.\n"),
+               rec_name,
+               "PKEY");
+      ret = 1;
+      test_finished ();
+      return;
+    }
+    break;
+  case GNUNET_GNSRECORD_TYPE_GNS2DNS:
+    if (0 != rd_count)
+    {
+      fprintf (stderr,
+               _("Records already exist under `%s', cannot add `%s' record.\n"),
+               rec_name,
+               "GNS2DNS");
       ret = 1;
       test_finished ();
       return;
     }
+    break;
   }
   memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
   memcpy (&rdn[1], rd, rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
@@ -524,8 +547,6 @@ get_existing_record (void *cls,
     rde->flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
   if (1 != is_public)
     rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
-  if (1 == is_pending)
-    rde->flags |= GNUNET_GNSRECORD_RF_PENDING;
   if (GNUNET_YES == etime_is_rel)
   {
     rde->expiration_time = etime_rel.rel_value_us;
@@ -836,7 +857,11 @@ testservice_task (void *cls,
     char sname[64];
     struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
 
-    if ( (2 != (sscanf (uri, "gnunet://gns/%52s/%63s", sh, sname)) ) ||
+    GNUNET_STRINGS_utf8_tolower (uri, uri);
+    if ( (2 != (sscanf (uri,
+                        "gnunet://gns/%52s/%63s",
+                        sh,
+                        sname)) ) ||
          (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, strlen (sh), &pkey)) )
     {
       fprintf (stderr,
@@ -1034,7 +1059,6 @@ int
 main (int argc, char *const *argv)
 {
   is_public = -1;
-  is_pending = -1;
   is_shadow = -1;
 
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -1074,9 +1098,6 @@ main (int argc, char *const *argv)
     {'p', "public", NULL,
      gettext_noop ("create or list public record"), 0,
      &GNUNET_GETOPT_set_one, &is_public},
-    {'P', "pending", NULL,
-     gettext_noop ("create record that is pending approval (and thus for now inactive)"), 0,
-     &GNUNET_GETOPT_set_one, &is_pending},
     {'s', "shadow", NULL,
      gettext_noop ("create shadow record (only valid if all other records of the same type have expired"), 0,
      &GNUNET_GETOPT_set_one, &is_shadow},