plane hacking
[oweals/gnunet.git] / src / fs / fs_uri.c
index 8f9fbba65b8ab844467ed4d7828f571581142804..7d03214643dddc080984e13a3a597ace9bb085f2 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -830,7 +830,7 @@ GNUNET_FS_uri_loc_get_uri (const struct GNUNET_FS_Uri *uri)
  */
 struct GNUNET_FS_Uri *
 GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
-                         struct GNUNET_CONFIGURATION_Handle *cfg,
+                         const struct GNUNET_CONFIGURATION_Handle *cfg,
                          struct GNUNET_TIME_Absolute expiration_time)
 {
   struct GNUNET_FS_Uri *uri;
@@ -909,6 +909,27 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns,
 }
 
 
+/**
+ * Create an SKS URI from a namespace ID and an identifier.
+ *
+ * @param nsid namespace ID
+ * @param id identifier
+ * @return an FS URI for the given namespace and identifier
+ */
+struct GNUNET_FS_Uri *
+GNUNET_FS_uri_sks_create_from_nsid (GNUNET_HashCode *nsid,
+                                   const char *id)
+{
+  struct GNUNET_FS_Uri *ns_uri;
+             
+  ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
+  ns_uri->type = sks;
+  ns_uri->data.sks.namespace = *nsid;
+  ns_uri->data.sks.identifier = GNUNET_strdup (id);
+  return ns_uri;
+}
+
+
 /**
  * Canonicalize a keyword.
  * 
@@ -1094,6 +1115,7 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri)
       if (ret->data.ksk.keywordCount >= GNUNET_MAX_MALLOC_CHECKED / sizeof (char*))
        {
          GNUNET_break (0);
+         GNUNET_free (ret);
          return NULL;
        }
       if (ret->data.ksk.keywordCount > 0)
@@ -1150,6 +1172,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords,
 
   if (keywords == NULL)
     {
+      *emsg = GNUNET_strdup (_("No keywords specified!\n"));
       GNUNET_break (0);
       return NULL;
     }