security/nss/lib/ssl/os2_err.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/ssl/os2_err.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,280 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/*
     1.6 + * This file essentially replicates NSPR's source for the functions that
     1.7 + * map system-specific error codes to NSPR error codes.  We would use 
     1.8 + * NSPR's functions, instead of duplicating them, but they're private.
     1.9 + * As long as SSL's server session cache code must do platform native I/O
    1.10 + * to accomplish its job, and NSPR's error mapping functions remain private,
    1.11 + * this code will continue to need to be replicated.
    1.12 + * 
    1.13 + * This Source Code Form is subject to the terms of the Mozilla Public
    1.14 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    1.15 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.16 +
    1.17 +#include "prerror.h"
    1.18 +#include "prlog.h"
    1.19 +#include <errno.h>
    1.20 +
    1.21 +
    1.22 +/*
    1.23 + * Based on win32err.c
    1.24 + * OS2TODO Stub everything for now to build. HCT
    1.25 + */
    1.26 +
    1.27 +/* forward declaration. */
    1.28 +void nss_MD_os2_map_default_error(PRInt32 err);
    1.29 +
    1.30 +void nss_MD_os2_map_opendir_error(PRInt32 err)
    1.31 +{
    1.32 +    nss_MD_os2_map_default_error(err);
    1.33 +}
    1.34 +
    1.35 +void nss_MD_os2_map_closedir_error(PRInt32 err)
    1.36 +{
    1.37 +    nss_MD_os2_map_default_error(err);
    1.38 +}
    1.39 +
    1.40 +void nss_MD_os2_map_readdir_error(PRInt32 err)
    1.41 +{
    1.42 +    nss_MD_os2_map_default_error(err);
    1.43 +}
    1.44 +
    1.45 +void nss_MD_os2_map_delete_error(PRInt32 err)
    1.46 +{
    1.47 +    nss_MD_os2_map_default_error(err);
    1.48 +}
    1.49 +
    1.50 +/* The error code for stat() is in errno. */
    1.51 +void nss_MD_os2_map_stat_error(PRInt32 err)
    1.52 +{
    1.53 +    nss_MD_os2_map_default_error(err);
    1.54 +}
    1.55 +
    1.56 +void nss_MD_os2_map_fstat_error(PRInt32 err)
    1.57 +{
    1.58 +    nss_MD_os2_map_default_error(err);
    1.59 +}
    1.60 +
    1.61 +void nss_MD_os2_map_rename_error(PRInt32 err)
    1.62 +{
    1.63 +    nss_MD_os2_map_default_error(err);
    1.64 +}
    1.65 +
    1.66 +/* The error code for access() is in errno. */
    1.67 +void nss_MD_os2_map_access_error(PRInt32 err)
    1.68 +{
    1.69 +    nss_MD_os2_map_default_error(err);
    1.70 +}
    1.71 +
    1.72 +void nss_MD_os2_map_mkdir_error(PRInt32 err)
    1.73 +{
    1.74 +    nss_MD_os2_map_default_error(err);
    1.75 +}
    1.76 +
    1.77 +void nss_MD_os2_map_rmdir_error(PRInt32 err)
    1.78 +{
    1.79 +    nss_MD_os2_map_default_error(err);
    1.80 +}
    1.81 +
    1.82 +void nss_MD_os2_map_read_error(PRInt32 err)
    1.83 +{
    1.84 +    nss_MD_os2_map_default_error(err);
    1.85 +}
    1.86 +
    1.87 +void nss_MD_os2_map_transmitfile_error(PRInt32 err)
    1.88 +{
    1.89 +    nss_MD_os2_map_default_error(err);
    1.90 +}
    1.91 +
    1.92 +void nss_MD_os2_map_write_error(PRInt32 err)
    1.93 +{
    1.94 +    nss_MD_os2_map_default_error(err);
    1.95 +}
    1.96 +
    1.97 +void nss_MD_os2_map_lseek_error(PRInt32 err)
    1.98 +{
    1.99 +    nss_MD_os2_map_default_error(err);
   1.100 +}
   1.101 +
   1.102 +void nss_MD_os2_map_fsync_error(PRInt32 err)
   1.103 +{
   1.104 +    nss_MD_os2_map_default_error(err);
   1.105 +}
   1.106 +
   1.107 +/*
   1.108 + * For both CloseHandle() and closesocket().
   1.109 + */
   1.110 +void nss_MD_os2_map_close_error(PRInt32 err)
   1.111 +{
   1.112 +    nss_MD_os2_map_default_error(err);
   1.113 +}
   1.114 +
   1.115 +void nss_MD_os2_map_socket_error(PRInt32 err)
   1.116 +{
   1.117 +//  PR_ASSERT(err != WSANOTINITIALISED);
   1.118 +    nss_MD_os2_map_default_error(err);
   1.119 +}
   1.120 +
   1.121 +void nss_MD_os2_map_recv_error(PRInt32 err)
   1.122 +{
   1.123 +    nss_MD_os2_map_default_error(err);
   1.124 +}
   1.125 +
   1.126 +void nss_MD_os2_map_recvfrom_error(PRInt32 err)
   1.127 +{
   1.128 +    nss_MD_os2_map_default_error(err);
   1.129 +}
   1.130 +
   1.131 +void nss_MD_os2_map_send_error(PRInt32 err)
   1.132 +{
   1.133 +    PRErrorCode prError;
   1.134 +    switch (err) {
   1.135 +//     case WSAEMSGSIZE: 	prError = PR_INVALID_ARGUMENT_ERROR; break;
   1.136 +    default:		nss_MD_os2_map_default_error(err); return;
   1.137 +    }
   1.138 +    PR_SetError(prError, err);
   1.139 +}
   1.140 +
   1.141 +void nss_MD_os2_map_sendto_error(PRInt32 err)
   1.142 +{
   1.143 +    PRErrorCode prError;
   1.144 +    switch (err) {
   1.145 +//    case WSAEMSGSIZE: 	prError = PR_INVALID_ARGUMENT_ERROR; break;
   1.146 +    default:		nss_MD_os2_map_default_error(err); return;
   1.147 +    }
   1.148 +    PR_SetError(prError, err);
   1.149 +}
   1.150 +
   1.151 +void nss_MD_os2_map_accept_error(PRInt32 err)
   1.152 +{
   1.153 +    PRErrorCode prError;
   1.154 +    switch (err) {
   1.155 +//    case WSAEOPNOTSUPP: prError = PR_NOT_TCP_SOCKET_ERROR; break;
   1.156 +//    case WSAEINVAL: 	prError = PR_INVALID_STATE_ERROR; break;
   1.157 +    default:		nss_MD_os2_map_default_error(err); return;
   1.158 +    }
   1.159 +    PR_SetError(prError, err);
   1.160 +}
   1.161 +
   1.162 +void nss_MD_os2_map_acceptex_error(PRInt32 err)
   1.163 +{
   1.164 +    nss_MD_os2_map_default_error(err);
   1.165 +}
   1.166 +
   1.167 +void nss_MD_os2_map_connect_error(PRInt32 err)
   1.168 +{
   1.169 +    PRErrorCode prError;
   1.170 +    switch (err) {
   1.171 +//    case WSAEWOULDBLOCK: prError = PR_IN_PROGRESS_ERROR; break;
   1.172 +//    case WSAEINVAL: 	prError = PR_ALREADY_INITIATED_ERROR; break;
   1.173 +//    case WSAETIMEDOUT: 	prError = PR_IO_TIMEOUT_ERROR; break;
   1.174 +    default:		nss_MD_os2_map_default_error(err); return;
   1.175 +    }
   1.176 +    PR_SetError(prError, err);
   1.177 +}
   1.178 +
   1.179 +void nss_MD_os2_map_bind_error(PRInt32 err)
   1.180 +{
   1.181 +    PRErrorCode prError;
   1.182 +    switch (err) {
   1.183 +//  case WSAEINVAL: 	prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR; break;
   1.184 +    default:		nss_MD_os2_map_default_error(err); return;
   1.185 +    }
   1.186 +    PR_SetError(prError, err);
   1.187 +}
   1.188 +
   1.189 +void nss_MD_os2_map_listen_error(PRInt32 err)
   1.190 +{
   1.191 +    PRErrorCode prError;
   1.192 +    switch (err) {
   1.193 +//    case WSAEOPNOTSUPP: prError = PR_NOT_TCP_SOCKET_ERROR; break;
   1.194 +//    case WSAEINVAL: 	prError = PR_INVALID_STATE_ERROR; break;
   1.195 +    default:		nss_MD_os2_map_default_error(err); return;
   1.196 +    }
   1.197 +    PR_SetError(prError, err);
   1.198 +}
   1.199 +
   1.200 +void nss_MD_os2_map_shutdown_error(PRInt32 err)
   1.201 +{
   1.202 +    nss_MD_os2_map_default_error(err);
   1.203 +}
   1.204 +
   1.205 +void nss_MD_os2_map_getsockname_error(PRInt32 err)
   1.206 +{
   1.207 +    PRErrorCode prError;
   1.208 +    switch (err) {
   1.209 +//    case WSAEINVAL: 	prError = PR_INVALID_STATE_ERROR; break;
   1.210 +    default:		nss_MD_os2_map_default_error(err); return;
   1.211 +    }
   1.212 +    PR_SetError(prError, err);
   1.213 +}
   1.214 +
   1.215 +void nss_MD_os2_map_getpeername_error(PRInt32 err)
   1.216 +{
   1.217 +    nss_MD_os2_map_default_error(err);
   1.218 +}
   1.219 +
   1.220 +void nss_MD_os2_map_getsockopt_error(PRInt32 err)
   1.221 +{
   1.222 +    nss_MD_os2_map_default_error(err);
   1.223 +}
   1.224 +
   1.225 +void nss_MD_os2_map_setsockopt_error(PRInt32 err)
   1.226 +{
   1.227 +    nss_MD_os2_map_default_error(err);
   1.228 +}
   1.229 +
   1.230 +void nss_MD_os2_map_open_error(PRInt32 err)
   1.231 +{
   1.232 +    nss_MD_os2_map_default_error(err);
   1.233 +}
   1.234 +
   1.235 +void nss_MD_os2_map_gethostname_error(PRInt32 err)
   1.236 +{
   1.237 +    nss_MD_os2_map_default_error(err);
   1.238 +}
   1.239 +
   1.240 +/* Win32 select() only works on sockets.  So in this
   1.241 +** context, WSAENOTSOCK is equivalent to EBADF on Unix.  
   1.242 +*/
   1.243 +void nss_MD_os2_map_select_error(PRInt32 err)
   1.244 +{
   1.245 +    PRErrorCode prError;
   1.246 +    switch (err) {
   1.247 +//    case WSAENOTSOCK:	prError = PR_BAD_DESCRIPTOR_ERROR; break;
   1.248 +    default:		nss_MD_os2_map_default_error(err); return;
   1.249 +    }
   1.250 +    PR_SetError(prError, err);
   1.251 +}
   1.252 +
   1.253 +void nss_MD_os2_map_lockf_error(PRInt32 err)
   1.254 +{
   1.255 +    nss_MD_os2_map_default_error(err);
   1.256 +}
   1.257 +
   1.258 +
   1.259 +
   1.260 +void nss_MD_os2_map_default_error(PRInt32 err)
   1.261 +{
   1.262 +    PRErrorCode prError;
   1.263 +
   1.264 +    switch (err) {
   1.265 +//    case ENOENT: 		prError = PR_FILE_NOT_FOUND_ERROR; break;
   1.266 +//    case ERROR_ACCESS_DENIED: 	prError = PR_NO_ACCESS_RIGHTS_ERROR; break;
   1.267 +//    case ERROR_ALREADY_EXISTS: 	prError = PR_FILE_EXISTS_ERROR; break;
   1.268 +//    case ERROR_DISK_CORRUPT: 	prError = PR_IO_ERROR; break;
   1.269 +//    case ERROR_DISK_FULL: 	prError = PR_NO_DEVICE_SPACE_ERROR; break;
   1.270 +//    case ERROR_DISK_OPERATION_FAILED: prError = PR_IO_ERROR; break;
   1.271 +//    case ERROR_DRIVE_LOCKED: 	prError = PR_FILE_IS_LOCKED_ERROR; break;
   1.272 +//    case ERROR_FILENAME_EXCED_RANGE: prError = PR_NAME_TOO_LONG_ERROR; break;
   1.273 +//    case ERROR_FILE_CORRUPT: 	prError = PR_IO_ERROR; break;
   1.274 +//    case ERROR_FILE_EXISTS: 	prError = PR_FILE_EXISTS_ERROR; break;
   1.275 +//    case ERROR_FILE_INVALID: 	prError = PR_BAD_DESCRIPTOR_ERROR; break;
   1.276 +#if ERROR_FILE_NOT_FOUND != ENOENT
   1.277 +//    case ERROR_FILE_NOT_FOUND: 	prError = PR_FILE_NOT_FOUND_ERROR; break;
   1.278 +#endif
   1.279 +    default: 			prError = PR_UNKNOWN_ERROR; break;
   1.280 +    }
   1.281 +    PR_SetError(prError, err);
   1.282 +}
   1.283 +

mercurial