diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-10-26 22:26:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-10-26 22:26:09 +0000 |
commit | 4c4162597814cdbbdd5748024671c03615b203d3 (patch) | |
tree | 6e241ad797a6a1e8733d8f348de223d05fdf3413 /src | |
parent | 695f7138383c64e438fc2a98ea0e730f8332c953 (diff) | |
download | gnunet-4c4162597814cdbbdd5748024671c03615b203d3.tar.gz gnunet-4c4162597814cdbbdd5748024671c03615b203d3.zip |
api to remove keyword
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs_uri.c | 31 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 12 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 781871824..dff4b8686 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -799,6 +799,37 @@ GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, | |||
799 | 799 | ||
800 | 800 | ||
801 | /** | 801 | /** |
802 | * Remove the given keyword from the set of keywords represented by the URI. | ||
803 | * Does nothing if the keyword is not present. | ||
804 | * | ||
805 | * @param uri ksk uri to modify | ||
806 | * @param keyword keyword to add | ||
807 | */ | ||
808 | void | ||
809 | GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri, | ||
810 | const char *keyword) | ||
811 | { | ||
812 | unsigned int i; | ||
813 | char *old; | ||
814 | |||
815 | GNUNET_assert (uri->type == ksk); | ||
816 | for (i = 0; i < uri->data.ksk.keywordCount; i++) | ||
817 | { | ||
818 | old = uri->data.ksk.keywords[i]; | ||
819 | if (0 == strcmp (&old[1], keyword)) | ||
820 | { | ||
821 | uri->data.ksk.keywords[i] = uri->data.ksk.keywords[uri->data.ksk.keywordCount-1]; | ||
822 | GNUNET_array_grow (uri->data.ksk.keywords, | ||
823 | uri->data.ksk.keywordCount, | ||
824 | uri->data.ksk.keywordCount - 1); | ||
825 | GNUNET_free (old); | ||
826 | return; | ||
827 | } | ||
828 | } | ||
829 | } | ||
830 | |||
831 | |||
832 | /** | ||
802 | * Obtain the identity of the peer offering the data | 833 | * Obtain the identity of the peer offering the data |
803 | * | 834 | * |
804 | * @param uri the location URI to inspect | 835 | * @param uri the location URI to inspect |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 8477c534d..0e5dccc2d 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -129,6 +129,18 @@ GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, | |||
129 | 129 | ||
130 | 130 | ||
131 | /** | 131 | /** |
132 | * Remove the given keyword from the set of keywords represented by the URI. | ||
133 | * Does nothing if the keyword is not present. | ||
134 | * | ||
135 | * @param uri ksk uri to modify | ||
136 | * @param keyword keyword to add | ||
137 | */ | ||
138 | void | ||
139 | GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri, | ||
140 | const char *keyword); | ||
141 | |||
142 | |||
143 | /** | ||
132 | * Convert a UTF-8 String to a URI. | 144 | * Convert a UTF-8 String to a URI. |
133 | * | 145 | * |
134 | * @param uri string to parse | 146 | * @param uri string to parse |