Imported Upstream version 3.2.0
[debian/amanda] / device-src / xfer-device.h
index 8fbc7a2c71339642a9088a6da78af31fa3072085..f18916b3df6d4836a77bc7eee2884df29c91abcf 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "amxfer.h"
 #include "device.h"
+#include "xfer-dest-taper.h"
 
 /* A transfer source that reads from a Device. The device must be positioned
  * at the start of a file before the transfer is started.  The transfer will
@@ -39,97 +40,40 @@ XferElement *xfer_source_device(
 
 /* A transfer destination that writes bytes to a Device.  The device should have a
  * file started, ready for a device_write_block call.  On completion of the transfer,
- * the file will be finished.
+ * the file will be finished.  If a device error occurs, the transfer will be cancelled.
+ *
+ * If cancel_at_leom is true, then the transfer will also be cancelled on LEOM, with
+ * the error message containing the string "LEOM detected" (this is used by amtapetype).
  *
  * Implemented in xfer-dest-device.c
  *
  * @param device: the Device to write to, with a file started
- * @param max_memory: total amount of memory to use for buffers, or zero
- *                    for a reasonable default.
+ * @param canel_at_leom: if true, the element will cancel the transfer at LEOM.
  * @return: new element
  */
 XferElement *xfer_dest_device(
     Device *device,
-    size_t max_memory);
-
-/*
- * class declaration for XferDestTaper (an abstract base class)
- */
-
-GType xfer_dest_taper_get_type(void);
-#define XFER_DEST_TAPER_TYPE (xfer_dest_taper_get_type())
-#define XFER_DEST_TAPER(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_taper_get_type(), XferDestTaper)
-#define XFER_DEST_TAPER_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_taper_get_type(), XferDestTaper const)
-#define XFER_DEST_TAPER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_dest_taper_get_type(), XferDestTaperClass)
-#define IS_XFER_DEST_TAPER(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_dest_taper_get_type ())
-#define XFER_DEST_TAPER_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_dest_taper_get_type(), XferDestTaperClass)
-
-typedef struct XferDestTaper_ {
-    XferElement __parent__;
-} XferDestTaper;
-
-typedef struct {
-    XferElementClass __parent__;
-
-    /* see xfer-device.h for details of these methods */
-    void (*start_part)(XferDestTaper *self, gboolean retry_part, dumpfile_t *header);
-    void (*use_device)(XferDestTaper *self, Device *device);
-    void (*cache_inform)(XferDestTaper *self, const char *filename, off_t offset,
-                        off_t length);
-    guint64 (*get_part_bytes_written)(XferDestTaper *self);
-} XferDestTaperClass;
-
-/* Start writing the next part to the given device.  The part will be written
- * to the device given to use_device, which should be open and properly positioned.
- * It should not have a file open yet.
- *
- * @param self: the XferDestTaper object
- * @param retry_part: retry the previous (incomplete) part if true
- * @param header: part header
- */
-void xfer_dest_taper_start_part(
-    XferElement *self,
-    gboolean retry_part,
-    dumpfile_t *header);
-
-/* Prepare to write subsequent parts to the given device.  The device must
- * not be started yet.  It is not necessary to call this method for the first
- * device used in a transfer.
- *
- * @param self: the XferDestTaper object
- * @param device: the device
- */
-void xfer_dest_taper_use_device(
-    XferElement *self,
-    Device *device);
-
-/* Add a slice of data to the cache for the element.  This is used by the taper
- * when reading from holding disk, to tell the element which holding disk files
- * contain the data that might be needed when rewinding, but can be used in any
- * situation where the part data is already on-disk.  The order of calls to this
- * function dictates the order in whch the files will be read, and no gaps or
- * overlaps are supported.  Note, too, that this must be called *before* any of
- * the data in the new file is sent into the transfer.
- *
- * @param self: the XferDestTaper object
- * @param filename: the fully qualified filename of the cache file
- * @param offset: offset into the file at which data begins
- * @param length: length of data in file
- */
-void xfer_dest_taper_cache_inform(
-    XferElement *self,
-    const char *filename,
-    off_t offset,
-    off_t length);
+    gboolean canel_at_leom);
 
-/* Return the number of bytes written for the current part.
+/* Constructor for XferDestTaperSplitter, which writes data to devices block by
+ * block and splitting parts but no caching.
  *
- * @param self: the XferDestTaper object
+ * @param first_device: the first device that will be used with this xfer, used
+ *                      to calculate some internal parameters
+ * @param max_memory: total amount of memory to use for buffers, or zero
+ *                    for a reasonable default.
+ * @param part_size: the desired size of each part
+ * @param expect_cache_inform: TRUE if this element will get cache_inform messages
+ * @return: new element
  */
-guint64 xfer_dest_taper_get_part_bytes_written(
-    XferElement *self);
+XferElement *
+xfer_dest_taper_splitter(
+    Device *first_device,
+    size_t max_memory,
+    guint64 part_size,
+    gboolean expect_cache_inform);
 
-/* Constructor for XferDestTaperSplitter, which writes data to devices block by
+/* Constructor for XferDestTaperCacher, which writes data to devices block by
  * block and handles caching and splitting parts.
  *
  * @param first_device: the first device that will be used with this xfer, used
@@ -143,7 +87,7 @@ guint64 xfer_dest_taper_get_part_bytes_written(
  * @return: new element
  */
 XferElement *
-xfer_dest_taper_splitter(
+xfer_dest_taper_cacher(
     Device *first_device,
     size_t max_memory,
     guint64 part_size,