api to remove keyword
authorChristian Grothoff <christian@grothoff.org>
Tue, 26 Oct 2010 22:26:09 +0000 (22:26 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 26 Oct 2010 22:26:09 +0000 (22:26 +0000)
src/fs/fs_uri.c
src/include/gnunet_fs_service.h

index 78187182465064137a88409f167909c933389892..dff4b868601b7d0fcfa353cbbbc4957432a61212 100644 (file)
@@ -798,6 +798,37 @@ GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri,
 }
 
 
+/**
+ * Remove the given keyword from the set of keywords represented by the URI.
+ * Does nothing if the keyword is not present.
+ *
+ * @param uri ksk uri to modify
+ * @param keyword keyword to add
+ */
+void
+GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri,
+                                 const char *keyword)
+{
+  unsigned int i;
+  char *old;
+
+  GNUNET_assert (uri->type == ksk);
+  for (i = 0; i < uri->data.ksk.keywordCount; i++)
+    {
+      old = uri->data.ksk.keywords[i];
+      if (0 == strcmp (&old[1], keyword))
+       {
+         uri->data.ksk.keywords[i] = uri->data.ksk.keywords[uri->data.ksk.keywordCount-1];
+         GNUNET_array_grow (uri->data.ksk.keywords,
+                            uri->data.ksk.keywordCount,
+                            uri->data.ksk.keywordCount - 1);
+         GNUNET_free (old);
+         return;
+       }
+    }
+}
+
+
 /**
  * Obtain the identity of the peer offering the data
  *
index 8477c534d691cec06d6d0156bf32b0acdfe32460..0e5dccc2d7ce3f2593dc972bc682e98339b0a314 100644 (file)
@@ -128,6 +128,18 @@ GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri,
                               int is_mandatory);
 
 
+/**
+ * Remove the given keyword from the set of keywords represented by the URI.
+ * Does nothing if the keyword is not present.
+ *
+ * @param uri ksk uri to modify
+ * @param keyword keyword to add
+ */
+void
+GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri,
+                                 const char *keyword);
+
+
 /**
  * Convert a UTF-8 String to a URI.
  *