summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps-win.c
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2007-03-10 09:10:36 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2007-03-10 09:10:36 +0000
commit47e318a6e1893069e1326945ce1af25ddf8201d1 (patch)
treeaae5bbc914c095d75ce7c40712d89ac847002e00 /dbus/dbus-sysdeps-win.c
parentf3fd4d60ad5de9f0c6576f6e100f944792fed255 (diff)
* bus/bus.c, bus/bus.h, bus/main.c, bus/test.c, dbus/dbus-sysdeps-unix.c, dbus/dbus-sysdeps-util-unix.c, dbus/dbus-sysdeps-util-win.c, bus/dbus-sysdeps-win.c,dbus/dbus-sysdeps.h: renamed _dbus_xxx_pipe to _dbus_pipe_xxx, completed _dbus_pipe support.
Diffstat (limited to 'dbus/dbus-sysdeps-win.c')
-rw-r--r--dbus/dbus-sysdeps-win.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c
index 9f62e5ba..fe80d100 100644
--- a/dbus/dbus-sysdeps-win.c
+++ b/dbus/dbus-sysdeps-win.c
@@ -266,27 +266,97 @@ dbus_bool_t _dbus_fstat (DBusFile *file,
return fstat(file->FDATA, sb) >= 0;
}
+/**
+ * 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
+ * @returns the number of bytes written or -1 on error
+ */
int
-_dbus_write_pipe (DBusPipe pipe,
+_dbus_pipe_write (DBusPipe pipe,
const DBusString *buffer,
int start,
int len)
{
DBusFile file;
- file.FDATA = pipe;
+ file.FDATA = pipe.fd;
return _dbus_write_file(&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_read_pipe(DBusPipe pipe,
+_dbus_pipe_read(DBusPipe pipe,
DBusString *buffer,
int count)
{
DBusFile file;
- file.FDATA = pipe;
+ file.FDATA = pipe.fd;
return _dbus_read_file(&file, buffer, count);
}
+/**
+ * close a pipe.
+ *
+ * @param pipe the pipe instance
+ * @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_close_file(&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)
+{
+ return pipe.fd > 2;
+}
+
#undef FDATA
/**