Debian Codegraph @

device-src/directtcp-connection.h

raw
1 /*
2 * Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
3 * Copyright (c) 2013-2016 Carbonite, Inc. All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Contact information: Zmanda Inc., 465 N Mathlida Ave, Suite 300
20 * Sunnyvale, CA 94085, or: http://www.zmanda.com
21 */
22
23 #ifndef DIRECTTCP_CONNECTION_H
24 #define DIRECTTCP_CONNECTION_H
25
26 #include <glib.h>
27 #include <glib-object.h>
28
29 GType directtcp_connection_get_type (void);
30 #define TYPE_DIRECTTCP_CONNECTION (directtcp_connection_get_type())
31 #define DIRECTTCP_CONNECTION(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_get_type(), DirectTCPConnection)
32 #define IS_DIRECTTCP_CONNECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), directtcp_connection_get_type ())
33 #define DIRECTTCP_CONNECTION_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), directtcp_connection_get_type(), DirectTCPConnectionClass)
34
35 /*
36 * Parent class for connections
37 */
38
39 typedef struct DirectTCPConnection {
40 GObject __parent__;
41
42 gboolean closed;
43 } DirectTCPConnection;
44
45 typedef struct DirectTCPConnectionClass_ {
46 GObjectClass __parent__;
47
48 /* The DirectTCPConnection object allows a particular connection to "span"
49 * multiple devices -- the caller gets the connection from one device,
50 * reads or writes as desired, then creates a new device and passes the
51 * connection to that device. If the new device cannot use the old
52 * connection, then it generates a suitable error message.
53 */
54
55 /* call this to close the connection (even if the Device that created
56 * it is long gone). Note that this will be called automatically by
57 * finalize, but it is a programming error to allow this to happen as
58 * any error will be fatal.
59 *
60 * @param self: object
61 * @returns: error message on error, NULL for no error (caller should
62 * free the error message)
63 */
64 char *(* close)(struct DirectTCPConnection *self);
65 } DirectTCPConnectionClass;
66
67 /* Method Stubs */
68
69 char *directtcp_connection_close(
70 DirectTCPConnection *self);
71
72 /*
73 * A simple connection subclass containing a local TCP socket, useful for testing
74 */
75
76 #define TYPE_DIRECTTCP_CONNECTION_SOCKET (directtcp_connection_socket_get_type())
77 #define DIRECTTCP_CONNECTION_SOCKET(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocket)
78 #define DIRECTTCP_CONNECTION_SOCKET_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocket const)
79 #define DIRECTTCP_CONNECTION_SOCKET_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), directtcp_connection_socket_get_type(), DirectTCPConnectionSocketClass)
80 #define IS_DIRECTTCP_CONNECTION_SOCKET(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), directtcp_connection_socket_get_type ())
81 #define DIRECTTCP_CONNECTION_SOCKET_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocketClass)
82 GType directtcp_connection_socket_get_type(void);
83
84 typedef struct DirectTCPConnectionSocket_ {
85 DirectTCPConnection __parent__;
86 int socket;
87 } DirectTCPConnectionSocket;
88
89 typedef struct DirectTCPConnectionSocketClass_ {
90 DirectTCPConnectionClass __parent__;
91 } DirectTCPConnectionSocketClass;
92
93 /* Method Stubs */
94
95 DirectTCPConnectionSocket *directtcp_connection_socket_new(int socket);
96
97 #endif /* DIRECTTCP_CONNECTION_H */