*
*/
+#include <config.h>
#include "dbus-internals.h"
#include "dbus-sysdeps.h"
#include "dbus-threads.h"
#include <string.h>
#include <stdio.h>
-/* This is UNIX-specific (on windows it's just in stdlib.h I believe)
- * but OK since the same stuff does exist on Windows in stdlib.h
- * and covered by a configure check.
- */
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef DBUS_WIN
#include <stdlib.h>
+#elif (defined __APPLE__)
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif
return environment;
}
-/*
- * init a pipe instance.
- *
- * @param pipe the pipe
- * @param fd the file descriptor to init from
- */
-void
-_dbus_pipe_init (DBusPipe *pipe,
- int fd)
-{
- pipe->fd_or_handle = fd;
-}
-
-/**
- * init a pipe with stdout
- *
- * @param pipe the pipe
- */
-void
-_dbus_pipe_init_stdout (DBusPipe *pipe)
-{
- _dbus_pipe_init (pipe, 1);
-}
-
-/**
- * check if a pipe is valid; pipes can be set invalid, similar to
- * a -1 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_or_handle >= 0;
-}
-
-/**
- * Check if a pipe is stdout or stderr.
- *
- * @param pipe the pipe instance
- * @returns #TRUE if pipe is one of the standard out/err channels
- */
-dbus_bool_t
-_dbus_pipe_is_stdout_or_stderr (DBusPipe *pipe)
-{
- return pipe->fd_or_handle == 1 || pipe->fd_or_handle == 2;
-}
-
-/**
- * Initializes a pipe to an invalid value.
- * @param pipe the pipe
- */
-void
-_dbus_pipe_invalidate (DBusPipe *pipe)
-{
- pipe->fd_or_handle = -1;
-}
-
/**
* Split paths into a list of char strings
*
}
/**
- * Converts a UNIX or Windows errno
- * into a #DBusError name.
+ * Converts a UNIX errno, or Windows errno or WinSock error value into
+ * a #DBusError name.
*
* @todo should cover more errnos, specifically those
* from open().
case EPROTONOSUPPORT:
return DBUS_ERROR_NOT_SUPPORTED;
#endif
+#ifdef WSAEPROTONOSUPPORT
+ case WSAEPROTONOSUPPORT:
+ return DBUS_ERROR_NOT_SUPPORTED;
+#endif
#ifdef EAFNOSUPPORT
case EAFNOSUPPORT:
return DBUS_ERROR_NOT_SUPPORTED;
#endif
+#ifdef WSAEAFNOSUPPORT
+ case WSAEAFNOSUPPORT:
+ return DBUS_ERROR_NOT_SUPPORTED;
+#endif
#ifdef ENFILE
case ENFILE:
return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */
case ENOMEM:
return DBUS_ERROR_NO_MEMORY;
#endif
-#ifdef EINVAL
- case EINVAL:
- return DBUS_ERROR_FAILED;
-#endif
-#ifdef EBADF
- case EBADF:
- return DBUS_ERROR_FAILED;
-#endif
-#ifdef EFAULT
- case EFAULT:
- return DBUS_ERROR_FAILED;
-#endif
-#ifdef ENOTSOCK
- case ENOTSOCK:
- return DBUS_ERROR_FAILED;
-#endif
-#ifdef EISCONN
- case EISCONN:
- return DBUS_ERROR_FAILED;
-#endif
#ifdef ECONNREFUSED
case ECONNREFUSED:
return DBUS_ERROR_NO_SERVER;
#endif
+#ifdef WSAECONNREFUSED
+ case WSAECONNREFUSED:
+ return DBUS_ERROR_NO_SERVER;
+#endif
#ifdef ETIMEDOUT
case ETIMEDOUT:
return DBUS_ERROR_TIMEOUT;
#endif
+#ifdef WSAETIMEDOUT
+ case WSAETIMEDOUT:
+ return DBUS_ERROR_TIMEOUT;
+#endif
#ifdef ENETUNREACH
case ENETUNREACH:
return DBUS_ERROR_NO_NETWORK;
#endif
+#ifdef WSAENETUNREACH
+ case WSAENETUNREACH:
+ return DBUS_ERROR_NO_NETWORK;
+#endif
#ifdef EADDRINUSE
case EADDRINUSE:
return DBUS_ERROR_ADDRESS_IN_USE;
#endif
+#ifdef WSAEADDRINUSE
+ case WSAEADDRINUSE:
+ return DBUS_ERROR_ADDRESS_IN_USE;
+#endif
#ifdef EEXIST
case EEXIST:
return DBUS_ERROR_FILE_EXISTS;