koffi 2.3.13 → 2.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build/2.3.14/koffi_darwin_arm64/koffi.node +0 -0
- package/build/2.3.14/koffi_darwin_x64/koffi.node +0 -0
- package/build/2.3.14/koffi_freebsd_arm64/koffi.node +0 -0
- package/build/2.3.14/koffi_freebsd_ia32/koffi.node +0 -0
- package/build/2.3.14/koffi_freebsd_x64/koffi.node +0 -0
- package/build/2.3.14/koffi_linux_arm32hf/koffi.node +0 -0
- package/build/2.3.14/koffi_linux_arm64/koffi.node +0 -0
- package/build/2.3.14/koffi_linux_ia32/koffi.node +0 -0
- package/build/2.3.14/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/build/{2.3.13 → 2.3.14}/koffi_linux_x64/koffi.node +0 -0
- package/build/2.3.14/koffi_openbsd_ia32/koffi.node +0 -0
- package/build/2.3.14/koffi_openbsd_x64/koffi.node +0 -0
- package/build/2.3.14/koffi_win32_arm64/koffi.node +0 -0
- package/build/{2.3.13 → 2.3.14}/koffi_win32_ia32/koffi.node +0 -0
- package/build/{2.3.13 → 2.3.14}/koffi_win32_x64/koffi.node +0 -0
- package/doc/misc.md +22 -0
- package/package.json +2 -2
- package/src/index.d.ts +9 -2
- package/src/koffi/src/errno.inc +480 -0
- package/src/koffi/src/ffi.cc +37 -0
- package/build/2.3.13/koffi_darwin_arm64/koffi.node +0 -0
- package/build/2.3.13/koffi_darwin_x64/koffi.node +0 -0
- package/build/2.3.13/koffi_freebsd_arm64/koffi.node +0 -0
- package/build/2.3.13/koffi_freebsd_ia32/koffi.node +0 -0
- package/build/2.3.13/koffi_freebsd_x64/koffi.node +0 -0
- package/build/2.3.13/koffi_linux_arm32hf/koffi.node +0 -0
- package/build/2.3.13/koffi_linux_arm64/koffi.node +0 -0
- package/build/2.3.13/koffi_linux_ia32/koffi.node +0 -0
- package/build/2.3.13/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/build/2.3.13/koffi_openbsd_ia32/koffi.node +0 -0
- package/build/2.3.13/koffi_openbsd_x64/koffi.node +0 -0
- package/build/2.3.13/koffi_win32_arm64/koffi.node +0 -0
- /package/build/{2.3.13 → 2.3.14}/koffi_win32_arm64/koffi.exp +0 -0
- /package/build/{2.3.13 → 2.3.14}/koffi_win32_arm64/koffi.lib +0 -0
- /package/build/{2.3.13 → 2.3.14}/koffi_win32_ia32/koffi.exp +0 -0
- /package/build/{2.3.13 → 2.3.14}/koffi_win32_ia32/koffi.lib +0 -0
- /package/build/{2.3.13 → 2.3.14}/koffi_win32_x64/koffi.exp +0 -0
- /package/build/{2.3.13 → 2.3.14}/koffi_win32_x64/koffi.lib +0 -0
package/CHANGELOG.md
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/doc/misc.md
CHANGED
|
@@ -101,3 +101,25 @@ max_type_size | 64 MiB | Maximum size of Koffi types (for arrays and str
|
|
|
101
101
|
*New in Koffi 2.3.2*
|
|
102
102
|
|
|
103
103
|
You can use `koffi.stats()` to get a few statistics related to Koffi.
|
|
104
|
+
|
|
105
|
+
## POSIX error codes
|
|
106
|
+
|
|
107
|
+
*New in Koffi 2.3.14*
|
|
108
|
+
|
|
109
|
+
You can use `koffi.errno()` to the current errno value, and `koffi.errno(value)` to change it.
|
|
110
|
+
|
|
111
|
+
The standard POSIX error codes are available in `koffi.os.errno`, as in the example below:
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
const assert = require('assert');
|
|
115
|
+
const koffi = require('koffi');
|
|
116
|
+
|
|
117
|
+
const lib = koffi.load('libc.so.6');
|
|
118
|
+
|
|
119
|
+
const close = lib.func('int close(int fd)');
|
|
120
|
+
|
|
121
|
+
close(-1);
|
|
122
|
+
assert.equal(koffi.errno(), koffi.os.errno.EBADF);
|
|
123
|
+
|
|
124
|
+
console.log('close() with invalid FD is POSIX compliant!');
|
|
125
|
+
```
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -131,6 +131,13 @@ declare module 'koffi' {
|
|
|
131
131
|
export function config(cfg: Record<string, unknown>): Record<string, unknown>;
|
|
132
132
|
export function stats(): Record<string, unknown>;
|
|
133
133
|
|
|
134
|
-
export
|
|
135
|
-
export
|
|
134
|
+
export function errno(): number;
|
|
135
|
+
export function errno(value: number): number;
|
|
136
|
+
|
|
137
|
+
export const internal: Boolean;
|
|
138
|
+
export const extension: String;
|
|
139
|
+
|
|
140
|
+
export const os: {
|
|
141
|
+
errno: Record<string, number>
|
|
142
|
+
};
|
|
136
143
|
}
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
// Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
6
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
8
|
+
// subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
// copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
15
|
+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
18
|
+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
19
|
+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
20
|
+
// OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
#include <errno.h>
|
|
23
|
+
|
|
24
|
+
struct ErrnoCodeInfo {
|
|
25
|
+
const char *name;
|
|
26
|
+
int value;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const ErrnoCodeInfo ErrnoCodes[] = {
|
|
30
|
+
#ifdef E2BIG
|
|
31
|
+
{"E2BIG", E2BIG },
|
|
32
|
+
#endif
|
|
33
|
+
#ifdef EACCES
|
|
34
|
+
{"EACCES", EACCES },
|
|
35
|
+
#endif
|
|
36
|
+
#ifdef EADDRINUSE
|
|
37
|
+
{"EADDRINUSE", EADDRINUSE },
|
|
38
|
+
#endif
|
|
39
|
+
#ifdef EADDRNOTAVAIL
|
|
40
|
+
{"EADDRNOTAVAIL", EADDRNOTAVAIL },
|
|
41
|
+
#endif
|
|
42
|
+
#ifdef EADV
|
|
43
|
+
{"EADV", EADV },
|
|
44
|
+
#endif
|
|
45
|
+
#ifdef EAFNOSUPPORT
|
|
46
|
+
{"EAFNOSUPPORT", EAFNOSUPPORT },
|
|
47
|
+
#endif
|
|
48
|
+
#ifdef EAGAIN
|
|
49
|
+
{"EAGAIN", EAGAIN },
|
|
50
|
+
#endif
|
|
51
|
+
#ifdef EALREADY
|
|
52
|
+
{"EALREADY", EALREADY },
|
|
53
|
+
#endif
|
|
54
|
+
#ifdef EAUTH
|
|
55
|
+
{"EAUTH", EAUTH },
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef EBADE
|
|
58
|
+
{"EBADE", EBADE },
|
|
59
|
+
#endif
|
|
60
|
+
#ifdef EBADF
|
|
61
|
+
{"EBADF", EBADF },
|
|
62
|
+
#endif
|
|
63
|
+
#ifdef EBADFD
|
|
64
|
+
{"EBADFD", EBADFD },
|
|
65
|
+
#endif
|
|
66
|
+
#ifdef EBADMSG
|
|
67
|
+
{"EBADMSG", EBADMSG },
|
|
68
|
+
#endif
|
|
69
|
+
#ifdef EBADR
|
|
70
|
+
{"EBADR", EBADR },
|
|
71
|
+
#endif
|
|
72
|
+
#ifdef EBADRPC
|
|
73
|
+
{"EBADRPC", EBADRPC },
|
|
74
|
+
#endif
|
|
75
|
+
#ifdef EBADRQC
|
|
76
|
+
{"EBADRQC", EBADRQC },
|
|
77
|
+
#endif
|
|
78
|
+
#ifdef EBADSLT
|
|
79
|
+
{"EBADSLT", EBADSLT },
|
|
80
|
+
#endif
|
|
81
|
+
#ifdef EBFONT
|
|
82
|
+
{"EBFONT", EBFONT },
|
|
83
|
+
#endif
|
|
84
|
+
#ifdef EBUSY
|
|
85
|
+
{"EBUSY", EBUSY },
|
|
86
|
+
#endif
|
|
87
|
+
#ifdef ECANCELED
|
|
88
|
+
{"ECANCELED", ECANCELED },
|
|
89
|
+
#endif
|
|
90
|
+
#ifdef ECAPMODE
|
|
91
|
+
{"ECAPMODE", ECAPMODE },
|
|
92
|
+
#endif
|
|
93
|
+
#ifdef ECHILD
|
|
94
|
+
{"ECHILD", ECHILD },
|
|
95
|
+
#endif
|
|
96
|
+
#ifdef ECHRNG
|
|
97
|
+
{"ECHRNG", ECHRNG },
|
|
98
|
+
#endif
|
|
99
|
+
#ifdef ECOMM
|
|
100
|
+
{"ECOMM", ECOMM },
|
|
101
|
+
#endif
|
|
102
|
+
#ifdef ECONNABORTED
|
|
103
|
+
{"ECONNABORTED", ECONNABORTED },
|
|
104
|
+
#endif
|
|
105
|
+
#ifdef ECONNREFUSED
|
|
106
|
+
{"ECONNREFUSED", ECONNREFUSED },
|
|
107
|
+
#endif
|
|
108
|
+
#ifdef ECONNRESET
|
|
109
|
+
{"ECONNRESET", ECONNRESET },
|
|
110
|
+
#endif
|
|
111
|
+
#ifdef EDEADLK
|
|
112
|
+
{"EDEADLK", EDEADLK },
|
|
113
|
+
#endif
|
|
114
|
+
#ifdef EDEADLOCK
|
|
115
|
+
{"EDEADLOCK", EDEADLOCK },
|
|
116
|
+
#endif
|
|
117
|
+
#ifdef EDESTADDRREQ
|
|
118
|
+
{"EDESTADDRREQ", EDESTADDRREQ },
|
|
119
|
+
#endif
|
|
120
|
+
#ifdef EDOM
|
|
121
|
+
{"EDOM", EDOM },
|
|
122
|
+
#endif
|
|
123
|
+
#ifdef EDOOFUS
|
|
124
|
+
{"EDOOFUS", EDOOFUS },
|
|
125
|
+
#endif
|
|
126
|
+
#ifdef EDOTDOT
|
|
127
|
+
{"EDOTDOT", EDOTDOT },
|
|
128
|
+
#endif
|
|
129
|
+
#ifdef EDQUOT
|
|
130
|
+
{"EDQUOT", EDQUOT },
|
|
131
|
+
#endif
|
|
132
|
+
#ifdef EEXIST
|
|
133
|
+
{"EEXIST", EEXIST },
|
|
134
|
+
#endif
|
|
135
|
+
#ifdef EFAULT
|
|
136
|
+
{"EFAULT", EFAULT },
|
|
137
|
+
#endif
|
|
138
|
+
#ifdef EFBIG
|
|
139
|
+
{"EFBIG", EFBIG },
|
|
140
|
+
#endif
|
|
141
|
+
#ifdef EFTYPE
|
|
142
|
+
{"EFTYPE", EFTYPE },
|
|
143
|
+
#endif
|
|
144
|
+
#ifdef EHOSTDOWN
|
|
145
|
+
{"EHOSTDOWN", EHOSTDOWN },
|
|
146
|
+
#endif
|
|
147
|
+
#ifdef EHOSTUNREACH
|
|
148
|
+
{"EHOSTUNREACH", EHOSTUNREACH },
|
|
149
|
+
#endif
|
|
150
|
+
#ifdef EHWPOISON
|
|
151
|
+
{"EHWPOISON", EHWPOISON },
|
|
152
|
+
#endif
|
|
153
|
+
#ifdef EIDRM
|
|
154
|
+
{"EIDRM", EIDRM },
|
|
155
|
+
#endif
|
|
156
|
+
#ifdef EILSEQ
|
|
157
|
+
{"EILSEQ", EILSEQ },
|
|
158
|
+
#endif
|
|
159
|
+
#ifdef EINPROGRESS
|
|
160
|
+
{"EINPROGRESS", EINPROGRESS },
|
|
161
|
+
#endif
|
|
162
|
+
#ifdef EINTEGRITY
|
|
163
|
+
{"EINTEGRITY", EINTEGRITY },
|
|
164
|
+
#endif
|
|
165
|
+
#ifdef EINTR
|
|
166
|
+
{"EINTR", EINTR },
|
|
167
|
+
#endif
|
|
168
|
+
#ifdef EINVAL
|
|
169
|
+
{"EINVAL", EINVAL },
|
|
170
|
+
#endif
|
|
171
|
+
#ifdef EIO
|
|
172
|
+
{"EIO", EIO },
|
|
173
|
+
#endif
|
|
174
|
+
#ifdef EISCONN
|
|
175
|
+
{"EISCONN", EISCONN },
|
|
176
|
+
#endif
|
|
177
|
+
#ifdef EISDIR
|
|
178
|
+
{"EISDIR", EISDIR },
|
|
179
|
+
#endif
|
|
180
|
+
#ifdef EISNAM
|
|
181
|
+
{"EISNAM", EISNAM },
|
|
182
|
+
#endif
|
|
183
|
+
#ifdef EKEYEXPIRED
|
|
184
|
+
{"EKEYEXPIRED", EKEYEXPIRED },
|
|
185
|
+
#endif
|
|
186
|
+
#ifdef EKEYREJECTED
|
|
187
|
+
{"EKEYREJECTED", EKEYREJECTED },
|
|
188
|
+
#endif
|
|
189
|
+
#ifdef EKEYREVOKED
|
|
190
|
+
{"EKEYREVOKED", EKEYREVOKED },
|
|
191
|
+
#endif
|
|
192
|
+
#ifdef EL2HLT
|
|
193
|
+
{"EL2HLT", EL2HLT },
|
|
194
|
+
#endif
|
|
195
|
+
#ifdef EL2NSYNC
|
|
196
|
+
{"EL2NSYNC", EL2NSYNC },
|
|
197
|
+
#endif
|
|
198
|
+
#ifdef EL3HLT
|
|
199
|
+
{"EL3HLT", EL3HLT },
|
|
200
|
+
#endif
|
|
201
|
+
#ifdef EL3RST
|
|
202
|
+
{"EL3RST", EL3RST },
|
|
203
|
+
#endif
|
|
204
|
+
#ifdef ELIBACC
|
|
205
|
+
{"ELIBACC", ELIBACC },
|
|
206
|
+
#endif
|
|
207
|
+
#ifdef ELIBBAD
|
|
208
|
+
{"ELIBBAD", ELIBBAD },
|
|
209
|
+
#endif
|
|
210
|
+
#ifdef ELIBEXEC
|
|
211
|
+
{"ELIBEXEC", ELIBEXEC },
|
|
212
|
+
#endif
|
|
213
|
+
#ifdef ELIBMAX
|
|
214
|
+
{"ELIBMAX", ELIBMAX },
|
|
215
|
+
#endif
|
|
216
|
+
#ifdef ELIBSCN
|
|
217
|
+
{"ELIBSCN", ELIBSCN },
|
|
218
|
+
#endif
|
|
219
|
+
#ifdef ELNRNG
|
|
220
|
+
{"ELNRNG", ELNRNG },
|
|
221
|
+
#endif
|
|
222
|
+
#ifdef ELOOP
|
|
223
|
+
{"ELOOP", ELOOP },
|
|
224
|
+
#endif
|
|
225
|
+
#ifdef EMEDIUMTYPE
|
|
226
|
+
{"EMEDIUMTYPE", EMEDIUMTYPE },
|
|
227
|
+
#endif
|
|
228
|
+
#ifdef EMFILE
|
|
229
|
+
{"EMFILE", EMFILE },
|
|
230
|
+
#endif
|
|
231
|
+
#ifdef EMLINK
|
|
232
|
+
{"EMLINK", EMLINK },
|
|
233
|
+
#endif
|
|
234
|
+
#ifdef EMSGSIZE
|
|
235
|
+
{"EMSGSIZE", EMSGSIZE },
|
|
236
|
+
#endif
|
|
237
|
+
#ifdef EMULTIHOP
|
|
238
|
+
{"EMULTIHOP", EMULTIHOP },
|
|
239
|
+
#endif
|
|
240
|
+
#ifdef ENAMETOOLONG
|
|
241
|
+
{"ENAMETOOLONG", ENAMETOOLONG },
|
|
242
|
+
#endif
|
|
243
|
+
#ifdef ENAVAIL
|
|
244
|
+
{"ENAVAIL", ENAVAIL },
|
|
245
|
+
#endif
|
|
246
|
+
#ifdef ENEEDAUTH
|
|
247
|
+
{"ENEEDAUTH", ENEEDAUTH },
|
|
248
|
+
#endif
|
|
249
|
+
#ifdef ENETDOWN
|
|
250
|
+
{"ENETDOWN", ENETDOWN },
|
|
251
|
+
#endif
|
|
252
|
+
#ifdef ENETRESET
|
|
253
|
+
{"ENETRESET", ENETRESET },
|
|
254
|
+
#endif
|
|
255
|
+
#ifdef ENETUNREACH
|
|
256
|
+
{"ENETUNREACH", ENETUNREACH },
|
|
257
|
+
#endif
|
|
258
|
+
#ifdef ENFILE
|
|
259
|
+
{"ENFILE", ENFILE },
|
|
260
|
+
#endif
|
|
261
|
+
#ifdef ENOANO
|
|
262
|
+
{"ENOANO", ENOANO },
|
|
263
|
+
#endif
|
|
264
|
+
#ifdef ENOATTR
|
|
265
|
+
{"ENOATTR", ENOATTR },
|
|
266
|
+
#endif
|
|
267
|
+
#ifdef ENOBUFS
|
|
268
|
+
{"ENOBUFS", ENOBUFS },
|
|
269
|
+
#endif
|
|
270
|
+
#ifdef ENOCSI
|
|
271
|
+
{"ENOCSI", ENOCSI },
|
|
272
|
+
#endif
|
|
273
|
+
#ifdef ENODATA
|
|
274
|
+
{"ENODATA", ENODATA },
|
|
275
|
+
#endif
|
|
276
|
+
#ifdef ENODEV
|
|
277
|
+
{"ENODEV", ENODEV },
|
|
278
|
+
#endif
|
|
279
|
+
#ifdef ENOENT
|
|
280
|
+
{"ENOENT", ENOENT },
|
|
281
|
+
#endif
|
|
282
|
+
#ifdef ENOEXEC
|
|
283
|
+
{"ENOEXEC", ENOEXEC },
|
|
284
|
+
#endif
|
|
285
|
+
#ifdef ENOKEY
|
|
286
|
+
{"ENOKEY", ENOKEY },
|
|
287
|
+
#endif
|
|
288
|
+
#ifdef ENOLCK
|
|
289
|
+
{"ENOLCK", ENOLCK },
|
|
290
|
+
#endif
|
|
291
|
+
#ifdef ENOLINK
|
|
292
|
+
{"ENOLINK", ENOLINK },
|
|
293
|
+
#endif
|
|
294
|
+
#ifdef ENOMEDIUM
|
|
295
|
+
{"ENOMEDIUM", ENOMEDIUM },
|
|
296
|
+
#endif
|
|
297
|
+
#ifdef ENOMEM
|
|
298
|
+
{"ENOMEM", ENOMEM },
|
|
299
|
+
#endif
|
|
300
|
+
#ifdef ENOMSG
|
|
301
|
+
{"ENOMSG", ENOMSG },
|
|
302
|
+
#endif
|
|
303
|
+
#ifdef ENONET
|
|
304
|
+
{"ENONET", ENONET },
|
|
305
|
+
#endif
|
|
306
|
+
#ifdef ENOPKG
|
|
307
|
+
{"ENOPKG", ENOPKG },
|
|
308
|
+
#endif
|
|
309
|
+
#ifdef ENOPROTOOPT
|
|
310
|
+
{"ENOPROTOOPT", ENOPROTOOPT },
|
|
311
|
+
#endif
|
|
312
|
+
#ifdef ENOSPC
|
|
313
|
+
{"ENOSPC", ENOSPC },
|
|
314
|
+
#endif
|
|
315
|
+
#ifdef ENOSR
|
|
316
|
+
{"ENOSR", ENOSR },
|
|
317
|
+
#endif
|
|
318
|
+
#ifdef ENOSTR
|
|
319
|
+
{"ENOSTR", ENOSTR },
|
|
320
|
+
#endif
|
|
321
|
+
#ifdef ENOSYS
|
|
322
|
+
{"ENOSYS", ENOSYS },
|
|
323
|
+
#endif
|
|
324
|
+
#ifdef ENOTBLK
|
|
325
|
+
{"ENOTBLK", ENOTBLK },
|
|
326
|
+
#endif
|
|
327
|
+
#ifdef ENOTCAPABLE
|
|
328
|
+
{"ENOTCAPABLE", ENOTCAPABLE },
|
|
329
|
+
#endif
|
|
330
|
+
#ifdef ENOTCONN
|
|
331
|
+
{"ENOTCONN", ENOTCONN },
|
|
332
|
+
#endif
|
|
333
|
+
#ifdef ENOTDIR
|
|
334
|
+
{"ENOTDIR", ENOTDIR },
|
|
335
|
+
#endif
|
|
336
|
+
#ifdef ENOTEMPTY
|
|
337
|
+
{"ENOTEMPTY", ENOTEMPTY },
|
|
338
|
+
#endif
|
|
339
|
+
#ifdef ENOTNAM
|
|
340
|
+
{"ENOTNAM", ENOTNAM },
|
|
341
|
+
#endif
|
|
342
|
+
#ifdef ENOTRECOVERABLE
|
|
343
|
+
{"ENOTRECOVERABLE", ENOTRECOVERABLE },
|
|
344
|
+
#endif
|
|
345
|
+
#ifdef ENOTSOCK
|
|
346
|
+
{"ENOTSOCK", ENOTSOCK },
|
|
347
|
+
#endif
|
|
348
|
+
#ifdef ENOTSUP
|
|
349
|
+
{"ENOTSUP", ENOTSUP },
|
|
350
|
+
#endif
|
|
351
|
+
#ifdef ENOTTY
|
|
352
|
+
{"ENOTTY", ENOTTY },
|
|
353
|
+
#endif
|
|
354
|
+
#ifdef ENOTUNIQ
|
|
355
|
+
{"ENOTUNIQ", ENOTUNIQ },
|
|
356
|
+
#endif
|
|
357
|
+
#ifdef ENXIO
|
|
358
|
+
{"ENXIO", ENXIO },
|
|
359
|
+
#endif
|
|
360
|
+
#ifdef EOPNOTSUPP
|
|
361
|
+
{"EOPNOTSUPP", EOPNOTSUPP },
|
|
362
|
+
#endif
|
|
363
|
+
#ifdef EOTHER
|
|
364
|
+
{"EOTHER", EOTHER },
|
|
365
|
+
#endif
|
|
366
|
+
#ifdef EOVERFLOW
|
|
367
|
+
{"EOVERFLOW", EOVERFLOW },
|
|
368
|
+
#endif
|
|
369
|
+
#ifdef EOWNERDEAD
|
|
370
|
+
{"EOWNERDEAD", EOWNERDEAD },
|
|
371
|
+
#endif
|
|
372
|
+
#ifdef EPERM
|
|
373
|
+
{"EPERM", EPERM },
|
|
374
|
+
#endif
|
|
375
|
+
#ifdef EPFNOSUPPORT
|
|
376
|
+
{"EPFNOSUPPORT", EPFNOSUPPORT },
|
|
377
|
+
#endif
|
|
378
|
+
#ifdef EPIPE
|
|
379
|
+
{"EPIPE", EPIPE },
|
|
380
|
+
#endif
|
|
381
|
+
#ifdef EPROCLIM
|
|
382
|
+
{"EPROCLIM", EPROCLIM },
|
|
383
|
+
#endif
|
|
384
|
+
#ifdef EPROCUNAVAIL
|
|
385
|
+
{"EPROCUNAVAIL", EPROCUNAVAIL },
|
|
386
|
+
#endif
|
|
387
|
+
#ifdef EPROGMISMATCH
|
|
388
|
+
{"EPROGMISMATCH", EPROGMISMATCH },
|
|
389
|
+
#endif
|
|
390
|
+
#ifdef EPROGUNAVAIL
|
|
391
|
+
{"EPROGUNAVAIL", EPROGUNAVAIL },
|
|
392
|
+
#endif
|
|
393
|
+
#ifdef EPROTO
|
|
394
|
+
{"EPROTO", EPROTO },
|
|
395
|
+
#endif
|
|
396
|
+
#ifdef EPROTONOSUPPORT
|
|
397
|
+
{"EPROTONOSUPPORT", EPROTONOSUPPORT },
|
|
398
|
+
#endif
|
|
399
|
+
#ifdef EPROTOTYPE
|
|
400
|
+
{"EPROTOTYPE", EPROTOTYPE },
|
|
401
|
+
#endif
|
|
402
|
+
#ifdef ERANGE
|
|
403
|
+
{"ERANGE", ERANGE },
|
|
404
|
+
#endif
|
|
405
|
+
#ifdef EREMCHG
|
|
406
|
+
{"EREMCHG", EREMCHG },
|
|
407
|
+
#endif
|
|
408
|
+
#ifdef EREMOTE
|
|
409
|
+
{"EREMOTE", EREMOTE },
|
|
410
|
+
#endif
|
|
411
|
+
#ifdef EREMOTEIO
|
|
412
|
+
{"EREMOTEIO", EREMOTEIO },
|
|
413
|
+
#endif
|
|
414
|
+
#ifdef ERESTART
|
|
415
|
+
{"ERESTART", ERESTART },
|
|
416
|
+
#endif
|
|
417
|
+
#ifdef ERFKILL
|
|
418
|
+
{"ERFKILL", ERFKILL },
|
|
419
|
+
#endif
|
|
420
|
+
#ifdef EROFS
|
|
421
|
+
{"EROFS", EROFS },
|
|
422
|
+
#endif
|
|
423
|
+
#ifdef ERPCMISMATCH
|
|
424
|
+
{"ERPCMISMATCH", ERPCMISMATCH },
|
|
425
|
+
#endif
|
|
426
|
+
#ifdef ESHUTDOWN
|
|
427
|
+
{"ESHUTDOWN", ESHUTDOWN },
|
|
428
|
+
#endif
|
|
429
|
+
#ifdef ESOCKTNOSUPPORT
|
|
430
|
+
{"ESOCKTNOSUPPORT", ESOCKTNOSUPPORT },
|
|
431
|
+
#endif
|
|
432
|
+
#ifdef ESPIPE
|
|
433
|
+
{"ESPIPE", ESPIPE },
|
|
434
|
+
#endif
|
|
435
|
+
#ifdef ESRCH
|
|
436
|
+
{"ESRCH", ESRCH },
|
|
437
|
+
#endif
|
|
438
|
+
#ifdef ESRMNT
|
|
439
|
+
{"ESRMNT", ESRMNT },
|
|
440
|
+
#endif
|
|
441
|
+
#ifdef ESTALE
|
|
442
|
+
{"ESTALE", ESTALE },
|
|
443
|
+
#endif
|
|
444
|
+
#ifdef ESTRPIPE
|
|
445
|
+
{"ESTRPIPE", ESTRPIPE },
|
|
446
|
+
#endif
|
|
447
|
+
#ifdef ETIME
|
|
448
|
+
{"ETIME", ETIME },
|
|
449
|
+
#endif
|
|
450
|
+
#ifdef ETIMEDOUT
|
|
451
|
+
{"ETIMEDOUT", ETIMEDOUT },
|
|
452
|
+
#endif
|
|
453
|
+
#ifdef ETOOMANYREFS
|
|
454
|
+
{"ETOOMANYREFS", ETOOMANYREFS },
|
|
455
|
+
#endif
|
|
456
|
+
#ifdef ETXTBSY
|
|
457
|
+
{"ETXTBSY", ETXTBSY },
|
|
458
|
+
#endif
|
|
459
|
+
#ifdef EUCLEAN
|
|
460
|
+
{"EUCLEAN", EUCLEAN },
|
|
461
|
+
#endif
|
|
462
|
+
#ifdef EUNATCH
|
|
463
|
+
{"EUNATCH", EUNATCH },
|
|
464
|
+
#endif
|
|
465
|
+
#ifdef EUSERS
|
|
466
|
+
{"EUSERS", EUSERS },
|
|
467
|
+
#endif
|
|
468
|
+
#ifdef EWOULDBLOCK
|
|
469
|
+
{"EWOULDBLOCK", EWOULDBLOCK },
|
|
470
|
+
#endif
|
|
471
|
+
#ifdef EXDEV
|
|
472
|
+
{"EXDEV", EXDEV },
|
|
473
|
+
#endif
|
|
474
|
+
#ifdef EXFULL
|
|
475
|
+
{"EXFULL", EXFULL },
|
|
476
|
+
#endif
|
|
477
|
+
#ifdef STRUNCATE
|
|
478
|
+
{"STRUNCATE", STRUNCATE },
|
|
479
|
+
#endif
|
|
480
|
+
};
|
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
#ifdef _WIN32
|
|
28
28
|
#include "win32.hh"
|
|
29
29
|
#endif
|
|
30
|
+
#include "errno.inc"
|
|
30
31
|
|
|
31
32
|
#ifdef _WIN32
|
|
32
33
|
#ifndef NOMINMAX
|
|
@@ -755,6 +756,26 @@ static Napi::Value CallFree(const Napi::CallbackInfo &info)
|
|
|
755
756
|
return env.Undefined();
|
|
756
757
|
}
|
|
757
758
|
|
|
759
|
+
static Napi::Value GetOrSetErrNo(const Napi::CallbackInfo &info)
|
|
760
|
+
{
|
|
761
|
+
Napi::Env env = info.Env();
|
|
762
|
+
InstanceData *instance = env.GetInstanceData<InstanceData>();
|
|
763
|
+
|
|
764
|
+
if (info.Length() >= 1) {
|
|
765
|
+
Napi::Number value = info[0].As<Napi::Number>();
|
|
766
|
+
|
|
767
|
+
if (!value.IsNumber()) {
|
|
768
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for errno, expected integer", GetValueType(instance, value));
|
|
769
|
+
return env.Null();
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
errno = value;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
Napi::Number ret = Napi::Number::New(env, errno);
|
|
776
|
+
return ret;
|
|
777
|
+
}
|
|
778
|
+
|
|
758
779
|
static Napi::Value CreateArrayType(const Napi::CallbackInfo &info)
|
|
759
780
|
{
|
|
760
781
|
Napi::Env env = info.Env();
|
|
@@ -2071,6 +2092,22 @@ static void SetExports(Napi::Env env, Func func)
|
|
|
2071
2092
|
func("decode", Napi::Function::New(env, DecodeValue));
|
|
2072
2093
|
func("address", Napi::Function::New(env, GetPointerAddress));
|
|
2073
2094
|
|
|
2095
|
+
func("errno", Napi::Function::New(env, GetOrSetErrNo));
|
|
2096
|
+
|
|
2097
|
+
Napi::Object os = Napi::Object::New(env);
|
|
2098
|
+
func("os", os);
|
|
2099
|
+
|
|
2100
|
+
// Init constants mapping
|
|
2101
|
+
{
|
|
2102
|
+
Napi::Object codes = Napi::Object::New(env);
|
|
2103
|
+
|
|
2104
|
+
for (const ErrnoCodeInfo &info: ErrnoCodes) {
|
|
2105
|
+
codes.Set(info.name, Napi::Number::New(env, info.value));
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
os.Set("errno", codes);
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2074
2111
|
#if defined(_WIN32)
|
|
2075
2112
|
func("extension", Napi::String::New(env, ".dll"));
|
|
2076
2113
|
#elif defined(__APPLE__)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|