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 | |
parent | b7c944dd5acdcdb01503a69ca6e4899341791232 (diff) | |
download | gnunet-695f7138383c64e438fc2a98ea0e730f8332c953.tar.gz gnunet-695f7138383c64e438fc2a98ea0e730f8332c953.zip |
api to add keyword
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs_uri.c | 33 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 14 |
2 files changed, 47 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 |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 8e71308ba..8477c534d 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -115,6 +115,20 @@ GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri); | |||
115 | 115 | ||
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Add the given keyword to the set of keywords represented by the URI. | ||
119 | * Does nothing if the keyword is already present. | ||
120 | * | ||
121 | * @param uri ksk uri to modify | ||
122 | * @param keyword keyword to add | ||
123 | * @param is_mandatory is this keyword mandatory? | ||
124 | */ | ||
125 | void | ||
126 | GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, | ||
127 | const char *keyword, | ||
128 | int is_mandatory); | ||
129 | |||
130 | |||
131 | /** | ||
118 | * Convert a UTF-8 String to a URI. | 132 | * Convert a UTF-8 String to a URI. |
119 | * | 133 | * |
120 | * @param uri string to parse | 134 | * @param uri string to parse |