+ struct GNUNET_BIO_WriteHandle *wh;
+ char *uris;
+
+ GNUNET_assert ( (GNUNET_YES == GNUNET_FS_uri_test_chk (sr->uri)) ||
+ (GNUNET_YES == GNUNET_FS_uri_test_loc (sr->uri)) );
+ uris = NULL;
+ if (NULL == sr->serialization)
+ sr->serialization = make_serialization_file_name (sr->sc->h,
+ "search-results");
+ if (NULL == sr->serialization)
+ return;
+ wh = get_write_handle (sr->sc->h, "search-results", sr->serialization);
+ uris = GNUNET_FS_uri_to_string (sr->uri);
+ if ( (GNUNET_OK !=
+ GNUNET_BIO_write_string (wh, uris)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_write_meta_data (wh, sr->meta)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_write (wh, key, sizeof (GNUNET_HashCode))) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_write_int32 (wh, sr->mandatory_missing)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_write_int32 (wh, sr->optional_support)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_write_int32 (wh, sr->availability_success)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_write_int32 (wh, sr->availability_trials)) )
+ goto cleanup;
+ if (GNUNET_OK !=
+ GNUNET_BIO_write_close (wh))
+ {
+ wh = NULL;
+ goto cleanup;
+ }
+ GNUNET_free_non_null (uris);
+ return;
+ cleanup:
+ GNUNET_free_non_null (uris);
+ if (wh != NULL)
+ (void) GNUNET_BIO_write_close (wh);
+ GNUNET_FS_remove_sync_file_ (sr->sc->h, "search-results", sr->serialization);
+ GNUNET_free (sr->serialization);
+ sr->serialization = NULL;