2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 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
22 #include "simpleprng.h"
27 * This declaration is entirely private; nothing but xfer_dest_null() references
31 GType xfer_dest_null_get_type(void);
32 #define XFER_DEST_NULL_TYPE (xfer_dest_null_get_type())
33 #define XFER_DEST_NULL(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_null_get_type(), XferDestNull)
34 #define XFER_DEST_NULL_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_null_get_type(), XferDestNull const)
35 #define XFER_DEST_NULL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_dest_null_get_type(), XferDestNullClass)
36 #define IS_XFER_DEST_NULL(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_dest_null_get_type ())
37 #define XFER_DEST_NULL_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_dest_null_get_type(), XferDestNullClass)
39 static GObjectClass *parent_class = NULL;
42 * Main object structure
45 typedef struct XferDestNull {
46 XferElement __parent__;
51 simpleprng_state_t prng;
59 XferElementClass __parent__;
72 XferDestNull *self = (XferDestNull *)elt;
77 if (self->do_verify && !elt->cancelled) {
78 if (!simpleprng_verify_buffer(&self->prng, buf, len)) {
79 xfer_element_handle_error(elt,
80 _("verification of incoming bytestream failed"));
86 if (!self->sent_info) {
87 /* send a superfluous message (this is a testing XferElement,
89 XMsg *msg = xmsg_new((XferElement *)self, XMSG_INFO, 0);
90 msg->message = stralloc("Is this thing on?");
91 xfer_queue_message(XFER_ELEMENT(self)->xfer, msg);
92 self->sent_info = TRUE;
100 XferDestNullClass * selfc)
102 XferElementClass *klass = XFER_ELEMENT_CLASS(selfc);
103 static xfer_element_mech_pair_t mech_pairs[] = {
104 { XFER_MECH_PUSH_BUFFER, XFER_MECH_NONE, 0, 0},
105 { XFER_MECH_NONE, XFER_MECH_NONE, 0, 0},
108 klass->push_buffer = push_buffer_impl;
110 klass->perl_class = "Amanda::Xfer::Dest::Null";
111 klass->mech_pairs = mech_pairs;
113 parent_class = g_type_class_peek_parent(selfc);
117 xfer_dest_null_get_type (void)
119 static GType type = 0;
121 if G_UNLIKELY(type == 0) {
122 static const GTypeInfo info = {
123 sizeof (XferDestNullClass),
124 (GBaseInitFunc) NULL,
125 (GBaseFinalizeFunc) NULL,
126 (GClassInitFunc) class_init,
127 (GClassFinalizeFunc) NULL,
128 NULL /* class_data */,
129 sizeof (XferDestNull),
131 (GInstanceInitFunc) NULL,
135 type = g_type_register_static (XFER_ELEMENT_TYPE, "XferDestNull", &info, 0);
141 /* create an element of this class; prototype is in xfer-element.h */
146 XferDestNull *self = (XferDestNull *)g_object_new(XFER_DEST_NULL_TYPE, NULL);
147 XferElement *elt = XFER_ELEMENT(self);
150 self->do_verify = TRUE;
151 simpleprng_seed(&self->prng, prng_seed);
154 self->do_verify = FALSE;