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