search stuff
authorChristian Grothoff <christian@grothoff.org>
Sat, 1 May 2010 11:25:18 +0000 (11:25 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 1 May 2010 11:25:18 +0000 (11:25 +0000)
src/fs/fs.c
src/fs/fs.h

index 84985855b4cd8d1ff4f4c4259f5c231e0ca48720..c25e1919e736331a85ba3ba475260c4df4a071e3 100644 (file)
@@ -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.
  *
index 9441b76e05959203ad8272196d098a14baccda20..3c111f33e65617929ba14fe96c10707fed3e1903 100644 (file)
@@ -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