gio2 0.90.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/ChangeLog +60 -0
  2. data/README +34 -0
  3. data/Rakefile +76 -0
  4. data/ext/gio2/depend +5 -0
  5. data/ext/gio2/extconf.rb +91 -0
  6. data/ext/gio2/gappinfo.c +318 -0
  7. data/ext/gio2/gapplaunchcontext.c +79 -0
  8. data/ext/gio2/gasyncinitable.c +244 -0
  9. data/ext/gio2/gasyncresult.c +39 -0
  10. data/ext/gio2/gbufferedinputstream.c +184 -0
  11. data/ext/gio2/gbufferedoutputstream.c +82 -0
  12. data/ext/gio2/gcancellable.c +177 -0
  13. data/ext/gio2/gcharsetconverter.c +72 -0
  14. data/ext/gio2/gcontenttype.c +135 -0
  15. data/ext/gio2/gconverter.c +117 -0
  16. data/ext/gio2/gconverterinputstream.c +48 -0
  17. data/ext/gio2/gconverteroutputstream.c +48 -0
  18. data/ext/gio2/gdatainputstream.c +341 -0
  19. data/ext/gio2/gdataoutputstream.c +202 -0
  20. data/ext/gio2/gdesktopappinfo.c +90 -0
  21. data/ext/gio2/gdrive.c +267 -0
  22. data/ext/gio2/gemblem.c +71 -0
  23. data/ext/gio2/gemblemedicon.c +63 -0
  24. data/ext/gio2/gfile.c +2058 -0
  25. data/ext/gio2/gfileattribute.c +263 -0
  26. data/ext/gio2/gfileattributematcher.c +90 -0
  27. data/ext/gio2/gfiledescriptorbased.c +42 -0
  28. data/ext/gio2/gfileenumerator.c +167 -0
  29. data/ext/gio2/gfileicon.c +46 -0
  30. data/ext/gio2/gfileinfo.c +641 -0
  31. data/ext/gio2/gfileinputstream.c +92 -0
  32. data/ext/gio2/gfileiostream.c +98 -0
  33. data/ext/gio2/gfilemonitor.c +63 -0
  34. data/ext/gio2/gfilenamecompleter.c +72 -0
  35. data/ext/gio2/gfileoutputstream.c +100 -0
  36. data/ext/gio2/gfilterinputstream.c +56 -0
  37. data/ext/gio2/gfilteroutputstream.c +56 -0
  38. data/ext/gio2/gicon.c +69 -0
  39. data/ext/gio2/ginetaddress.c +188 -0
  40. data/ext/gio2/ginetsocketaddress.c +54 -0
  41. data/ext/gio2/ginitable.c +195 -0
  42. data/ext/gio2/ginputstream.c +341 -0
  43. data/ext/gio2/gio2.c +120 -0
  44. data/ext/gio2/gio2.def +2 -0
  45. data/ext/gio2/gio2.h +343 -0
  46. data/ext/gio2/gioerror.c +67 -0
  47. data/ext/gio2/giomodule.c +63 -0
  48. data/ext/gio2/gioscheduler.c +195 -0
  49. data/ext/gio2/giostream.c +129 -0
  50. data/ext/gio2/gloadableicon.c +91 -0
  51. data/ext/gio2/gmemoryinputstream.c +65 -0
  52. data/ext/gio2/gmemoryoutputstream.c +65 -0
  53. data/ext/gio2/gmount.c +283 -0
  54. data/ext/gio2/gmountoperation.c +168 -0
  55. data/ext/gio2/gnetworkaddress.c +71 -0
  56. data/ext/gio2/gnetworkservice.c +64 -0
  57. data/ext/gio2/goutputstream.c +343 -0
  58. data/ext/gio2/gresolver.c +230 -0
  59. data/ext/gio2/gseekable.c +89 -0
  60. data/ext/gio2/gsimpleasyncresult.c +153 -0
  61. data/ext/gio2/gsocket.c +451 -0
  62. data/ext/gio2/gsocketaddress.c +45 -0
  63. data/ext/gio2/gsocketclient.c +273 -0
  64. data/ext/gio2/gsocketconnectable.c +97 -0
  65. data/ext/gio2/gsocketconnection.c +82 -0
  66. data/ext/gio2/gsocketcontrolmessage.c +82 -0
  67. data/ext/gio2/gsocketlistener.c +239 -0
  68. data/ext/gio2/gsocketservice.c +64 -0
  69. data/ext/gio2/gsrvtarget.c +77 -0
  70. data/ext/gio2/gtcpconnection.c +48 -0
  71. data/ext/gio2/gthemedicon.c +86 -0
  72. data/ext/gio2/gthreadedsocketservice.c +39 -0
  73. data/ext/gio2/gunixconnection.c +69 -0
  74. data/ext/gio2/gunixfdlist.c +112 -0
  75. data/ext/gio2/gunixfdmessage.c +81 -0
  76. data/ext/gio2/gunixinputstream.c +73 -0
  77. data/ext/gio2/gunixmounts.c +346 -0
  78. data/ext/gio2/gunixoutputstream.c +73 -0
  79. data/ext/gio2/gunixsocketaddress.c +79 -0
  80. data/ext/gio2/gvfs.c +84 -0
  81. data/ext/gio2/gvolume.c +191 -0
  82. data/ext/gio2/gvolumemonitor.c +77 -0
  83. data/ext/gio2/gzlibcompressor.c +47 -0
  84. data/ext/gio2/gzlibdecompressor.c +43 -0
  85. data/ext/gio2/util.c +323 -0
  86. data/extconf.rb +49 -0
  87. data/lib/gio2.rb +141 -0
  88. metadata +184 -0
@@ -0,0 +1,117 @@
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) G_CONVERTER(RVAL2GOBJ(value))
24
+
25
+ #define RVAL2GCONVERTERFLAGS(value) \
26
+ RVAL2GFLAGS((value), G_TYPE_CONVERTER_FLAGS)
27
+
28
+ #define RVAL2GCONVERTERFLAGSDEFAULT(value) \
29
+ RVAL2TYPE_WITH_DEFAULT((value), \
30
+ RVAL2GCONVERTERFLAGS, \
31
+ G_CONVERTER_NO_FLAGS)
32
+
33
+ #define GCONVERTERRESULT2RVAL(value) \
34
+ GFLAGS2RVAL((value), G_TYPE_CONVERTER_RESULT)
35
+
36
+ /* TODO: Look at gconverteroutputstream for implementing this. */
37
+ /* TODO: Actually, is there any point in implementing this? */
38
+ static VALUE
39
+ converter_convert(int argc, VALUE *argv, VALUE self)
40
+ {
41
+ VALUE input, rbflags;
42
+ GConverter *converter;
43
+ gsize input_remaining, output_size, output_remaining, bytes_read, bytes_written;
44
+ GConverterFlags flags;
45
+ /* TODO: Use a Ruby string instead. */
46
+ char *output_base, *output;
47
+ GError *error = NULL;
48
+ GConverterResult result;
49
+
50
+ rb_scan_args(argc, argv, "11", &input, &rbflags);
51
+ converter = _SELF(self);
52
+ StringValue(input);
53
+ input_remaining = RSTRING_LEN(input);
54
+ flags = RVAL2GCONVERTERFLAGSDEFAULT(rbflags);
55
+ output_remaining = output_size = BUFSIZ;
56
+ output_base = output = ALLOCA_N(char, output_size);
57
+ do {
58
+ result = g_converter_convert(converter,
59
+ RSTRING_PTR(input),
60
+ input_remaining,
61
+ output,
62
+ output_remaining,
63
+ flags,
64
+ &bytes_read,
65
+ &bytes_written,
66
+ &error);
67
+ switch (result) {
68
+ case G_CONVERTER_ERROR:
69
+ switch (error->code) {
70
+ case G_IO_ERROR_NO_SPACE:
71
+ /* TODO: Expand the buffer? */
72
+ break;
73
+ case G_IO_ERROR_PARTIAL_INPUT:
74
+ /* TODO: How do we request/tell the user that
75
+ * they need to provide more data? */
76
+ break;
77
+ default:
78
+ break;
79
+ }
80
+ rbgio_raise_error(error);
81
+ break;
82
+ case G_CONVERTER_CONVERTED:
83
+ case G_CONVERTER_FLUSHED:
84
+ input_remaining -= bytes_read;
85
+ input += bytes_read;
86
+ output_remaining -= bytes_written;
87
+ output += bytes_written;
88
+ /* TODO: Do we need to do anything else? */
89
+ break;
90
+ case G_CONVERTER_FINISHED:
91
+ /* TODO: Do we simply break, or do we need to consider
92
+ * something else? */
93
+ break;
94
+ default:
95
+ break;
96
+ }
97
+ } while (input_remaining > 0);
98
+
99
+ return CSTR2RVAL(output_base);
100
+ }
101
+
102
+ static VALUE
103
+ converter_reset(VALUE self)
104
+ {
105
+ g_converter_reset(_SELF(self));
106
+
107
+ return self;
108
+ }
109
+
110
+ void
111
+ Init_gconverter(VALUE glib)
112
+ {
113
+ VALUE converter = G_DEF_INTERFACE(G_TYPE_CONVERTER, "Converter", glib);
114
+
115
+ rb_define_method(converter, "convert", converter_convert, -1);
116
+ rb_define_method(converter, "reset", converter_reset, 0);
117
+ }
@@ -0,0 +1,48 @@
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) G_CONVERTER_INPUT_STREAM(RVAL2GOBJ(value))
24
+
25
+ static VALUE
26
+ converterinputstream_initialize(VALUE self, VALUE base_stream, VALUE converter)
27
+ {
28
+ G_INITIALIZE(self,
29
+ g_converter_input_stream_new(RVAL2GINPUTSTREAM(base_stream),
30
+ RVAL2GCONVERTER(converter)));
31
+
32
+ return Qnil;
33
+ }
34
+
35
+ static VALUE
36
+ converterinputstream_get_converter(VALUE self)
37
+ {
38
+ return GOBJ2RVAL(g_converter_input_stream_get_converter(_SELF(self)));
39
+ }
40
+
41
+ void
42
+ Init_gconverterinputstream(VALUE glib)
43
+ {
44
+ VALUE converterinputstream = G_DEF_CLASS(G_TYPE_CONVERTER_INPUT_STREAM, "ConverterInputStream", glib);
45
+
46
+ rb_define_method(converterinputstream, "initialize", converterinputstream_initialize, 2);
47
+ rb_define_method(converterinputstream, "converter", converterinputstream_get_converter, 0);
48
+ }
@@ -0,0 +1,48 @@
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) G_CONVERTER_OUTPUT_STREAM(RVAL2GOBJ(value))
24
+
25
+ static VALUE
26
+ converteroutputstream_initialize(VALUE self, VALUE base_stream, VALUE converter)
27
+ {
28
+ G_INITIALIZE(self,
29
+ g_converter_output_stream_new(RVAL2GOUTPUTSTREAM(base_stream),
30
+ RVAL2GCONVERTER(converter)));
31
+
32
+ return Qnil;
33
+ }
34
+
35
+ static VALUE
36
+ converteroutputstream_get_converter(VALUE self)
37
+ {
38
+ return GOBJ2RVAL(g_converter_output_stream_get_converter(_SELF(self)));
39
+ }
40
+
41
+ void
42
+ Init_gconverteroutputstream(VALUE glib)
43
+ {
44
+ VALUE converteroutputstream = G_DEF_CLASS(G_TYPE_CONVERTER_OUTPUT_STREAM, "ConverterOutputStream", glib);
45
+
46
+ rb_define_method(converteroutputstream, "initialize", converteroutputstream_initialize, 2);
47
+ rb_define_method(converteroutputstream, "converter", converteroutputstream_get_converter, 0);
48
+ }
@@ -0,0 +1,341 @@
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) G_DATA_INPUT_STREAM(RVAL2GOBJ(value))
24
+
25
+ #define GDATASTREAMNEWLINETYPE2RVAL(value) \
26
+ RVAL2GENUM((value), G_TYPE_DATA_STREAM_NEWLINE_TYPE)
27
+
28
+ #define RVAL2GDATASTREAMNEWLINETYPE(value) \
29
+ GENUM2RVAL((value), G_TYPE_DATA_STREAM_NEWLINE_TYPE)
30
+
31
+ static VALUE
32
+ datainputstream_initialize(int argc, VALUE *argv, VALUE self)
33
+ {
34
+ VALUE base_stream, byte_order, newline_type;
35
+
36
+ rb_scan_args(argc, argv, "12", &base_stream, &byte_order, &newline_type);
37
+
38
+ G_INITIALIZE(self, g_data_input_stream_new(RVAL2GINPUTSTREAM(base_stream)));
39
+
40
+ if (!NIL_P(byte_order))
41
+ g_data_input_stream_set_byte_order(_SELF(self),
42
+ RVAL2GDATASTREAMBYTEORDER(byte_order));
43
+
44
+ if (!NIL_P(newline_type))
45
+ g_data_input_stream_set_newline_type(_SELF(self),
46
+ RVAL2GDATASTREAMNEWLINETYPE(newline_type));
47
+
48
+ return Qnil;
49
+ }
50
+
51
+ static VALUE
52
+ datainputstream_get_byte_order(VALUE self)
53
+ {
54
+ return GDATASTREAMBYTEORDER2RVAL(g_data_input_stream_get_byte_order(_SELF(self)));
55
+ }
56
+
57
+ static VALUE
58
+ datainputstream_set_byte_order(VALUE self, VALUE value)
59
+ {
60
+ g_data_input_stream_set_byte_order(_SELF(self),
61
+ RVAL2GDATASTREAMBYTEORDER(value));
62
+
63
+ return self;
64
+ }
65
+
66
+ static VALUE
67
+ datainputstream_set_newline_type(VALUE self, VALUE value)
68
+ {
69
+ g_data_input_stream_set_newline_type(_SELF(self),
70
+ RVAL2GDATASTREAMNEWLINETYPE(value));
71
+
72
+ return self;
73
+ }
74
+
75
+ static VALUE
76
+ datainputstream_get_newline_type(VALUE self)
77
+ {
78
+ return GDATASTREAMNEWLINETYPE2RVAL(g_data_input_stream_get_newline_type(_SELF(self)));
79
+ }
80
+
81
+ static VALUE
82
+ datainputstream_read_byte(int argc, VALUE *argv, VALUE self)
83
+ {
84
+ VALUE cancellable;
85
+ GError *error = NULL;
86
+ guchar value;
87
+
88
+ rb_scan_args(argc, argv, "01", &cancellable);
89
+ value = g_data_input_stream_read_byte(_SELF(self),
90
+ RVAL2GCANCELLABLE(cancellable),
91
+ &error);
92
+ if (error != NULL)
93
+ rbgio_raise_error(error);
94
+
95
+ return GUCHAR2RVAL(value);
96
+ }
97
+
98
+ static VALUE
99
+ datainputstream_read_int16(int argc, VALUE *argv, VALUE self)
100
+ {
101
+ VALUE cancellable;
102
+ GError *error = NULL;
103
+ gint16 value;
104
+
105
+ rb_scan_args(argc, argv, "01", &cancellable);
106
+ value = g_data_input_stream_read_int16(_SELF(self),
107
+ RVAL2GCANCELLABLE(cancellable),
108
+ &error);
109
+ if (error != NULL)
110
+ rbgio_raise_error(error);
111
+
112
+ return GINT162RVAL(value);
113
+ }
114
+
115
+ static VALUE
116
+ datainputstream_read_uint16(int argc, VALUE *argv, VALUE self)
117
+ {
118
+ VALUE cancellable;
119
+ GError *error = NULL;
120
+ guint16 value;
121
+
122
+ rb_scan_args(argc, argv, "01", &cancellable);
123
+ value = g_data_input_stream_read_uint16(_SELF(self),
124
+ RVAL2GCANCELLABLE(cancellable),
125
+ &error);
126
+ if (error != NULL)
127
+ rbgio_raise_error(error);
128
+
129
+ return GUINT162RVAL(value);
130
+ }
131
+
132
+ static VALUE
133
+ datainputstream_read_int32(int argc, VALUE *argv, VALUE self)
134
+ {
135
+ VALUE cancellable;
136
+ GError *error = NULL;
137
+ gint32 value;
138
+
139
+ rb_scan_args(argc, argv, "01", &cancellable);
140
+ value = g_data_input_stream_read_int32(_SELF(self),
141
+ RVAL2GCANCELLABLE(cancellable),
142
+ &error);
143
+ if (error != NULL)
144
+ rbgio_raise_error(error);
145
+
146
+ return GINT322RVAL(value);
147
+ }
148
+
149
+ static VALUE
150
+ datainputstream_read_uint32(int argc, VALUE *argv, VALUE self)
151
+ {
152
+ VALUE cancellable;
153
+ GError *error = NULL;
154
+ guint32 value;
155
+
156
+ rb_scan_args(argc, argv, "01", &cancellable);
157
+ value = g_data_input_stream_read_uint32(_SELF(self),
158
+ RVAL2GCANCELLABLE(cancellable),
159
+ &error);
160
+ if (error != NULL)
161
+ rbgio_raise_error(error);
162
+
163
+ return GUINT322RVAL(value);
164
+ }
165
+
166
+ static VALUE
167
+ datainputstream_read_int64(int argc, VALUE *argv, VALUE self)
168
+ {
169
+ VALUE cancellable;
170
+ GError *error = NULL;
171
+ gint64 value;
172
+
173
+ rb_scan_args(argc, argv, "01", &cancellable);
174
+ value = g_data_input_stream_read_int64(_SELF(self),
175
+ RVAL2GCANCELLABLE(cancellable),
176
+ &error);
177
+ if (error != NULL)
178
+ rbgio_raise_error(error);
179
+
180
+ return GINT642RVAL(value);
181
+ }
182
+
183
+ static VALUE
184
+ datainputstream_read_uint64(int argc, VALUE *argv, VALUE self)
185
+ {
186
+ VALUE cancellable;
187
+ GError *error = NULL;
188
+ guint64 value;
189
+
190
+ rb_scan_args(argc, argv, "01", &cancellable);
191
+ value = g_data_input_stream_read_uint64(_SELF(self),
192
+ RVAL2GCANCELLABLE(cancellable),
193
+ &error);
194
+ if (error != NULL)
195
+ rbgio_raise_error(error);
196
+
197
+ return GUINT642RVAL(value);
198
+ }
199
+
200
+ static VALUE
201
+ datainputstream_read_line(int argc, VALUE *argv, VALUE self)
202
+ {
203
+ VALUE cancellable;
204
+ gsize length;
205
+ GError *error;
206
+ char *line;
207
+
208
+ rb_scan_args(argc, argv, "01", &cancellable);
209
+ line = g_data_input_stream_read_line(_SELF(self),
210
+ &length,
211
+ RVAL2GCANCELLABLE(cancellable),
212
+ &error);
213
+ if (error != NULL)
214
+ rbgio_raise_error(error);
215
+
216
+ return CSTR2RVAL_TAINTED_FREE(line, length);
217
+ }
218
+
219
+ static VALUE
220
+ datainputstream_read_line_async(int argc, VALUE *argv, VALUE self)
221
+ {
222
+ VALUE rbio_priority, rbcancellable, block;
223
+ int io_priority;
224
+ GCancellable *cancellable;
225
+
226
+ rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
227
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
228
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
229
+ SAVE_BLOCK(block);
230
+ g_data_input_stream_read_line_async(_SELF(self),
231
+ io_priority,
232
+ cancellable,
233
+ rbgio_async_ready_callback,
234
+ (gpointer)block);
235
+
236
+ return self;
237
+ }
238
+
239
+ static VALUE
240
+ datainputstream_read_line_finish(VALUE self, VALUE result)
241
+ {
242
+ GError *error = NULL;
243
+ gsize length;
244
+ char *line;
245
+
246
+ line = g_data_input_stream_read_line_finish(_SELF(self),
247
+ RVAL2GASYNCRESULT(result),
248
+ &length,
249
+ &error);
250
+ if (error != NULL)
251
+ rbgio_raise_error(error);
252
+
253
+ return CSTR2RVAL_TAINTED_FREE(line, length);
254
+ }
255
+
256
+ static VALUE
257
+ datainputstream_read_until(int argc, VALUE *argv, VALUE self)
258
+ {
259
+ VALUE stop_chars, cancellable;
260
+ gsize length;
261
+ GError *error;
262
+ char *string;
263
+
264
+ rb_scan_args(argc, argv, "11", &stop_chars, &cancellable);
265
+ string = g_data_input_stream_read_until(_SELF(self),
266
+ RVAL2CSTR(stop_chars),
267
+ &length,
268
+ RVAL2GCANCELLABLE(cancellable),
269
+ &error);
270
+ if (error != NULL)
271
+ rbgio_raise_error(error);
272
+
273
+ return CSTR2RVAL_TAINTED_FREE(string, length);
274
+ }
275
+
276
+ static VALUE
277
+ datainputstream_read_until_async(int argc, VALUE *argv, VALUE self)
278
+ {
279
+ VALUE rbstop_chars, rbcancellable, rbio_priority, block;
280
+ const char *stop_chars;
281
+ int io_priority;
282
+ GCancellable *cancellable;
283
+
284
+ rb_scan_args(argc, argv, "12&", &rbstop_chars, &rbio_priority, &rbcancellable, &block);
285
+ stop_chars = RVAL2CSTR(rbstop_chars);
286
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
287
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
288
+ SAVE_BLOCK(block);
289
+ g_data_input_stream_read_until_async(_SELF(self),
290
+ stop_chars,
291
+ io_priority,
292
+ cancellable,
293
+ rbgio_async_ready_callback,
294
+ (gpointer)block);
295
+
296
+ return self;
297
+ }
298
+
299
+ static VALUE
300
+ datainputstream_read_until_finish(VALUE self, VALUE result)
301
+ {
302
+ GError *error = NULL;
303
+ gsize length;
304
+ char *string;
305
+
306
+ string = g_data_input_stream_read_until_finish(_SELF(self),
307
+ RVAL2GASYNCRESULT(result),
308
+ &length,
309
+ &error);
310
+ if (error != NULL)
311
+ rbgio_raise_error(error);
312
+
313
+ return CSTR2RVAL_TAINTED_FREE(string, length);
314
+ }
315
+
316
+ void
317
+ Init_gdatainputstream(VALUE glib)
318
+ {
319
+ VALUE datainputstream = G_DEF_CLASS(G_TYPE_DATA_INPUT_STREAM, "DataInputStream", glib);
320
+
321
+ rb_define_method(datainputstream, "initialize", datainputstream_initialize, -1);
322
+ rb_define_method(datainputstream, "byte_order", datainputstream_get_byte_order, 0);
323
+ rb_define_method(datainputstream, "set_byte_order", datainputstream_set_byte_order, 1);
324
+ G_DEF_SETTER(datainputstream, "byte_order");
325
+ rb_define_method(datainputstream, "set_newline_type", datainputstream_set_newline_type, 1);
326
+ G_DEF_SETTER(datainputstream, "newline_type");
327
+ rb_define_method(datainputstream, "newline_type", datainputstream_get_newline_type, 0);
328
+ rb_define_method(datainputstream, "read_byte", datainputstream_read_byte, -1);
329
+ rb_define_method(datainputstream, "read_int16", datainputstream_read_int16, -1);
330
+ rb_define_method(datainputstream, "read_uint16", datainputstream_read_uint16, -1);
331
+ rb_define_method(datainputstream, "read_int32", datainputstream_read_int32, -1);
332
+ rb_define_method(datainputstream, "read_uint32", datainputstream_read_uint32, -1);
333
+ rb_define_method(datainputstream, "read_int64", datainputstream_read_int64, -1);
334
+ rb_define_method(datainputstream, "read_uint64", datainputstream_read_uint64, -1);
335
+ rb_define_method(datainputstream, "read_line", datainputstream_read_line, -1);
336
+ rb_define_method(datainputstream, "read_line_async", datainputstream_read_line_async, -1);
337
+ rb_define_method(datainputstream, "read_line_finish", datainputstream_read_line_finish, 1);
338
+ rb_define_method(datainputstream, "read_until", datainputstream_read_until, -1);
339
+ rb_define_method(datainputstream, "read_until_async", datainputstream_read_until_async, -1);
340
+ rb_define_method(datainputstream, "read_until_finish", datainputstream_read_until_finish, 1);
341
+ }