dbus/dbus dbus-sysdeps-unix.c, 1.21, 1.22 dbus-sysdeps-util-unix.c, 1.11, 1.12 dbus-sysdeps-util-win.c, 1.1, 1.2 dbus-sysdeps-win.c, 1.4, 1.5 dbus-sysdeps.h, 1.70, 1.71

Ralf Habacker rhabacker at kemper.freedesktop.org
Sat Mar 10 01:10:39 PST 2007


Update of /cvs/dbus/dbus/dbus
In directory kemper:/tmp/cvs-serv3846/dbus

Modified Files:
	dbus-sysdeps-unix.c dbus-sysdeps-util-unix.c 
	dbus-sysdeps-util-win.c dbus-sysdeps-win.c dbus-sysdeps.h 
Log Message:
* 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.

Index: dbus-sysdeps-unix.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-unix.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dbus-sysdeps-unix.c	10 Mar 2007 08:04:39 -0000	1.21
+++ dbus-sysdeps-unix.c	10 Mar 2007 09:10:36 -0000	1.22
@@ -169,16 +169,77 @@
   return _dbus_write (fd, buffer, start, len);
 }
 
+/**
+ * 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)
 {
-	return _dbus_write (pipe, buffer, start, len);
+  return _dbus_write (pipe.fd, buffer, start, len);
 }
 
 /**
+ * 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)
+{
+  return _dbus_close (pipe.fd, 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;
+}
+
+
+/**
  * Like _dbus_write_two() but only works on sockets and is thus
  * available on Windows.
  * 
@@ -765,8 +826,8 @@
 /**
  * Creates a socket and binds it to the given path,
  * then listens on the socket. The socket is
- * set to be nonblocking. 
- * In case of port=0 a random free port is used and 
+ * set to be nonblocking. 
+ * In case of port=0 a random free port is used and 
  * returned in the port parameter. 
  *
  * @param host the host name to listen on

Index: dbus-sysdeps-util-unix.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-util-unix.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus-sysdeps-util-unix.c	2 Nov 2006 19:19:08 -0000	1.11
+++ dbus-sysdeps-util-unix.c	10 Mar 2007 09:10:36 -0000	1.12
@@ -67,7 +67,7 @@
  */
 dbus_bool_t
 _dbus_become_daemon (const DBusString *pidfile,
-		     int               print_pid_fd,
+                     DBusPipe         print_pid_fd,
                      DBusError        *error)
 {
   const char *s;
@@ -157,7 +157,7 @@
 	    }
 	  
 	  bytes = _dbus_string_get_length (&pid);
-	  if (_dbus_write_socket (print_pid_fd, &pid, 0, bytes) != bytes)
+	  if (_dbus_pipe_write (print_pid_fd, &pid, 0, bytes) != bytes)
 	    {
 	      dbus_set_error (error, DBUS_ERROR_FAILED,
 			      "Printing message bus PID: %s\n",

Index: dbus-sysdeps-util-win.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-util-win.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-sysdeps-util-win.c	3 Mar 2007 17:25:53 -0000	1.1
+++ dbus-sysdeps-util-win.c	10 Mar 2007 09:10:36 -0000	1.2
@@ -52,7 +52,7 @@
  */
 dbus_bool_t
 _dbus_become_daemon (const DBusString *pidfile,
-                     int               print_pid_fd,
+                     DBusPipe         print_pid_fd,
                      DBusError        *error)
 {
   return TRUE;

Index: dbus-sysdeps-win.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-win.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dbus-sysdeps-win.c	10 Mar 2007 08:04:39 -0000	1.4
+++ dbus-sysdeps-win.c	10 Mar 2007 09:10:36 -0000	1.5
@@ -266,27 +266,97 @@
   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
 
 /**
@@ -3437,8 +3507,8 @@
 /**
  * Creates a socket and binds it to the given port,
  * then listens on the socket. The socket is
- * set to be nonblocking. 
- * In case of port=0 a random free port is used and 
+ * set to be nonblocking. 
+ * In case of port=0 a random free port is used and 
  * returned in the port parameter. 
  *
  * @param host the interface to listen on, NULL for loopback, empty for any

Index: dbus-sysdeps.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- dbus-sysdeps.h	10 Mar 2007 08:04:39 -0000	1.70
+++ dbus-sysdeps.h	10 Mar 2007 09:10:36 -0000	1.71
@@ -302,12 +302,23 @@
 
 dbus_bool_t _dbus_get_standard_session_servicedirs (DBusList **dirs);
 
-typedef int DBusPipe;
-int _dbus_write_pipe (DBusPipe          pipe,
+typedef struct {
+	int fd; 
+} DBusPipe;
+
+DBusPipe _dbus_pipe_init(int         fd);
+
+int _dbus_pipe_write (DBusPipe          pipe,
                       const DBusString *buffer,
                       int               start,
                       int               len);
 
+int _dbus_pipe_close  (DBusPipe          pipe,
+					   DBusError        *error);
+
+dbus_bool_t _dbus_pipe_is_valid(DBusPipe pipe);
+dbus_bool_t _dbus_pipe_is_special(DBusPipe pipe);
+
 /** Opaque type for reading a directory listing */
 typedef struct DBusDirIter DBusDirIter;
 
@@ -374,7 +385,7 @@
 void        _dbus_print_backtrace  (void);
 
 dbus_bool_t _dbus_become_daemon   (const DBusString *pidfile,
-				   int               print_pid_fd,
+                                   DBusPipe         print_pid_fd,
                                    DBusError        *error);
 dbus_bool_t _dbus_write_pid_file  (const DBusString *filename,
                                    unsigned long     pid,



More information about the dbus-commit mailing list