/src/wrappers/glib/library/core/g_io_channel.e
Specman e | 750 lines | 146 code | 152 blank | 452 comment | 6 complexity | 76c32c2f209925469de28f18ebd87a9f MD5 | raw file
1indexing 2 copyright: "(C) 2005 Paolo Redaelli, 2007 Soluciones Informaticas Libres S.A. (Except)" 3 license: "LGPL v2 or later" 4 date: "$Date:$" 5 revision: "$REvision:$" 6 7class G_IO_CHANNEL 8 -- IO Channels -- portable support for using files, pipes and sockets. 9 10inherit 11 C_STRUCT 12 REFERENCE_COUNTED redefine dispose end 13 14insert 15 GLIB_TYPES 16 SHARED_G_ERROR 17 GIOCHANNEL_EXTERNALS 18 GIOCHANNEL_STRUCT 19 20create 21 from_unix_fd --, from_win32_fd, from_win32_socket 22 23feature {} -- Creation 24 -- TODO: provide OS-specfic heirs for Unix and Win32. 25 26 from_unix_fd (fd: INTEGER) is 27 -- Creates from file descriptor `fd'. On UNIX systems this 28 -- works for plain files, pipes, and sockets. 29 do 30 handle := g_io_channel_unix_new (fd) 31 ensure 32 encoding.is_equal (once "UTF-8") 33 end 34 35 -- from_win32_fd (fd: INTEGER) is 36 -- -- Creates from file descriptor `fd' on Windows. This works for 37 -- -- file descriptors as returned by the open(), creat(), pipe() 38 -- -- and fileno() calls in the Microsoft C runtime. In order to 39 -- -- meaningfully use this routine your code should use the same 40 -- -- C runtime as GLib uses, which is msvcrt.dll. 41 -- -- This function is available only in GLib on Windows. 42 -- do 43 -- handle := g_io_channel_win32_new_fd (fd) 44 -- end 45 46 -- from_win32_socket (socket: INTEGER) is 47 -- -- Creates from socket handle `socket' 48 -- do 49 -- handle := g_io_channel_win32_new_socket (socket) 50 -- end 51 52 new_file (a_file_name, a_mode: STRING) is 53 -- Open a file named `a_file_name' as a GIOChannel using `a_mode'. This channel 54 -- will be closed when the last reference to it is dropped, so there is 55 -- no need to call `close' (though doing so will not cause 56 -- problems, as long as no attempt is made to access the channel after 57 -- it is closed). 58 59 -- mode shall be one of "r", "w", "a", "r+", "w+", "a+". These have the 60 -- same meaning as in fopen(). 61 62 -- `error' will be updated. 63 local p: POINTER 64 do 65 p := g_io_channel_new_file 66 (a_file_name.to_external, a_mode.to_external, error.reference) 67 if p.is_not_null then 68 is_successful:=True 69 from_external_pointer(p) 70 end 71 ensure 72 not is_successful implies error/=Void 73 end 74 75feature -- Memory handling 76 ref is 77 -- Increments the reference count of a GIOChannel. 78 local p: POINTER 79 do 80 p:=g_io_channel_ref(handle) 81 check p=handle end 82 end 83 84 unref is 85 do 86 g_io_channel_unref (handle) 87 end 88 89 dispose is 90 do 91 Precursor 92 watch_list := Void 93 end 94 95feature -- Access 96 97 encoding: STRING is 98 -- Encoding for the input/output of the channel. The internal 99 -- encoding is always UTF-8. The encoding Void makes the 100 -- channel safe for binary data. 101 local 102 enc: POINTER 103 do 104 enc := g_io_channel_get_encoding (handle) 105 if enc.is_not_null then 106 create Result.from_external_copy (enc) 107 end 108 end 109 110 flags: GIOFLAGS_ENUM is 111 -- Flags for Current channel. 112 do 113 Result.change_value(g_io_channel_get_flags(handle)) 114 end 115 116 is_buffered: BOOLEAN is 117 -- Is the channel buffered? 118 do 119 Result:=g_io_channel_get_buffered(handle).to_boolean 120 end 121 122 last_event_source: NATURAL_32 123 -- glib id of last g_io_add_watch 124 125 last_status: GIOSTATUS_ENUM 126 -- Status code of last operation 127 128 last_failed: BOOLEAN is 129 -- Error status of last operation 130 do 131 Result := not last_status.is_normal 132 end 133 134 last_written: INTEGER 135 -- Number of bytes read/written by last operation 136 137feature -- Operations 138 139 add_watch (condition: GIOCONDITION_ENUM; action: FUNCTION [TUPLE [G_IO_CHANNEL, INTEGER], BOOLEAN]) is 140 -- Adds into the main event loop with the default priority. 141 require 142 action /= Void 143 local 144 callback: G_IO_FUNC 145 do 146 create callback.make (Current, action) 147 if watch_list = Void then 148 create watch_list.make (0) 149 end 150 watch_list.add_last (callback) 151 last_event_source := g_io_add_watch (handle, condition.value, callback.function, callback.data) 152 end 153 154 set_blocking (block: BOOLEAN) is 155 do 156 last_status.change_value 157 (g_io_channel_set_flags(handle, flags.value, default_pointer)) 158 end 159 160 set_buffered (buffered: BOOLEAN) is 161 -- Enable/disable channel buffering. 162 -- Default state is buffered 163 require 164 no_encoding_set: encoding = Void 165 -- The buffering state can only be set if the channel's 166 -- encoding is Void. For any other encoding, the channel 167 -- must be buffered. 168 no_buffered_data: -- No way to query this from GIOChannel 169 -- A buffered channel can only be set unbuffered if the 170 -- channel's internal buffers have been flushed. Newly 171 -- created channels or channels which have returned 172 -- G_IO_STATUS_EOF not require such a flush. 173 -- For write-only channels, a call to g_io_channel_flush() 174 -- is sufficient. For all other channels, 175 -- the buffers may be flushed by a call to 176 -- g_io_channel_seek_position(). This includes the possibility 177 -- of seeking with seek type G_SEEK_CUR and an offset 178 -- of zero. Note that this means that socket-based channels 179 -- cannot be set unbuffered once they have had data 180 -- read from them. 181 -- On unbuffered channels, it is safe to mix read and 182 -- write calls from the new and old APIs, if this is 183 -- necessary for maintaining old code. 184 do 185 g_io_channel_set_buffered (handle, buffered.to_integer) 186 ensure 187 is_buffered = buffered 188 end 189 190-- guint g_io_add_watch_full (GIOChannel *channel, 191-- gint priority, 192-- GIOCondition condition, 193-- GIOFunc func, 194-- gpointer user_data, 195-- GDestroyNotify notify); 196-- enum GIOCondition; 197-- gboolean (*GIOFunc) (GIOChannel *source, 198-- GIOCondition condition, 199-- gpointer data); 200 201-- GIOFuncs; 202 203-- gsize g_io_channel_get_buffer_size (GIOChannel *channel); 204-- void g_io_channel_set_buffer_size (GIOChannel *channel, 205-- gsize size); 206-- GIOCondition g_io_channel_get_buffer_condition 207-- (GIOChannel *channel); 208-- GIOFlags g_io_channel_get_flags (GIOChannel *channel); 209-- GIOStatus g_io_channel_set_flags (GIOChannel *channel, 210-- GIOFlags flags, 211-- GError **error); 212-- enum GIOFlags; 213-- const gchar* g_io_channel_get_line_term (GIOChannel *channel, 214-- gint *length); 215-- void g_io_channel_set_line_term (GIOChannel *channel, 216-- const gchar *line_term, 217-- gint length); 218 219-- gboolean g_io_channel_get_close_on_unref (GIOChannel *channel); 220-- void g_io_channel_set_close_on_unref (GIOChannel *channel, 221-- gboolean do_close); 222 223 224-- GIOError g_io_channel_read (GIOChannel *channel, 225-- gchar *buf, 226-- gsize count, 227-- gsize *bytes_read); 228-- enum GIOError; 229 230-- GIOError g_io_channel_write (GIOChannel *channel, 231-- const gchar *buf, 232-- gsize count, 233-- gsize *bytes_written); 234-- GIOError g_io_channel_seek (GIOChannel *channel, 235-- gint64 offset, 236-- GSeekType type); 237-- void g_io_channel_close (GIOChannel *channel); 238 239 240-- Description 241 242-- The GIOChannel data type aims to provide a portable method for using file descriptors, pipes, and sockets, and integrating them into the main event loop. Currently full support is available on UNIX platforms, support for Windows is only partially complete. 243 244-- To create a new GIOChannel on UNIX systems use g_io_channel_unix_new(). This works for plain file descriptors, pipes and sockets. Alternatively, a channel can be created for a file in a system independent manner using g_io_channel_new_file(). 245 246-- Once a GIOChannel has been created, it can be used in a generic manner with the functions g_io_channel_read_chars(), g_io_channel_write_chars(), g_io_channel_seek_position(), and g_io_channel_shutdown(). 247 248-- To add a GIOChannel to the main event loop use g_io_add_watch() or g_io_add_watch_full(). Here you specify which events you are interested in on the GIOChannel, and provide a function to be called whenever these events occur. 249 250-- GIOChannel instances are created with an initial reference count of 1. g_io_channel_ref() and g_io_channel_unref() can be used to increment or decrement the reference count respectively. When the reference count falls to 0, the GIOChannel is freed. (Though it isn't closed automatically, unless it was created using g_io_channel_new_from_file().) Using g_io_add_watch() or g_io_add_watch_full() increments a channel's reference count. 251 252-- The new functions g_io_channel_read_chars(), g_io_channel_read_line(), g_io_channel_read_line_string(), g_io_channel_read_to_end(), g_io_channel_write_chars(), g_io_channel_seek_position(), and g_io_channel_flush() should not be mixed with the deprecated functions g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek() on the same channel. 253-- Details 254-- GIOChannel 255 256-- typedef struct { 257-- } GIOChannel; 258 259-- A data structure representing an IO Channel. The fields should be considered private and should only be accessed with the following functions. 260-- g_io_channel_unix_new () 261 262 263feature -- Queries 264 file_descriptor: like gint is 265 -- the file descriptor of the GIOChannel. 266 do 267 Result := g_io_channel_unix_get_fd (handle) 268 end 269 270 -- g_io_channel_init () 271 272-- void g_io_channel_init (GIOChannel *channel); 273 274-- Initializes a GIOChannel struct. This is called by each of the above functions when creating a GIOChannel, and so is not often needed by the application programmer (unless you are creating a new type of GIOChannel). 275-- channel : a GIOChannel. 276-- g_io_channel_read_chars () 277 278-- GIOStatus g_io_channel_read_chars (GIOChannel *channel, 279-- gchar *buf, 280-- gsize count, 281-- gsize *bytes_read, 282-- GError **error); 283 284-- Replacement for g_io_channel_read() with the new API. 285 286-- channel : a GIOChannel 287-- buf : a buffer to read data into 288-- count : the size of the buffer. Note that the buffer may not be complelely filled even if there is data in the buffer if the remaining data is not a complete character. 289-- bytes_read : The number of bytes read. This may be zero even on success if count < 6 and the channel's encoding is non-NULL. This indicates that the next UTF-8 character is too wide for the buffer. 290-- error : A location to return an error of type GConvertError or GIOChannelError. 291-- Returns : the status of the operation. 292-- g_io_channel_read_unichar () 293 294-- GIOStatus g_io_channel_read_unichar (GIOChannel *channel, 295-- gunichar *thechar, 296-- GError **error); 297 298-- This function cannot be called on a channel with NULL encoding. 299 300-- channel : a GIOChannel 301-- thechar : a location to return a character 302-- error : A location to return an error of type GConvertError or GIOChannelError 303-- Returns : a GIOStatus 304-- g_io_channel_read_line () 305 306-- GIOStatus g_io_channel_read_line (GIOChannel *channel, 307-- gchar **str_return, 308-- gsize *length, 309-- gsize *terminator_pos, 310-- GError **error); 311 312-- Reads a line, including the terminating character(s), from a GIOChannel into a newly-allocated string. str_return will contain allocated memory if the return is G_IO_STATUS_NORMAL. 313 314-- channel : a GIOChannel 315-- str_return : The line read from the GIOChannel, including the line terminator. This data should be freed with g_free() when no longer needed. This is a nul-terminated string. If a length of zero is returned, this will be NULL instead. 316-- length : location to store length of the read data, or NULL 317-- terminator_pos : location to store position of line terminator, or NULL 318-- error : A location to return an error of type GConvertError or GIOChannelError 319-- Returns : the status of the operation. 320-- g_io_channel_read_line_string () 321 322-- GIOStatus g_io_channel_read_line_string (GIOChannel *channel, 323-- GString *buffer, 324-- gsize *terminator_pos, 325-- GError **error); 326 327-- Reads a line from a GIOChannel, using a GString as a buffer. 328 329-- channel : a GIOChannel 330-- buffer : a GString into which the line will be written. If buffer already contains data, the old data will be overwritten. 331-- terminator_pos : location to store position of line terminator, or NULL 332-- error : a location to store an error of type GConvertError or GIOChannelError 333-- Returns : the status of the operation. 334-- g_io_channel_read_to_end () 335 336-- GIOStatus g_io_channel_read_to_end (GIOChannel *channel, 337-- gchar **str_return, 338-- gsize *length, 339-- GError **error); 340 341-- Reads all the remaining data from the file. 342 343-- channel : a GIOChannel 344-- str_return : Location to store a pointer to a string holding the remaining data in the GIOChannel. This data should be freed with g_free() when no longer needed. This data is terminated by an extra nul character, but there may be other nuls in the intervening data. 345-- length : Location to store length of the data 346-- error : A location to return an error of type GConvertError or GIOChannelError 347-- Returns : G_IO_STATUS_NORMAL on success. This function never returns G_IO_STATUS_EOF. 348-- g_io_channel_write_chars () 349 350 351 write_chars (chars: ABSTRACT_STRING) is 352 -- Replacement for g_io_channel_write() with the new API. 353 -- On seekable channels with encodings other than NULL or 354 -- UTF-8, generic mixing of reading and writing is not 355 -- allowed. A call to g_io_channel_write_chars() may only 356 -- be made on a channel from which data has been read in 357 -- the cases described in the documentation for 358 -- g_io_channel_set_encoding(). 359 do 360 debug 361 print (once "Flags ") print(g_io_channel_get_flags (handle).to_string) print("%N") 362 if chars.count <= 512 then chars.print_on(std_output) print(once "%N") 363 else print (once "Writing ") print(chars.count.to_string) print(once " chars...%N") 364 end 365 end 366 last_status.change_value 367 (g_io_channel_write_chars (handle, chars.to_external, 368 chars.count, $last_written, default_pointer)) 369 debug 370 print (once "failed=") print(last_failed.to_string) print(once "%N") 371 end 372 end 373 374-- GIOStatus g_io_channel_write_chars (GIOChannel *channel, 375-- const gchar *buf, 376-- gssize count, 377-- gsize *bytes_written, 378-- GError **error); 379 380-- Replacement for g_io_channel_write() with the new API. 381 382-- On seekable channels with encodings other than NULL or UTF-8, generic mixing of reading and writing is not allowed. A call to g_io_channel_write_chars() may only be made on a channel from which data has been read in the cases described in the documentation for g_io_channel_set_encoding(). 383 384-- channel : a GIOChannel 385-- buf : a buffer to write data from 386-- count : the size of the buffer. If -1, the buffer is taken to be a nul-terminated string. 387-- bytes_written : The number of bytes written. This can be nonzero even if the return value is not G_IO_STATUS_NORMAL. If the return value is G_IO_STATUS_NORMAL and the channel is blocking, this will always be equal to count if count >= 0. 388-- error : A location to return an error of type GConvertError or GIOChannelError 389-- Returns : the status of the operation. 390-- g_io_channel_write_unichar () 391 392-- GIOStatus g_io_channel_write_unichar (GIOChannel *channel, 393-- gunichar thechar, 394-- GError **error); 395 396-- This function cannot be called on a channel with NULL encoding. 397 398-- channel : a GIOChannel 399-- thechar : a character 400-- error : A location to return an error of type GConvertError or GIOChannelError 401-- Returns : a GIOStatus 402 403 flush is 404 -- Flushes the write buffer for the GIOChannel. 405 do 406 last_status.change_value(g_io_channel_flush (handle, default_pointer)) 407 --TODO: error handling 408 end 409 410-- g_io_channel_seek_position () 411 412-- GIOStatus g_io_channel_seek_position (GIOChannel *channel, 413-- gint64 offset, 414-- GSeekType type, 415-- GError **error); 416 417-- Replacement for g_io_channel_seek() with the new API. 418 419-- channel : a GIOChannel 420-- offset : The offset in bytes from the position specified by type 421-- type : a GSeekType. The type G_SEEK_CUR is only allowed in those cases where a call to g_io_channel_set_encoding() is allowed. See the documentation for g_io_channel_set_encoding() for details. 422-- error : A location to return an error of type GIOChannelError 423-- Returns : the status of the operation. 424-- enum GSeekType 425 426-- typedef enum 427-- { 428-- G_SEEK_CUR, 429-- G_SEEK_SET, 430-- G_SEEK_END 431-- } GSeekType; 432 433-- An enumeration specifying the base position for a g_io_channel_seek_position() operation. 434-- G_SEEK_CUR the current position in the file. 435-- G_SEEK_SET the start of the file. 436-- G_SEEK_END the end of the file. 437 438 shutdown (after_flush: BOOLEAN) is 439 -- Close an IO channel. Any pending data to be written will be 440 -- flushed if flush is TRUE. The channel will not be freed until the 441 -- last reference is dropped using g_io_channel_unref(). 442 do 443 last_status.change_value(g_io_channel_shutdown(handle, after_flush.to_integer, default_pointer)) 444 end 445 446 set_encoding (new_encoding: ABSTRACT_STRING) is 447 -- Sets the encoding for the input/output of the channel. 448 -- The internal encoding is always "UTF-8". The default encoding 449 -- for the external file is "UTF-8". encoding=Void sets binary 450 -- encoding. 451 require 452 -- The encoding can only be set if one of the following conditions 453 -- is true: 454 -- 1. The channel was just created, and has not been written to 455 -- or read from yet. 456 -- 2. The channel is write-only. 457 -- 3. The channel is a file, and the file pointer was just 458 -- repositioned by a call to g_io_channel_seek_position(). 459 -- (This flushes all the internal buffers.) 460 -- 4. The current `encoding' is Void or "UTF-8". 461 -- 5. One of the (new API) read functions has just returned 462 -- G_IO_STATUS_EOF (or, in the case of 463 -- g_io_channel_read_to_end(), G_IO_STATUS_NORMAL). 464 -- 6. One of the functions g_io_channel_read_chars() or 465 -- g_io_channel_read_unichar() has returned G_IO_STATUS_AGAIN 466 -- or G_IO_STATUS_ERROR. This may be useful in the case of 467 -- G_CONVERT_ERROR_ILLEGAL_SEQUENCE. Returning one of these 468 -- statuses from g_io_channel_read_line(), 469 -- g_io_channel_read_line_string(), or 470 -- g_io_channel_read_to_end() does not guarantee that the 471 -- encoding can be changed. 472 -- 473 -- Channels which do not meet one of the above conditions 474 -- cannot call g_io_channel_seek_position() with an offset 475 -- of G_SEEK_CUR, and, if they are "seekable", cannot call 476 -- g_io_channel_write_chars() after calling one of the API 477 -- "read" functions. 478 local 479 p_encoding: POINTER 480 do 481 if new_encoding /= Void then 482 p_encoding := new_encoding.to_external 483 end 484 last_status.change_value(g_io_channel_set_encoding 485 (handle, p_encoding, default_pointer)) 486 -- TODO: GError Handling 487 end 488 489-- #define G_IO_CHANNEL_ERROR g_io_channel_error_quark() 490 491-- Error domain for GIOChannel operations. Errors in this domain will be from the GIOChannelError enumeration. See GError for information on error domains. 492-- g_io_channel_error_from_errno () 493 494-- GIOChannelError g_io_channel_error_from_errno 495-- (gint en); 496 497-- Converts an errno error number to a GIOChannelError. 498 499-- en : an errno error number, e.g. EINVAL. 500-- Returns : a GIOChannelError error number, e.g. G_IO_CHANNEL_ERROR_INVAL. 501 502-- g_io_create_watch () 503 504-- GSource* g_io_create_watch (GIOChannel *channel, 505-- GIOCondition condition); 506 507-- Creates a GSource that's dispatched when condition is met for the given channel. For example, if condition is G_IO_IN, the source will be dispatched when there's data available for reading. g_io_add_watch() is a simpler interface to this same functionality, for the case where you want to add the source to the default main loop at the default priority. 508-- channel : a GIOChannel to watch 509-- condition : conditions to watch for 510-- Returns : a new GSource 511-- g_io_add_watch_full () 512 513-- guint g_io_add_watch_full (GIOChannel *channel, 514-- gint priority, 515-- GIOCondition condition, 516-- GIOFunc func, 517-- gpointer user_data, 518-- GDestroyNotify notify); 519 520-- Adds the GIOChannel into the main event loop with the given priority. 521-- channel : a GIOChannel. 522-- priority : the priority of the GIOChannel source. 523-- condition : the condition to watch for. 524-- func : the function to call when the condition is satisfied. 525-- user_data : user data to pass to func. 526-- notify : the function to call when the source is removed. 527-- Returns : the event source id. 528-- enum GIOCondition 529 530-- typedef enum 531-- { 532-- G_IO_IN GLIB_SYSDEF_POLLIN, 533-- G_IO_OUT GLIB_SYSDEF_POLLOUT, 534-- G_IO_PRI GLIB_SYSDEF_POLLPRI, 535-- G_IO_ERR GLIB_SYSDEF_POLLERR, 536-- G_IO_HUP GLIB_SYSDEF_POLLHUP, 537-- G_IO_NVAL GLIB_SYSDEF_POLLNVAL 538-- } GIOCondition; 539 540-- A bitwise combination representing a condition to watch for on an event source. 541-- G_IO_IN There is data to read. 542-- G_IO_OUT Data can be written (without blocking). 543-- G_IO_PRI There is urgent data to read. 544-- G_IO_ERR Error condition. 545-- G_IO_HUP Hung up (the connection has been broken, usually for pipes and sockets). 546-- G_IO_NVAL Invalid request. The file descriptor is not open. 547-- GIOFunc () 548 549-- gboolean (*GIOFunc) (GIOChannel *source, 550-- GIOCondition condition, 551-- gpointer data); 552 553-- Specifies the type of function passed to g_io_add_watch() or g_io_add_watch_full(), which is called when the requested condition on a GIOChannel is satisfied. 554-- source : the GIOChannel event source. 555-- condition : the condition which has been satisfied. 556-- data : user data set in g_io_add_watch() or g_io_add_watch_full(). 557-- Returns : the function should return FALSE if the event source should be removed. 558-- GIOFuncs 559 560-- typedef struct { 561-- GIOStatus (*io_read) (GIOChannel *channel, 562-- gchar *buf, 563-- gsize count, 564-- gsize *bytes_read, 565-- GError **err); 566-- GIOStatus (*io_write) (GIOChannel *channel, 567-- const gchar *buf, 568-- gsize count, 569-- gsize *bytes_written, 570-- GError **err); 571-- GIOStatus (*io_seek) (GIOChannel *channel, 572-- gint64 offset, 573-- GSeekType type, 574-- GError **err); 575-- GIOStatus (*io_close) (GIOChannel *channel, 576-- GError **err); 577-- GSource* (*io_create_watch) (GIOChannel *channel, 578-- GIOCondition condition); 579-- void (*io_free) (GIOChannel *channel); 580-- GIOStatus (*io_set_flags) (GIOChannel *channel, 581-- GIOFlags flags, 582-- GError **err); 583-- GIOFlags (*io_get_flags) (GIOChannel *channel); 584-- } GIOFuncs; 585 586-- A table of functions used to handle different types of GIOChannel in a generic way. 587-- g_io_channel_get_buffer_size () 588 589-- gsize g_io_channel_get_buffer_size (GIOChannel *channel); 590 591-- Gets the buffer size. 592 593-- channel : a GIOChannel 594-- Returns : the size of the buffer. 595-- g_io_channel_set_buffer_size () 596 597-- void g_io_channel_set_buffer_size (GIOChannel *channel, 598-- gsize size); 599 600-- Sets the buffer size. 601 602-- channel : a GIOChannel 603-- size : the size of the buffer. 0 == pick a good size 604-- g_io_channel_get_buffer_condition () 605 606-- GIOCondition g_io_channel_get_buffer_condition 607-- (GIOChannel *channel); 608 609-- This function returns a GIOCondition depending on whether there is data to be read/space to write data in the internal buffers in the GIOChannel. Only the flags G_IO_IN and G_IO_OUT may be set. 610 611-- channel : A GIOChannel 612-- Returns : A GIOCondition 613-- g_io_channel_get_flags () 614 615-- GIOFlags g_io_channel_get_flags (GIOChannel *channel); 616 617-- Gets the current flags for a GIOChannel, including read-only flags such as G_IO_FLAG_IS_READABLE. 618 619-- The values of the flags G_IO_FLAG_IS_READABLE and G_IO_FLAG_IS_WRITEABLE are cached for internal use by the channel when it is created. If they should change at some later point (e.g. partial shutdown of a socket with the UNIX shutdown() function), the user should immediately call g_io_channel_get_flags() to update the internal values of these flags. 620 621-- channel : a GIOChannel 622-- Returns : the flags which are set on the channel 623-- g_io_channel_set_flags () 624 625-- GIOStatus g_io_channel_set_flags (GIOChannel *channel, 626-- GIOFlags flags, 627-- GError **error); 628 629-- Sets the (writeable) flags in channel to (flags & G_IO_CHANNEL_SET_MASK). 630 631-- channel : a GIOChannel. 632-- flags : the flags to set on the IO channel. 633-- error : A location to return an error of type GIOChannelError. 634-- Returns : the status of the operation. 635-- enum GIOFlags 636 637-- g_io_channel_get_line_term () 638 639-- const gchar* g_io_channel_get_line_term (GIOChannel *channel, 640-- gint *length); 641 642-- This returns the string that GIOChannel uses to determine where in the file a line break occurs. A value of NULL indicates auto detection. 643 644-- channel : a GIOChannel 645-- length : a location to return the length of the line terminator 646-- Returns : The line termination string. This value is owned by GLib and must not be freed. 647-- g_io_channel_set_line_term () 648 649-- void g_io_channel_set_line_term (GIOChannel *channel, 650-- const gchar *line_term, 651-- gint length); 652 653-- This sets the string that GIOChannel uses to determine where in the file a line break occurs. 654 655-- channel : a GIOChannel 656-- line_term : The line termination string. Use NULL for auto detect. Auto detection breaks on "\n", "\r\n", "\r", "\0", and the Unicode paragraph separator. Auto detection should not be used for anything other than file-based channels. 657-- length : The length of the termination string. If -1 is passed, the string is assumed to be nul-terminated. This option allows termination strings with embeded nuls. 658 659-- g_io_channel_get_close_on_unref () 660 661-- gboolean g_io_channel_get_close_on_unref (GIOChannel *channel); 662 663-- Returns whether the file/socket/whatever associated with channel will be closed when channel receives its final unref and is destroyed. The default value of this is TRUE for channels created by g_io_channel_new_file(), and FALSE for all other channels. 664 665-- channel : a GIOChannel. 666-- Returns : Whether the channel will be closed on the final unref of the GIOChannel data structure. 667-- g_io_channel_set_close_on_unref () 668 669-- void g_io_channel_set_close_on_unref (GIOChannel *channel, 670-- gboolean do_close); 671 672-- Setting this flag to TRUE for a channel you have already closed can cause problems. 673 674-- channel : a GIOChannel 675-- do_close : Whether to close the channel on the final unref of the GIOChannel data structure. The default value of this is TRUE for channels created by g_io_channel_new_file(), and FALSE for all other channels. 676-- g_io_channel_read () 677 678-- GIOError g_io_channel_read (GIOChannel *channel, 679-- gchar *buf, 680-- gsize count, 681-- gsize *bytes_read); 682 683-- Warning 684 685-- g_io_channel_read is deprecated and should not be used in newly-written code. Use g_io_channel_read_chars() instead. 686 687-- Reads data from a GIOChannel. 688 689-- channel : a GIOChannel. 690-- buf : a buffer to read the data into (which should be at least count bytes long). 691-- count : the number of bytes to read from the GIOChannel. 692-- bytes_read : returns the number of bytes actually read. 693-- Returns : G_IO_ERROR_NONE if the operation was successful. 694-- g_io_channel_write () 695 696-- GIOError g_io_channel_write (GIOChannel *channel, 697-- const gchar *buf, 698-- gsize count, 699-- gsize *bytes_written); 700 701-- Warning 702 703-- g_io_channel_write is deprecated and should not be used in newly-written code. Use g_io_channel_write_chars() instead. 704 705-- Writes data to a GIOChannel. 706 707-- channel : a GIOChannel. 708-- buf : the buffer containing the data to write. 709-- count : the number of bytes to write. 710-- bytes_written : the number of bytes actually written. 711-- Returns : G_IO_ERROR_NONE if the operation was successful. 712-- g_io_channel_seek () 713 714-- GIOError g_io_channel_seek (GIOChannel *channel, 715-- gint64 offset, 716-- GSeekType type); 717 718-- Warning 719 720-- g_io_channel_seek is deprecated and should not be used in newly-written code. Use g_io_channel_seek_position() instead. 721 722-- Sets the current position in the GIOChannel, similar to the standard library function fseek(). 723 724-- channel : a GIOChannel. 725-- offset : an offset, in bytes, which is added to the position specified by type 726-- type : the position in the file, which can be G_SEEK_CUR (the current position), G_SEEK_SET (the start of the file), or G_SEEK_END (the end of the file). 727-- Returns : G_IO_ERROR_NONE if the operation was successful. 728-- g_io_channel_close () 729 730-- void g_io_channel_close (GIOChannel *channel); 731 732-- Warning 733 734-- g_io_channel_close is deprecated and should not be used in newly-written code. Use g_io_channel_shutdown() instead. 735 736-- Close an IO channel. Any pending data to be written will be flushed, ignoring errors. The channel will not be freed until the last reference is dropped using g_io_channel_unref(). 737 738-- channel : A GIOChannel 739-- See Also 740 741-- gtk_input_add_full(), gtk_input_remove(), gdk_input_add(), gdk_input_add_full(), gdk_input_remove() 742 743-- Convenience functions for creating GIOChannel instances and adding them to the main event loop. 744 745feature {} -- Internal 746 747 watch_list: FAST_ARRAY [G_IO_FUNC] 748 -- We keep g_io_funcs here, to save them from the GC 749 750end -- class G_IO_CHANNEL