From: Tor Lillqvist Date: Sun, 27 Aug 2000 10:53:36 +0000 (+0000) Subject: New function, otherwise like g_io_channel_win32_wait_for_condition(), but X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=3d0a1b3b221d32a53557a3512ab6eeadbf816352;p=dana%2Fcg-glib.git New function, otherwise like g_io_channel_win32_wait_for_condition(), but 2000-08-27 Tor Lillqvist * giowin32.c (g_io_channel_win32_poll): New function, otherwise like g_io_channel_win32_wait_for_condition(), but accept several GIOChannels. (g_io_channel_win32_wait_for_condition): Call g_io_channel_win32_poll(). * glib.h: Declare g_io_channel_win32_poll(). * gwin32.c (g_win32_error_message): Don't believe return value from FormatMessage. --- diff --git a/ChangeLog b/ChangeLog index d10e1d8b..dd894914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d10e1d8b..dd894914 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +2000-08-27 Tor Lillqvist + + * giowin32.c (g_io_channel_win32_poll): New function, otherwise + like g_io_channel_win32_wait_for_condition(), but accept several + GIOChannels. + (g_io_channel_win32_wait_for_condition): Call + g_io_channel_win32_poll(). + + * glib.h: Declare g_io_channel_win32_poll(). + + * gwin32.c (g_win32_error_message): Don't believe return value + from FormatMessage. + 2000-08-25 Elliot Lee * glib.h, gunicode.h, gmodule/gmodule.h: : Mark the following functions G_GNUC_CONST (to allow diff --git a/giowin32.c b/giowin32.c index 68fee3b4..db5e9ca4 100644 --- a/giowin32.c +++ b/giowin32.c @@ -872,29 +872,62 @@ g_io_channel_win32_set_debug (GIOChannel *channel, } gint -g_io_channel_win32_wait_for_condition (GIOChannel *channel, - GIOCondition condition, - gint timeout) +g_io_channel_win32_poll (GIOChannel **channels, + gint n_channels, + GIOCondition condition, + gint timeout) { - GPollFD pollfd; - GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; + GPollFD *pollfd; + GIOWin32Channel *win32_channel; + int i; int result; + gboolean debug = FALSE; - pollfd.fd = (gint) win32_channel->data_avail_event; - pollfd.events = condition; + g_return_val_if_fail (n_channels >= 0, 0); - if (win32_channel->debug) - g_print ("g_io_channel_win32_wait_for_condition: fd:%d event:%#x timeout:%d\n", - win32_channel->fd, pollfd.fd, timeout); + pollfd = g_new (GPollFD, n_channels); - result = (*g_main_win32_get_poll_func ()) (&pollfd, 1, timeout); + for (i = 0; i < n_channels; i++) + { + win32_channel = (GIOWin32Channel *) channels[i]; + debug |= win32_channel->debug; + pollfd[i].fd = (gint) win32_channel->data_avail_event; + pollfd[i].events = condition; + } - if (win32_channel->debug) - g_print ("g_io_channel_win32_wait_for_condition: done:%d\n", result); + if (debug) + { + g_print ("g_io_channel_win32_poll: "); + for (i = 0; i < n_channels; i++) + { + win32_channel = (GIOWin32Channel *) channels[i]; + g_print ("fd:%d event:%#x ", win32_channel->fd, pollfd[i].fd); + } + g_print ("condition:%s%s%s%s timeout:%d\n", + (condition & G_IO_ERR) ? " ERR" : "", + (condition & G_IO_HUP) ? " HUP" : "", + (condition & G_IO_IN) ? " IN" : "", + (condition & G_IO_PRI) ? " PRI" : "", + timeout); + } + + result = (*g_main_win32_get_poll_func ()) (pollfd, n_channels, timeout); + + if (debug) + g_print ("g_io_channel_win32_poll: done:%d\n", result); + + g_free (pollfd); return result; } +gint +g_io_channel_win32_wait_for_condition (GIOChannel *channel, + GIOCondition condition, + gint timeout) +{ + return g_io_channel_win32_poll (&channel, 1, condition, timeout); +} /* This variable and the functions below are present just to be * binary compatible with old clients... But note that in GIMP, the diff --git a/glib.def b/glib.def index 2781cb48..0843575b 100644 --- a/glib.def +++ b/glib.def @@ -166,6 +166,7 @@ EXPORTS g_io_channel_win32_new_stream_socket g_io_channel_win32_pipe_readable g_io_channel_win32_pipe_request_wakeups + g_io_channel_win32_poll g_io_channel_win32_set_debug g_io_channel_win32_wait_for_condition g_io_channel_write diff --git a/glib.h b/glib.h index 6b684088..31805dde 100644 --- a/glib.h +++ b/glib.h @@ -2921,20 +2921,21 @@ gint g_io_channel_unix_get_fd (GIOChannel *channel); #define G_WIN32_MSG_HANDLE 19981206 -/* This can be used to wait until a channel is readable. On Unix you - * would do a select() on the fd of the channel. This should probably - * be replaced by something for all platforms? +/* This can be used to wait a until at least one of the channels is readable. + * On Unix you would do a select() on the file descriptors of the channels. + * This should probably be available for all platforms? */ -gint g_io_channel_win32_wait_for_condition (GIOChannel *channel, - GIOCondition condition, - gint timeout); +gint g_io_channel_win32_poll (GIOChannel **channels, + gint n_channels, + GIOCondition condition, + 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); +void g_main_poll_win32_msg_add (gint priority, + GPollFD *fd, + guint hwnd); /* An IO channel for Windows messages for window handle hwnd. */ GIOChannel *g_io_channel_win32_new_messages (guint hwnd); diff --git a/glib/giowin32.c b/glib/giowin32.c index 68fee3b4..db5e9ca4 100644 --- a/glib/giowin32.c +++ b/glib/giowin32.c @@ -872,29 +872,62 @@ g_io_channel_win32_set_debug (GIOChannel *channel, } gint -g_io_channel_win32_wait_for_condition (GIOChannel *channel, - GIOCondition condition, - gint timeout) +g_io_channel_win32_poll (GIOChannel **channels, + gint n_channels, + GIOCondition condition, + gint timeout) { - GPollFD pollfd; - GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; + GPollFD *pollfd; + GIOWin32Channel *win32_channel; + int i; int result; + gboolean debug = FALSE; - pollfd.fd = (gint) win32_channel->data_avail_event; - pollfd.events = condition; + g_return_val_if_fail (n_channels >= 0, 0); - if (win32_channel->debug) - g_print ("g_io_channel_win32_wait_for_condition: fd:%d event:%#x timeout:%d\n", - win32_channel->fd, pollfd.fd, timeout); + pollfd = g_new (GPollFD, n_channels); - result = (*g_main_win32_get_poll_func ()) (&pollfd, 1, timeout); + for (i = 0; i < n_channels; i++) + { + win32_channel = (GIOWin32Channel *) channels[i]; + debug |= win32_channel->debug; + pollfd[i].fd = (gint) win32_channel->data_avail_event; + pollfd[i].events = condition; + } - if (win32_channel->debug) - g_print ("g_io_channel_win32_wait_for_condition: done:%d\n", result); + if (debug) + { + g_print ("g_io_channel_win32_poll: "); + for (i = 0; i < n_channels; i++) + { + win32_channel = (GIOWin32Channel *) channels[i]; + g_print ("fd:%d event:%#x ", win32_channel->fd, pollfd[i].fd); + } + g_print ("condition:%s%s%s%s timeout:%d\n", + (condition & G_IO_ERR) ? " ERR" : "", + (condition & G_IO_HUP) ? " HUP" : "", + (condition & G_IO_IN) ? " IN" : "", + (condition & G_IO_PRI) ? " PRI" : "", + timeout); + } + + result = (*g_main_win32_get_poll_func ()) (pollfd, n_channels, timeout); + + if (debug) + g_print ("g_io_channel_win32_poll: done:%d\n", result); + + g_free (pollfd); return result; } +gint +g_io_channel_win32_wait_for_condition (GIOChannel *channel, + GIOCondition condition, + gint timeout) +{ + return g_io_channel_win32_poll (&channel, 1, condition, timeout); +} /* This variable and the functions below are present just to be * binary compatible with old clients... But note that in GIMP, the diff --git a/glib/glib.def b/glib/glib.def index 2781cb48..0843575b 100644 --- a/glib/glib.def +++ b/glib/glib.def @@ -166,6 +166,7 @@ EXPORTS g_io_channel_win32_new_stream_socket g_io_channel_win32_pipe_readable g_io_channel_win32_pipe_request_wakeups + g_io_channel_win32_poll g_io_channel_win32_set_debug g_io_channel_win32_wait_for_condition g_io_channel_write diff --git a/glib/glib.h b/glib/glib.h index 6b684088..31805dde 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -2921,20 +2921,21 @@ gint g_io_channel_unix_get_fd (GIOChannel *channel); #define G_WIN32_MSG_HANDLE 19981206 -/* This can be used to wait until a channel is readable. On Unix you - * would do a select() on the fd of the channel. This should probably - * be replaced by something for all platforms? +/* This can be used to wait a until at least one of the channels is readable. + * On Unix you would do a select() on the file descriptors of the channels. + * This should probably be available for all platforms? */ -gint g_io_channel_win32_wait_for_condition (GIOChannel *channel, - GIOCondition condition, - gint timeout); +gint g_io_channel_win32_poll (GIOChannel **channels, + gint n_channels, + GIOCondition condition, + 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); +void g_main_poll_win32_msg_add (gint priority, + GPollFD *fd, + guint hwnd); /* An IO channel for Windows messages for window handle hwnd. */ GIOChannel *g_io_channel_win32_new_messages (guint hwnd); diff --git a/glib/gwin32.c b/glib/gwin32.c index adc8a239..256fe021 100644 --- a/glib/gwin32.c +++ b/glib/gwin32.c @@ -806,11 +806,13 @@ g_win32_error_message (gint error) gchar *retval; int nbytes; - nbytes = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER - |FORMAT_MESSAGE_IGNORE_INSERTS - |FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, - (LPTSTR) &msg, 0, NULL); + FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER + |FORMAT_MESSAGE_IGNORE_INSERTS + |FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, + (LPTSTR) &msg, 0, NULL); + nbytes = strlen (msg); + if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r') msg[nbytes-2] = '\0'; diff --git a/gwin32.c b/gwin32.c index adc8a239..256fe021 100644 --- a/gwin32.c +++ b/gwin32.c @@ -806,11 +806,13 @@ g_win32_error_message (gint error) gchar *retval; int nbytes; - nbytes = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER - |FORMAT_MESSAGE_IGNORE_INSERTS - |FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, - (LPTSTR) &msg, 0, NULL); + FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER + |FORMAT_MESSAGE_IGNORE_INSERTS + |FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, + (LPTSTR) &msg, 0, NULL); + nbytes = strlen (msg); + if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r') msg[nbytes-2] = '\0';