From: Christian Grothoff Date: Sat, 1 May 2010 11:25:18 +0000 (+0000) Subject: search stuff X-Git-Tag: initial-import-from-subversion-38251~21930 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9ad7467ccbfd92fb30881579344ffb3cc5ff3584;p=oweals%2Fgnunet.git search stuff --- diff --git a/src/fs/fs.c b/src/fs/fs.c index 84985855b..c25e1919e 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -1243,6 +1243,60 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) } +/** + * Synchronize this search struct with its mirror + * on disk. Note that all internal FS-operations that change + * publishing structs should already call "sync" internally, + * so this function is likely not useful for clients. + * + * @param sc the struct to sync + */ +void +GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) +{ + struct GNUNET_BIO_WriteHandle *wh; + + if (NULL == sc->serialization) + sc->serialization = make_serialization_file_name (sc->h, + "search"); + if (NULL == sc->serialization) + return; + wh = get_write_handle (sc->h, "search", sc->serialization); +#if 0 + if ( (GNUNET_OK != + GNUNET_BIO_write_string (wh, pc->nid)) || + (GNUNET_OK != + GNUNET_BIO_write_string (wh, pc->nuid)) || + (GNUNET_OK != + GNUNET_BIO_write_int32 (wh, pc->options)) || + (GNUNET_OK != + GNUNET_BIO_write_int32 (wh, pc->all_done)) || + (GNUNET_OK != + GNUNET_BIO_write_string (wh, pc->fi->serialization)) || + (GNUNET_OK != + GNUNET_BIO_write_string (wh, (pc->fi_pos == NULL) ? NULL : pc->fi_pos->serialization)) || + (GNUNET_OK != + GNUNET_BIO_write_string (wh, (pc->namespace == NULL) ? NULL : pc->namespace->name)) ) + { + (void) GNUNET_BIO_write_close (wh); + GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization); + GNUNET_free (pc->serialization); + pc->serialization = NULL; + return; + } +#endif + /* FIXME: do search-specific deserialization here! */ + if (GNUNET_OK != + GNUNET_BIO_write_close (wh)) + { + GNUNET_FS_remove_sync_file_ (sc->h, "search", sc->serialization); + GNUNET_free (sc->serialization); + sc->serialization = NULL; + return; + } +} + + /** * Deserialize information about pending publish operations. * diff --git a/src/fs/fs.h b/src/fs/fs.h index 9441b76e0..3c111f33e 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -757,6 +757,19 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); +/** + * Synchronize this search struct with its mirror + * on disk. Note that all internal FS-operations that change + * publishing structs should already call "sync" internally, + * so this function is likely not useful for clients. + * + * @param sc the struct to sync + */ +void +GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); + + + /** * Master context for most FS operations. */ @@ -1222,6 +1235,11 @@ struct GNUNET_FS_SearchContext */ void *client_info; + /** + * Name of the file on disk we use for persistence. + */ + char *serialization; + /** * Map that contains a "struct SearchResult" for each result that * was found in the search. The key for each entry is the XOR of