aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_uri.c
diff options
context:
space:
mode:
authorgrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2010-10-26 22:20:20 +0000
committergrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2010-10-26 22:20:20 +0000
commit952facbf6422370501844830f36646b5160ea2cb (patch)
treea7a06cf980ce5d2af2fa975d6f6ca6cb8f9615ea /src/fs/fs_uri.c
parentaf494e2323b80938f87141e54a495cede5ce0c7d (diff)
api to add keyword
git-svn-id: https://gnunet.org/svn/gnunet@13408 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r--src/fs/fs_uri.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 9a4f72201b..7818718246 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -766,6 +766,39 @@ GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri,
/**
+ * Add the given keyword to the set of keywords represented by the URI.
+ * Does nothing if the keyword is already present.
+ *
+ * @param uri ksk uri to modify
+ * @param keyword keyword to add
+ * @param is_mandatory is this keyword mandatory?
+ */
+void
+GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri,
+ const char *keyword,
+ int is_mandatory)
+{
+ unsigned int i;
+ const char *old;
+ char *n;
+
+ 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))
+ return;
+ }
+ GNUNET_asprintf (&n,
+ is_mandatory ? "+%s" : " %s",
+ keyword);
+ GNUNET_array_append (uri->data.ksk.keywords,
+ uri->data.ksk.keywordCount,
+ n);
+}
+
+
+/**
* Obtain the identity of the peer offering the data
*
* @param uri the location URI to inspect