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