mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Modified Files: glib/ChangeLog glib/glib.def glib/glib/giochannel.c
Modified Files: glib/ChangeLog glib/glib.def glib/glib/giochannel.c glib/glib/giochannel.h glib/glib/giounix.c glib/glib/giowin32.c glib/docs/reference/glib/glib-sections.txt glib/tests/iochannel-test.c glib/tests/unicode-collate.c glib/tests/unicode-normalize.c Added Files: glib/tests/iochannel-test-infile * glib/giochannel.c: API changes, fixes to error handling, some internal restructuring * glib/giochannel.h: API changes, documentation for elements in GIOChannel structure * glib/giounix.c: Matched API changes, implemented backend to set is_readable, is_writeable, is_seekable flags, added a test to catch large values of count for which the behavior of write() is undefined * glib/giowin32.c: Changed to match new prototypes for io_close() and io_seek(), removed references to G_IO_STATUS_INTR, set is_seekable flag in channel creation functions * glib.def: Renamed g_channel_error_quark() and g_channel_error_from_errno() to g_io_channel_error_quark() and g_io_channel_error_from_errno(); added new functions g_io_channel_get_buffered() and g_io_channel_set_buffered() * docs/reference/glib/glib-sections.txt: Modified iochannel section to reflect new functions and API changes * tests/iochannel-test.c: Fixed to work with API changes * tests/iochannel-test-infile: New file; input file for iochannel-test * tests/unicode-collate.c tests/unicode-normalize.c: Changed G_IO_FILE_MODE_READ to "r" to match API change
This commit is contained in:
parent
c71a77a520
commit
e070fdea39
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: API changes, fixes to
|
||||||
|
error handling, some internal restructuring
|
||||||
|
* glib/giochannel.h: API changes, documentation for
|
||||||
|
elements in GIOChannel structure
|
||||||
|
* glib/giounix.c: Matched API changes, implemented
|
||||||
|
backend to set is_readable, is_writeable, is_seekable
|
||||||
|
flags, added a test to catch large values of count
|
||||||
|
for which the behavior of write() is undefined
|
||||||
|
* glib/giowin32.c: Changed to match new prototypes for
|
||||||
|
io_close() and io_seek(), removed references to
|
||||||
|
G_IO_STATUS_INTR, set is_seekable flag in channel
|
||||||
|
creation functions
|
||||||
|
* glib.def: Renamed g_channel_error_quark() and
|
||||||
|
g_channel_error_from_errno() to g_io_channel_error_quark() and
|
||||||
|
g_io_channel_error_from_errno(); added new functions
|
||||||
|
g_io_channel_get_buffered() and g_io_channel_set_buffered()
|
||||||
|
* docs/reference/glib/glib-sections.txt: Modified iochannel
|
||||||
|
section to reflect new functions and API changes
|
||||||
|
* tests/iochannel-test.c: Fixed to work with API changes
|
||||||
|
* tests/iochannel-test-infile: New file; input file
|
||||||
|
for iochannel-test
|
||||||
|
* tests/unicode-collate.c tests/unicode-normalize.c:
|
||||||
|
Changed G_IO_FILE_MODE_READ to "r" to match API change
|
||||||
|
|
||||||
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
Fri Jul 20 19:16:24 (UTC) 2001 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
* gobject/glib-genmarshal.c: modified to create header files
|
* gobject/glib-genmarshal.c: modified to create header files
|
||||||
|
@ -594,7 +594,6 @@ g_io_channel_init
|
|||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_io_channel_new_file
|
g_io_channel_new_file
|
||||||
GIOFileMode
|
|
||||||
g_io_channel_read_chars
|
g_io_channel_read_chars
|
||||||
g_io_channel_read_line
|
g_io_channel_read_line
|
||||||
g_io_channel_read_line_string
|
g_io_channel_read_line_string
|
||||||
@ -603,14 +602,14 @@ g_io_channel_write_chars
|
|||||||
g_io_channel_flush
|
g_io_channel_flush
|
||||||
g_io_channel_seek_position
|
g_io_channel_seek_position
|
||||||
GSeekType
|
GSeekType
|
||||||
g_io_channel_close
|
g_io_channel_shutdown
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
GChannelStatus
|
GIOStatus
|
||||||
GChannelError
|
GIOChannelError
|
||||||
G_CHANNEL_ERROR
|
G_IO_CHANNEL_ERROR
|
||||||
g_channel_error_quark
|
g_io_channel_error_quark
|
||||||
g_channel_error_from_errno
|
g_io_channel_error_from_errno
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_io_channel_ref
|
g_io_channel_ref
|
||||||
@ -638,10 +637,10 @@ g_io_channel_set_line_term
|
|||||||
G_IO_CHANNEL_UNIX_LINE_TERM
|
G_IO_CHANNEL_UNIX_LINE_TERM
|
||||||
G_IO_CHANNEL_DOS_LINE_TERM
|
G_IO_CHANNEL_DOS_LINE_TERM
|
||||||
G_IO_CHANNEL_MACINTOSH_LINE_TERM
|
G_IO_CHANNEL_MACINTOSH_LINE_TERM
|
||||||
G_IO_CHANNEL_DEFAULT_LINE_TERM
|
g_io_channel_get_buffered
|
||||||
|
g_io_channel_set_buffered
|
||||||
g_io_channel_get_encoding
|
g_io_channel_get_encoding
|
||||||
g_io_channel_set_encoding
|
g_io_channel_set_encoding
|
||||||
G_IO_CHANNEL_ENCODE_RAW
|
|
||||||
|
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
g_io_channel_win32_new_fd
|
g_io_channel_win32_new_fd
|
||||||
@ -656,6 +655,7 @@ g_io_channel_read
|
|||||||
GIOError
|
GIOError
|
||||||
g_io_channel_write
|
g_io_channel_write
|
||||||
g_io_channel_seek
|
g_io_channel_seek
|
||||||
|
g_io_channel_close
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
|
6
glib.def
6
glib.def
@ -51,8 +51,6 @@ EXPORTS
|
|||||||
g_cache_new
|
g_cache_new
|
||||||
g_cache_remove
|
g_cache_remove
|
||||||
g_cache_value_foreach
|
g_cache_value_foreach
|
||||||
g_channel_error_quark
|
|
||||||
g_channel_error_from_errno
|
|
||||||
g_clear_error
|
g_clear_error
|
||||||
g_completion_add_items
|
g_completion_add_items
|
||||||
g_completion_clear_items
|
g_completion_clear_items
|
||||||
@ -186,9 +184,12 @@ EXPORTS
|
|||||||
g_io_add_watch
|
g_io_add_watch
|
||||||
g_io_add_watch_full
|
g_io_add_watch_full
|
||||||
g_io_channel_close
|
g_io_channel_close
|
||||||
|
g_io_channel_error_from_errno
|
||||||
|
g_io_channel_error_quark
|
||||||
g_io_channel_flush
|
g_io_channel_flush
|
||||||
g_io_channel_get_buffer_condition
|
g_io_channel_get_buffer_condition
|
||||||
g_io_channel_get_buffer_size
|
g_io_channel_get_buffer_size
|
||||||
|
g_io_channel_get_buffered
|
||||||
g_io_channel_get_encoding
|
g_io_channel_get_encoding
|
||||||
g_io_channel_get_flags
|
g_io_channel_get_flags
|
||||||
g_io_channel_get_line_term
|
g_io_channel_get_line_term
|
||||||
@ -203,6 +204,7 @@ EXPORTS
|
|||||||
g_io_channel_seek
|
g_io_channel_seek
|
||||||
g_io_channel_seek_position
|
g_io_channel_seek_position
|
||||||
g_io_channel_set_buffer_size
|
g_io_channel_set_buffer_size
|
||||||
|
g_io_channel_set_buffered
|
||||||
g_io_channel_set_encoding
|
g_io_channel_set_encoding
|
||||||
g_io_channel_set_flags
|
g_io_channel_set_flags
|
||||||
g_io_channel_set_line_term
|
g_io_channel_set_line_term
|
||||||
|
1153
glib/giochannel.c
1153
glib/giochannel.c
File diff suppressed because it is too large
Load Diff
@ -47,26 +47,22 @@ typedef enum
|
|||||||
G_IO_ERROR_UNKNOWN
|
G_IO_ERROR_UNKNOWN
|
||||||
} GIOError;
|
} GIOError;
|
||||||
|
|
||||||
#define G_IO_CHANNEL_ERROR g_channel_error_quark()
|
#define G_IO_CHANNEL_ERROR g_io_channel_error_quark()
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
/* Derived from errno */
|
/* Derived from errno */
|
||||||
G_IO_CHANNEL_ERROR_ACCES,
|
G_IO_CHANNEL_ERROR_FBIG,
|
||||||
G_IO_CHANNEL_ERROR_BADF,
|
|
||||||
G_IO_CHANNEL_ERROR_DEADLK,
|
|
||||||
G_IO_CHANNEL_ERROR_FAULT,
|
|
||||||
G_IO_CHANNEL_ERROR_INVAL,
|
G_IO_CHANNEL_ERROR_INVAL,
|
||||||
G_IO_CHANNEL_ERROR_IO,
|
G_IO_CHANNEL_ERROR_IO,
|
||||||
G_IO_CHANNEL_ERROR_ISDIR,
|
G_IO_CHANNEL_ERROR_ISDIR,
|
||||||
G_IO_CHANNEL_ERROR_MFILE,
|
|
||||||
G_IO_CHANNEL_ERROR_NOLCK,
|
|
||||||
G_IO_CHANNEL_ERROR_NOSPC,
|
G_IO_CHANNEL_ERROR_NOSPC,
|
||||||
G_IO_CHANNEL_ERROR_PERM,
|
G_IO_CHANNEL_ERROR_NXIO,
|
||||||
|
G_IO_CHANNEL_ERROR_OVERFLOW,
|
||||||
G_IO_CHANNEL_ERROR_PIPE,
|
G_IO_CHANNEL_ERROR_PIPE,
|
||||||
G_IO_CHANNEL_ERROR_SPIPE,
|
|
||||||
/* Other */
|
/* Other */
|
||||||
G_IO_CHANNEL_ERROR_ENCODE_RW,
|
G_IO_CHANNEL_ERROR_PCHAR_FLUSH,
|
||||||
|
/* Unconverted partial UTF-8 chars in buffer during flush */
|
||||||
G_IO_CHANNEL_ERROR_FAILED
|
G_IO_CHANNEL_ERROR_FAILED
|
||||||
} GIOChannelError;
|
} GIOChannelError;
|
||||||
|
|
||||||
@ -75,7 +71,6 @@ typedef enum
|
|||||||
G_IO_STATUS_ERROR,
|
G_IO_STATUS_ERROR,
|
||||||
G_IO_STATUS_NORMAL,
|
G_IO_STATUS_NORMAL,
|
||||||
G_IO_STATUS_EOF,
|
G_IO_STATUS_EOF,
|
||||||
G_IO_STATUS_PARTIAL_CHARS, /* like EOF, but with unconverted data left */
|
|
||||||
G_IO_STATUS_AGAIN
|
G_IO_STATUS_AGAIN
|
||||||
} GIOStatus;
|
} GIOStatus;
|
||||||
|
|
||||||
@ -99,7 +94,6 @@ typedef enum
|
|||||||
#define G_IO_CHANNEL_UNIX_LINE_TERM "\n"
|
#define G_IO_CHANNEL_UNIX_LINE_TERM "\n"
|
||||||
#define G_IO_CHANNEL_DOS_LINE_TERM "\r\n"
|
#define G_IO_CHANNEL_DOS_LINE_TERM "\r\n"
|
||||||
#define G_IO_CHANNEL_MACINTOSH_LINE_TERM "\r"
|
#define G_IO_CHANNEL_MACINTOSH_LINE_TERM "\r"
|
||||||
#define G_IO_CHANNEL_ENCODE_RAW "GIOChannelEncodeRaw"
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -113,41 +107,30 @@ typedef enum
|
|||||||
G_IO_FLAG_SET_MASK = G_IO_FLAG_APPEND | G_IO_FLAG_NONBLOCK,
|
G_IO_FLAG_SET_MASK = G_IO_FLAG_APPEND | G_IO_FLAG_NONBLOCK,
|
||||||
} GIOFlags;
|
} GIOFlags;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
G_IO_FILE_MODE_READ,
|
|
||||||
G_IO_FILE_MODE_WRITE,
|
|
||||||
G_IO_FILE_MODE_APPEND,
|
|
||||||
G_IO_FILE_MODE_READ_WRITE,
|
|
||||||
G_IO_FILE_MODE_READ_WRITE_TRUNCATE,
|
|
||||||
G_IO_FILE_MODE_READ_WRITE_APPEND,
|
|
||||||
} GIOFileMode;
|
|
||||||
|
|
||||||
struct _GIOChannel
|
struct _GIOChannel
|
||||||
{
|
{
|
||||||
guint channel_flags;
|
|
||||||
guint ref_count;
|
guint ref_count;
|
||||||
GIOFuncs *funcs;
|
GIOFuncs *funcs;
|
||||||
|
|
||||||
gchar *encoding;
|
gchar *encoding;
|
||||||
GIConv read_cd;
|
GIConv read_cd;
|
||||||
GIConv write_cd;
|
GIConv write_cd;
|
||||||
gchar *line_term;
|
gchar *line_term; /* String which indicates the end of a line of text */
|
||||||
|
|
||||||
gsize buf_size;
|
gsize buf_size;
|
||||||
GString *read_buf;
|
GString *read_buf; /* Raw data from the channel */
|
||||||
GString *encoded_read_buf;
|
GString *encoded_read_buf; /* Channel data converted to UTF-8 */
|
||||||
GString *write_buf;
|
GString *write_buf; /* Data ready to be written to the file */
|
||||||
|
gchar partial_write_buf[6]; /* UTF-8 partial characters, null terminated */
|
||||||
|
|
||||||
/* Group the flags together to save memory */
|
/* Group the flags together, immediately after partial_write_buf, to save memory */
|
||||||
|
|
||||||
gboolean use_buffer : 1;
|
gboolean use_buffer : 1; /* The encoding uses the buffers */
|
||||||
gboolean do_encode : 1;
|
gboolean do_encode : 1; /* The encoding uses the GIConv coverters */
|
||||||
gboolean ready_to_read : 1;
|
gboolean close_on_unref : 1; /* Close the channel on final unref */
|
||||||
gboolean ready_to_write : 1;
|
gboolean is_readable : 1; /* Cached GIOFlag */
|
||||||
gboolean close_on_unref : 1;
|
gboolean is_writeable : 1; /* ditto */
|
||||||
gboolean seekable_cached : 1;
|
gboolean is_seekable : 1; /* ditto */
|
||||||
gboolean is_seekable : 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef gboolean (*GIOFunc) (GIOChannel *source,
|
typedef gboolean (*GIOFunc) (GIOChannel *source,
|
||||||
@ -229,6 +212,9 @@ GIOFlags g_io_channel_get_flags (GIOChannel *channel);
|
|||||||
void g_io_channel_set_line_term (GIOChannel *channel,
|
void g_io_channel_set_line_term (GIOChannel *channel,
|
||||||
const gchar *line_term);
|
const gchar *line_term);
|
||||||
G_CONST_RETURN gchar* g_io_channel_get_line_term (GIOChannel *channel);
|
G_CONST_RETURN gchar* g_io_channel_get_line_term (GIOChannel *channel);
|
||||||
|
void g_io_channel_set_buffered (GIOChannel *channel,
|
||||||
|
gboolean buffered);
|
||||||
|
gboolean g_io_channel_get_buffered (GIOChannel *channel);
|
||||||
GIOStatus g_io_channel_set_encoding (GIOChannel *channel,
|
GIOStatus g_io_channel_set_encoding (GIOChannel *channel,
|
||||||
const gchar *encoding,
|
const gchar *encoding,
|
||||||
GError **error);
|
GError **error);
|
||||||
@ -265,13 +251,13 @@ GIOStatus g_io_channel_seek_position (GIOChannel *channel,
|
|||||||
GSeekType type,
|
GSeekType type,
|
||||||
GError **error);
|
GError **error);
|
||||||
GIOChannel* g_io_channel_new_file (const gchar *filename,
|
GIOChannel* g_io_channel_new_file (const gchar *filename,
|
||||||
GIOFileMode mode,
|
const gchar *mode,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Error handling */
|
/* Error handling */
|
||||||
|
|
||||||
GQuark g_channel_error_quark (void);
|
GQuark g_io_channel_error_quark (void);
|
||||||
GIOChannelError g_channel_error_from_errno (gint en);
|
GIOChannelError g_io_channel_error_from_errno (gint en);
|
||||||
|
|
||||||
/* On Unix, IO channels created with this function for any file
|
/* On Unix, IO channels created with this function for any file
|
||||||
* descriptor or socket.
|
* descriptor or socket.
|
||||||
|
215
glib/giounix.c
215
glib/giounix.c
@ -177,6 +177,9 @@ g_io_unix_read (GIOChannel *channel,
|
|||||||
GIOUnixChannel *unix_channel = (GIOUnixChannel *)channel;
|
GIOUnixChannel *unix_channel = (GIOUnixChannel *)channel;
|
||||||
gssize result;
|
gssize result;
|
||||||
|
|
||||||
|
if (count > SSIZE_MAX) /* At least according to the Debian manpage for read */
|
||||||
|
count = SSIZE_MAX;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
result = read (unix_channel->fd, buf, count);
|
result = read (unix_channel->fd, buf, count);
|
||||||
|
|
||||||
@ -196,7 +199,7 @@ g_io_unix_read (GIOChannel *channel,
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -236,7 +239,7 @@ g_io_unix_write (GIOChannel *channel,
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -278,7 +281,7 @@ g_io_unix_seek (GIOChannel *channel,
|
|||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -296,7 +299,7 @@ g_io_unix_close (GIOChannel *channel,
|
|||||||
if (close (unix_channel->fd) < 0)
|
if (close (unix_channel->fd) < 0)
|
||||||
{
|
{
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -351,19 +354,6 @@ static const glong g_io_unix_fcntl_posix_flags[] = {
|
|||||||
};
|
};
|
||||||
#define G_IO_UNIX_NUM_FCNTL_FLAGS G_N_ELEMENTS (g_io_unix_fcntl_flags)
|
#define G_IO_UNIX_NUM_FCNTL_FLAGS G_N_ELEMENTS (g_io_unix_fcntl_flags)
|
||||||
|
|
||||||
static const GIOFlags g_io_unix_fcntl_flags_read_only[] = {
|
|
||||||
G_IO_FLAG_IS_READABLE,
|
|
||||||
G_IO_FLAG_IS_WRITEABLE,
|
|
||||||
};
|
|
||||||
static const glong g_io_unix_fcntl_posix_flags_read_only[] = {
|
|
||||||
O_RDONLY | O_RDWR,
|
|
||||||
O_WRONLY | O_RDWR,
|
|
||||||
};
|
|
||||||
/* Only need to map posix_flags -> flags for read only, not the
|
|
||||||
* other way around, so this works.
|
|
||||||
*/
|
|
||||||
#define G_IO_UNIX_NUM_FCNTL_FLAGS_READ_ONLY G_N_ELEMENTS (g_io_unix_fcntl_flags_read_only)
|
|
||||||
|
|
||||||
static GIOStatus
|
static GIOStatus
|
||||||
g_io_unix_set_flags (GIOChannel *channel,
|
g_io_unix_set_flags (GIOChannel *channel,
|
||||||
GIOFlags flags,
|
GIOFlags flags,
|
||||||
@ -382,7 +372,7 @@ g_io_unix_set_flags (GIOChannel *channel,
|
|||||||
if (fcntl (unix_channel->fd, F_SETFL, fcntl_flags) == -1)
|
if (fcntl (unix_channel->fd, F_SETFL, fcntl_flags) == -1)
|
||||||
{
|
{
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -397,80 +387,100 @@ g_io_unix_get_flags (GIOChannel *channel)
|
|||||||
glong fcntl_flags;
|
glong fcntl_flags;
|
||||||
gint loop;
|
gint loop;
|
||||||
GIOUnixChannel *unix_channel = (GIOUnixChannel *) channel;
|
GIOUnixChannel *unix_channel = (GIOUnixChannel *) channel;
|
||||||
struct stat buffer;
|
|
||||||
|
|
||||||
fcntl_flags = fcntl (unix_channel->fd, F_GETFL);
|
fcntl_flags = fcntl (unix_channel->fd, F_GETFL);
|
||||||
|
|
||||||
if (fcntl_flags == -1)
|
if (fcntl_flags == -1)
|
||||||
{
|
{
|
||||||
g_warning (G_STRLOC "Error while getting flags for FD: %s (%d)\n",
|
g_warning (G_STRLOC "Error while getting flags for FD: %s (%d)\n",
|
||||||
g_strerror (errno), errno);
|
g_strerror (errno), errno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!channel->seekable_cached)
|
|
||||||
{
|
|
||||||
channel->seekable_cached = TRUE;
|
|
||||||
|
|
||||||
/* I'm not sure if fstat on a non-file (e.g., socket) works
|
|
||||||
* it should be safe to sat if it fails, the fd isn't seekable.
|
|
||||||
*/
|
|
||||||
if (fstat (unix_channel->fd, &buffer) == -1 ||
|
|
||||||
!S_ISREG (buffer.st_mode))
|
|
||||||
channel->is_seekable = FALSE;
|
|
||||||
else
|
|
||||||
channel->is_seekable = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (loop = 0; loop < G_IO_UNIX_NUM_FCNTL_FLAGS; loop++)
|
for (loop = 0; loop < G_IO_UNIX_NUM_FCNTL_FLAGS; loop++)
|
||||||
if (fcntl_flags & g_io_unix_fcntl_posix_flags[loop])
|
if (fcntl_flags & g_io_unix_fcntl_posix_flags[loop])
|
||||||
flags |= g_io_unix_fcntl_flags[loop];
|
flags |= g_io_unix_fcntl_flags[loop];
|
||||||
|
|
||||||
for (loop = 0; loop < G_IO_UNIX_NUM_FCNTL_FLAGS_READ_ONLY; loop++)
|
|
||||||
if (fcntl_flags & g_io_unix_fcntl_posix_flags_read_only[loop])
|
|
||||||
flags |= g_io_unix_fcntl_flags_read_only[loop];
|
|
||||||
|
|
||||||
if (channel->is_seekable)
|
|
||||||
flags |= G_IO_FLAG_IS_SEEKABLE;
|
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
GIOChannel *
|
GIOChannel *
|
||||||
g_io_channel_new_file (const gchar *filename,
|
g_io_channel_new_file (const gchar *filename,
|
||||||
GIOFileMode mode,
|
const gchar *mode,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
FILE *f;
|
int fid, flags;
|
||||||
int fid;
|
|
||||||
gchar *mode_name;
|
|
||||||
GIOChannel *channel;
|
GIOChannel *channel;
|
||||||
|
enum { /* Cheesy hack */
|
||||||
|
MODE_R = 1 << 0,
|
||||||
|
MODE_W = 1 << 1,
|
||||||
|
MODE_A = 1 << 2,
|
||||||
|
MODE_PLUS = 1 << 3,
|
||||||
|
} mode_num;
|
||||||
|
|
||||||
switch (mode)
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
|
g_return_val_if_fail (mode != NULL, NULL);
|
||||||
|
g_return_val_if_fail ((error == NULL) || (*error == NULL), NULL);
|
||||||
|
|
||||||
|
switch (mode[0])
|
||||||
{
|
{
|
||||||
case G_IO_FILE_MODE_READ:
|
case 'r':
|
||||||
mode_name = "r";
|
mode_num = MODE_R;
|
||||||
break;
|
break;
|
||||||
case G_IO_FILE_MODE_WRITE:
|
case 'w':
|
||||||
mode_name = "w";
|
mode_num = MODE_W;
|
||||||
break;
|
break;
|
||||||
case G_IO_FILE_MODE_APPEND:
|
case 'a':
|
||||||
mode_name = "a";
|
mode_num = MODE_A;
|
||||||
break;
|
|
||||||
case G_IO_FILE_MODE_READ_WRITE:
|
|
||||||
mode_name = "r+";
|
|
||||||
break;
|
|
||||||
case G_IO_FILE_MODE_READ_WRITE_TRUNCATE:
|
|
||||||
mode_name = "w+";
|
|
||||||
break;
|
|
||||||
case G_IO_FILE_MODE_READ_WRITE_APPEND:
|
|
||||||
mode_name = "a+";
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("Invalid GIOFileMode %i.\n", mode);
|
g_warning ("Invalid GIOFileMode %s.\n", mode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fopen (filename, mode_name);
|
switch (mode[1])
|
||||||
if (!f)
|
{
|
||||||
|
case '\0':
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
if (mode[2] == '\0')
|
||||||
|
{
|
||||||
|
mode_num |= MODE_PLUS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Fall through */
|
||||||
|
default:
|
||||||
|
g_warning ("Invalid GIOFileMode %s.\n", mode);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mode_num)
|
||||||
|
{
|
||||||
|
case MODE_R:
|
||||||
|
flags = O_RDONLY;
|
||||||
|
break;
|
||||||
|
case MODE_W:
|
||||||
|
flags = O_WRONLY | O_TRUNC | O_CREAT;
|
||||||
|
break;
|
||||||
|
case MODE_A:
|
||||||
|
flags = O_WRONLY | O_APPEND | O_CREAT;
|
||||||
|
break;
|
||||||
|
case MODE_R | MODE_PLUS:
|
||||||
|
flags = O_RDWR;
|
||||||
|
break;
|
||||||
|
case MODE_W | MODE_PLUS:
|
||||||
|
flags = O_RDWR | O_TRUNC | O_CREAT;
|
||||||
|
break;
|
||||||
|
case MODE_A | MODE_PLUS:
|
||||||
|
flags = O_RDWR | O_APPEND | O_CREAT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fid = open (filename, flags);
|
||||||
|
if (fid < 0)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_FILE_ERROR,
|
g_set_error (error, G_FILE_ERROR,
|
||||||
g_file_error_from_errno (errno),
|
g_file_error_from_errno (errno),
|
||||||
@ -478,22 +488,99 @@ g_io_channel_new_file (const gchar *filename,
|
|||||||
return (GIOChannel *)NULL;
|
return (GIOChannel *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fid = fileno (f);
|
channel = (GIOChannel *) g_new (GIOUnixChannel, 1);
|
||||||
|
|
||||||
channel = g_io_channel_unix_new (fid);
|
|
||||||
channel->close_on_unref = TRUE;
|
channel->close_on_unref = TRUE;
|
||||||
|
channel->is_seekable = TRUE;
|
||||||
|
|
||||||
|
switch (mode_num)
|
||||||
|
{
|
||||||
|
case MODE_R:
|
||||||
|
channel->is_readable = TRUE;
|
||||||
|
channel->is_writeable = FALSE;
|
||||||
|
break;
|
||||||
|
case MODE_W:
|
||||||
|
case MODE_A:
|
||||||
|
channel->is_readable = FALSE;
|
||||||
|
channel->is_writeable = TRUE;
|
||||||
|
break;
|
||||||
|
case MODE_R | MODE_PLUS:
|
||||||
|
case MODE_W | MODE_PLUS:
|
||||||
|
case MODE_A | MODE_PLUS:
|
||||||
|
channel->is_readable = TRUE;
|
||||||
|
channel->is_writeable = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_io_channel_init (channel);
|
||||||
|
channel->funcs = &unix_channel_funcs;
|
||||||
|
|
||||||
|
((GIOUnixChannel *) channel)->fd = fid;
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
GIOChannel *
|
GIOChannel *
|
||||||
g_io_channel_unix_new (gint fd)
|
g_io_channel_unix_new (gint fd)
|
||||||
{
|
{
|
||||||
|
struct stat buffer;
|
||||||
GIOUnixChannel *unix_channel = g_new (GIOUnixChannel, 1);
|
GIOUnixChannel *unix_channel = g_new (GIOUnixChannel, 1);
|
||||||
GIOChannel *channel = (GIOChannel *)unix_channel;
|
GIOChannel *channel = (GIOChannel *)unix_channel;
|
||||||
|
int flags;
|
||||||
|
|
||||||
g_io_channel_init (channel);
|
g_io_channel_init (channel);
|
||||||
channel->funcs = &unix_channel_funcs;
|
channel->funcs = &unix_channel_funcs;
|
||||||
|
|
||||||
|
/* I'm not sure if fstat on a non-file (e.g., socket) works
|
||||||
|
* it should be safe to say if it fails, the fd isn't seekable.
|
||||||
|
*/
|
||||||
|
/* Newer UNIX versions support S_ISSOCK(), fstat() will probably
|
||||||
|
* succeed in most cases.
|
||||||
|
*/
|
||||||
|
if (fstat (unix_channel->fd, &buffer) == 0)
|
||||||
|
channel->is_seekable = S_ISREG (buffer.st_mode) || S_ISCHR (buffer.st_mode)
|
||||||
|
|| S_ISBLK (buffer.st_mode);
|
||||||
|
else /* Assume not seekable */
|
||||||
|
channel->is_seekable = FALSE;
|
||||||
|
|
||||||
|
flags = fcntl (fd, F_GETFL);
|
||||||
|
|
||||||
|
if (flags != -1)
|
||||||
|
{
|
||||||
|
/* Don't know if fcntl flags overlap, be careful */
|
||||||
|
|
||||||
|
if (flags & O_WRONLY)
|
||||||
|
{
|
||||||
|
channel->is_readable = FALSE;
|
||||||
|
channel->is_writeable = TRUE;
|
||||||
|
}
|
||||||
|
else if (flags & O_RDWR)
|
||||||
|
channel->is_readable = channel->is_writeable = TRUE;
|
||||||
|
#if O_RDONLY == 0
|
||||||
|
else /* O_RDONLY defined as zero on linux (elsewhere?) */
|
||||||
|
{
|
||||||
|
channel->is_readable = TRUE;
|
||||||
|
channel->is_writeable = FALSE;
|
||||||
|
}
|
||||||
|
#else /* O_RDONLY == 0 */
|
||||||
|
else if (flags & O_RDONLY)
|
||||||
|
{
|
||||||
|
channel->is_readable = TRUE;
|
||||||
|
channel->is_writeable = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
channel->is_readable = channel->is_writeable = FALSE;
|
||||||
|
#endif /* O_RDONLY == 0 */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_warning (G_STRLOC "Error while getting flags for FD: %s (%d)\n",
|
||||||
|
g_strerror (errno), errno);
|
||||||
|
g_free (channel);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
unix_channel->fd = fd;
|
unix_channel->fd = fd;
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
@ -699,20 +699,22 @@ g_io_win32_msg_write (GIOChannel *channel,
|
|||||||
|
|
||||||
static GIOStatus
|
static GIOStatus
|
||||||
g_io_win32_no_seek (GIOChannel *channel,
|
g_io_win32_no_seek (GIOChannel *channel,
|
||||||
gint offset,
|
glong offset,
|
||||||
GSeekType type,
|
GSeekType type,
|
||||||
GError **err)
|
GError **err)
|
||||||
{
|
{
|
||||||
g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_SPIPE,
|
g_assert_not_reached ();
|
||||||
_("Seeking not allowed on this type of channel"));
|
|
||||||
|
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GIOStatus
|
||||||
g_io_win32_msg_close (GIOChannel *channel)
|
g_io_win32_msg_close (GIOChannel *channel,
|
||||||
|
GError **err)
|
||||||
{
|
{
|
||||||
/* Nothing to be done. Or should we set hwnd to some invalid value? */
|
/* Nothing to be done. Or should we set hwnd to some invalid value? */
|
||||||
|
|
||||||
|
return G_IO_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -794,7 +796,7 @@ g_io_win32_fd_read (GIOChannel *channel,
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -832,7 +834,7 @@ g_io_win32_fd_write (GIOChannel *channel,
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -845,7 +847,7 @@ g_io_win32_fd_write (GIOChannel *channel,
|
|||||||
|
|
||||||
static GIOStatus
|
static GIOStatus
|
||||||
g_io_win32_fd_seek (GIOChannel *channel,
|
g_io_win32_fd_seek (GIOChannel *channel,
|
||||||
gint offset,
|
glong offset,
|
||||||
GSeekType type,
|
GSeekType type,
|
||||||
GError **err)
|
GError **err)
|
||||||
{
|
{
|
||||||
@ -874,7 +876,7 @@ g_io_win32_fd_seek (GIOChannel *channel,
|
|||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
g_set_error (err, G_IO_CHANNEL_ERROR,
|
g_set_error (err, G_IO_CHANNEL_ERROR,
|
||||||
g_channel_error_from_errno (errno),
|
g_io_channel_error_from_errno (errno),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -882,8 +884,9 @@ g_io_win32_fd_seek (GIOChannel *channel,
|
|||||||
return G_IO_STATUS_NORMAL;
|
return G_IO_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GIOStatus
|
||||||
g_io_win32_fd_close (GIOChannel *channel)
|
g_io_win32_fd_close (GIOChannel *channel,
|
||||||
|
GError **err)
|
||||||
{
|
{
|
||||||
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
|
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
|
||||||
|
|
||||||
@ -912,6 +915,10 @@ g_io_win32_fd_close (GIOChannel *channel)
|
|||||||
win32_channel->fd = -1;
|
win32_channel->fd = -1;
|
||||||
}
|
}
|
||||||
UNLOCK (win32_channel->mutex);
|
UNLOCK (win32_channel->mutex);
|
||||||
|
|
||||||
|
/* FIXME error detection? */
|
||||||
|
|
||||||
|
return G_IO_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSource *
|
static GSource *
|
||||||
@ -935,7 +942,7 @@ g_io_win32_sock_read (GIOChannel *channel,
|
|||||||
if (win32_channel->debug)
|
if (win32_channel->debug)
|
||||||
g_print ("g_io_win32_sock_read: sockfd:%d count:%d\n",
|
g_print ("g_io_win32_sock_read: sockfd:%d count:%d\n",
|
||||||
win32_channel->fd, count);
|
win32_channel->fd, count);
|
||||||
|
repeat:
|
||||||
result = recv (win32_channel->fd, buf, count, 0);
|
result = recv (win32_channel->fd, buf, count, 0);
|
||||||
|
|
||||||
if (win32_channel->debug)
|
if (win32_channel->debug)
|
||||||
@ -954,7 +961,7 @@ g_io_win32_sock_read (GIOChannel *channel,
|
|||||||
return G_IO_STATUS_AGAIN;
|
return G_IO_STATUS_AGAIN;
|
||||||
#ifdef WE_NEED_TO_HANDLE_WSAEINTR /* not anymore with wsock2 ? */
|
#ifdef WE_NEED_TO_HANDLE_WSAEINTR /* not anymore with wsock2 ? */
|
||||||
case WSAEINTR:
|
case WSAEINTR:
|
||||||
return G_IO_STATUS_INTR;
|
goto repeat;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
error = G_IO_CHANNEL_ERROR_FAILED;
|
error = G_IO_CHANNEL_ERROR_FAILED;
|
||||||
@ -986,7 +993,7 @@ g_io_win32_sock_write (GIOChannel *channel,
|
|||||||
if (win32_channel->debug)
|
if (win32_channel->debug)
|
||||||
g_print ("g_io_win32_sock_write: sockfd:%d count:%d\n",
|
g_print ("g_io_win32_sock_write: sockfd:%d count:%d\n",
|
||||||
win32_channel->fd, count);
|
win32_channel->fd, count);
|
||||||
|
repeat:
|
||||||
result = send (win32_channel->fd, buf, count, 0);
|
result = send (win32_channel->fd, buf, count, 0);
|
||||||
|
|
||||||
if (win32_channel->debug)
|
if (win32_channel->debug)
|
||||||
@ -1005,7 +1012,7 @@ g_io_win32_sock_write (GIOChannel *channel,
|
|||||||
return G_IO_STATUS_AGAIN;
|
return G_IO_STATUS_AGAIN;
|
||||||
#ifdef WE_NEED_TO_HANDLE_WSAEINTR /* not anymore with wsock2 ? */
|
#ifdef WE_NEED_TO_HANDLE_WSAEINTR /* not anymore with wsock2 ? */
|
||||||
case WSAEINTR:
|
case WSAEINTR:
|
||||||
return G_IO_STATUS_INTR;
|
goto repeat;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
error = G_IO_CHANNEL_ERROR_FAILED;
|
error = G_IO_CHANNEL_ERROR_FAILED;
|
||||||
@ -1023,8 +1030,9 @@ g_io_win32_sock_write (GIOChannel *channel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GIOStatus
|
||||||
g_io_win32_sock_close (GIOChannel *channel)
|
g_io_win32_sock_close (GIOChannel *channel,
|
||||||
|
GError **err)
|
||||||
{
|
{
|
||||||
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
|
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
|
||||||
|
|
||||||
@ -1049,6 +1057,10 @@ g_io_win32_sock_close (GIOChannel *channel)
|
|||||||
win32_channel->fd = -1;
|
win32_channel->fd = -1;
|
||||||
}
|
}
|
||||||
UNLOCK(win32_channel->mutex);
|
UNLOCK(win32_channel->mutex);
|
||||||
|
|
||||||
|
/* FIXME error detection? */
|
||||||
|
|
||||||
|
return G_IO_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSource *
|
static GSource *
|
||||||
@ -1135,6 +1147,10 @@ g_io_channel_win32_new_messages (guint hwnd)
|
|||||||
win32_channel->type = G_IO_WIN32_WINDOWS_MESSAGES;
|
win32_channel->type = G_IO_WIN32_WINDOWS_MESSAGES;
|
||||||
win32_channel->hwnd = (HWND) hwnd;
|
win32_channel->hwnd = (HWND) hwnd;
|
||||||
|
|
||||||
|
/* FIXME set is_readable, is_writeable */
|
||||||
|
|
||||||
|
channel->is_seekable = FALSE;
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,6 +1178,10 @@ g_io_channel_win32_new_fd (gint fd)
|
|||||||
win32_channel->type = G_IO_WIN32_FILE_DESC;
|
win32_channel->type = G_IO_WIN32_FILE_DESC;
|
||||||
win32_channel->fd = fd;
|
win32_channel->fd = fd;
|
||||||
|
|
||||||
|
/* FIXME set is_readable, is_writeable */
|
||||||
|
|
||||||
|
channel->is_seekable = TRUE;
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1187,6 +1207,10 @@ g_io_channel_win32_new_socket (int socket)
|
|||||||
win32_channel->type = G_IO_WIN32_SOCKET;
|
win32_channel->type = G_IO_WIN32_SOCKET;
|
||||||
win32_channel->fd = socket;
|
win32_channel->fd = socket;
|
||||||
|
|
||||||
|
/* FIXME set is_readable, is_writeable */
|
||||||
|
|
||||||
|
channel->is_seekable = FALSE;
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
tests/iochannel-test-infile
Normal file
5
tests/iochannel-test-infile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Line one
|
||||||
|
Line two
|
||||||
|
Line three
|
||||||
|
/* Hello */
|
||||||
|
\x1234\x567890\x6666
|
@ -19,43 +19,42 @@ gint main (gint argc, gchar * argv[])
|
|||||||
GIOStatus status;
|
GIOStatus status;
|
||||||
GIOFlags flags;
|
GIOFlags flags;
|
||||||
|
|
||||||
if (argc < 2)
|
|
||||||
{
|
|
||||||
g_print( "Usage: foo in-file\n" );
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
setbuf(stdout, NULL); /* For debugging */
|
setbuf(stdout, NULL); /* For debugging */
|
||||||
|
|
||||||
gio_r = g_io_channel_new_file (argv[1], G_IO_FILE_MODE_READ, &gerr);
|
gio_r = g_io_channel_new_file ("iochannel-test-infile", "r", &gerr);
|
||||||
if(gerr) {
|
if (gerr)
|
||||||
g_warning(gerr->message);
|
{
|
||||||
g_warning("Unable to open file %s", argv[1]);
|
g_warning(gerr->message);
|
||||||
g_free(gerr);
|
g_warning("Unable to open file %s", "iochannel-test-infile");
|
||||||
return 0;
|
g_free(gerr);
|
||||||
}
|
return 0;
|
||||||
gio_w = g_io_channel_new_file( "/var/tmp/fooOut.txt", G_IO_FILE_MODE_WRITE, &gerr);
|
}
|
||||||
if(gerr) {
|
gio_w = g_io_channel_new_file( "iochannel-test-outfile", "w", &gerr);
|
||||||
g_warning(gerr->message);
|
if (gerr)
|
||||||
g_free(gerr);
|
{
|
||||||
return 0;
|
g_warning(gerr->message);
|
||||||
}
|
g_warning("Unable to open file %s", "iochannel-test-outfile");
|
||||||
|
g_free(gerr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_io_channel_set_encoding (gio_r, encoding, &gerr);
|
g_io_channel_set_encoding (gio_r, encoding, &gerr);
|
||||||
if(gerr) {
|
if (gerr)
|
||||||
g_warning(gerr->message);
|
{
|
||||||
g_free(gerr);
|
g_warning(gerr->message);
|
||||||
return 0;
|
g_free(gerr);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_io_channel_set_buffer_size (gio_r, BUFFER_SIZE);
|
g_io_channel_set_buffer_size (gio_r, BUFFER_SIZE);
|
||||||
|
|
||||||
status = g_io_channel_set_flags (gio_r, G_IO_FLAG_NONBLOCK, &gerr);
|
status = g_io_channel_set_flags (gio_r, G_IO_FLAG_NONBLOCK, &gerr);
|
||||||
if(status == G_IO_STATUS_ERROR) {
|
if (status == G_IO_STATUS_ERROR)
|
||||||
g_warning(gerr->message);
|
{
|
||||||
g_error_free(gerr);
|
g_warning(gerr->message);
|
||||||
gerr = NULL;
|
g_error_free(gerr);
|
||||||
}
|
gerr = NULL;
|
||||||
|
}
|
||||||
flags = g_io_channel_get_flags (gio_r);
|
flags = g_io_channel_get_flags (gio_r);
|
||||||
block = ! (flags & G_IO_FLAG_NONBLOCK);
|
block = ! (flags & G_IO_FLAG_NONBLOCK);
|
||||||
if (block)
|
if (block)
|
||||||
@ -106,9 +105,6 @@ gint main (gint argc, gchar * argv[])
|
|||||||
{
|
{
|
||||||
case G_IO_STATUS_EOF:
|
case G_IO_STATUS_EOF:
|
||||||
break;
|
break;
|
||||||
case G_IO_STATUS_PARTIAL_CHARS:
|
|
||||||
g_warning ("Partial characters at the end of input.");
|
|
||||||
break;
|
|
||||||
case G_IO_STATUS_ERROR:
|
case G_IO_STATUS_ERROR:
|
||||||
g_warning (gerr->message);
|
g_warning (gerr->message);
|
||||||
g_error_free (gerr);
|
g_error_free (gerr);
|
||||||
@ -123,11 +119,12 @@ gint main (gint argc, gchar * argv[])
|
|||||||
status = g_io_channel_flush (gio_w, &gerr);
|
status = g_io_channel_flush (gio_w, &gerr);
|
||||||
while (status == G_IO_STATUS_AGAIN);
|
while (status == G_IO_STATUS_AGAIN);
|
||||||
|
|
||||||
if(status == G_IO_STATUS_ERROR) {
|
if (status == G_IO_STATUS_ERROR)
|
||||||
g_warning(gerr->message);
|
{
|
||||||
g_error_free(gerr);
|
g_warning(gerr->message);
|
||||||
gerr = NULL;
|
g_error_free(gerr);
|
||||||
}
|
gerr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_print ("read %d bytes, wrote %d bytes\n", rlength, wlength);
|
g_print ("read %d bytes, wrote %d bytes\n", rlength, wlength);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
in = g_io_channel_new_file (argv[1], G_IO_FILE_MODE_READ, &error);
|
in = g_io_channel_new_file (argv[1], "r", &error);
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Cannot open %s: %s\n", argv[1], error->message);
|
fprintf (stderr, "Cannot open %s: %s\n", argv[1], error->message);
|
||||||
|
@ -141,7 +141,7 @@ int main (int argc, char **argv)
|
|||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
line_to_do = atoi(argv[2]);
|
line_to_do = atoi(argv[2]);
|
||||||
|
|
||||||
in = g_io_channel_new_file (argv[1], G_IO_FILE_MODE_READ, &error);
|
in = g_io_channel_new_file (argv[1], "r", &error);
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Cannot open %s: %s\n", argv[1], error->message);
|
fprintf (stderr, "Cannot open %s: %s\n", argv[1], error->message);
|
||||||
|
Loading…
Reference in New Issue
Block a user