aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_uri.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r--src/fs/fs_uri.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 11968b750..b90c75981 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -96,8 +96,9 @@
96 * 96 *
97 * @param uri uri to convert to a unique key 97 * @param uri uri to convert to a unique key
98 * @param key where to store the unique key 98 * @param key where to store the unique key
99 * @return #GNUNET_OK on success
99 */ 100 */
100void 101int
101GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, 102GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
102 struct GNUNET_HashCode *key) 103 struct GNUNET_HashCode *key)
103{ 104{
@@ -105,25 +106,35 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
105 { 106 {
106 case GNUNET_FS_URI_CHK: 107 case GNUNET_FS_URI_CHK:
107 *key = uri->data.chk.chk.query; 108 *key = uri->data.chk.chk.query;
108 return; 109 return GNUNET_OK;
109 case GNUNET_FS_URI_SKS: 110 case GNUNET_FS_URI_SKS:
110 GNUNET_CRYPTO_hash (uri->data.sks.identifier, 111 GNUNET_CRYPTO_hash (uri->data.sks.identifier,
111 strlen (uri->data.sks.identifier), key); 112 strlen (uri->data.sks.identifier),
112 break; 113 key);
114 return GNUNET_OK;
113 case GNUNET_FS_URI_KSK: 115 case GNUNET_FS_URI_KSK:
114 if (uri->data.ksk.keywordCount > 0) 116 if (uri->data.ksk.keywordCount > 0)
117 {
115 GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], 118 GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0],
116 strlen (uri->data.ksk.keywords[0]), key); 119 strlen (uri->data.ksk.keywords[0]),
120 key);
121 return GNUNET_OK;
122 }
123 else
124 {
125 memset (key, 0, sizeof (struct GNUNET_HashCode));
126 return GNUNET_SYSERR;
127 }
117 break; 128 break;
118 case GNUNET_FS_URI_LOC: 129 case GNUNET_FS_URI_LOC:
119 GNUNET_CRYPTO_hash (&uri->data.loc.fi, 130 GNUNET_CRYPTO_hash (&uri->data.loc.fi,
120 sizeof (struct FileIdentifier) + 131 sizeof (struct FileIdentifier) +
121 sizeof (struct GNUNET_PeerIdentity), 132 sizeof (struct GNUNET_PeerIdentity),
122 key); 133 key);
123 break; 134 return GNUNET_OK;
124 default: 135 default:
125 memset (key, 0, sizeof (struct GNUNET_HashCode)); 136 memset (key, 0, sizeof (struct GNUNET_HashCode));
126 break; 137 return GNUNET_SYSERR;
127 } 138 }
128} 139}
129 140