Imported Upstream version 3.2.0
[debian/amanda] / xfer-src / dest-directtcp-listen.c
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 2008, 2009, 2010 Zmanda, Inc.  All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17  *
18  * Contact information: Zmanda Inc., 465 N Mathlida Ave, Suite 300
19  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
20  */
21
22 #include "amanda.h"
23 #include "amxfer.h"
24 #include "sockaddr-util.h"
25
26 /*
27  * Class declaration
28  *
29  * This declaration is entirely private; nothing but xfer_dest_directtcp_listen() references
30  * it directly.
31  */
32
33 GType xfer_dest_directtcp_listen_get_type(void);
34 #define XFER_DEST_DIRECTTCP_LISTEN_TYPE (xfer_dest_directtcp_listen_get_type())
35 #define XFER_DEST_DIRECTTCP_LISTEN(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_directtcp_listen_get_type(), XferDestDirectTCPListen)
36 #define XFER_DEST_DIRECTTCP_LISTEN_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_directtcp_listen_get_type(), XferDestDirectTCPListen const)
37 #define XFER_DEST_DIRECTTCP_LISTEN_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_dest_directtcp_listen_get_type(), XferDestDirectTCPListenClass)
38 #define IS_XFER_DEST_DIRECTTCP_LISTEN(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_dest_directtcp_listen_get_type ())
39 #define XFER_DEST_DIRECTTCP_LISTEN_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_dest_directtcp_listen_get_type(), XferDestDirectTCPListenClass)
40
41 static GObjectClass *parent_class = NULL;
42
43 /*
44  * Main object structure
45  */
46
47 typedef struct XferDestDirectTCPListen {
48     XferElement __parent__;
49 } XferDestDirectTCPListen;
50
51 /*
52  * Class definition
53  */
54
55 typedef struct {
56     XferElementClass __parent__;
57 } XferDestDirectTCPListenClass;
58
59 /*
60  * Implementation
61  */
62
63 static gboolean
64 start_impl(
65     XferElement *elt)
66 {
67     elt->output_listen_addrs = elt->upstream->output_listen_addrs;
68
69     return FALSE;
70 }
71
72 static void
73 class_init(
74     XferDestDirectTCPListenClass * selfc)
75 {
76     XferElementClass *klass = XFER_ELEMENT_CLASS(selfc);
77     static xfer_element_mech_pair_t mech_pairs[] = {
78         { XFER_MECH_DIRECTTCP_CONNECT, XFER_MECH_NONE, 0, 0},
79         { XFER_MECH_NONE, XFER_MECH_NONE, 0, 0},
80     };
81
82     klass->start = start_impl;
83
84     klass->perl_class = "Amanda::Xfer::Dest::DirectTCPListen";
85     klass->mech_pairs = mech_pairs;
86
87     parent_class = g_type_class_peek_parent(selfc);
88 }
89
90 GType
91 xfer_dest_directtcp_listen_get_type (void)
92 {
93     static GType type = 0;
94
95     if G_UNLIKELY(type == 0) {
96         static const GTypeInfo info = {
97             sizeof (XferDestDirectTCPListenClass),
98             (GBaseInitFunc) NULL,
99             (GBaseFinalizeFunc) NULL,
100             (GClassInitFunc) class_init,
101             (GClassFinalizeFunc) NULL,
102             NULL /* class_data */,
103             sizeof (XferDestDirectTCPListen),
104             0 /* n_preallocs */,
105             (GInstanceInitFunc) NULL,
106             NULL
107         };
108
109         type = g_type_register_static (XFER_ELEMENT_TYPE, "XferDestDirectTCPListen", &info, 0);
110     }
111
112     return type;
113 }
114
115 /* create an element of this class; prototype is in xfer-element.h */
116 XferElement *
117 xfer_dest_directtcp_listen(void)
118 {
119     XferDestDirectTCPListen *self = (XferDestDirectTCPListen *)
120                 g_object_new(XFER_DEST_DIRECTTCP_LISTEN_TYPE, NULL);
121     XferElement *elt = XFER_ELEMENT(self);
122
123     return elt;
124 }