2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 2006 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_TYPE_SOURCE (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 TAPER_IS_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;
68 typedef struct _TaperSourceClass TaperSourceClass;
69 struct _TaperSourceClass {
70 GObjectClass __parent__;
71 ssize_t (* read) (TaperSource * self, void * buf, size_t count);
72 gboolean (* seek_to_part_start) (TaperSource * self);
73 void (* start_new_part) (TaperSource * self);
74 gboolean (* is_partial) (TaperSource * self);
75 gboolean (* get_end_of_data)(TaperSource * self);
76 gboolean (* get_end_of_part)(TaperSource * self);
77 dumpfile_t * (* get_first_header)(TaperSource * self);
78 int (* predict_parts)(TaperSource * self);
85 GType taper_source_get_type (void);
86 ssize_t taper_source_read (TaperSource * self,
89 gboolean taper_source_get_end_of_data (TaperSource * self);
90 gboolean taper_source_get_end_of_part (TaperSource * self);
91 dumpfile_t * taper_source_get_first_header (TaperSource * self);
92 /* Returns -1 for an unknown number of splits, or a positive integer if the
93 * number of splits is exactly known. Should never return zero. */
94 int taper_source_predict_parts (TaperSource * self);
96 /* You can only call this function (and expect to get an accurate
97 result) if taper_source_get_end_of_data() has already returned
99 gboolean taper_source_is_partial (TaperSource * self);
101 gboolean taper_source_seek_to_part_start (TaperSource * self);
102 void taper_source_start_new_part (TaperSource * self);
104 /* This function is how you get a taper source. Call it with the
105 relevant parameters, and the return value is yours to
106 keep. Arguments must be consistant (e.g., if you specify FILE_WRITE
107 mode, then you must provide a holding disk file). Input strings are
108 copied internally. */
109 TaperSource * taper_source_new(char * handle,
110 cmd_t mode, char * holding_disk_file,
112 char * split_disk_buffer,
114 guint64 fallback_splitsize);
116 /* This function is a ProducerFunctor, as that type is defined in
117 device-src/queueing.h. */
118 producer_result_t taper_source_producer(gpointer taper_source,
119 queue_buffer_t * buffer,