* Modified by the GLib Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
+#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
+#error "Only <glib.h> can be included directly."
+#endif
+
#ifndef __G_IOCHANNEL_H__
#define __G_IOCHANNEL_H__
G_IO_FLAG_IS_SEEKABLE = 1 << 4, /* Read only flag */
G_IO_FLAG_MASK = (1 << 5) - 1,
G_IO_FLAG_GET_MASK = G_IO_FLAG_MASK,
- 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;
struct _GIOChannel
{
- /*<private>*/
-
- guint ref_count;
+ /*< private >*/
+ gint ref_count;
GIOFuncs *funcs;
gchar *encoding;
GIConv read_cd;
GIConv write_cd;
gchar *line_term; /* String which indicates the end of a line of text */
+ guint line_term_len; /* So we can have null in the line term */
gsize buf_size;
GString *read_buf; /* Raw data from the channel */
/* Group the flags together, immediately after partial_write_buf, to save memory */
- gboolean use_buffer : 1; /* The encoding uses the buffers */
- gboolean do_encode : 1; /* The encoding uses the GIConv coverters */
-
- /*<public>*/
-
- gboolean close_on_unref : 1; /* Close the channel on final unref */
+ guint use_buffer : 1; /* The encoding uses the buffers */
+ guint do_encode : 1; /* The encoding uses the GIConv coverters */
+ guint close_on_unref : 1; /* Close the channel on final unref */
+ guint is_readable : 1; /* Cached GIOFlag */
+ guint is_writeable : 1; /* ditto */
+ guint is_seekable : 1; /* ditto */
- /* The is_readable and is_writeable flags should really be marked
- * <protected> instead of <private>. Some applications of GIOChannel,
- * like GNet which implements the unix shutdown function to partially
- * or completely disconnect sockets, may need to set these. For most
- * cases, people won't need to touch them.
- */
-
- /*<private>*/
-
- gboolean is_readable : 1; /* Cached GIOFlag */
- gboolean is_writeable : 1; /* ditto */
- gboolean is_seekable : 1; /* ditto */
+ gpointer reserved1;
+ gpointer reserved2;
};
typedef gboolean (*GIOFunc) (GIOChannel *source,
gsize *bytes_written,
GError **err);
GIOStatus (*io_seek) (GIOChannel *channel,
- glong offset,
+ gint64 offset,
GSeekType type,
GError **err);
GIOStatus (*io_close) (GIOChannel *channel,
};
void g_io_channel_init (GIOChannel *channel);
-void g_io_channel_ref (GIOChannel *channel);
+GIOChannel *g_io_channel_ref (GIOChannel *channel);
void g_io_channel_unref (GIOChannel *channel);
#ifndef G_DISABLE_DEPRECATED
gsize count,
gsize *bytes_written);
GIOError g_io_channel_seek (GIOChannel *channel,
- glong offset,
+ gint64 offset,
GSeekType type);
void g_io_channel_close (GIOChannel *channel);
#endif /* G_DISABLE_DEPRECATED */
GError **error);
GIOFlags g_io_channel_get_flags (GIOChannel *channel);
void g_io_channel_set_line_term (GIOChannel *channel,
- const gchar *line_term);
-G_CONST_RETURN gchar* g_io_channel_get_line_term (GIOChannel *channel);
+ const gchar *line_term,
+ gint length);
+G_CONST_RETURN gchar* g_io_channel_get_line_term (GIOChannel *channel,
+ gint *length);
void g_io_channel_set_buffered (GIOChannel *channel,
gboolean buffered);
gboolean g_io_channel_get_buffered (GIOChannel *channel);
const gchar *encoding,
GError **error);
G_CONST_RETURN gchar* g_io_channel_get_encoding (GIOChannel *channel);
+void g_io_channel_set_close_on_unref (GIOChannel *channel,
+ gboolean do_close);
+gboolean g_io_channel_get_close_on_unref (GIOChannel *channel);
GIOStatus g_io_channel_flush (GIOChannel *channel,
gunichar thechar,
GError **error);
GIOStatus g_io_channel_seek_position (GIOChannel *channel,
- glong offset,
+ gint64 offset,
GSeekType type,
GError **error);
+#ifdef G_OS_WIN32
+#define g_io_channel_new_file g_io_channel_new_file_utf8
+#endif
+
GIOChannel* g_io_channel_new_file (const gchar *filename,
const gchar *mode,
GError **error);
GIOChannel* g_io_channel_unix_new (int fd);
gint g_io_channel_unix_get_fd (GIOChannel *channel);
+
+/* Hook for GClosure / GSource integration. Don't touch */
+GLIB_VAR GSourceFuncs g_io_watch_funcs;
+
#ifdef G_OS_WIN32
+/* You can use this "pseudo file descriptor" in a GPollFD to add
+ * polling for Windows messages. GTK applications should not do that.
+ */
+
#define G_WIN32_MSG_HANDLE 19981206
/* Use this to get a GPollFD from a GIOChannel, so that you can call
*/
gint g_io_channel_win32_poll (GPollFD *fds,
gint n_fds,
- gint timeout);
-
-/* This is used to add polling for Windows messages. GDK (GTk+) programs
- * should *not* use this.
- */
-void g_main_poll_win32_msg_add (gint priority,
- GPollFD *fd,
- guint hwnd);
+ gint timeout_);
/* Create an IO channel for Windows messages for window handle hwnd. */
+#if GLIB_SIZEOF_VOID_P == 8
+/* We use gsize here so that it is still an integer type and not a
+ * pointer, like the guint in the traditional prototype. We can't use
+ * intptr_t as that is not portable enough.
+ */
+GIOChannel *g_io_channel_win32_new_messages (gsize hwnd);
+#else
GIOChannel *g_io_channel_win32_new_messages (guint hwnd);
+#endif
/* Create an IO channel for C runtime (emulated Unix-like) file
* descriptors. After calling g_io_add_watch() on a IO channel
* implemented on Win32 by starting a thread that sits blocked in a
* read() from the file descriptor most of the time. All reads from
* the file descriptor should be done by this internal GLib
- * thread. Your code should call only g_io_channel_read().
+ * thread. Your code should call only g_io_channel_read_chars().
*/
GIOChannel* g_io_channel_win32_new_fd (gint fd);