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
00028
00029
00030
00031
00032
00033
00034 #include "config.h"
00035
00036 #include "glib.h"
00037 #ifdef HAVE_UNISTD_H
00038 #include <unistd.h>
00039 #endif
00040
00041 void
00042 g_io_channel_init (GIOChannel *channel)
00043 {
00044 channel->channel_flags = 0;
00045 channel->ref_count = 1;
00046 }
00047
00048
00049 void
00050 g_io_channel_ref (GIOChannel *channel)
00051 {
00052 g_return_if_fail (channel != NULL);
00053
00054 channel->ref_count++;
00055 }
00056
00057 void
00058 g_io_channel_unref (GIOChannel *channel)
00059 {
00060 g_return_if_fail (channel != NULL);
00061
00062 channel->ref_count--;
00063 if (channel->ref_count == 0)
00064 channel->funcs->io_free (channel);
00065 }
00066
00067 GIOError
00068 g_io_channel_read (GIOChannel *channel,
00069 gchar *buf,
00070 guint count,
00071 guint *bytes_read)
00072 {
00073 g_return_val_if_fail (channel != NULL, G_IO_ERROR_UNKNOWN);
00074
00075 return channel->funcs->io_read (channel, buf, count, bytes_read);
00076 }
00077
00078 GIOError
00079 g_io_channel_write (GIOChannel *channel,
00080 gchar *buf,
00081 guint count,
00082 guint *bytes_written)
00083 {
00084 g_return_val_if_fail (channel != NULL, G_IO_ERROR_UNKNOWN);
00085
00086 return channel->funcs->io_write (channel, buf, count, bytes_written);
00087 }
00088
00089 GIOError
00090 g_io_channel_seek (GIOChannel *channel,
00091 gint offset,
00092 GSeekType type)
00093 {
00094 g_return_val_if_fail (channel != NULL, G_IO_ERROR_UNKNOWN);
00095
00096 return channel->funcs->io_seek (channel, offset, type);
00097 }
00098
00099 void
00100 g_io_channel_close (GIOChannel *channel)
00101 {
00102 g_return_if_fail (channel != NULL);
00103
00104 channel->funcs->io_close (channel);
00105 }
00106
00107 guint
00108 g_io_add_watch_full (GIOChannel *channel,
00109 gint priority,
00110 GIOCondition condition,
00111 GIOFunc func,
00112 gpointer user_data,
00113 GDestroyNotify notify)
00114 {
00115 g_return_val_if_fail (channel != NULL, 0);
00116
00117 return channel->funcs->io_add_watch (channel, priority, condition,
00118 func, user_data, notify);
00119 }
00120
00121 guint
00122 g_io_add_watch (GIOChannel *channel,
00123 GIOCondition condition,
00124 GIOFunc func,
00125 gpointer user_data)
00126 {
00127 return g_io_add_watch_full (channel, 0, condition, func, user_data, NULL);
00128 }