Imported Upstream version 2.6.1
[debian/amanda] / device-src / tape-device.h
1 /*
2  * Copyright (c) 2005-2008 Zmanda Inc.  All Rights Reserved.
3  * 
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 2.1 as 
6  * published by the Free Software Foundation.
7  * 
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
11  * License for more details.
12  * 
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
16  * 
17  * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
18  * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19  */
20
21 #ifndef TAPE_DEVICE_H
22 #define TAPE_DEVICE_H
23
24 #include <device.h>
25
26 /* Unlike other Device classes, this class is implemented across multiple source
27  * files, so its class declaration is placed in a header file.
28  */
29
30 /*
31  * Type checking and casting macros
32  */
33
34 #define TYPE_TAPE_DEVICE        (tape_device_get_type())
35 #define TAPE_DEVICE(obj)        G_TYPE_CHECK_INSTANCE_CAST((obj), tape_device_get_type(), TapeDevice)
36 #define TAPE_DEVICE_CONST(obj)  G_TYPE_CHECK_INSTANCE_CAST((obj), tape_device_get_type(), TapeDevice const)
37 #define TAPE_DEVICE_CLASS(klass)        G_TYPE_CHECK_CLASS_CAST((klass), tape_device_get_type(), TapeDeviceClass)
38 #define IS_TAPE_DEVICE(obj)     G_TYPE_CHECK_INSTANCE_TYPE((obj), tape_device_get_type ())
39 #define TAPE_DEVICE_GET_CLASS(obj)      G_TYPE_INSTANCE_GET_CLASS((obj), tape_device_get_type(), TapeDeviceClass)
40 GType   tape_device_get_type    (void);
41
42 /*
43  * Main object structure
44  */
45 typedef struct TapeDevicePrivate_s TapeDevicePrivate;
46 typedef struct _TapeDevice {
47     Device __parent__;
48
49     /* It should go without saying that all this stuff is
50      * look-but-don't-touch. */
51
52     /* characteristics of the device */
53     gboolean fsf, bsf, fsr, bsr, eom, bsf_after_eom, broken_gmt_online;
54     int final_filemarks;
55
56     /* 0 if we opened with O_RDWR; error otherwise. */
57     gboolean write_open_errno;
58     int fd;
59
60     TapeDevicePrivate * private;
61 } TapeDevice;
62
63 /*
64  * Class definition
65  */
66 typedef struct _TapeDeviceClass TapeDeviceClass;
67 struct _TapeDeviceClass {
68         DeviceClass __parent__;
69 };
70
71 /* Tape device properties. These properties do not exist on non-linear
72    devices. */
73 extern DevicePropertyBase device_property_broken_gmt_online;
74 #define PROPERTY_BROKEN_GMT_ONLINE (device_property_broken_gmt_online.ID)
75
76 extern DevicePropertyBase device_property_fsf;
77 #define PROPERTY_FSF (device_property_fsf.ID)
78
79 extern DevicePropertyBase device_property_bsf;
80 #define PROPERTY_BSF (device_property_bsf.ID)
81
82 extern DevicePropertyBase device_property_fsr;
83 #define PROPERTY_FSR (device_property_fsr.ID)
84
85 extern DevicePropertyBase device_property_bsr;
86 #define PROPERTY_BSR (device_property_bsr.ID)
87
88 /* Is EOM supported? Must be able to read file number afterwards as
89    well. */
90 extern DevicePropertyBase device_property_eom;
91 #define PROPERTY_EOM (device_property_eom.ID)
92
93 /* Is it necessary to perform a BSF after EOM? */
94 extern DevicePropertyBase device_property_bsf_after_eom;
95 #define PROPERTY_BSF_AFTER_EOM (device_property_bsf_after_eom.ID)
96
97 /* How many filemarks to write at EOD? (Default is 2).
98  * This property is a G_TYPE_UINT, but can only really be set to 1 or 2. */
99 extern DevicePropertyBase device_property_final_filemarks;
100 #define PROPERTY_FINAL_FILEMARKS (device_property_final_filemarks.ID)
101
102 /* useful callback for tape ops */
103 void tape_device_set_capabilities(TapeDevice *self,
104         gboolean fsf, PropertySurety fsf_surety, PropertySource fsf_source,
105         gboolean bsf, PropertySurety bsf_surety, PropertySource bsf_source,
106         gboolean fsr, PropertySurety fsr_surety, PropertySource fsr_source,
107         gboolean bsr, PropertySurety bsr_surety, PropertySource bsr_source,
108         gboolean eom, PropertySurety eom_surety, PropertySource eom_source,
109         gboolean bsf_after_eom, PropertySurety bae_surety, PropertySource bae_source,
110         guint final_filemarks, PropertySurety ff_surety, PropertySource ff_source);
111
112 #endif