Imported Upstream version 3.1.0
[debian/amanda] / device-src / xfer-dest-taper.c
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 2009 Zmanda, Inc.  All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17  *
18  * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
20  */
21
22 #include "amanda.h"
23 #include "xfer-device.h"
24
25 static void
26 class_init(
27     XferDestTaperClass * selfc)
28 {
29     XferElementClass *klass = XFER_ELEMENT_CLASS(selfc);
30
31     klass->perl_class = "Amanda::Xfer::Dest::Taper";
32 }
33
34 GType
35 xfer_dest_taper_get_type (void)
36 {
37     static GType type = 0;
38
39     if G_UNLIKELY(type == 0) {
40         static const GTypeInfo info = {
41             sizeof (XferDestTaperClass),
42             (GBaseInitFunc) NULL,
43             (GBaseFinalizeFunc) NULL,
44             (GClassInitFunc) class_init,
45             (GClassFinalizeFunc) NULL,
46             NULL /* class_data */,
47             sizeof (XferDestTaper),
48             0 /* n_preallocs */,
49             (GInstanceInitFunc) NULL,
50             NULL
51         };
52
53         type = g_type_register_static (XFER_ELEMENT_TYPE, "XferDestTaper", &info, 0);
54     }
55
56     return type;
57 }
58
59 /*
60  * Method stubs
61  */
62
63 void
64 xfer_dest_taper_start_part(
65     XferElement *elt,
66     gboolean retry_part,
67     dumpfile_t *header)
68 {
69     XferDestTaperClass *klass;
70     g_assert(IS_XFER_DEST_TAPER(elt));
71
72     klass = XFER_DEST_TAPER_GET_CLASS(elt);
73     klass->start_part(XFER_DEST_TAPER(elt), retry_part, header);
74 }
75
76 void
77 xfer_dest_taper_use_device(
78     XferElement *elt,
79     Device *device)
80 {
81     XferDestTaperClass *klass;
82     g_assert(IS_XFER_DEST_TAPER(elt));
83
84     klass = XFER_DEST_TAPER_GET_CLASS(elt);
85     klass->use_device(XFER_DEST_TAPER(elt), device);
86 }
87
88 void
89 xfer_dest_taper_cache_inform(
90     XferElement *elt,
91     const char *filename,
92     off_t offset,
93     off_t length)
94 {
95     XferDestTaperClass *klass;
96     g_assert(IS_XFER_DEST_TAPER(elt));
97
98     klass = XFER_DEST_TAPER_GET_CLASS(elt);
99     klass->cache_inform(XFER_DEST_TAPER(elt), filename, offset, length);
100 }
101
102 guint64
103 xfer_dest_taper_get_part_bytes_written(
104     XferElement *elt G_GNUC_UNUSED)
105 {
106     XferDestTaperClass *klass;
107     g_assert(IS_XFER_DEST_TAPER(elt));
108
109     klass = XFER_DEST_TAPER_GET_CLASS(elt);
110     if (klass->get_part_bytes_written)
111         return klass->get_part_bytes_written(XFER_DEST_TAPER(elt));
112     else
113         return 0;
114 }