PostgreSQL Source Code git master
Loading...
Searching...
No Matches
win32error.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * win32error.c
4 * Map win32 error codes to errno values
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 *
8 * IDENTIFICATION
9 * src/port/win32error.c
10 *
11 *-------------------------------------------------------------------------
12 */
13
14#ifndef FRONTEND
15#include "postgres.h"
16#else
17#include "postgres_fe.h"
18#endif
19
20static const struct
21{
23 int doserr;
24} doserrors[] =
25
26{
27 {
29 },
30 {
32 },
33 {
35 },
36 {
38 },
39 {
41 },
42 {
44 },
45 {
47 },
48 {
50 },
51 {
53 },
54 {
56 },
57 {
59 },
60 {
62 },
63 {
65 },
66 {
68 },
69 {
71 },
72 {
74 },
75 {
77 },
78 {
80 },
81 {
83 },
84 {
86 },
87 {
89 },
90 {
92 },
93 {
95 },
96 {
98 },
99 {
101 },
102 {
104 },
105 {
107 },
108 {
110 },
111 {
113 },
114 {
116 },
117 {
119 },
120 {
122 },
123 {
125 },
126 {
128 },
129 {
131 },
132 {
134 },
135 {
137 },
138 {
140 },
141 {
143 },
144 {
146 },
147 {
149 },
150 {
152 },
153 {
155 },
156 {
158 },
159 {
161 },
162 {
164 },
165 {
167 },
168 {
170 },
171 {
173 }
175
176void
177_dosmaperr(unsigned long e)
178{
179 int i;
180
181 if (e == 0)
182 {
183 errno = 0;
184 return;
185 }
186
187 for (i = 0; i < lengthof(doserrors); i++)
188 {
189 if (doserrors[i].winerr == e)
190 {
191 int doserr = doserrors[i].doserr;
192
193#ifndef FRONTEND
195 (errmsg_internal("mapped win32 error code %lu to %d",
196 e, doserr)));
197#elif defined(FRONTEND_DEBUG)
198 fprintf(stderr, "mapped win32 error code %lu to %d", e, doserr);
199#endif
200 errno = doserr;
201 return;
202 }
203 }
204
205#ifndef FRONTEND
206 ereport(LOG,
207 (errmsg_internal("unrecognized win32 error code: %lu",
208 e)));
209#else
210 fprintf(stderr, "unrecognized win32 error code: %lu", e);
211#endif
212
213 errno = EINVAL;
214}
#define lengthof(array)
Definition c.h:803
#define fprintf(file, fmt, msg)
Definition cubescan.l:21
int errmsg_internal(const char *fmt,...)
Definition elog.c:1170
#define LOG
Definition elog.h:31
#define ereport(elevel,...)
Definition elog.h:150
#define DEBUG5
Definition elog.h:26
int i
Definition isn.c:77
e
static int fb(int x)
#define EAGAIN
Definition win32_port.h:359
static const struct @203 doserrors[]
int doserr
Definition win32error.c:23
void _dosmaperr(unsigned long e)
Definition win32error.c:177
DWORD winerr
Definition win32error.c:22