00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __G_IOCHANNEL_H__
00028 #define __G_IOCHANNEL_H__
00029
00030 #include <gmain.h>
00031 #include <g_types.h>
00032
00033 G_BEGIN_DECLS
00034
00035
00036
00037
00038 typedef struct _GIOChannel GIOChannel;
00039 typedef struct _GIOFuncs GIOFuncs;
00040 typedef enum
00041 {
00042 G_IO_ERROR_NONE,
00043 G_IO_ERROR_AGAIN,
00044 G_IO_ERROR_INVAL,
00045 G_IO_ERROR_UNKNOWN
00046 } GIOError;
00047 typedef enum
00048 {
00049 G_SEEK_CUR,
00050 G_SEEK_SET,
00051 G_SEEK_END
00052 } GSeekType;
00053 typedef enum
00054 {
00055 G_IO_IN GLIB_SYSDEF_POLLIN,
00056 G_IO_OUT GLIB_SYSDEF_POLLOUT,
00057 G_IO_PRI GLIB_SYSDEF_POLLPRI,
00058 G_IO_ERR GLIB_SYSDEF_POLLERR,
00059 G_IO_HUP GLIB_SYSDEF_POLLHUP,
00060 G_IO_NVAL GLIB_SYSDEF_POLLNVAL
00061 } GIOCondition;
00062
00063 struct _GIOChannel
00064 {
00065 guint channel_flags;
00066 guint ref_count;
00067 GIOFuncs *funcs;
00068 };
00069
00070 typedef gboolean (*GIOFunc) (GIOChannel *source,
00071 GIOCondition condition,
00072 gpointer data);
00073 struct _GIOFuncs
00074 {
00075 GIOError (*io_read) (GIOChannel *channel,
00076 gchar *buf,
00077 guint count,
00078 guint *bytes_read);
00079 GIOError (*io_write) (GIOChannel *channel,
00080 gchar *buf,
00081 guint count,
00082 guint *bytes_written);
00083 GIOError (*io_seek) (GIOChannel *channel,
00084 gint offset,
00085 GSeekType type);
00086 void (*io_close) (GIOChannel *channel);
00087 GSource * (*io_create_watch) (GIOChannel *channel,
00088 GIOCondition condition);
00089 void (*io_free) (GIOChannel *channel);
00090 };
00091
00092 void g_io_channel_init (GIOChannel *channel);
00093 void g_io_channel_ref (GIOChannel *channel);
00094 void g_io_channel_unref (GIOChannel *channel);
00095 GIOError g_io_channel_read (GIOChannel *channel,
00096 gchar *buf,
00097 guint count,
00098 guint *bytes_read);
00099 GIOError g_io_channel_write (GIOChannel *channel,
00100 gchar *buf,
00101 guint count,
00102 guint *bytes_written);
00103 GIOError g_io_channel_seek (GIOChannel *channel,
00104 gint offset,
00105 GSeekType type);
00106 void g_io_channel_close (GIOChannel *channel);
00107 guint g_io_add_watch_full (GIOChannel *channel,
00108 gint priority,
00109 GIOCondition condition,
00110 GIOFunc func,
00111 gpointer user_data,
00112 GDestroyNotify notify);
00113 GSource *g_io_create_watch (GIOChannel *channel,
00114 GIOCondition condition);
00115 guint g_io_add_watch (GIOChannel *channel,
00116 GIOCondition condition,
00117 GIOFunc func,
00118 gpointer user_data);
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 GIOChannel* g_io_channel_unix_new (int fd);
00133 gint g_io_channel_unix_get_fd (GIOChannel *channel);
00134
00135 #ifdef G_OS_WIN32
00136
00137 #define G_WIN32_MSG_HANDLE 19981206
00138
00139
00140
00141
00142
00143
00144 void g_io_channel_win32_make_pollfd (GIOChannel *channel,
00145 GIOCondition condition,
00146 GPollFD *fd);
00147
00148
00149
00150
00151
00152 gint g_io_channel_win32_poll (GPollFD *fds,
00153 gint n_fds,
00154 gint timeout);
00155
00156
00157
00158
00159 void g_main_poll_win32_msg_add (gint priority,
00160 GPollFD *fd,
00161 guint hwnd);
00162
00163
00164 GIOChannel *g_io_channel_win32_new_messages (guint hwnd);
00165
00166
00167
00168
00169
00170
00171
00172 GIOChannel* g_io_channel_win32_new_fd (int fd);
00173
00174
00175 gint g_io_channel_win32_get_fd (GIOChannel *channel);
00176
00177
00178
00179
00180
00181 GIOChannel *g_io_channel_win32_new_stream_socket (int socket);
00182
00183 #endif
00184
00185 G_END_DECLS
00186
00187 #endif