Commit 3d0a1b3b authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

New function, otherwise like g_io_channel_win32_wait_for_condition(), but

2000-08-27  Tor Lillqvist  <tml@iki.fi>

	* 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.
parent a435aaff
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
2000-08-27 Tor Lillqvist <tml@iki.fi>
* 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 <sopwith@redhat.com>
* glib.h, gunicode.h, gmodule/gmodule.h:
: Mark the following functions G_GNUC_CONST (to allow
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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';
......
......@@ -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';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment