Asynchronous namespace creation. With a test.
[oweals/gnunet.git] / src / include / gnunet_fs_service.h
index a80662867e0d8404d02b8a12e41dcacca2aa52de..d6b26d92794924c275f6b9dd5ba4189cbfef9e59 100644 (file)
@@ -2239,6 +2239,45 @@ struct GNUNET_FS_Namespace *
 GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h, const char *name);
 
 
+/**
+ * Context for creating a namespace asynchronously.
+ */
+struct GNUNET_FS_NamespaceCreationContext;
+
+/**
+ * Function called upon completion of 'GNUNET_FS_namespace_create_start'.
+ *
+ * @param cls closure
+ * @param ns NULL on error, otherwise the namespace (which must be free'd by the callee)
+ * @param emsg NULL on success, otherwise an error message
+ */
+typedef void (*GNUNET_FS_NamespaceCreationCallback)(void *cls,
+    struct GNUNET_FS_Namespace *ns, const char *emsg);
+
+
+/**
+ * Create a namespace with the given name; if one already
+ * exists, return a handle to the existing namespace immediately.
+ * Otherwise create a namespace asynchronously.
+ *
+ * @param h handle to the file sharing subsystem
+ * @param name name to use for the namespace
+ * @return namespace creation context, NULL on error (i.e. invalid filename)
+ */
+struct GNUNET_FS_NamespaceCreationContext *
+GNUNET_FS_namespace_create_start (struct GNUNET_FS_Handle *h, const char *name,
+    GNUNET_FS_NamespaceCreationCallback cont, void *cont_cls);
+
+
+/**
+ * Abort namespace creation.
+ *
+ * @param ncc namespace creation context to abort
+ */
+void
+GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc);
+
+
 /**
  * Duplicate a namespace handle.
  *