X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgioerror.c;h=0faff254d35b312a41b47b1059bce79424acdfed;hb=356a3987cee7ceddcb3fe623edf0bd2881895add;hp=cce1dfecf845c9b6d4092f5c4bf7ac593a600542;hpb=9fc35dbfb6b804c0ead5dd3dba1bbf14773a2f8f;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gioerror.c b/gio/gioerror.c index cce1dfe..0faff25 100644 --- a/gio/gioerror.c +++ b/gio/gioerror.c @@ -22,6 +22,9 @@ #include #include "gioerror.h" +#ifdef G_OS_WIN32 +#include +#endif /** * SECTION:gioerror @@ -239,6 +242,18 @@ g_io_error_from_errno (gint err_no) break; #endif +#ifdef ECONNRESET + case ECONNRESET: + return G_IO_ERROR_CONNECTION_CLOSED; + break; +#endif + +#ifdef ENOTCONN + case ENOTCONN: + return G_IO_ERROR_NOT_CONNECTED; + break; +#endif + default: return G_IO_ERROR_FAILED; break; @@ -251,11 +266,16 @@ g_io_error_from_errno (gint err_no) * g_io_error_from_win32_error: * @error_code: Windows error number. * - * Converts some common error codes into GIO error codes. The fallback - * value %G_IO_ERROR_FAILED is returned for error codes not currently + * Converts some common error codes (as returned from GetLastError() + * or WSAGetLastError()) into GIO error codes. The fallback value + * %G_IO_ERROR_FAILED is returned for error codes not currently * handled (but note that future GLib releases may return a more * specific value instead). * + * You can use g_win32_error_message() to get a localized string + * corresponding to @error_code. (But note that unlike g_strerror(), + * g_win32_error_message() returns a string that must be freed.) + * * Returns: #GIOErrorEnum value for the given error number. * * Since: 2.26 @@ -263,11 +283,48 @@ g_io_error_from_errno (gint err_no) GIOErrorEnum g_io_error_from_win32_error (gint error_code) { + /* Note: Winsock errors are a subset of Win32 error codes as a + * whole. (The fact that the Winsock API makes them look like they + * aren't is just because the API predates Win32.) + */ + switch (error_code) { + case WSAEADDRINUSE: + return G_IO_ERROR_ADDRESS_IN_USE; + + case WSAEWOULDBLOCK: + return G_IO_ERROR_WOULD_BLOCK; + + case WSAEACCES: + return G_IO_ERROR_PERMISSION_DENIED; + + case WSA_INVALID_HANDLE: + case WSA_INVALID_PARAMETER: + case WSAEBADF: + case WSAENOTSOCK: + return G_IO_ERROR_INVALID_ARGUMENT; + + case WSAEPROTONOSUPPORT: + return G_IO_ERROR_NOT_SUPPORTED; + + case WSAECANCELLED: + return G_IO_ERROR_CANCELLED; + + case WSAESOCKTNOSUPPORT: + case WSAEOPNOTSUPP: + case WSAEPFNOSUPPORT: + case WSAEAFNOSUPPORT: + return G_IO_ERROR_NOT_SUPPORTED; + + case WSAECONNRESET: + return G_IO_ERROR_CONNECTION_CLOSED; + + case ERROR_PIPE_LISTENING: + return G_IO_ERROR_NOT_CONNECTED; + default: return G_IO_ERROR_FAILED; - break; } }