summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps-win.c
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2007-03-13 17:14:35 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2007-03-13 17:14:35 +0000
commitfabc97752724d36149fec6fde3caf354336862eb (patch)
treed7f863cbbfeb5e4d68fab29b98b4b5e518e6582c /dbus/dbus-sysdeps-win.c
parent288d47c7833c58cef3747b15f2ece36d8612964b (diff)
* dbus/dbus-sysdeps-win.c: fixed broken DBusPipe on win32.
* dbus/dbus-sysdeps-win.c, dbus/dbus-sysdeps-unix.c: moved platform independent DBusPipe function to dbus-sysdeps.c.
Diffstat (limited to 'dbus/dbus-sysdeps-win.c')
-rw-r--r--dbus/dbus-sysdeps-win.c95
1 files changed, 29 insertions, 66 deletions
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c
index 2ffb3e2d..64c2f99d 100644
--- a/dbus/dbus-sysdeps-win.c
+++ b/dbus/dbus-sysdeps-win.c
@@ -267,54 +267,33 @@ dbus_bool_t _dbus_fstat (DBusFile *file,
}
/**
- * init a pipe instance.
- *
- * @param fd the file descriptor to init from
- * @returns a DBusPipe instance
- */
-DBusPipe _dbus_pipe_init(int fd)
-{
- DBusPipe pipe;
- pipe.fd = fd;
- return pipe;
-}
-
-/**
* write data to a pipe.
*
* @param pipe the pipe instance
* @param buffer the buffer to write data from
* @param start the first byte in the buffer to write
* @param len the number of bytes to try to write
+ * @param error error return
* @returns the number of bytes written or -1 on error
*/
int
-_dbus_pipe_write (DBusPipe pipe,
+_dbus_pipe_write (DBusPipe *pipe,
const DBusString *buffer,
int start,
- int len)
+ int len,
+ DBusError *error)
{
- DBusFile file;
- file.FDATA = pipe.fd;
- return _dbus_file_write(&file, buffer, start, len);
-}
-
-/**
- * read data from a pipe.
- *
- * @param pipe the pipe instance
- * @param buffer the buffer to read data in
- * @param count the number of bytes to try to read
- * @returns the number of bytes read or -1 on error
- */
-int
-_dbus_pipe_read(DBusPipe pipe,
- DBusString *buffer,
- int count)
-{
- DBusFile file;
- file.FDATA = pipe.fd;
- return _dbus_file_read(&file, buffer, count);
+ int written;
+ DBusFile file;
+ file.FDATA = pipe->fd_or_handle;
+ written = _dbus_file_write (&file, buffer, start, len);
+ if (written < 0)
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Writing to pipe: %s\n",
+ _dbus_strerror (errno));
+ }
+ return written;
}
/**
@@ -324,37 +303,21 @@ _dbus_pipe_read(DBusPipe pipe,
* @param error return location for an error
* @returns #FALSE if error is set
*/
- int
-_dbus_pipe_close(DBusPipe pipe,
- DBusError *error)
-{
- DBusFile file;
- file.FDATA = pipe.fd;
- return _dbus_file_close(&file, error);
-}
-
-/**
- * check if a pipe is valid, which means is constructed
- * by a valid file descriptor
- *
- * @param pipe the pipe instance
- * @returns #FALSE if pipe is not valid
- */
-dbus_bool_t _dbus_pipe_is_valid(DBusPipe pipe)
-{
- return pipe.fd >= 0;
-}
-
-/**
- * check if a pipe is a special pipe, which means using
- * a non default file descriptor (>2)
- *
- * @param pipe the pipe instance
- * @returns #FALSE if pipe is not a special pipe
- */
-dbus_bool_t _dbus_pipe_is_special(DBusPipe pipe)
+int
+_dbus_pipe_close (DBusPipe *pipe,
+ DBusError *error)
{
- return pipe.fd > 2;
+ DBusFile file;
+ file.FDATA = pipe->fd_or_handle;
+ if (_dbus_file_close (&file, error) < 0)
+ {
+ return -1;
+ }
+ else
+ {
+ _dbus_pipe_invalidate (pipe);
+ return 0;
+ }
}
#undef FDATA