summaryrefslogtreecommitdiff
path: root/pr/src/md/windows/w16error.c
blob: f3ef99aeedd279d2bd1de1512cb6a3e80e802355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * The contents of this file are subject to the Netscape Public License
 * Version 1.0 (the "NPL"); you may not use this file except in
 * compliance with the NPL.  You may obtain a copy of the NPL at
 * http://www.mozilla.org/NPL/
 * 
 * Software distributed under the NPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
 * for the specific language governing rights and limitations under the
 * NPL.
 * 
 * The Initial Developer of this code under the NPL is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
 * Reserved.
 */

/*
** Note: A single error mapping function is provided.
**
*/ 
#include "prerror.h"
#include <errno.h>
#include <winsock.h>


void _PR_MD_map_error( int err )
{

    switch ( err )
    {
        case  ENOENT:   /* No such file or directory */
			PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
            break;
        case  E2BIG:    /* Argument list too big */
            PR_SetError( PR_INVALID_ARGUMENT_ERROR, err );
            break;
        case  ENOEXEC:  /* Exec format error */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EBADF:    /* Bad file number */
            PR_SetError( PR_BAD_DESCRIPTOR_ERROR, err );
            break;
        case  ENOMEM:   /* Not enough Memory */
            PR_SetError( PR_OUT_OF_MEMORY_ERROR, err );
            break;
        case  EACCES:   /* Permission denied */
            PR_SetError( PR_NO_ACCESS_RIGHTS_ERROR, err );
            break;
        case  EEXIST:   /* File exists */
        
 /* RESTART here */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EXDEV:    /* Cross device link */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EINVAL:   /* Invalid argument */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENFILE:   /* File table overflow */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EMFILE:   /* Too many open files */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOSPC:   /* No space left on device */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        /* math errors */
        case  EDOM:     /* Argument too large */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ERANGE:   /* Result too large */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        /* file locking error */
        case  EDEADLK:      /* Resource deadlock would occur */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EINTR:    /* Interrupt */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ECHILD:   /* Child does not exist */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        /* POSIX errors */
        case  EAGAIN:   /* Resource unavailable, try again */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EBUSY:    /* Device or Resource is busy */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EFBIG:    /* File too large */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EIO:      /* I/O error */
            PR_SetError( PR_IO_ERROR, err );
            break;
        case  EISDIR:   /* Is a directory */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOTDIR:  /* Not a directory */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EMLINK:   /* Too many links */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOTBLK:  /* Block device required */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOTTY:   /* Not a character device */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENXIO:    /* No such device or address */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EPERM:    /* Not owner */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EPIPE:    /* Broken pipe */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EROFS:    /* Read only file system */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ESPIPE:   /* Illegal seek */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ESRCH:    /* No such process */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ETXTBSY:  /* Text file busy */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  EFAULT:   /* Bad address */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENAMETOOLONG: /* Name too long */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENODEV:   /* No such device */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOLCK:   /* No locks available on system */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOSYS:   /* Unknown system call */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
        case  ENOTEMPTY:    /* Directory not empty */
        /* Normative Addendum error */
        case  EILSEQ:   /* Multibyte/widw character encoding error */
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
            
        /* WinSock errors */
        case WSAEACCES:
            PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
            break;
        case WSAEADDRINUSE:
            PR_SetError(PR_ADDRESS_IN_USE_ERROR, err);
            break;
        case WSAEADDRNOTAVAIL:
            PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err);
            break;
        case WSAEAFNOSUPPORT:
            PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
            break;
        case WSAEBADF:
            PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
            break;
        case WSAECONNREFUSED:
            PR_SetError(PR_CONNECT_REFUSED_ERROR, err);
            break;
        case WSAEFAULT:
            PR_SetError(PR_ACCESS_FAULT_ERROR, err);
            break;
        case WSAEINVAL:
            PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err);
            break;
        case WSAEISCONN:
            PR_SetError(PR_IS_CONNECTED_ERROR, err);
            break;
        case WSAEMFILE:
            PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
            break;
        case WSAENETDOWN:
        case WSAENETUNREACH:
            PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, err);
            break;
        case WSAENOBUFS:
            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
            break;
        case WSAENOPROTOOPT:
        case WSAEMSGSIZE:
            PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
            break;
        case WSAENOTCONN:
            PR_SetError(PR_NOT_CONNECTED_ERROR, err);
            break;
        case WSAENOTSOCK:
            PR_SetError(PR_NOT_SOCKET_ERROR, err);
            break;
        case WSAEOPNOTSUPP:
            PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err);
            break;
        case WSAEPROTONOSUPPORT:
            PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err);
            break;
        case WSAETIMEDOUT:
            PR_SetError(PR_IO_TIMEOUT_ERROR, err);
            break;
        case WSAEINTR:
            PR_SetError(PR_PENDING_INTERRUPT_ERROR, err );
            break;
        case WSASYSNOTREADY:
        case WSAVERNOTSUPPORTED:
            PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err);
            break;
		case WSAEWOULDBLOCK:
			PR_SetError(PR_WOULD_BLOCK_ERROR, err);
			break;
            
        default:
            PR_SetError( PR_UNKNOWN_ERROR, err );
            break;
    }
    return;
} /* end _MD_map_win16_error() */