Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / src / port / win32error.c
blobeb9a20f13ee833160ef5e9c22b19abf035e444db
1 /*-------------------------------------------------------------------------
3 * win32error.c
4 * Map win32 error codes to errno values
6 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
8 * IDENTIFICATION
9 * $PostgreSQL$
11 *-------------------------------------------------------------------------
14 #include "postgres.h"
16 static const struct
18 DWORD winerr;
19 int doserr;
20 } doserrors[] =
24 ERROR_INVALID_FUNCTION, EINVAL
27 ERROR_FILE_NOT_FOUND, ENOENT
30 ERROR_PATH_NOT_FOUND, ENOENT
33 ERROR_TOO_MANY_OPEN_FILES, EMFILE
36 ERROR_ACCESS_DENIED, EACCES
39 ERROR_INVALID_HANDLE, EBADF
42 ERROR_ARENA_TRASHED, ENOMEM
45 ERROR_NOT_ENOUGH_MEMORY, ENOMEM
48 ERROR_INVALID_BLOCK, ENOMEM
51 ERROR_BAD_ENVIRONMENT, E2BIG
54 ERROR_BAD_FORMAT, ENOEXEC
57 ERROR_INVALID_ACCESS, EINVAL
60 ERROR_INVALID_DATA, EINVAL
63 ERROR_INVALID_DRIVE, ENOENT
66 ERROR_CURRENT_DIRECTORY, EACCES
69 ERROR_NOT_SAME_DEVICE, EXDEV
72 ERROR_NO_MORE_FILES, ENOENT
75 ERROR_LOCK_VIOLATION, EACCES
78 ERROR_SHARING_VIOLATION, EACCES
81 ERROR_BAD_NETPATH, ENOENT
84 ERROR_NETWORK_ACCESS_DENIED, EACCES
87 ERROR_BAD_NET_NAME, ENOENT
90 ERROR_FILE_EXISTS, EEXIST
93 ERROR_CANNOT_MAKE, EACCES
96 ERROR_FAIL_I24, EACCES
99 ERROR_INVALID_PARAMETER, EINVAL
102 ERROR_NO_PROC_SLOTS, EAGAIN
105 ERROR_DRIVE_LOCKED, EACCES
108 ERROR_BROKEN_PIPE, EPIPE
111 ERROR_DISK_FULL, ENOSPC
114 ERROR_INVALID_TARGET_HANDLE, EBADF
117 ERROR_INVALID_HANDLE, EINVAL
120 ERROR_WAIT_NO_CHILDREN, ECHILD
123 ERROR_CHILD_NOT_COMPLETE, ECHILD
126 ERROR_DIRECT_ACCESS_HANDLE, EBADF
129 ERROR_NEGATIVE_SEEK, EINVAL
132 ERROR_SEEK_ON_DEVICE, EACCES
135 ERROR_DIR_NOT_EMPTY, ENOTEMPTY
138 ERROR_NOT_LOCKED, EACCES
141 ERROR_BAD_PATHNAME, ENOENT
144 ERROR_MAX_THRDS_REACHED, EAGAIN
147 ERROR_LOCK_FAILED, EACCES
150 ERROR_ALREADY_EXISTS, EEXIST
153 ERROR_FILENAME_EXCED_RANGE, ENOENT
156 ERROR_NESTING_NOT_ALLOWED, EAGAIN
159 ERROR_NOT_ENOUGH_QUOTA, ENOMEM
163 void
164 _dosmaperr(unsigned long e)
166 int i;
168 if (e == 0)
170 errno = 0;
171 return;
174 for (i = 0; i < lengthof(doserrors); i++)
176 if (doserrors[i].winerr == e)
178 errno = doserrors[i].doserr;
179 #ifndef FRONTEND
180 ereport(DEBUG5,
181 (errmsg_internal("mapped win32 error code %lu to %d",
182 e, errno)));
183 #elif FRONTEND_DEBUG
184 fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);
185 #endif
186 return;
190 #ifndef FRONTEND
191 ereport(LOG,
192 (errmsg_internal("unrecognized win32 error code: %lu",
193 e)));
194 #else
195 fprintf(stderr, _("unrecognized win32 error code: %lu"), e);
196 #endif
198 errno = EINVAL;
199 return;