gio2 0.90.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +60 -0
- data/README +34 -0
- data/Rakefile +76 -0
- data/ext/gio2/depend +5 -0
- data/ext/gio2/extconf.rb +91 -0
- data/ext/gio2/gappinfo.c +318 -0
- data/ext/gio2/gapplaunchcontext.c +79 -0
- data/ext/gio2/gasyncinitable.c +244 -0
- data/ext/gio2/gasyncresult.c +39 -0
- data/ext/gio2/gbufferedinputstream.c +184 -0
- data/ext/gio2/gbufferedoutputstream.c +82 -0
- data/ext/gio2/gcancellable.c +177 -0
- data/ext/gio2/gcharsetconverter.c +72 -0
- data/ext/gio2/gcontenttype.c +135 -0
- data/ext/gio2/gconverter.c +117 -0
- data/ext/gio2/gconverterinputstream.c +48 -0
- data/ext/gio2/gconverteroutputstream.c +48 -0
- data/ext/gio2/gdatainputstream.c +341 -0
- data/ext/gio2/gdataoutputstream.c +202 -0
- data/ext/gio2/gdesktopappinfo.c +90 -0
- data/ext/gio2/gdrive.c +267 -0
- data/ext/gio2/gemblem.c +71 -0
- data/ext/gio2/gemblemedicon.c +63 -0
- data/ext/gio2/gfile.c +2058 -0
- data/ext/gio2/gfileattribute.c +263 -0
- data/ext/gio2/gfileattributematcher.c +90 -0
- data/ext/gio2/gfiledescriptorbased.c +42 -0
- data/ext/gio2/gfileenumerator.c +167 -0
- data/ext/gio2/gfileicon.c +46 -0
- data/ext/gio2/gfileinfo.c +641 -0
- data/ext/gio2/gfileinputstream.c +92 -0
- data/ext/gio2/gfileiostream.c +98 -0
- data/ext/gio2/gfilemonitor.c +63 -0
- data/ext/gio2/gfilenamecompleter.c +72 -0
- data/ext/gio2/gfileoutputstream.c +100 -0
- data/ext/gio2/gfilterinputstream.c +56 -0
- data/ext/gio2/gfilteroutputstream.c +56 -0
- data/ext/gio2/gicon.c +69 -0
- data/ext/gio2/ginetaddress.c +188 -0
- data/ext/gio2/ginetsocketaddress.c +54 -0
- data/ext/gio2/ginitable.c +195 -0
- data/ext/gio2/ginputstream.c +341 -0
- data/ext/gio2/gio2.c +120 -0
- data/ext/gio2/gio2.def +2 -0
- data/ext/gio2/gio2.h +343 -0
- data/ext/gio2/gioerror.c +67 -0
- data/ext/gio2/giomodule.c +63 -0
- data/ext/gio2/gioscheduler.c +195 -0
- data/ext/gio2/giostream.c +129 -0
- data/ext/gio2/gloadableicon.c +91 -0
- data/ext/gio2/gmemoryinputstream.c +65 -0
- data/ext/gio2/gmemoryoutputstream.c +65 -0
- data/ext/gio2/gmount.c +283 -0
- data/ext/gio2/gmountoperation.c +168 -0
- data/ext/gio2/gnetworkaddress.c +71 -0
- data/ext/gio2/gnetworkservice.c +64 -0
- data/ext/gio2/goutputstream.c +343 -0
- data/ext/gio2/gresolver.c +230 -0
- data/ext/gio2/gseekable.c +89 -0
- data/ext/gio2/gsimpleasyncresult.c +153 -0
- data/ext/gio2/gsocket.c +451 -0
- data/ext/gio2/gsocketaddress.c +45 -0
- data/ext/gio2/gsocketclient.c +273 -0
- data/ext/gio2/gsocketconnectable.c +97 -0
- data/ext/gio2/gsocketconnection.c +82 -0
- data/ext/gio2/gsocketcontrolmessage.c +82 -0
- data/ext/gio2/gsocketlistener.c +239 -0
- data/ext/gio2/gsocketservice.c +64 -0
- data/ext/gio2/gsrvtarget.c +77 -0
- data/ext/gio2/gtcpconnection.c +48 -0
- data/ext/gio2/gthemedicon.c +86 -0
- data/ext/gio2/gthreadedsocketservice.c +39 -0
- data/ext/gio2/gunixconnection.c +69 -0
- data/ext/gio2/gunixfdlist.c +112 -0
- data/ext/gio2/gunixfdmessage.c +81 -0
- data/ext/gio2/gunixinputstream.c +73 -0
- data/ext/gio2/gunixmounts.c +346 -0
- data/ext/gio2/gunixoutputstream.c +73 -0
- data/ext/gio2/gunixsocketaddress.c +79 -0
- data/ext/gio2/gvfs.c +84 -0
- data/ext/gio2/gvolume.c +191 -0
- data/ext/gio2/gvolumemonitor.c +77 -0
- data/ext/gio2/gzlibcompressor.c +47 -0
- data/ext/gio2/gzlibdecompressor.c +43 -0
- data/ext/gio2/util.c +323 -0
- data/extconf.rb +49 -0
- data/lib/gio2.rb +141 -0
- metadata +184 -0
data/ext/gio2/gsocket.c
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
|
5
|
+
*
|
|
6
|
+
* This library is free software; you can redistribute it and/or
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
* License as published by the Free Software Foundation; either
|
|
9
|
+
* version 2.1 of the License.
|
|
10
|
+
*
|
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
* Lesser General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
* License along with this library; if not, write to the Free Software
|
|
18
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#include "gio2.h"
|
|
22
|
+
|
|
23
|
+
#define _SELF(value) RVAL2GSOCKET(value)
|
|
24
|
+
|
|
25
|
+
#define RVAL2GIOCONDITION(value) RVAL2GFLAGS((value), G_TYPE_IO_CONDITION)
|
|
26
|
+
|
|
27
|
+
#define GIOCONDITION2RVAL(value) GENUM2RVAL((value), G_TYPE_IO_CONDITION)
|
|
28
|
+
|
|
29
|
+
static VALUE
|
|
30
|
+
socket_initialize(int argc, VALUE *argv, VALUE self)
|
|
31
|
+
{
|
|
32
|
+
VALUE family, type, protocol;
|
|
33
|
+
GError *error = NULL;
|
|
34
|
+
GSocket *socket;
|
|
35
|
+
|
|
36
|
+
rb_scan_args(argc, argv, "21", &family, &type, &protocol);
|
|
37
|
+
socket = g_socket_new(RVAL2GSOCKETFAMILY(family),
|
|
38
|
+
RVAL2GSOCKETTYPE(type),
|
|
39
|
+
RVAL2GSOCKETPROTOCOLDEFAULT(protocol),
|
|
40
|
+
&error);
|
|
41
|
+
if (socket == NULL)
|
|
42
|
+
rbgio_raise_error(error);
|
|
43
|
+
|
|
44
|
+
G_INITIALIZE(self, socket);
|
|
45
|
+
|
|
46
|
+
return Qnil;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE
|
|
50
|
+
socket_new_from_fd(G_GNUC_UNUSED VALUE self, VALUE id)
|
|
51
|
+
{
|
|
52
|
+
GError *error = NULL;
|
|
53
|
+
GSocket *socket;
|
|
54
|
+
|
|
55
|
+
socket = g_socket_new_from_fd(RVAL2FD(id), &error);
|
|
56
|
+
if (socket == NULL)
|
|
57
|
+
rbgio_raise_error(error);
|
|
58
|
+
|
|
59
|
+
return GOBJ2RVAL_UNREF(socket);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static VALUE
|
|
63
|
+
socket_bind(VALUE self, VALUE address, VALUE allow_reuse)
|
|
64
|
+
{
|
|
65
|
+
GError *error = NULL;
|
|
66
|
+
|
|
67
|
+
if (!g_socket_bind(_SELF(self),
|
|
68
|
+
RVAL2GSOCKETADDRESS(address),
|
|
69
|
+
RVAL2CBOOL(allow_reuse),
|
|
70
|
+
&error))
|
|
71
|
+
rbgio_raise_error(error);
|
|
72
|
+
|
|
73
|
+
return self;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static VALUE
|
|
77
|
+
socket_listen(VALUE self)
|
|
78
|
+
{
|
|
79
|
+
GError *error = NULL;
|
|
80
|
+
|
|
81
|
+
if (!g_socket_listen(_SELF(self), &error))
|
|
82
|
+
rbgio_raise_error(error);
|
|
83
|
+
|
|
84
|
+
return self;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static VALUE
|
|
88
|
+
socket_accept(int argc, VALUE *argv, VALUE self)
|
|
89
|
+
{
|
|
90
|
+
VALUE cancellable;
|
|
91
|
+
GError *error = NULL;
|
|
92
|
+
GSocket *socket;
|
|
93
|
+
|
|
94
|
+
rb_scan_args(argc, argv, "01", &cancellable);
|
|
95
|
+
socket = g_socket_accept(_SELF(self),
|
|
96
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
97
|
+
&error);
|
|
98
|
+
if (socket == NULL)
|
|
99
|
+
rbgio_raise_error(error);
|
|
100
|
+
|
|
101
|
+
return self;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static VALUE
|
|
105
|
+
socket_connect(int argc, VALUE *argv, VALUE self)
|
|
106
|
+
{
|
|
107
|
+
VALUE address, cancellable;
|
|
108
|
+
GError *error = NULL;
|
|
109
|
+
|
|
110
|
+
rb_scan_args(argc, argv, "11", &address, &cancellable);
|
|
111
|
+
if (!g_socket_connect(_SELF(self),
|
|
112
|
+
RVAL2GSOCKETADDRESS(address),
|
|
113
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
114
|
+
&error))
|
|
115
|
+
rbgio_raise_error(error);
|
|
116
|
+
|
|
117
|
+
return self;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* TODO: This makes very little sense in Ruby. How do we deal with it? */
|
|
121
|
+
static VALUE
|
|
122
|
+
socket_check_connect_result(VALUE self)
|
|
123
|
+
{
|
|
124
|
+
GError *error = NULL;
|
|
125
|
+
|
|
126
|
+
if (!g_socket_check_connect_result(_SELF(self), &error))
|
|
127
|
+
rbgio_raise_error(error);
|
|
128
|
+
|
|
129
|
+
return self;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static VALUE
|
|
133
|
+
socket_receive(int argc, VALUE *argv, VALUE self)
|
|
134
|
+
{
|
|
135
|
+
VALUE rbbytes, cancellable, result;
|
|
136
|
+
GError *error = NULL;
|
|
137
|
+
gsize bytes;
|
|
138
|
+
gssize read;
|
|
139
|
+
|
|
140
|
+
rb_scan_args(argc, argv, "11", &rbbytes, &cancellable);
|
|
141
|
+
bytes = RVAL2GSIZE(rbbytes);
|
|
142
|
+
result = rb_str_new(NULL, bytes);
|
|
143
|
+
read = g_socket_receive(_SELF(self),
|
|
144
|
+
RSTRING_PTR(result),
|
|
145
|
+
bytes,
|
|
146
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
147
|
+
&error);
|
|
148
|
+
if (read == -1)
|
|
149
|
+
rbgio_raise_error(error);
|
|
150
|
+
|
|
151
|
+
/* TODO: This is what Ruby does, but I can’t figure out why one needs
|
|
152
|
+
* both. */
|
|
153
|
+
rb_str_set_len(result, read);
|
|
154
|
+
rb_str_resize(result, read);
|
|
155
|
+
OBJ_TAINT(result);
|
|
156
|
+
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static VALUE
|
|
161
|
+
socket_receive_from(int argc, VALUE *argv, VALUE self)
|
|
162
|
+
{
|
|
163
|
+
VALUE rbbytes, cancellable, result;
|
|
164
|
+
GSocketAddress *address;
|
|
165
|
+
GError *error = NULL;
|
|
166
|
+
gsize bytes;
|
|
167
|
+
gssize read;
|
|
168
|
+
|
|
169
|
+
rb_scan_args(argc, argv, "11", &rbbytes, &cancellable);
|
|
170
|
+
bytes = RVAL2GSIZE(rbbytes);
|
|
171
|
+
result = rb_str_new(NULL, bytes);
|
|
172
|
+
read = g_socket_receive_from(_SELF(self),
|
|
173
|
+
&address,
|
|
174
|
+
RSTRING_PTR(result),
|
|
175
|
+
bytes,
|
|
176
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
177
|
+
&error);
|
|
178
|
+
if (read == -1)
|
|
179
|
+
rbgio_raise_error(error);
|
|
180
|
+
|
|
181
|
+
rb_str_set_len(result, read);
|
|
182
|
+
rb_str_resize(result, read);
|
|
183
|
+
OBJ_TAINT(result);
|
|
184
|
+
|
|
185
|
+
return rb_assoc_new(GOBJ2RVAL_UNREF(address), result);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static VALUE
|
|
189
|
+
socket_send(int argc, VALUE *argv, VALUE self)
|
|
190
|
+
{
|
|
191
|
+
VALUE buffer, cancellable;
|
|
192
|
+
GError *error = NULL;
|
|
193
|
+
gssize sent;
|
|
194
|
+
|
|
195
|
+
rb_scan_args(argc, argv, "11", &buffer, &cancellable);
|
|
196
|
+
StringValue(buffer);
|
|
197
|
+
sent = g_socket_send(_SELF(self),
|
|
198
|
+
RSTRING_PTR(buffer),
|
|
199
|
+
RSTRING_LEN(buffer),
|
|
200
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
201
|
+
&error);
|
|
202
|
+
if (sent == -1)
|
|
203
|
+
rbgio_raise_error(error);
|
|
204
|
+
|
|
205
|
+
return GSSIZE2RVAL(sent);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static VALUE
|
|
209
|
+
socket_send_to(int argc, VALUE *argv, VALUE self)
|
|
210
|
+
{
|
|
211
|
+
VALUE address, buffer, cancellable;
|
|
212
|
+
GError *error = NULL;
|
|
213
|
+
gssize sent;
|
|
214
|
+
|
|
215
|
+
rb_scan_args(argc, argv, "11", &address, &buffer, &cancellable);
|
|
216
|
+
StringValue(buffer);
|
|
217
|
+
sent = g_socket_send_to(_SELF(self),
|
|
218
|
+
RVAL2GSOCKETADDRESS(address),
|
|
219
|
+
RSTRING_PTR(buffer),
|
|
220
|
+
RSTRING_LEN(buffer),
|
|
221
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
222
|
+
&error);
|
|
223
|
+
if (sent == -1)
|
|
224
|
+
rbgio_raise_error(error);
|
|
225
|
+
|
|
226
|
+
return GSSIZE2RVAL(sent);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static VALUE
|
|
230
|
+
socket_close(VALUE self)
|
|
231
|
+
{
|
|
232
|
+
GError *error = NULL;
|
|
233
|
+
|
|
234
|
+
if (!g_socket_close(_SELF(self), &error))
|
|
235
|
+
rbgio_raise_error(error);
|
|
236
|
+
|
|
237
|
+
return self;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
static VALUE
|
|
241
|
+
socket_is_closed(VALUE self)
|
|
242
|
+
{
|
|
243
|
+
return CBOOL2RVAL(g_socket_is_closed(_SELF(self)));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
static VALUE
|
|
247
|
+
socket_shutdown(VALUE self, VALUE shutdown_read, VALUE shutdown_write)
|
|
248
|
+
{
|
|
249
|
+
GError *error = NULL;
|
|
250
|
+
|
|
251
|
+
if (!g_socket_shutdown(_SELF(self),
|
|
252
|
+
RVAL2CBOOL(shutdown_read),
|
|
253
|
+
RVAL2CBOOL(shutdown_write),
|
|
254
|
+
&error))
|
|
255
|
+
rbgio_raise_error(error);
|
|
256
|
+
|
|
257
|
+
return self;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
static VALUE
|
|
261
|
+
socket_is_connected(VALUE self)
|
|
262
|
+
{
|
|
263
|
+
return (g_socket_is_connected(_SELF(self)));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
static VALUE
|
|
267
|
+
socket_create_source(int argc, VALUE *argv, VALUE self)
|
|
268
|
+
{
|
|
269
|
+
VALUE condition, cancellable;
|
|
270
|
+
|
|
271
|
+
rb_scan_args(argc, argv, "11", &condition, &cancellable);
|
|
272
|
+
|
|
273
|
+
return GOBJ2RVAL_UNREF(g_socket_create_source(_SELF(self),
|
|
274
|
+
RVAL2GIOCONDITION(condition),
|
|
275
|
+
RVAL2GCANCELLABLE(cancellable)));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static VALUE
|
|
279
|
+
socket_condition_check(VALUE self, VALUE condition)
|
|
280
|
+
{
|
|
281
|
+
return GIOCONDITION2RVAL(g_socket_condition_check(_SELF(self),
|
|
282
|
+
RVAL2GIOCONDITION(condition)));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
static VALUE
|
|
286
|
+
socket_condition_wait(int argc, VALUE *argv, VALUE self)
|
|
287
|
+
{
|
|
288
|
+
VALUE condition, cancellable;
|
|
289
|
+
GError *error = NULL;
|
|
290
|
+
|
|
291
|
+
rb_scan_args(argc, argv, "11", &condition, &cancellable);
|
|
292
|
+
if (!g_socket_condition_wait(_SELF(self),
|
|
293
|
+
RVAL2GIOCONDITION(condition),
|
|
294
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
295
|
+
&error))
|
|
296
|
+
rbgio_raise_error(error);
|
|
297
|
+
|
|
298
|
+
return self;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static VALUE
|
|
302
|
+
socket_set_listen_backlog(VALUE self, VALUE backlog)
|
|
303
|
+
{
|
|
304
|
+
g_socket_set_listen_backlog(_SELF(self), RVAL2GINT(backlog));
|
|
305
|
+
|
|
306
|
+
return self;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
static VALUE
|
|
310
|
+
socket_get_listen_backlog(VALUE self)
|
|
311
|
+
{
|
|
312
|
+
return GINT2RVAL(g_socket_get_listen_backlog(_SELF(self)));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static VALUE
|
|
316
|
+
socket_get_blocking(VALUE self)
|
|
317
|
+
{
|
|
318
|
+
return CBOOL2RVAL(g_socket_get_blocking(_SELF(self)));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
static VALUE
|
|
322
|
+
socket_set_blocking(VALUE self, VALUE blocking)
|
|
323
|
+
{
|
|
324
|
+
g_socket_set_blocking(_SELF(self), RVAL2CBOOL(blocking));
|
|
325
|
+
|
|
326
|
+
return self;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
static VALUE
|
|
330
|
+
socket_get_keepalive(VALUE self)
|
|
331
|
+
{
|
|
332
|
+
return CBOOL2RVAL(g_socket_get_keepalive(_SELF(self)));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
static VALUE
|
|
336
|
+
socket_set_keepalive(VALUE self, VALUE keepalive)
|
|
337
|
+
{
|
|
338
|
+
g_socket_set_keepalive(_SELF(self), RVAL2CBOOL(keepalive));
|
|
339
|
+
|
|
340
|
+
return self;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
static VALUE
|
|
344
|
+
socket_get_family(VALUE self)
|
|
345
|
+
{
|
|
346
|
+
return GSOCKETFAMILY2RVAL(g_socket_get_family(_SELF(self)));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
static VALUE
|
|
350
|
+
socket_get_fd(VALUE self)
|
|
351
|
+
{
|
|
352
|
+
return FD2RVAL(g_socket_get_fd(_SELF(self)));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
static VALUE
|
|
356
|
+
socket_get_local_address(VALUE self)
|
|
357
|
+
{
|
|
358
|
+
GError *error = NULL;
|
|
359
|
+
GSocketAddress *address;
|
|
360
|
+
|
|
361
|
+
address = g_socket_get_local_address(_SELF(self), &error);
|
|
362
|
+
if (address == NULL)
|
|
363
|
+
rbgio_raise_error(error);
|
|
364
|
+
|
|
365
|
+
return GOBJ2RVAL_UNREF(address);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
static VALUE
|
|
369
|
+
socket_get_protocol(VALUE self)
|
|
370
|
+
{
|
|
371
|
+
return GSOCKETPROTOCOL2RVAL(g_socket_get_protocol(_SELF(self)));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
static VALUE
|
|
375
|
+
socket_get_remote_address(VALUE self)
|
|
376
|
+
{
|
|
377
|
+
GError *error = NULL;
|
|
378
|
+
GSocketAddress *address;
|
|
379
|
+
|
|
380
|
+
address = g_socket_get_remote_address(_SELF(self), &error);
|
|
381
|
+
if (address == NULL)
|
|
382
|
+
rbgio_raise_error(error);
|
|
383
|
+
|
|
384
|
+
return GOBJ2RVAL_UNREF(address);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
static VALUE
|
|
388
|
+
socket_get_socket_type(VALUE self)
|
|
389
|
+
{
|
|
390
|
+
return GSOCKETTYPE2RVAL(g_socket_get_socket_type(_SELF(self)));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
static VALUE
|
|
394
|
+
socket_speaks_ipv4(VALUE self)
|
|
395
|
+
{
|
|
396
|
+
return CBOOL2RVAL(g_socket_speaks_ipv4(_SELF(self)));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
void
|
|
400
|
+
Init_gsocket(VALUE glib)
|
|
401
|
+
{
|
|
402
|
+
VALUE socket = G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS, "Socket", glib);
|
|
403
|
+
|
|
404
|
+
G_DEF_CLASS(G_TYPE_SOCKET_FAMILY, "Family", socket);
|
|
405
|
+
G_DEF_CONSTANTS(socket, G_TYPE_SOCKET_FAMILY, "G_SOCKET_");
|
|
406
|
+
|
|
407
|
+
G_DEF_CLASS(G_TYPE_SOCKET_TYPE, "Type", socket);
|
|
408
|
+
G_DEF_CONSTANTS(socket, G_TYPE_SOCKET_TYPE, "G_SOCKET_");
|
|
409
|
+
|
|
410
|
+
G_DEF_CLASS(G_TYPE_SOCKET_PROTOCOL, "Protocol", socket);
|
|
411
|
+
G_DEF_CONSTANTS(socket, G_TYPE_SOCKET_PROTOCOL, "G_SOCKET_");
|
|
412
|
+
|
|
413
|
+
G_DEF_CLASS(G_TYPE_SOCKET_MSG_FLAGS, "MsgFlags", socket);
|
|
414
|
+
G_DEF_CONSTANTS(socket, G_TYPE_SOCKET_MSG_FLAGS, "G_SOCKET_");
|
|
415
|
+
|
|
416
|
+
rb_define_singleton_method(socket, "new_from_fd", socket_new_from_fd, 1);
|
|
417
|
+
|
|
418
|
+
rb_define_method(socket, "initialize", socket_initialize, -1);
|
|
419
|
+
rb_define_method(socket, "bind", socket_bind, 2);
|
|
420
|
+
rb_define_method(socket, "listen", socket_listen, 0);
|
|
421
|
+
rb_define_method(socket, "accept", socket_accept, -1);
|
|
422
|
+
rb_define_method(socket, "connect", socket_connect, -1);
|
|
423
|
+
rb_define_method(socket, "check_connect_result", socket_check_connect_result, 0);
|
|
424
|
+
rb_define_method(socket, "receive", socket_receive, -1);
|
|
425
|
+
rb_define_method(socket, "receive_from", socket_receive_from, -1);
|
|
426
|
+
rb_define_method(socket, "send", socket_send, -1);
|
|
427
|
+
rb_define_method(socket, "send_to", socket_send_to, -1);
|
|
428
|
+
rb_define_method(socket, "close", socket_close, -1);
|
|
429
|
+
rb_define_method(socket, "closed?", socket_is_closed, 0);
|
|
430
|
+
rb_define_method(socket, "shutdown", socket_shutdown, 2);
|
|
431
|
+
rb_define_method(socket, "connected?", socket_is_connected, 0);
|
|
432
|
+
rb_define_method(socket, "create_source", socket_create_source, -1);
|
|
433
|
+
rb_define_method(socket, "condition_check", socket_condition_check, 1);
|
|
434
|
+
rb_define_method(socket, "condition_wait", socket_condition_wait, -1);
|
|
435
|
+
rb_define_method(socket, "set_listen_backlog", socket_set_listen_backlog, 1);
|
|
436
|
+
G_DEF_SETTER(socket, "listen_backlog");
|
|
437
|
+
rb_define_method(socket, "listen_backlog", socket_get_listen_backlog, 0);
|
|
438
|
+
rb_define_method(socket, "blocking?", socket_get_blocking, 0);
|
|
439
|
+
rb_define_method(socket, "set_blocking", socket_set_blocking, 1);
|
|
440
|
+
G_DEF_SETTER(socket, "blocking");
|
|
441
|
+
rb_define_method(socket, "keepalive?", socket_get_keepalive, 0);
|
|
442
|
+
rb_define_method(socket, "set_keepalive", socket_set_keepalive, 1);
|
|
443
|
+
G_DEF_SETTER(socket, "keepalive");
|
|
444
|
+
rb_define_method(socket, "family", socket_get_family, 0);
|
|
445
|
+
rb_define_method(socket, "fd", socket_get_fd, 0);
|
|
446
|
+
rb_define_method(socket, "local_address", socket_get_local_address, 0);
|
|
447
|
+
rb_define_method(socket, "protocol", socket_get_protocol, 0);
|
|
448
|
+
rb_define_method(socket, "remote_address", socket_get_remote_address, 0);
|
|
449
|
+
rb_define_method(socket, "socket_type", socket_get_socket_type, 0);
|
|
450
|
+
rb_define_method(socket, "speaks_ipv4?", socket_speaks_ipv4, 0);
|
|
451
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
|
5
|
+
*
|
|
6
|
+
* This library is free software; you can redistribute it and/or
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
* License as published by the Free Software Foundation; either
|
|
9
|
+
* version 2.1 of the License.
|
|
10
|
+
*
|
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
* Lesser General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
* License along with this library; if not, write to the Free Software
|
|
18
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#include "gio2.h"
|
|
22
|
+
|
|
23
|
+
#define _SELF(value) RVAL2GSOCKETADDRESS(value)
|
|
24
|
+
|
|
25
|
+
/* TODO: new_from_native? */
|
|
26
|
+
|
|
27
|
+
static VALUE
|
|
28
|
+
socketaddress_get_family(VALUE self)
|
|
29
|
+
{
|
|
30
|
+
return GSOCKETFAMILY2RVAL(g_socket_address_get_family(_SELF(self)));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* TODO: to_native? */
|
|
34
|
+
|
|
35
|
+
/* TODO: get_native_size? */
|
|
36
|
+
|
|
37
|
+
void
|
|
38
|
+
Init_gsocketaddress(VALUE glib)
|
|
39
|
+
{
|
|
40
|
+
VALUE socketaddress = G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS, "SocketAddress", glib);
|
|
41
|
+
|
|
42
|
+
rb_undef_alloc_func(socketaddress);
|
|
43
|
+
|
|
44
|
+
rb_define_method(socketaddress, "family", socketaddress_get_family, 0);
|
|
45
|
+
}
|