#include <unistd.h>
#endif
-#undef G_DISABLE_DEPRECATED
-
-#include "glib.h"
-
#include "giochannel.h"
+#include "gstrfuncs.h"
+#include "gtestutils.h"
#include "glibintl.h"
-#include "galias.h"
/**
- * SECTION: iochannels
+ * SECTION:iochannels
* @title: IO Channels
* @short_description: portable support for using files, pipes and
* sockets
* 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_channel_new_file().) Using g_io_add_watch() or
* g_io_add_watch_full() increments a channel's reference count.
*
* The new functions g_io_channel_read_chars(),
g_io_channel_purge (GIOChannel *channel)
{
GError *err = NULL;
- GIOStatus status;
+ GIOStatus status G_GNUC_UNUSED;
g_return_if_fail (channel != NULL);
if (channel->write_buf && channel->write_buf->len > 0)
{
GIOFlags flags;
-
+
/* Set the channel to blocking, to avoid a busy loop
*/
flags = g_io_channel_get_flags (channel);
status = g_io_channel_flush (channel, &err);
if (err)
- { /* No way to return the error */
- g_warning ("Error flushing string: %s", err->message);
- g_error_free (err);
- }
+ { /* No way to return the error */
+ g_warning ("Error flushing string: %s", err->message);
+ g_error_free (err);
+ }
}
/* Flush these in case anyone tries to close without unrefing */
*
* This internally creates a main loop source using g_io_create_watch()
* and attaches it to the main loop context with g_source_attach().
- * You can do these steps manuallt if you need greater control.
+ * You can do these steps manually if you need greater control.
*
* Returns: the event source id
+ * Rename to: g_io_add_watch
*/
guint
g_io_add_watch_full (GIOChannel *channel,
* Return value: The line termination string. This value
* is owned by GLib and must not be freed.
**/
-G_CONST_RETURN gchar*
+const gchar *
g_io_channel_get_line_term (GIOChannel *channel,
gint *length)
{
* %O_NONBLOCK/%O_NDELAY (see the documentation of
* the UNIX open() syscall).
* @G_IO_FLAG_IS_READABLE: indicates that the io channel is readable.
- * This flag can not be changed.
- * @G_IO_FLAG_IS_WRITEABLE: indicates that the io channel is writable.
- * This flag can not be changed.
+ * This flag cannot be changed.
+ * @G_IO_FLAG_IS_WRITABLE: indicates that the io channel is writable.
+ * This flag cannot be changed.
* @G_IO_FLAG_IS_SEEKABLE: indicates that the io channel is seekable,
* i.e. that g_io_channel_seek_position() can
- * be used on it. This flag can not be changed.
+ * be used on it. This flag cannot be changed.
* @G_IO_FLAG_MASK: the mask that specifies all the valid flags.
* @G_IO_FLAG_GET_MASK: the mask of the flags that are returned from
* g_io_channel_get_flags().
* read with g_io_channel_get_flags(), but not changed with
* g_io_channel_set_flags().
**/
+/**
+ * G_IO_FLAG_IS_WRITEABLE:
+ *
+ * This is a misspelled version of G_IO_FLAG_IS_WRITABLE that existed
+ * before the spelling was fixed in GLib 2.30. It is kept here for
+ * compatibility reasons.
+ *
+ * Deprecated:2.30:Use G_IO_FLAG_IS_WRITABLE instead.
+ **/
GIOStatus
g_io_channel_set_flags (GIOChannel *channel,
GIOFlags flags,
* Gets the current flags for a #GIOChannel, including read-only
* flags such as %G_IO_FLAG_IS_READABLE.
*
- * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITEABLE
+ * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
* 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
if (channel->is_readable)
flags |= G_IO_FLAG_IS_READABLE;
if (channel->is_writeable)
- flags |= G_IO_FLAG_IS_WRITEABLE;
+ flags |= G_IO_FLAG_IS_WRITABLE;
return flags;
}
* Return value: A string containing the encoding, this string is
* owned by GLib and must not be freed.
**/
-G_CONST_RETURN gchar*
+const gchar *
g_io_channel_get_encoding (GIOChannel *channel)
{
g_return_val_if_fail (channel != NULL, NULL);
* g_io_channel_read_chars:
* @channel: a #GIOChannel
* @buf: a buffer to read data into
- * @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.
- * @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.
+ * @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.
+ * @bytes_read: (allow-none): 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.
* @error: a location to return an error of type #GConvertError
- * or #GIOChannelError.
+ * or #GIOChannelError.
*
* Replacement for g_io_channel_read() with the new API.
*
* Return value: the status of the operation.
- **/
+ */
GIOStatus
g_io_channel_read_chars (GIOChannel *channel,
- gchar *buf,
- gsize count,
- gsize *bytes_read,
+ gchar *buf,
+ gsize count,
+ gsize *bytes_read,
GError **error)
{
GIOStatus status;
gsize got_bytes;
g_return_val_if_fail (channel != NULL, G_IO_STATUS_ERROR);
- g_return_val_if_fail ((error == NULL) || (*error == NULL),
- G_IO_STATUS_ERROR);
+ g_return_val_if_fail ((error == NULL) || (*error == NULL), G_IO_STATUS_ERROR);
g_return_val_if_fail (channel->is_readable, G_IO_STATUS_ERROR);
if (count == 0)
{
- *bytes_read = 0;
+ if (bytes_read)
+ *bytes_read = 0;
return G_IO_STATUS_NORMAL;
}
g_return_val_if_fail (buf != NULL, G_IO_STATUS_ERROR);
if (!channel->use_buffer)
{
gsize tmp_bytes;
-
+
g_assert (!channel->read_buf || channel->read_buf->len == 0);
status = channel->funcs->io_read (channel, buf, count, &tmp_bytes, error);
-
+
if (bytes_read)
- *bytes_read = tmp_bytes;
+ *bytes_read = tmp_bytes;
return status;
}
{
return g_quark_from_static_string ("g-io-channel-error-quark");
}
-
-#define __G_IOCHANNEL_C__
-#include "galiasdef.c"