diff options
author | LRN <lrn1986@gmail.com> | 2013-03-04 01:20:48 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-03-04 01:20:48 +0000 |
commit | a100428ffd01733a28f4e66b61c958d9367209c2 (patch) | |
tree | 02bbbe1f798a8ab987533505d5e6a3bfabbe828a | |
parent | 93beeb2fafd68d5173587ad13f7538c4de2d000a (diff) | |
download | gnunet-a100428ffd01733a28f4e66b61c958d9367209c2.tar.gz gnunet-a100428ffd01733a28f4e66b61c958d9367209c2.zip |
Implement GNUNET_FS_namespace_insert_advertisement_into_metadata
-rw-r--r-- | src/fs/fs_namespace_advertise.c | 40 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 15 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/fs/fs_namespace_advertise.c b/src/fs/fs_namespace_advertise.c index 3b64e619c..554f61657 100644 --- a/src/fs/fs_namespace_advertise.c +++ b/src/fs/fs_namespace_advertise.c | |||
@@ -200,6 +200,46 @@ advertisement_cont (void *cls, int success, | |||
200 | 200 | ||
201 | 201 | ||
202 | /** | 202 | /** |
203 | * Create an SKS uri that points to the root entry of the namespace, | ||
204 | * then insert that SKS uri into metadata. | ||
205 | * | ||
206 | * @param ns handle for the namespace that should be advertised | ||
207 | * @param meta meta-data into which namespace advertisement should be inserted | ||
208 | * @param rootEntry name of the root of the namespace (use NULL to use default) | ||
209 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
210 | */ | ||
211 | int | ||
212 | GNUNET_FS_namespace_insert_advertisement_into_metadata ( | ||
213 | struct GNUNET_FS_Namespace *ns, struct GNUNET_CONTAINER_MetaData *meta, | ||
214 | const char *rootEntry) | ||
215 | { | ||
216 | struct GNUNET_FS_Uri *sks_uri; | ||
217 | char *emsg; | ||
218 | char *sks_uri_string; | ||
219 | int md_insert; | ||
220 | |||
221 | if (NULL == rootEntry) | ||
222 | rootEntry = "/"; | ||
223 | |||
224 | emsg = NULL; | ||
225 | sks_uri = GNUNET_FS_uri_sks_create (ns, rootEntry, &emsg); | ||
226 | GNUNET_free_non_null (emsg); | ||
227 | if (NULL == sks_uri) | ||
228 | return GNUNET_SYSERR; | ||
229 | |||
230 | sks_uri_string = GNUNET_FS_uri_to_string (sks_uri); | ||
231 | GNUNET_FS_uri_destroy (sks_uri); | ||
232 | if (NULL == sks_uri_string) | ||
233 | return GNUNET_SYSERR; | ||
234 | |||
235 | md_insert = GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", | ||
236 | EXTRACTOR_METATYPE_URI, EXTRACTOR_METAFORMAT_UTF8, | ||
237 | "text/plain", sks_uri_string, strlen (sks_uri_string) + 1); | ||
238 | GNUNET_free (sks_uri_string); | ||
239 | return md_insert; | ||
240 | } | ||
241 | |||
242 | /** | ||
203 | * Publish an advertismement for a namespace. | 243 | * Publish an advertismement for a namespace. |
204 | * | 244 | * |
205 | * @param h handle to the file sharing subsystem | 245 | * @param h handle to the file sharing subsystem |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index c4cec81cd..efe2cd004 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -2219,6 +2219,21 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | |||
2219 | 2219 | ||
2220 | 2220 | ||
2221 | /** | 2221 | /** |
2222 | * Create an SKS uri that points to the root entry of the namespace, | ||
2223 | * then insert that SKS uri into metadata. | ||
2224 | * | ||
2225 | * @param ns handle for the namespace that should be advertised | ||
2226 | * @param meta meta-data into which namespace advertisement should be inserted | ||
2227 | * @param rootEntry name of the root of the namespace (use NULL to use default) | ||
2228 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
2229 | */ | ||
2230 | int | ||
2231 | GNUNET_FS_namespace_insert_advertisement_into_metadata ( | ||
2232 | struct GNUNET_FS_Namespace *ns, struct GNUNET_CONTAINER_MetaData *meta, | ||
2233 | const char *rootEntry); | ||
2234 | |||
2235 | |||
2236 | /** | ||
2222 | * Abort the namespace advertisement operation. | 2237 | * Abort the namespace advertisement operation. |
2223 | * | 2238 | * |
2224 | * @param ac context of the operation to abort. | 2239 | * @param ac context of the operation to abort. |