diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-10-26 22:20:20 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-10-26 22:20:20 +0000 |
commit | 695f7138383c64e438fc2a98ea0e730f8332c953 (patch) | |
tree | a7a06cf980ce5d2af2fa975d6f6ca6cb8f9615ea /src/fs/fs_uri.c | |
parent | b7c944dd5acdcdb01503a69ca6e4899341791232 (diff) | |
download | gnunet-695f7138383c64e438fc2a98ea0e730f8332c953.tar.gz gnunet-695f7138383c64e438fc2a98ea0e730f8332c953.zip |
api to add keyword
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r-- | src/fs/fs_uri.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 9a4f72201..781871824 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, | |||
766 | 766 | ||
767 | 767 | ||
768 | /** | 768 | /** |
769 | * Add the given keyword to the set of keywords represented by the URI. | ||
770 | * Does nothing if the keyword is already present. | ||
771 | * | ||
772 | * @param uri ksk uri to modify | ||
773 | * @param keyword keyword to add | ||
774 | * @param is_mandatory is this keyword mandatory? | ||
775 | */ | ||
776 | void | ||
777 | GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, | ||
778 | const char *keyword, | ||
779 | int is_mandatory) | ||
780 | { | ||
781 | unsigned int i; | ||
782 | const char *old; | ||
783 | char *n; | ||
784 | |||
785 | GNUNET_assert (uri->type == ksk); | ||
786 | for (i = 0; i < uri->data.ksk.keywordCount; i++) | ||
787 | { | ||
788 | old = uri->data.ksk.keywords[i]; | ||
789 | if (0 == strcmp (&old[1], keyword)) | ||
790 | return; | ||
791 | } | ||
792 | GNUNET_asprintf (&n, | ||
793 | is_mandatory ? "+%s" : " %s", | ||
794 | keyword); | ||
795 | GNUNET_array_append (uri->data.ksk.keywords, | ||
796 | uri->data.ksk.keywordCount, | ||
797 | n); | ||
798 | } | ||
799 | |||
800 | |||
801 | /** | ||
769 | * Obtain the identity of the peer offering the data | 802 | * Obtain the identity of the peer offering the data |
770 | * | 803 | * |
771 | * @param uri the location URI to inspect | 804 | * @param uri the location URI to inspect |