cpu: privatize vlc_CPU_init()
[vlc.git] / src / win32 / error.c
blobdd14dfa8c4945ecd767fd8a6aadd09b9ad95b5d4
1 /*****************************************************************************
2 * error.c: DOS and Winsock error messages formatting
3 *****************************************************************************
4 * Copyright © 2006-2013 Rémi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <stdlib.h>
26 #include <errno.h>
27 #include <winerror.h>
29 #include <vlc_common.h>
31 #ifndef WSA_QOS_EUNKNOWNPSOBJ
32 # define WSA_QOS_EUNKNOWNPSOBJ 11024L
33 #endif
35 typedef struct
37 int code;
38 const char *msg;
39 } wsaerrmsg_t;
41 static const wsaerrmsg_t wsaerrmsg[] =
43 { WSAEINTR, "Interrupted function call" },
44 { WSAEBADF, "File handle is not valid" },
45 { WSAEACCES, "Access denied" },
46 { WSAEFAULT, "Invalid memory address" },
47 { WSAEINVAL, "Invalid argument" },
48 { WSAEMFILE, "Too many open sockets" },
49 { WSAEWOULDBLOCK, "Resource temporarily unavailable" },
50 { WSAEINPROGRESS, "Operation now in progress" },
51 { WSAEALREADY, "Operation already in progress" },
52 { WSAENOTSOCK, "Non-socket handle specified" },
53 { WSAEDESTADDRREQ, "Missing destination address" },
54 { WSAEMSGSIZE, "Message too long" },
55 { WSAEPROTOTYPE, "Protocol wrong type for socket", },
56 { WSAENOPROTOOPT, "Option not supported by protocol" },
57 { WSAEPROTONOSUPPORT, "Protocol not supported" },
58 { WSAESOCKTNOSUPPORT, "Socket type not supported" },
59 { WSAEOPNOTSUPP, "Operation not supported" },
60 { WSAEPFNOSUPPORT, "Protocol family not supported" },
61 { WSAEAFNOSUPPORT, "Address family not supported by protocol family" },
62 { WSAEADDRINUSE, "Address already in use" },
63 { WSAEADDRNOTAVAIL, "Cannot assign requested address" },
64 { WSAENETDOWN, "Network is down" },
65 { WSAENETUNREACH, "Network unreachable" },
66 { WSAENETRESET, "Network dropped connection on reset" },
67 { WSAECONNABORTED, "Software caused connection abort" },
68 { WSAECONNRESET, "Connection reset by peer" },
69 { WSAENOBUFS, "No buffer space available (not enough memory)" },
70 { WSAEISCONN, "Socket is already connected" },
71 { WSAENOTCONN, "Socket is not connected" },
72 { WSAESHUTDOWN, "Cannot send after socket shutdown" },
73 { WSAETOOMANYREFS, "Too many references" },
74 { WSAETIMEDOUT, "Connection timed out" },
75 { WSAECONNREFUSED, "Connection refused by peer" },
76 { WSAELOOP, "Cannot translate name" },
77 { WSAENAMETOOLONG, "Name too long" },
78 { WSAEHOSTDOWN, "Remote host is down" },
79 { WSAEHOSTUNREACH, "No route to host (unreachable)" },
80 { WSAENOTEMPTY, "Directory not empty" },
81 { WSAEPROCLIM, "Too many processes" },
82 { WSAEUSERS, "User quota exceeded" },
83 { WSAEDQUOT, "Disk quota exceeded" },
84 { WSAESTALE, "Stale file handle reference" },
85 { WSAEREMOTE, "Item is remote", },
86 { WSASYSNOTREADY, "Network subsystem is unavailable (network stack not ready)" },
87 { WSAVERNOTSUPPORTED, "Winsock.dll version out of range (network stack version not supported" },
88 { WSANOTINITIALISED, "Network not initialized" },
89 { WSAEDISCON, "Graceful shutdown in progress" },
90 { WSAENOMORE, "No more results" },
91 { WSAECANCELLED, "Call has been cancelled" },
92 { WSAEINVALIDPROCTABLE, "Procedure call table is invalid" },
93 { WSAEINVALIDPROVIDER, "Service provider is invalid" },
94 { WSAEPROVIDERFAILEDINIT, "Service provider failed to initialize" },
95 { WSASYSCALLFAILURE, "System call failure" },
96 { WSASERVICE_NOT_FOUND, "Service not found" },
97 { WSATYPE_NOT_FOUND, "Class type not found" },
98 { WSA_E_NO_MORE, "No more results" },
99 { WSA_E_CANCELLED, "Call was cancelled" },
100 { WSAEREFUSED, "Database query was refused" },
101 { WSAHOST_NOT_FOUND, "Host not found" },
102 { WSATRY_AGAIN, "Nonauthoritative host not found (temporary hostname error)" },
103 { WSANO_RECOVERY, "Non-recoverable hostname error" },
104 { WSANO_DATA, "Valid name, no data record of requested type" },
105 { WSA_QOS_RECEIVERS, "QOS receivers" },
106 { WSA_QOS_SENDERS, "QOS senders" },
107 { WSA_QOS_NO_SENDERS, "No QOS senders" },
108 { WSA_QOS_NO_RECEIVERS, "QOS no receivers" },
109 { WSA_QOS_REQUEST_CONFIRMED, "QOS request confirmed" },
110 { WSA_QOS_ADMISSION_FAILURE, "QOS admission error" },
111 { WSA_QOS_POLICY_FAILURE, "QOS policy failure" },
112 { WSA_QOS_BAD_STYLE, "QOS bad style" },
113 { WSA_QOS_BAD_OBJECT, "QOS bad object" },
114 { WSA_QOS_TRAFFIC_CTRL_ERROR, "QOS traffic control error" },
115 { WSA_QOS_GENERIC_ERROR, "QOS generic error" },
116 { WSA_QOS_ESERVICETYPE, "QOS service type error" },
117 { WSA_QOS_EFLOWSPEC, "QOS flowspec error" },
118 { WSA_QOS_EPROVSPECBUF, "Invalid QOS provider buffer" },
119 { WSA_QOS_EFILTERSTYLE, "Invalid QOS filter style" },
120 { WSA_QOS_EFILTERTYPE, "Invalid QOS filter type" },
121 { WSA_QOS_EFILTERCOUNT, "Incorrect QOS filter count" },
122 { WSA_QOS_EOBJLENGTH, "Invalid QOS object length" },
123 { WSA_QOS_EFLOWCOUNT, "Incorrect QOS flow count" },
124 { WSA_QOS_EUNKNOWNPSOBJ, "Unrecognized QOS object" },
125 { WSA_QOS_EPOLICYOBJ, "Invalid QOS policy object" },
126 { WSA_QOS_EFLOWDESC, "Invalid QOS flow descriptor" },
127 { WSA_QOS_EPSFLOWSPEC, "Invalid QOS provider-specific flowspec" },
128 { WSA_QOS_EPSFILTERSPEC, "Invalid QOS provider-specific filterspec" },
129 { WSA_QOS_ESDMODEOBJ, "Invalid QOS shape discard mode object" },
130 { WSA_QOS_ESHAPERATEOBJ, "Invalid QOS shaping rate object" },
131 { WSA_QOS_RESERVED_PETYPE, "Reserved policy QOS element type" },
132 { 0, NULL }
133 /* Winsock2 error codes are missing, they "never" occur */
136 const char *vlc_strerror_c(int errnum)
138 /* C run-time errors */
139 if ((unsigned)errnum < (unsigned)_sys_nerr)
140 return _sys_errlist[errnum];
142 /* Windows socket errors */
143 for (const wsaerrmsg_t *e = wsaerrmsg; e->msg != NULL; e++)
144 if (e->code == errnum)
145 return e->msg;
147 return "Unknown error";
150 const char *vlc_strerror(int errnum)
152 return /*vlc_gettext*/(vlc_strerror_c(errnum));