| OLD | NEW |
| (Empty) |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
| 2 /* | |
| 3 * This file essentially replicates NSPR's source for the functions that | |
| 4 * map system-specific error codes to NSPR error codes. We would use | |
| 5 * NSPR's functions, instead of duplicating them, but they're private. | |
| 6 * As long as SSL's server session cache code must do platform native I/O | |
| 7 * to accomplish its job, and NSPR's error mapping functions remain private, | |
| 8 * this code will continue to need to be replicated. | |
| 9 * | |
| 10 * This Source Code Form is subject to the terms of the Mozilla Public | |
| 11 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
| 12 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 13 | |
| 14 #include "prerror.h" | |
| 15 #include "prlog.h" | |
| 16 #include <errno.h> | |
| 17 | |
| 18 /* | |
| 19 * Based on win32err.c | |
| 20 * OS2TODO Stub everything for now to build. HCT | |
| 21 */ | |
| 22 | |
| 23 /* forward declaration. */ | |
| 24 void nss_MD_os2_map_default_error(PRInt32 err); | |
| 25 | |
| 26 void | |
| 27 nss_MD_os2_map_opendir_error(PRInt32 err) | |
| 28 { | |
| 29 nss_MD_os2_map_default_error(err); | |
| 30 } | |
| 31 | |
| 32 void | |
| 33 nss_MD_os2_map_closedir_error(PRInt32 err) | |
| 34 { | |
| 35 nss_MD_os2_map_default_error(err); | |
| 36 } | |
| 37 | |
| 38 void | |
| 39 nss_MD_os2_map_readdir_error(PRInt32 err) | |
| 40 { | |
| 41 nss_MD_os2_map_default_error(err); | |
| 42 } | |
| 43 | |
| 44 void | |
| 45 nss_MD_os2_map_delete_error(PRInt32 err) | |
| 46 { | |
| 47 nss_MD_os2_map_default_error(err); | |
| 48 } | |
| 49 | |
| 50 /* The error code for stat() is in errno. */ | |
| 51 void | |
| 52 nss_MD_os2_map_stat_error(PRInt32 err) | |
| 53 { | |
| 54 nss_MD_os2_map_default_error(err); | |
| 55 } | |
| 56 | |
| 57 void | |
| 58 nss_MD_os2_map_fstat_error(PRInt32 err) | |
| 59 { | |
| 60 nss_MD_os2_map_default_error(err); | |
| 61 } | |
| 62 | |
| 63 void | |
| 64 nss_MD_os2_map_rename_error(PRInt32 err) | |
| 65 { | |
| 66 nss_MD_os2_map_default_error(err); | |
| 67 } | |
| 68 | |
| 69 /* The error code for access() is in errno. */ | |
| 70 void | |
| 71 nss_MD_os2_map_access_error(PRInt32 err) | |
| 72 { | |
| 73 nss_MD_os2_map_default_error(err); | |
| 74 } | |
| 75 | |
| 76 void | |
| 77 nss_MD_os2_map_mkdir_error(PRInt32 err) | |
| 78 { | |
| 79 nss_MD_os2_map_default_error(err); | |
| 80 } | |
| 81 | |
| 82 void | |
| 83 nss_MD_os2_map_rmdir_error(PRInt32 err) | |
| 84 { | |
| 85 nss_MD_os2_map_default_error(err); | |
| 86 } | |
| 87 | |
| 88 void | |
| 89 nss_MD_os2_map_read_error(PRInt32 err) | |
| 90 { | |
| 91 nss_MD_os2_map_default_error(err); | |
| 92 } | |
| 93 | |
| 94 void | |
| 95 nss_MD_os2_map_transmitfile_error(PRInt32 err) | |
| 96 { | |
| 97 nss_MD_os2_map_default_error(err); | |
| 98 } | |
| 99 | |
| 100 void | |
| 101 nss_MD_os2_map_write_error(PRInt32 err) | |
| 102 { | |
| 103 nss_MD_os2_map_default_error(err); | |
| 104 } | |
| 105 | |
| 106 void | |
| 107 nss_MD_os2_map_lseek_error(PRInt32 err) | |
| 108 { | |
| 109 nss_MD_os2_map_default_error(err); | |
| 110 } | |
| 111 | |
| 112 void | |
| 113 nss_MD_os2_map_fsync_error(PRInt32 err) | |
| 114 { | |
| 115 nss_MD_os2_map_default_error(err); | |
| 116 } | |
| 117 | |
| 118 /* | |
| 119 * For both CloseHandle() and closesocket(). | |
| 120 */ | |
| 121 void | |
| 122 nss_MD_os2_map_close_error(PRInt32 err) | |
| 123 { | |
| 124 nss_MD_os2_map_default_error(err); | |
| 125 } | |
| 126 | |
| 127 void | |
| 128 nss_MD_os2_map_socket_error(PRInt32 err) | |
| 129 { | |
| 130 // PR_ASSERT(err != WSANOTINITIALISED); | |
| 131 nss_MD_os2_map_default_error(err); | |
| 132 } | |
| 133 | |
| 134 void | |
| 135 nss_MD_os2_map_recv_error(PRInt32 err) | |
| 136 { | |
| 137 nss_MD_os2_map_default_error(err); | |
| 138 } | |
| 139 | |
| 140 void | |
| 141 nss_MD_os2_map_recvfrom_error(PRInt32 err) | |
| 142 { | |
| 143 nss_MD_os2_map_default_error(err); | |
| 144 } | |
| 145 | |
| 146 void | |
| 147 nss_MD_os2_map_send_error(PRInt32 err) | |
| 148 { | |
| 149 PRErrorCode prError; | |
| 150 switch (err) { | |
| 151 // case WSAEMSGSIZE: prError = PR_INVALID_ARGUMENT_ERROR; break; | |
| 152 default: | |
| 153 nss_MD_os2_map_default_error(err); | |
| 154 return; | |
| 155 } | |
| 156 PR_SetError(prError, err); | |
| 157 } | |
| 158 | |
| 159 void | |
| 160 nss_MD_os2_map_sendto_error(PRInt32 err) | |
| 161 { | |
| 162 PRErrorCode prError; | |
| 163 switch (err) { | |
| 164 // case WSAEMSGSIZE: prError = PR_INVALID_ARGUMENT_ERROR; break; | |
| 165 default: | |
| 166 nss_MD_os2_map_default_error(err); | |
| 167 return; | |
| 168 } | |
| 169 PR_SetError(prError, err); | |
| 170 } | |
| 171 | |
| 172 void | |
| 173 nss_MD_os2_map_accept_error(PRInt32 err) | |
| 174 { | |
| 175 PRErrorCode prError; | |
| 176 switch (err) { | |
| 177 // case WSAEOPNOTSUPP: prError = PR_NOT_TCP_SOCKET_ERROR; break; | |
| 178 // case WSAEINVAL: prError = PR_INVALID_STATE_ERROR; break; | |
| 179 default: | |
| 180 nss_MD_os2_map_default_error(err); | |
| 181 return; | |
| 182 } | |
| 183 PR_SetError(prError, err); | |
| 184 } | |
| 185 | |
| 186 void | |
| 187 nss_MD_os2_map_acceptex_error(PRInt32 err) | |
| 188 { | |
| 189 nss_MD_os2_map_default_error(err); | |
| 190 } | |
| 191 | |
| 192 void | |
| 193 nss_MD_os2_map_connect_error(PRInt32 err) | |
| 194 { | |
| 195 PRErrorCode prError; | |
| 196 switch (err) { | |
| 197 // case WSAEWOULDBLOCK: prError = PR_IN_PROGRESS_ERROR; break; | |
| 198 // case WSAEINVAL: prError = PR_ALREADY_INITIATED_ERROR; break; | |
| 199 // case WSAETIMEDOUT: prError = PR_IO_TIMEOUT_ERROR; break; | |
| 200 default: | |
| 201 nss_MD_os2_map_default_error(err); | |
| 202 return; | |
| 203 } | |
| 204 PR_SetError(prError, err); | |
| 205 } | |
| 206 | |
| 207 void | |
| 208 nss_MD_os2_map_bind_error(PRInt32 err) | |
| 209 { | |
| 210 PRErrorCode prError; | |
| 211 switch (err) { | |
| 212 // case WSAEINVAL: prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR; brea
k; | |
| 213 default: | |
| 214 nss_MD_os2_map_default_error(err); | |
| 215 return; | |
| 216 } | |
| 217 PR_SetError(prError, err); | |
| 218 } | |
| 219 | |
| 220 void | |
| 221 nss_MD_os2_map_listen_error(PRInt32 err) | |
| 222 { | |
| 223 PRErrorCode prError; | |
| 224 switch (err) { | |
| 225 // case WSAEOPNOTSUPP: prError = PR_NOT_TCP_SOCKET_ERROR; break; | |
| 226 // case WSAEINVAL: prError = PR_INVALID_STATE_ERROR; break; | |
| 227 default: | |
| 228 nss_MD_os2_map_default_error(err); | |
| 229 return; | |
| 230 } | |
| 231 PR_SetError(prError, err); | |
| 232 } | |
| 233 | |
| 234 void | |
| 235 nss_MD_os2_map_shutdown_error(PRInt32 err) | |
| 236 { | |
| 237 nss_MD_os2_map_default_error(err); | |
| 238 } | |
| 239 | |
| 240 void | |
| 241 nss_MD_os2_map_getsockname_error(PRInt32 err) | |
| 242 { | |
| 243 PRErrorCode prError; | |
| 244 switch (err) { | |
| 245 // case WSAEINVAL: prError = PR_INVALID_STATE_ERROR; break; | |
| 246 default: | |
| 247 nss_MD_os2_map_default_error(err); | |
| 248 return; | |
| 249 } | |
| 250 PR_SetError(prError, err); | |
| 251 } | |
| 252 | |
| 253 void | |
| 254 nss_MD_os2_map_getpeername_error(PRInt32 err) | |
| 255 { | |
| 256 nss_MD_os2_map_default_error(err); | |
| 257 } | |
| 258 | |
| 259 void | |
| 260 nss_MD_os2_map_getsockopt_error(PRInt32 err) | |
| 261 { | |
| 262 nss_MD_os2_map_default_error(err); | |
| 263 } | |
| 264 | |
| 265 void | |
| 266 nss_MD_os2_map_setsockopt_error(PRInt32 err) | |
| 267 { | |
| 268 nss_MD_os2_map_default_error(err); | |
| 269 } | |
| 270 | |
| 271 void | |
| 272 nss_MD_os2_map_open_error(PRInt32 err) | |
| 273 { | |
| 274 nss_MD_os2_map_default_error(err); | |
| 275 } | |
| 276 | |
| 277 void | |
| 278 nss_MD_os2_map_gethostname_error(PRInt32 err) | |
| 279 { | |
| 280 nss_MD_os2_map_default_error(err); | |
| 281 } | |
| 282 | |
| 283 /* Win32 select() only works on sockets. So in this | |
| 284 ** context, WSAENOTSOCK is equivalent to EBADF on Unix. | |
| 285 */ | |
| 286 void | |
| 287 nss_MD_os2_map_select_error(PRInt32 err) | |
| 288 { | |
| 289 PRErrorCode prError; | |
| 290 switch (err) { | |
| 291 // case WSAENOTSOCK: prError = PR_BAD_DESCRIPTOR_ERROR; break; | |
| 292 default: | |
| 293 nss_MD_os2_map_default_error(err); | |
| 294 return; | |
| 295 } | |
| 296 PR_SetError(prError, err); | |
| 297 } | |
| 298 | |
| 299 void | |
| 300 nss_MD_os2_map_lockf_error(PRInt32 err) | |
| 301 { | |
| 302 nss_MD_os2_map_default_error(err); | |
| 303 } | |
| 304 | |
| 305 void | |
| 306 nss_MD_os2_map_default_error(PRInt32 err) | |
| 307 { | |
| 308 PRErrorCode prError; | |
| 309 | |
| 310 switch (err) { | |
| 311 // case ENOENT: prError = PR_FILE_NOT_FOUND_ERROR; break; | |
| 312 // case ERROR_ACCESS_DENIED: prError = PR_NO_ACCESS_RIGHTS_ERROR; break; | |
| 313 // case ERROR_ALREADY_EXISTS: prError = PR_FILE_EXISTS_ERROR; break; | |
| 314 // case ERROR_DISK_CORRUPT: prError = PR_IO_ERROR; break; | |
| 315 // case ERROR_DISK_FULL: prError = PR_NO_DEVICE_SPACE_ERROR; break; | |
| 316 // case ERROR_DISK_OPERATION_FAILED: prError = PR_IO_ERROR; break; | |
| 317 // case ERROR_DRIVE_LOCKED: prError = PR_FILE_IS_LOCKED_ERROR; break; | |
| 318 // case ERROR_FILENAME_EXCED_RANGE: prError = PR_NAME_TOO_LONG_ERROR; break; | |
| 319 // case ERROR_FILE_CORRUPT: prError = PR_IO_ERROR; break; | |
| 320 // case ERROR_FILE_EXISTS: prError = PR_FILE_EXISTS_ERROR; break; | |
| 321 // case ERROR_FILE_INVALID: prError = PR_BAD_DESCRIPTOR_ERROR; break; | |
| 322 #if ERROR_FILE_NOT_FOUND != ENOENT | |
| 323 // case ERROR_FILE_NOT_FOUND: prError = PR_FILE_NOT_FOUND_ERROR; break; | |
| 324 #endif | |
| 325 default: | |
| 326 prError = PR_UNKNOWN_ERROR; | |
| 327 break; | |
| 328 } | |
| 329 PR_SetError(prError, err); | |
| 330 } | |
| OLD | NEW |