1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
3  *
4  * This library is free software: you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library.  If not, see
16  * <https://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __GIMP_WIRE_H__
20 #define __GIMP_WIRE_H__
21 
22 G_BEGIN_DECLS
23 
24 /* For information look into the C source or the html documentation */
25 
26 
27 typedef struct _GimpWireMessage  GimpWireMessage;
28 
29 typedef void     (* GimpWireReadFunc)    (GIOChannel      *channel,
30                                           GimpWireMessage *msg,
31                                           gpointer         user_data);
32 typedef void     (* GimpWireWriteFunc)   (GIOChannel      *channel,
33                                           GimpWireMessage *msg,
34                                           gpointer         user_data);
35 typedef void     (* GimpWireDestroyFunc) (GimpWireMessage *msg);
36 typedef gboolean (* GimpWireIOFunc)      (GIOChannel      *channel,
37                                           const guint8    *buf,
38                                           gulong           count,
39                                           gpointer         user_data);
40 typedef gboolean (* GimpWireFlushFunc)   (GIOChannel      *channel,
41                                           gpointer         user_data);
42 
43 
44 struct _GimpWireMessage
45 {
46   guint32  type;
47   gpointer data;
48 };
49 
50 
51 void      gimp_wire_register      (guint32              type,
52                                    GimpWireReadFunc     read_func,
53                                    GimpWireWriteFunc    write_func,
54                                    GimpWireDestroyFunc  destroy_func);
55 
56 void      gimp_wire_set_reader    (GimpWireIOFunc       read_func);
57 void      gimp_wire_set_writer    (GimpWireIOFunc       write_func);
58 void      gimp_wire_set_flusher   (GimpWireFlushFunc    flush_func);
59 
60 gboolean  gimp_wire_read          (GIOChannel          *channel,
61                                    guint8              *buf,
62                                    gsize                count,
63                                    gpointer             user_data);
64 gboolean  gimp_wire_write         (GIOChannel          *channel,
65                                    const guint8        *buf,
66                                    gsize                count,
67                                    gpointer             user_data);
68 gboolean  gimp_wire_flush         (GIOChannel          *channel,
69                                    gpointer             user_data);
70 
71 gboolean  gimp_wire_error         (void);
72 void      gimp_wire_clear_error   (void);
73 
74 gboolean  gimp_wire_read_msg      (GIOChannel          *channel,
75                                    GimpWireMessage     *msg,
76                                    gpointer             user_data);
77 gboolean  gimp_wire_write_msg     (GIOChannel          *channel,
78                                    GimpWireMessage     *msg,
79                                    gpointer             user_data);
80 
81 void      gimp_wire_destroy       (GimpWireMessage     *msg);
82 
83 
84 /*  for internal use in libgimpbase  */
85 
86 G_GNUC_INTERNAL gboolean  _gimp_wire_read_int64   (GIOChannel     *channel,
87                                                    guint64        *data,
88                                                    gint            count,
89                                                    gpointer        user_data);
90 G_GNUC_INTERNAL gboolean  _gimp_wire_read_int32   (GIOChannel     *channel,
91                                                    guint32        *data,
92                                                    gint            count,
93                                                    gpointer        user_data);
94 G_GNUC_INTERNAL gboolean  _gimp_wire_read_int16   (GIOChannel     *channel,
95                                                    guint16        *data,
96                                                    gint            count,
97                                                    gpointer        user_data);
98 G_GNUC_INTERNAL gboolean  _gimp_wire_read_int8    (GIOChannel     *channel,
99                                                    guint8         *data,
100                                                    gint            count,
101                                                    gpointer        user_data);
102 G_GNUC_INTERNAL gboolean  _gimp_wire_read_double  (GIOChannel     *channel,
103                                                    gdouble        *data,
104                                                    gint            count,
105                                                    gpointer        user_data);
106 G_GNUC_INTERNAL gboolean  _gimp_wire_read_string  (GIOChannel     *channel,
107                                                    gchar         **data,
108                                                    gint            count,
109                                                    gpointer        user_data);
110 G_GNUC_INTERNAL gboolean  _gimp_wire_read_color   (GIOChannel     *channel,
111                                                    GimpRGB        *data,
112                                                    gint            count,
113                                                    gpointer        user_data);
114 G_GNUC_INTERNAL gboolean  _gimp_wire_write_int64  (GIOChannel     *channel,
115                                                    const guint64  *data,
116                                                    gint            count,
117                                                    gpointer        user_data);
118 G_GNUC_INTERNAL gboolean  _gimp_wire_write_int32  (GIOChannel     *channel,
119                                                    const guint32  *data,
120                                                    gint            count,
121                                                    gpointer        user_data);
122 G_GNUC_INTERNAL gboolean  _gimp_wire_write_int16  (GIOChannel     *channel,
123                                                    const guint16  *data,
124                                                    gint            count,
125                                                    gpointer        user_data);
126 G_GNUC_INTERNAL gboolean  _gimp_wire_write_int8   (GIOChannel     *channel,
127                                                    const guint8   *data,
128                                                    gint            count,
129                                                    gpointer        user_data);
130 G_GNUC_INTERNAL gboolean  _gimp_wire_write_double (GIOChannel     *channel,
131                                                    const gdouble  *data,
132                                                    gint            count,
133                                                    gpointer        user_data);
134 G_GNUC_INTERNAL gboolean  _gimp_wire_write_string (GIOChannel     *channel,
135                                                    gchar         **data,
136                                                    gint            count,
137                                                    gpointer        user_data);
138 G_GNUC_INTERNAL gboolean  _gimp_wire_write_color  (GIOChannel     *channel,
139                                                    const GimpRGB  *data,
140                                                    gint            count,
141                                                    gpointer        user_data);
142 
143 
144 G_END_DECLS
145 
146 #endif /* __GIMP_WIRE_H__ */
147