2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 2005-2008 Zmanda Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 /* The taper source object abstracts the different ways that taper can
21 * retrieve and buffer data on its way to the device. It handles all
22 * splitting up and re-reading of split-tape parts, as well as all
23 * holding-disk related actions. */
26 #include <glib-object.h>
29 #include "server_util.h"
30 #include "fileheader.h"
33 #ifndef __TAPER_SOURCE_H__
34 #define __TAPER_SOURCE_H__
38 * Type checking and casting macros
40 #define TAPER_SOURCE_TYPE (taper_source_get_type())
41 #define TAPER_SOURCE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), taper_source_get_type(), TaperSource)
42 #define TAPER_SOURCE_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), taper_source_get_type(), TaperSource const)
43 #define TAPER_SOURCE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), taper_source_get_type(), TaperSourceClass)
44 #define IS_TAPER_SOURCE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), taper_source_get_type ())
46 #define TAPER_SOURCE_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), taper_source_get_type(), TaperSourceClass)
49 * Main object structure
51 #ifndef __TYPEDEF_TAPER_SOURCE__
52 #define __TYPEDEF_TAPER_SOURCE__
53 typedef struct _TaperSource TaperSource;
58 gboolean end_of_data; /* protected */
59 gboolean end_of_part; /* protected */
60 guint64 max_part_size; /* protected */
61 dumpfile_t * first_header;
69 typedef struct _TaperSourceClass TaperSourceClass;
70 struct _TaperSourceClass {
71 GObjectClass __parent__;
72 ssize_t (* read) (TaperSource * self, void * buf, size_t count);
73 gboolean (* seek_to_part_start) (TaperSource * self);
74 void (* start_new_part) (TaperSource * self);
75 gboolean (* is_partial) (TaperSource * self);
76 gboolean (* get_end_of_data)(TaperSource * self);
77 gboolean (* get_end_of_part)(TaperSource * self);
78 dumpfile_t * (* get_first_header)(TaperSource * self);
79 char * (* get_errmsg)(TaperSource * self);
80 int (* predict_parts)(TaperSource * self);
87 GType taper_source_get_type (void);
88 ssize_t taper_source_read (TaperSource * self,
91 gboolean taper_source_get_end_of_data (TaperSource * self);
92 gboolean taper_source_get_end_of_part (TaperSource * self);
93 dumpfile_t * taper_source_get_first_header (TaperSource * self);
94 char * taper_source_get_errmsg (TaperSource * self);
95 /* Returns -1 for an unknown number of splits, or a positive integer if the
96 * number of splits is exactly known. Should never return zero. */
97 int taper_source_predict_parts (TaperSource * self);
99 /* You can only call this function (and expect to get an accurate
100 result) if taper_source_get_end_of_data() has already returned
102 gboolean taper_source_is_partial (TaperSource * self);
104 gboolean taper_source_seek_to_part_start (TaperSource * self);
105 void taper_source_start_new_part (TaperSource * self);
107 /* This function is how you get a taper source. Call it with the
108 relevant parameters, and the return value is yours to
109 keep. Arguments must be consistant (e.g., if you specify FILE_WRITE
110 mode, then you must provide a holding disk file). Input strings are
111 copied internally. */
112 TaperSource * taper_source_new(char * handle,
113 cmd_t mode, char * holding_disk_file,
115 char * split_disk_buffer,
117 guint64 fallback_splitsize);
119 /* This function is a ProducerFunctor, as that type is defined in
120 device-src/queueing.h. */
121 producer_result_t taper_source_producer(gpointer taper_source,
122 queue_buffer_t * buffer,