Some libdbus functions have as their API "this function sets errno",
but that just leads to strangeness on Windows, where socket (Winsock)
functions don't actually set errno themselves, leading to those
functions having to copy the Winsock error into errno to fake the
Unix-like behaviour. With hindsight, that was probably a bad idea.
This function should be portable enough to be used with functions that
are essentially the same on Unix and Windows, like inet_ntop().
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
}
}
+/*
+ * Return the low-level representation of a socket error, as used by
+ * cross-platform socket APIs like inet_ntop(), send() and recv(). This
+ * is the standard errno on Unix, but is WSAGetLastError() on Windows.
+ *
+ * Some libdbus internal functions copy this into errno, but with
+ * hindsight that was probably a design flaw.
+ */
+int
+_dbus_get_low_level_socket_errno (void)
+{
+ return errno;
+}
+
/* tests in dbus-sysdeps-util.c */
}
}
+/*
+ * Return the low-level representation of a socket error, as used by
+ * cross-platform socket APIs like inet_ntop(), send() and recv(). This
+ * is the standard errno on Unix, but is WSAGetLastError() on Windows.
+ *
+ * Some libdbus internal functions copy this into errno, but with
+ * hindsight that was probably a design flaw.
+ */
+int
+_dbus_get_low_level_socket_errno (void)
+{
+ return WSAGetLastError ();
+}
+
/** @} end of sysdeps-win */
/* tests in dbus-sysdeps-util.c */
DBUS_PRIVATE_EXPORT
const char* _dbus_error_from_system_errno (void);
+int _dbus_get_low_level_socket_errno (void);
+
int _dbus_save_socket_errno (void);
void _dbus_restore_socket_errno (int saved_errno);
void _dbus_set_errno_to_zero (void);