Back to index

lightning-sunbird  0.9+nobinonly
w16error.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039 ** Note: A single error mapping function is provided.
00040 **
00041 */ 
00042 #include "prerror.h"
00043 #include <errno.h>
00044 #include <winsock.h>
00045 
00046 
00047 void _PR_MD_map_error( int err )
00048 {
00049 
00050     switch ( err )
00051     {
00052         case  ENOENT:   /* No such file or directory */
00053                      PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
00054             break;
00055         case  E2BIG:    /* Argument list too big */
00056             PR_SetError( PR_INVALID_ARGUMENT_ERROR, err );
00057             break;
00058         case  ENOEXEC:  /* Exec format error */
00059             PR_SetError( PR_UNKNOWN_ERROR, err );
00060             break;
00061         case  EBADF:    /* Bad file number */
00062             PR_SetError( PR_BAD_DESCRIPTOR_ERROR, err );
00063             break;
00064         case  ENOMEM:   /* Not enough Memory */
00065             PR_SetError( PR_OUT_OF_MEMORY_ERROR, err );
00066             break;
00067         case  EACCES:   /* Permission denied */
00068             PR_SetError( PR_NO_ACCESS_RIGHTS_ERROR, err );
00069             break;
00070         case  EEXIST:   /* File exists */
00071         
00072  /* RESTART here */
00073             PR_SetError( PR_UNKNOWN_ERROR, err );
00074             break;
00075         case  EXDEV:    /* Cross device link */
00076             PR_SetError( PR_UNKNOWN_ERROR, err );
00077             break;
00078         case  EINVAL:   /* Invalid argument */
00079             PR_SetError( PR_UNKNOWN_ERROR, err );
00080             break;
00081         case  ENFILE:   /* File table overflow */
00082             PR_SetError( PR_UNKNOWN_ERROR, err );
00083             break;
00084         case  EMFILE:   /* Too many open files */
00085             PR_SetError( PR_UNKNOWN_ERROR, err );
00086             break;
00087         case  ENOSPC:   /* No space left on device */
00088             PR_SetError( PR_UNKNOWN_ERROR, err );
00089             break;
00090         /* math errors */
00091         case  EDOM:     /* Argument too large */
00092             PR_SetError( PR_UNKNOWN_ERROR, err );
00093             break;
00094         case  ERANGE:   /* Result too large */
00095             PR_SetError( PR_UNKNOWN_ERROR, err );
00096             break;
00097         /* file locking error */
00098         case  EDEADLK:      /* Resource deadlock would occur */
00099             PR_SetError( PR_UNKNOWN_ERROR, err );
00100             break;
00101         case  EINTR:    /* Interrupt */
00102             PR_SetError( PR_UNKNOWN_ERROR, err );
00103             break;
00104         case  ECHILD:   /* Child does not exist */
00105             PR_SetError( PR_UNKNOWN_ERROR, err );
00106             break;
00107         /* POSIX errors */
00108         case  EAGAIN:   /* Resource unavailable, try again */
00109             PR_SetError( PR_UNKNOWN_ERROR, err );
00110             break;
00111         case  EBUSY:    /* Device or Resource is busy */
00112             PR_SetError( PR_UNKNOWN_ERROR, err );
00113             break;
00114         case  EFBIG:    /* File too large */
00115             PR_SetError( PR_UNKNOWN_ERROR, err );
00116             break;
00117         case  EIO:      /* I/O error */
00118             PR_SetError( PR_IO_ERROR, err );
00119             break;
00120         case  EISDIR:   /* Is a directory */
00121             PR_SetError( PR_UNKNOWN_ERROR, err );
00122             break;
00123         case  ENOTDIR:  /* Not a directory */
00124             PR_SetError( PR_UNKNOWN_ERROR, err );
00125             break;
00126         case  EMLINK:   /* Too many links */
00127             PR_SetError( PR_UNKNOWN_ERROR, err );
00128             break;
00129         case  ENOTBLK:  /* Block device required */
00130             PR_SetError( PR_UNKNOWN_ERROR, err );
00131             break;
00132         case  ENOTTY:   /* Not a character device */
00133             PR_SetError( PR_UNKNOWN_ERROR, err );
00134             break;
00135         case  ENXIO:    /* No such device or address */
00136             PR_SetError( PR_UNKNOWN_ERROR, err );
00137             break;
00138         case  EPERM:    /* Not owner */
00139             PR_SetError( PR_UNKNOWN_ERROR, err );
00140             break;
00141         case  EPIPE:    /* Broken pipe */
00142             PR_SetError( PR_UNKNOWN_ERROR, err );
00143             break;
00144         case  EROFS:    /* Read only file system */
00145             PR_SetError( PR_UNKNOWN_ERROR, err );
00146             break;
00147         case  ESPIPE:   /* Illegal seek */
00148             PR_SetError( PR_UNKNOWN_ERROR, err );
00149             break;
00150         case  ESRCH:    /* No such process */
00151             PR_SetError( PR_UNKNOWN_ERROR, err );
00152             break;
00153         case  ETXTBSY:  /* Text file busy */
00154             PR_SetError( PR_UNKNOWN_ERROR, err );
00155             break;
00156         case  EFAULT:   /* Bad address */
00157             PR_SetError( PR_UNKNOWN_ERROR, err );
00158             break;
00159         case  ENAMETOOLONG: /* Name too long */
00160             PR_SetError( PR_UNKNOWN_ERROR, err );
00161             break;
00162         case  ENODEV:   /* No such device */
00163             PR_SetError( PR_UNKNOWN_ERROR, err );
00164             break;
00165         case  ENOLCK:   /* No locks available on system */
00166             PR_SetError( PR_UNKNOWN_ERROR, err );
00167             break;
00168         case  ENOSYS:   /* Unknown system call */
00169             PR_SetError( PR_UNKNOWN_ERROR, err );
00170             break;
00171         case  ENOTEMPTY:    /* Directory not empty */
00172         /* Normative Addendum error */
00173         case  EILSEQ:   /* Multibyte/widw character encoding error */
00174             PR_SetError( PR_UNKNOWN_ERROR, err );
00175             break;
00176             
00177         /* WinSock errors */
00178         case WSAEACCES:
00179             PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
00180             break;
00181         case WSAEADDRINUSE:
00182             PR_SetError(PR_ADDRESS_IN_USE_ERROR, err);
00183             break;
00184         case WSAEADDRNOTAVAIL:
00185             PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err);
00186             break;
00187         case WSAEAFNOSUPPORT:
00188             PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
00189             break;
00190         case WSAEBADF:
00191             PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
00192             break;
00193         case WSAECONNREFUSED:
00194             PR_SetError(PR_CONNECT_REFUSED_ERROR, err);
00195             break;
00196         case WSAEFAULT:
00197             PR_SetError(PR_ACCESS_FAULT_ERROR, err);
00198             break;
00199         case WSAEINVAL:
00200             PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err);
00201             break;
00202         case WSAEISCONN:
00203             PR_SetError(PR_IS_CONNECTED_ERROR, err);
00204             break;
00205         case WSAEMFILE:
00206             PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
00207             break;
00208         case WSAENETDOWN:
00209         case WSAENETUNREACH:
00210             PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, err);
00211             break;
00212         case WSAENOBUFS:
00213             PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
00214             break;
00215         case WSAENOPROTOOPT:
00216         case WSAEMSGSIZE:
00217             PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
00218             break;
00219         case WSAENOTCONN:
00220             PR_SetError(PR_NOT_CONNECTED_ERROR, err);
00221             break;
00222         case WSAENOTSOCK:
00223             PR_SetError(PR_NOT_SOCKET_ERROR, err);
00224             break;
00225         case WSAEOPNOTSUPP:
00226             PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err);
00227             break;
00228         case WSAEPROTONOSUPPORT:
00229             PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err);
00230             break;
00231         case WSAETIMEDOUT:
00232             PR_SetError(PR_IO_TIMEOUT_ERROR, err);
00233             break;
00234         case WSAEINTR:
00235             PR_SetError(PR_PENDING_INTERRUPT_ERROR, err );
00236             break;
00237         case WSASYSNOTREADY:
00238         case WSAVERNOTSUPPORTED:
00239             PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err);
00240             break;
00241               case WSAEWOULDBLOCK:
00242                      PR_SetError(PR_WOULD_BLOCK_ERROR, err);
00243                      break;
00244             
00245         default:
00246             PR_SetError( PR_UNKNOWN_ERROR, err );
00247             break;
00248     }
00249     return;
00250 } /* end _MD_map_win16_error() */
00251 
00252