Back to index

lightning-sunbird  0.9+nobinonly
os2_err.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file essentially replicates NSPR's source for the functions that
00004  * map system-specific error codes to NSPR error codes.  We would use 
00005  * NSPR's functions, instead of duplicating them, but they're private.
00006  * As long as SSL's server session cache code must do platform native I/O
00007  * to accomplish its job, and NSPR's error mapping functions remain private,
00008  * this code will continue to need to be replicated.
00009  * 
00010  * ***** BEGIN LICENSE BLOCK *****
00011  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00012  *
00013  * The contents of this file are subject to the Mozilla Public License Version
00014  * 1.1 (the "License"); you may not use this file except in compliance with
00015  * the License. You may obtain a copy of the License at
00016  * http://www.mozilla.org/MPL/
00017  *
00018  * Software distributed under the License is distributed on an "AS IS" basis,
00019  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00020  * for the specific language governing rights and limitations under the
00021  * License.
00022  *
00023  * The Original Code is the Netscape security libraries.
00024  *
00025  * The Initial Developer of the Original Code is
00026  * Netscape Communications Corporation.
00027  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00028  * the Initial Developer. All Rights Reserved.
00029  *
00030  * Contributor(s):
00031  *
00032  * Alternatively, the contents of this file may be used under the terms of
00033  * either the GNU General Public License Version 2 or later (the "GPL"), or
00034  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00035  * in which case the provisions of the GPL or the LGPL are applicable instead
00036  * of those above. If you wish to allow use of your version of this file only
00037  * under the terms of either the GPL or the LGPL, and not to allow others to
00038  * use your version of this file under the terms of the MPL, indicate your
00039  * decision by deleting the provisions above and replace them with the notice
00040  * and other provisions required by the GPL or the LGPL. If you do not delete
00041  * the provisions above, a recipient may use your version of this file under
00042  * the terms of any one of the MPL, the GPL or the LGPL.
00043  *
00044  * ***** END LICENSE BLOCK ***** */
00045 /* $Id: os2_err.c,v 1.4 2004/04/27 23:04:39 gerv%gerv.net Exp $ */
00046 
00047 #include "prerror.h"
00048 #include "prlog.h"
00049 #include <errno.h>
00050 
00051 
00052 /*
00053  * Based on win32err.c
00054  * OS2TODO Stub everything for now to build. HCT
00055  */
00056 
00057 /* forward declaration. */
00058 void nss_MD_os2_map_default_error(PRInt32 err);
00059 
00060 void nss_MD_os2_map_opendir_error(PRInt32 err)
00061 {
00062     nss_MD_os2_map_default_error(err);
00063 }
00064 
00065 void nss_MD_os2_map_closedir_error(PRInt32 err)
00066 {
00067     nss_MD_os2_map_default_error(err);
00068 }
00069 
00070 void nss_MD_os2_map_readdir_error(PRInt32 err)
00071 {
00072     nss_MD_os2_map_default_error(err);
00073 }
00074 
00075 void nss_MD_os2_map_delete_error(PRInt32 err)
00076 {
00077     nss_MD_os2_map_default_error(err);
00078 }
00079 
00080 /* The error code for stat() is in errno. */
00081 void nss_MD_os2_map_stat_error(PRInt32 err)
00082 {
00083     nss_MD_os2_map_default_error(err);
00084 }
00085 
00086 void nss_MD_os2_map_fstat_error(PRInt32 err)
00087 {
00088     nss_MD_os2_map_default_error(err);
00089 }
00090 
00091 void nss_MD_os2_map_rename_error(PRInt32 err)
00092 {
00093     nss_MD_os2_map_default_error(err);
00094 }
00095 
00096 /* The error code for access() is in errno. */
00097 void nss_MD_os2_map_access_error(PRInt32 err)
00098 {
00099     nss_MD_os2_map_default_error(err);
00100 }
00101 
00102 void nss_MD_os2_map_mkdir_error(PRInt32 err)
00103 {
00104     nss_MD_os2_map_default_error(err);
00105 }
00106 
00107 void nss_MD_os2_map_rmdir_error(PRInt32 err)
00108 {
00109     nss_MD_os2_map_default_error(err);
00110 }
00111 
00112 void nss_MD_os2_map_read_error(PRInt32 err)
00113 {
00114     nss_MD_os2_map_default_error(err);
00115 }
00116 
00117 void nss_MD_os2_map_transmitfile_error(PRInt32 err)
00118 {
00119     nss_MD_os2_map_default_error(err);
00120 }
00121 
00122 void nss_MD_os2_map_write_error(PRInt32 err)
00123 {
00124     nss_MD_os2_map_default_error(err);
00125 }
00126 
00127 void nss_MD_os2_map_lseek_error(PRInt32 err)
00128 {
00129     nss_MD_os2_map_default_error(err);
00130 }
00131 
00132 void nss_MD_os2_map_fsync_error(PRInt32 err)
00133 {
00134     nss_MD_os2_map_default_error(err);
00135 }
00136 
00137 /*
00138  * For both CloseHandle() and closesocket().
00139  */
00140 void nss_MD_os2_map_close_error(PRInt32 err)
00141 {
00142     nss_MD_os2_map_default_error(err);
00143 }
00144 
00145 void nss_MD_os2_map_socket_error(PRInt32 err)
00146 {
00147 //  PR_ASSERT(err != WSANOTINITIALISED);
00148     nss_MD_os2_map_default_error(err);
00149 }
00150 
00151 void nss_MD_os2_map_recv_error(PRInt32 err)
00152 {
00153     nss_MD_os2_map_default_error(err);
00154 }
00155 
00156 void nss_MD_os2_map_recvfrom_error(PRInt32 err)
00157 {
00158     nss_MD_os2_map_default_error(err);
00159 }
00160 
00161 void nss_MD_os2_map_send_error(PRInt32 err)
00162 {
00163     PRErrorCode prError;
00164     switch (err) {
00165 //     case WSAEMSGSIZE:    prError = PR_INVALID_ARGUMENT_ERROR; break;
00166     default:         nss_MD_os2_map_default_error(err); return;
00167     }
00168     PR_SetError(prError, err);
00169 }
00170 
00171 void nss_MD_os2_map_sendto_error(PRInt32 err)
00172 {
00173     PRErrorCode prError;
00174     switch (err) {
00175 //    case WSAEMSGSIZE:     prError = PR_INVALID_ARGUMENT_ERROR; break;
00176     default:         nss_MD_os2_map_default_error(err); return;
00177     }
00178     PR_SetError(prError, err);
00179 }
00180 
00181 void nss_MD_os2_map_accept_error(PRInt32 err)
00182 {
00183     PRErrorCode prError;
00184     switch (err) {
00185 //    case WSAEOPNOTSUPP: prError = PR_NOT_TCP_SOCKET_ERROR; break;
00186 //    case WSAEINVAL:       prError = PR_INVALID_STATE_ERROR; break;
00187     default:         nss_MD_os2_map_default_error(err); return;
00188     }
00189     PR_SetError(prError, err);
00190 }
00191 
00192 void nss_MD_os2_map_acceptex_error(PRInt32 err)
00193 {
00194     nss_MD_os2_map_default_error(err);
00195 }
00196 
00197 void nss_MD_os2_map_connect_error(PRInt32 err)
00198 {
00199     PRErrorCode prError;
00200     switch (err) {
00201 //    case WSAEWOULDBLOCK: prError = PR_IN_PROGRESS_ERROR; break;
00202 //    case WSAEINVAL:       prError = PR_ALREADY_INITIATED_ERROR; break;
00203 //    case WSAETIMEDOUT:    prError = PR_IO_TIMEOUT_ERROR; break;
00204     default:         nss_MD_os2_map_default_error(err); return;
00205     }
00206     PR_SetError(prError, err);
00207 }
00208 
00209 void nss_MD_os2_map_bind_error(PRInt32 err)
00210 {
00211     PRErrorCode prError;
00212     switch (err) {
00213 //  case WSAEINVAL:  prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR; break;
00214     default:         nss_MD_os2_map_default_error(err); return;
00215     }
00216     PR_SetError(prError, err);
00217 }
00218 
00219 void nss_MD_os2_map_listen_error(PRInt32 err)
00220 {
00221     PRErrorCode prError;
00222     switch (err) {
00223 //    case WSAEOPNOTSUPP: prError = PR_NOT_TCP_SOCKET_ERROR; break;
00224 //    case WSAEINVAL:       prError = PR_INVALID_STATE_ERROR; break;
00225     default:         nss_MD_os2_map_default_error(err); return;
00226     }
00227     PR_SetError(prError, err);
00228 }
00229 
00230 void nss_MD_os2_map_shutdown_error(PRInt32 err)
00231 {
00232     nss_MD_os2_map_default_error(err);
00233 }
00234 
00235 void nss_MD_os2_map_getsockname_error(PRInt32 err)
00236 {
00237     PRErrorCode prError;
00238     switch (err) {
00239 //    case WSAEINVAL:       prError = PR_INVALID_STATE_ERROR; break;
00240     default:         nss_MD_os2_map_default_error(err); return;
00241     }
00242     PR_SetError(prError, err);
00243 }
00244 
00245 void nss_MD_os2_map_getpeername_error(PRInt32 err)
00246 {
00247     nss_MD_os2_map_default_error(err);
00248 }
00249 
00250 void nss_MD_os2_map_getsockopt_error(PRInt32 err)
00251 {
00252     nss_MD_os2_map_default_error(err);
00253 }
00254 
00255 void nss_MD_os2_map_setsockopt_error(PRInt32 err)
00256 {
00257     nss_MD_os2_map_default_error(err);
00258 }
00259 
00260 void nss_MD_os2_map_open_error(PRInt32 err)
00261 {
00262     nss_MD_os2_map_default_error(err);
00263 }
00264 
00265 void nss_MD_os2_map_gethostname_error(PRInt32 err)
00266 {
00267     nss_MD_os2_map_default_error(err);
00268 }
00269 
00270 /* Win32 select() only works on sockets.  So in this
00271 ** context, WSAENOTSOCK is equivalent to EBADF on Unix.  
00272 */
00273 void nss_MD_os2_map_select_error(PRInt32 err)
00274 {
00275     PRErrorCode prError;
00276     switch (err) {
00277 //    case WSAENOTSOCK:     prError = PR_BAD_DESCRIPTOR_ERROR; break;
00278     default:         nss_MD_os2_map_default_error(err); return;
00279     }
00280     PR_SetError(prError, err);
00281 }
00282 
00283 void nss_MD_os2_map_lockf_error(PRInt32 err)
00284 {
00285     nss_MD_os2_map_default_error(err);
00286 }
00287 
00288 
00289 
00290 void nss_MD_os2_map_default_error(PRInt32 err)
00291 {
00292     PRErrorCode prError;
00293 
00294     switch (err) {
00295 //    case ENOENT:          prError = PR_FILE_NOT_FOUND_ERROR; break;
00296 //    case ERROR_ACCESS_DENIED:    prError = PR_NO_ACCESS_RIGHTS_ERROR; break;
00297 //    case ERROR_ALREADY_EXISTS:   prError = PR_FILE_EXISTS_ERROR; break;
00298 //    case ERROR_DISK_CORRUPT:     prError = PR_IO_ERROR; break;
00299 //    case ERROR_DISK_FULL:        prError = PR_NO_DEVICE_SPACE_ERROR; break;
00300 //    case ERROR_DISK_OPERATION_FAILED: prError = PR_IO_ERROR; break;
00301 //    case ERROR_DRIVE_LOCKED:     prError = PR_FILE_IS_LOCKED_ERROR; break;
00302 //    case ERROR_FILENAME_EXCED_RANGE: prError = PR_NAME_TOO_LONG_ERROR; break;
00303 //    case ERROR_FILE_CORRUPT:     prError = PR_IO_ERROR; break;
00304 //    case ERROR_FILE_EXISTS:      prError = PR_FILE_EXISTS_ERROR; break;
00305 //    case ERROR_FILE_INVALID:     prError = PR_BAD_DESCRIPTOR_ERROR; break;
00306 #if ERROR_FILE_NOT_FOUND != ENOENT
00307 //    case ERROR_FILE_NOT_FOUND:   prError = PR_FILE_NOT_FOUND_ERROR; break;
00308 #endif
00309     default:                prError = PR_UNKNOWN_ERROR; break;
00310     }
00311     PR_SetError(prError, err);
00312 }
00313