visaljs 0.0.3 → 0.0.5

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.
Files changed (266) hide show
  1. package/README.md +3 -1
  2. package/cli.js +155 -27
  3. package/node/include/js_node.h +2 -0
  4. package/node/prelude/async_hooks.js +0 -0
  5. package/node/prelude/buffer.js +0 -0
  6. package/node/prelude/events.js +0 -0
  7. package/node/prelude/fs.js +0 -0
  8. package/node/prelude/http2.js +0 -0
  9. package/node/prelude/internal/crypto/asym.js +0 -0
  10. package/node/prelude/internal/crypto/cipher.js +0 -0
  11. package/node/prelude/internal/crypto/kdf.js +0 -0
  12. package/node/prelude/internal/crypto/keys.js +0 -0
  13. package/node/prelude/internal/crypto/random.js +0 -0
  14. package/node/prelude/internal/crypto/util.js +0 -0
  15. package/node/prelude/internal/errors.js +0 -0
  16. package/node/prelude/internal/querystring.js +0 -0
  17. package/node/prelude/internal/tls/wrap.js +5 -2
  18. package/node/prelude/module.js +0 -0
  19. package/node/prelude/net.js +1 -2
  20. package/node/prelude/os.js +2 -2
  21. package/node/prelude/path.js +0 -0
  22. package/node/prelude/process.js +0 -0
  23. package/node/prelude/querystring.js +0 -0
  24. package/node/prelude/stream.js +0 -0
  25. package/node/prelude/stream_promises.js +0 -0
  26. package/node/prelude/stream_web.js +0 -0
  27. package/node/prelude/string_decoder.js +0 -0
  28. package/node/prelude/tty.js +0 -0
  29. package/node/prelude/url.js +0 -0
  30. package/node/prelude/util.js +0 -0
  31. package/node/prelude/zlib.js +0 -0
  32. package/node/src/host_fs.c +10 -2
  33. package/node/src/host_os.c +0 -0
  34. package/node/src/host_sys.c +44 -32
  35. package/node/third_party/libuv/LICENSE +0 -0
  36. package/node/third_party/libuv/include/uv/aix.h +0 -0
  37. package/node/third_party/libuv/include/uv/bsd.h +0 -0
  38. package/node/third_party/libuv/include/uv/darwin.h +0 -0
  39. package/node/third_party/libuv/include/uv/errno.h +0 -0
  40. package/node/third_party/libuv/include/uv/linux.h +0 -0
  41. package/node/third_party/libuv/include/uv/os390.h +0 -0
  42. package/node/third_party/libuv/include/uv/posix.h +0 -0
  43. package/node/third_party/libuv/include/uv/sunos.h +0 -0
  44. package/node/third_party/libuv/include/uv/threadpool.h +0 -0
  45. package/node/third_party/libuv/include/uv/tree.h +0 -0
  46. package/node/third_party/libuv/include/uv/unix.h +0 -0
  47. package/node/third_party/libuv/include/uv/version.h +0 -0
  48. package/node/third_party/libuv/include/uv/win.h +0 -0
  49. package/node/third_party/libuv/include/uv.h +0 -0
  50. package/node/third_party/libuv/src/fs-poll.c +0 -0
  51. package/node/third_party/libuv/src/heap-inl.h +0 -0
  52. package/node/third_party/libuv/src/idna.c +0 -0
  53. package/node/third_party/libuv/src/idna.h +0 -0
  54. package/node/third_party/libuv/src/inet.c +0 -0
  55. package/node/third_party/libuv/src/queue.h +0 -0
  56. package/node/third_party/libuv/src/random.c +0 -0
  57. package/node/third_party/libuv/src/strscpy.c +0 -0
  58. package/node/third_party/libuv/src/strscpy.h +0 -0
  59. package/node/third_party/libuv/src/strtok.c +0 -0
  60. package/node/third_party/libuv/src/strtok.h +0 -0
  61. package/node/third_party/libuv/src/thread-common.c +0 -0
  62. package/node/third_party/libuv/src/threadpool.c +0 -0
  63. package/node/third_party/libuv/src/timer.c +0 -0
  64. package/node/third_party/libuv/src/unix/async.c +0 -0
  65. package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
  66. package/node/third_party/libuv/src/unix/core.c +0 -0
  67. package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
  68. package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
  69. package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
  70. package/node/third_party/libuv/src/unix/darwin.c +0 -0
  71. package/node/third_party/libuv/src/unix/dl.c +0 -0
  72. package/node/third_party/libuv/src/unix/fs.c +0 -0
  73. package/node/third_party/libuv/src/unix/fsevents.c +0 -0
  74. package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
  75. package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
  76. package/node/third_party/libuv/src/unix/internal.h +0 -0
  77. package/node/third_party/libuv/src/unix/kqueue.c +0 -0
  78. package/node/third_party/libuv/src/unix/linux.c +0 -0
  79. package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
  80. package/node/third_party/libuv/src/unix/loop.c +0 -0
  81. package/node/third_party/libuv/src/unix/pipe.c +0 -0
  82. package/node/third_party/libuv/src/unix/poll.c +0 -0
  83. package/node/third_party/libuv/src/unix/process.c +0 -0
  84. package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
  85. package/node/third_party/libuv/src/unix/proctitle.c +0 -0
  86. package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
  87. package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
  88. package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
  89. package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
  90. package/node/third_party/libuv/src/unix/signal.c +0 -0
  91. package/node/third_party/libuv/src/unix/stream.c +0 -0
  92. package/node/third_party/libuv/src/unix/tcp.c +0 -0
  93. package/node/third_party/libuv/src/unix/thread.c +0 -0
  94. package/node/third_party/libuv/src/unix/tty.c +0 -0
  95. package/node/third_party/libuv/src/unix/udp.c +0 -0
  96. package/node/third_party/libuv/src/uv-common.c +0 -0
  97. package/node/third_party/libuv/src/uv-common.h +0 -0
  98. package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
  99. package/node/third_party/libuv/src/version.c +0 -0
  100. package/node/third_party/libuv/src/win/async.c +98 -0
  101. package/node/third_party/libuv/src/win/atomicops-inl.h +61 -0
  102. package/node/third_party/libuv/src/win/core.c +683 -0
  103. package/node/third_party/libuv/src/win/detect-wakeup.c +56 -0
  104. package/node/third_party/libuv/src/win/dl.c +135 -0
  105. package/node/third_party/libuv/src/win/error.c +183 -0
  106. package/node/third_party/libuv/src/win/fs-event.c +620 -0
  107. package/node/third_party/libuv/src/win/fs-fd-hash-inl.h +200 -0
  108. package/node/third_party/libuv/src/win/fs.c +3774 -0
  109. package/node/third_party/libuv/src/win/getaddrinfo.c +388 -0
  110. package/node/third_party/libuv/src/win/getnameinfo.c +146 -0
  111. package/node/third_party/libuv/src/win/handle-inl.h +180 -0
  112. package/node/third_party/libuv/src/win/handle.c +162 -0
  113. package/node/third_party/libuv/src/win/internal.h +335 -0
  114. package/node/third_party/libuv/src/win/loop-watcher.c +122 -0
  115. package/node/third_party/libuv/src/win/pipe.c +2725 -0
  116. package/node/third_party/libuv/src/win/poll.c +586 -0
  117. package/node/third_party/libuv/src/win/process-stdio.c +419 -0
  118. package/node/third_party/libuv/src/win/process.c +1407 -0
  119. package/node/third_party/libuv/src/win/req-inl.h +214 -0
  120. package/node/third_party/libuv/src/win/signal.c +282 -0
  121. package/node/third_party/libuv/src/win/snprintf.c +42 -0
  122. package/node/third_party/libuv/src/win/stream-inl.h +54 -0
  123. package/node/third_party/libuv/src/win/stream.c +252 -0
  124. package/node/third_party/libuv/src/win/tcp.c +1674 -0
  125. package/node/third_party/libuv/src/win/thread.c +568 -0
  126. package/node/third_party/libuv/src/win/tty.c +2460 -0
  127. package/node/third_party/libuv/src/win/udp.c +1162 -0
  128. package/node/third_party/libuv/src/win/util.c +1750 -0
  129. package/node/third_party/libuv/src/win/winapi.c +144 -0
  130. package/node/third_party/libuv/src/win/winapi.h +4831 -0
  131. package/node/third_party/libuv/src/win/winsock.c +575 -0
  132. package/node/third_party/libuv/src/win/winsock.h +160 -0
  133. package/node/third_party/llhttp/LICENSE +0 -0
  134. package/node/third_party/llhttp/api.c +0 -0
  135. package/node/third_party/llhttp/http.c +0 -0
  136. package/node/third_party/llhttp/llhttp.c +0 -0
  137. package/node/third_party/llhttp/llhttp.h +0 -0
  138. package/package.json +3 -2
  139. package/runtime/include/js_atoms.gen.h +0 -0
  140. package/runtime/include/js_atoms.h +0 -0
  141. package/runtime/include/js_bigint.h +0 -0
  142. package/runtime/include/js_buffer.h +0 -0
  143. package/runtime/include/js_builtins.h +0 -0
  144. package/runtime/include/js_console.h +0 -0
  145. package/runtime/include/js_convert.h +0 -0
  146. package/runtime/include/js_core.def +0 -0
  147. package/runtime/include/js_error.h +0 -0
  148. package/runtime/include/js_exception.h +0 -0
  149. package/runtime/include/js_function.h +0 -0
  150. package/runtime/include/js_gc.h +0 -0
  151. package/runtime/include/js_generator.h +0 -0
  152. package/runtime/include/js_host.h +0 -0
  153. package/runtime/include/js_jobs.h +0 -0
  154. package/runtime/include/js_module.h +0 -0
  155. package/runtime/include/js_object.h +0 -0
  156. package/runtime/include/js_ops.h +0 -0
  157. package/runtime/include/js_promise.h +0 -0
  158. package/runtime/include/js_regexp.h +0 -0
  159. package/runtime/include/js_runtime.h +0 -0
  160. package/runtime/include/js_symbol.h +0 -0
  161. package/runtime/include/js_web.h +0 -0
  162. package/runtime/include/jscell.h +0 -0
  163. package/runtime/include/jscontext.h +0 -0
  164. package/runtime/include/jsnum.h +0 -0
  165. package/runtime/include/jsstring.h +0 -0
  166. package/runtime/include/jsvalue.h +0 -0
  167. package/runtime/src/arguments.c +0 -0
  168. package/runtime/src/array.c +0 -0
  169. package/runtime/src/arraybuffer.c +0 -0
  170. package/runtime/src/async_iter.c +0 -0
  171. package/runtime/src/atoms.c +0 -0
  172. package/runtime/src/base64.c +0 -0
  173. package/runtime/src/bigint.c +0 -0
  174. package/runtime/src/blob.c +0 -0
  175. package/runtime/src/boringssl_support.cc +4 -1
  176. package/runtime/src/buffer.c +0 -0
  177. package/runtime/src/builtin_table.c +0 -0
  178. package/runtime/src/builtins.c +0 -0
  179. package/runtime/src/builtins_util.h +0 -0
  180. package/runtime/src/collections.c +0 -0
  181. package/runtime/src/components.c +0 -0
  182. package/runtime/src/console.c +0 -0
  183. package/runtime/src/convert.c +0 -0
  184. package/runtime/src/core_all.c +0 -0
  185. package/runtime/src/crypto.c +0 -0
  186. package/runtime/src/crypto_host.c +0 -0
  187. package/runtime/src/crypto_kdf.c +0 -0
  188. package/runtime/src/crypto_key.c +0 -0
  189. package/runtime/src/date.c +0 -0
  190. package/runtime/src/domexception.c +0 -0
  191. package/runtime/src/elements.c +0 -0
  192. package/runtime/src/elements.h +0 -0
  193. package/runtime/src/encoding.c +0 -0
  194. package/runtime/src/error.c +0 -0
  195. package/runtime/src/events.c +0 -0
  196. package/runtime/src/exception.c +0 -0
  197. package/runtime/src/fetch.c +0 -0
  198. package/runtime/src/function.c +0 -0
  199. package/runtime/src/gc.c +0 -0
  200. package/runtime/src/generator.c +0 -0
  201. package/runtime/src/global.c +0 -0
  202. package/runtime/src/headers.c +0 -0
  203. package/runtime/src/inspect.c +0 -0
  204. package/runtime/src/internal.h +0 -0
  205. package/runtime/src/iterate.c +0 -0
  206. package/runtime/src/iterator.c +0 -0
  207. package/runtime/src/jobs.c +0 -0
  208. package/runtime/src/jsnum.c +0 -0
  209. package/runtime/src/json.c +0 -0
  210. package/runtime/src/math.c +0 -0
  211. package/runtime/src/module.c +0 -0
  212. package/runtime/src/number.c +0 -0
  213. package/runtime/src/object.c +0 -0
  214. package/runtime/src/ops.c +0 -0
  215. package/runtime/src/os.c +0 -0
  216. package/runtime/src/os.h +0 -0
  217. package/runtime/src/process.c +7 -0
  218. package/runtime/src/promise.c +0 -0
  219. package/runtime/src/proxy.c +0 -0
  220. package/runtime/src/reflect.c +0 -0
  221. package/runtime/src/regexp.c +0 -0
  222. package/runtime/src/regexp_anchor.h +0 -0
  223. package/runtime/src/regexp_message.h +0 -0
  224. package/runtime/src/shape.c +0 -0
  225. package/runtime/src/shape.h +0 -0
  226. package/runtime/src/streams.c +0 -0
  227. package/runtime/src/streams.h +0 -0
  228. package/runtime/src/string.c +0 -0
  229. package/runtime/src/string_builtins.c +0 -0
  230. package/runtime/src/symbol.c +0 -0
  231. package/runtime/src/test_host.c +0 -0
  232. package/runtime/src/typedarray.c +0 -0
  233. package/runtime/src/tznames.gen.h +0 -0
  234. package/runtime/src/uri.c +0 -0
  235. package/runtime/src/url.c +0 -0
  236. package/runtime/src/weak.c +0 -0
  237. package/runtime/src/web.c +0 -0
  238. package/runtime/src/wrapper.c +0 -0
  239. package/runtime/src/writable.c +0 -0
  240. package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
  241. package/runtime/third_party/ada-idna/README.md +0 -0
  242. package/runtime/third_party/ada-idna/convert.mjs +0 -0
  243. package/runtime/third_party/ada-idna/idna.c +0 -0
  244. package/runtime/third_party/ada-idna/idna.h +0 -0
  245. package/runtime/third_party/ada-idna/idna_tables.h +0 -0
  246. package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
  247. package/runtime/third_party/quickjs-dtoa/README.md +0 -0
  248. package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
  249. package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
  250. package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
  251. package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
  252. package/runtime/third_party/quickjs-regexp/README.md +0 -0
  253. package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
  254. package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
  255. package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
  256. package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
  257. package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
  258. package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
  259. package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
  260. package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
  261. package/runtime/third_party/v8-ieee754/LICENSE +0 -0
  262. package/runtime/third_party/v8-ieee754/README.md +0 -0
  263. package/runtime/third_party/v8-ieee754/convert.py +0 -0
  264. package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
  265. package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
  266. package/runtime/tools/regexp_compile.c +0 -0
@@ -0,0 +1,162 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ #include <assert.h>
23
+ #include <io.h>
24
+ #include <stdlib.h>
25
+
26
+ #include "uv.h"
27
+ #include "internal.h"
28
+ #include "handle-inl.h"
29
+
30
+
31
+ uv_handle_type uv_guess_handle(uv_file file) {
32
+ HANDLE handle;
33
+ DWORD mode;
34
+
35
+ if (file < 0) {
36
+ return UV_UNKNOWN_HANDLE;
37
+ }
38
+
39
+ handle = uv__get_osfhandle(file);
40
+
41
+ switch (GetFileType(handle)) {
42
+ case FILE_TYPE_CHAR:
43
+ if (GetConsoleMode(handle, &mode)) {
44
+ return UV_TTY;
45
+ } else {
46
+ return UV_FILE;
47
+ }
48
+
49
+ case FILE_TYPE_PIPE:
50
+ return UV_NAMED_PIPE;
51
+
52
+ case FILE_TYPE_DISK:
53
+ return UV_FILE;
54
+
55
+ default:
56
+ return UV_UNKNOWN_HANDLE;
57
+ }
58
+ }
59
+
60
+
61
+ int uv_is_active(const uv_handle_t* handle) {
62
+ return (handle->flags & UV_HANDLE_ACTIVE) &&
63
+ !(handle->flags & UV_HANDLE_CLOSING);
64
+ }
65
+
66
+
67
+ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
68
+ uv_loop_t* loop = handle->loop;
69
+
70
+ if (handle->flags & UV_HANDLE_CLOSING) {
71
+ assert(0);
72
+ return;
73
+ }
74
+
75
+ handle->close_cb = cb;
76
+
77
+ /* Handle-specific close actions */
78
+ switch (handle->type) {
79
+ case UV_TCP:
80
+ uv__tcp_close(loop, (uv_tcp_t*)handle);
81
+ return;
82
+
83
+ case UV_NAMED_PIPE:
84
+ uv__pipe_close(loop, (uv_pipe_t*) handle);
85
+ return;
86
+
87
+ case UV_TTY:
88
+ uv__tty_close((uv_tty_t*) handle);
89
+ return;
90
+
91
+ case UV_UDP:
92
+ uv__udp_close(loop, (uv_udp_t*) handle);
93
+ return;
94
+
95
+ case UV_POLL:
96
+ uv__poll_close(loop, (uv_poll_t*) handle);
97
+ return;
98
+
99
+ case UV_TIMER:
100
+ uv_timer_stop((uv_timer_t*)handle);
101
+ uv__handle_closing(handle);
102
+ uv__want_endgame(loop, handle);
103
+ return;
104
+
105
+ case UV_PREPARE:
106
+ uv_prepare_stop((uv_prepare_t*)handle);
107
+ uv__handle_closing(handle);
108
+ uv__want_endgame(loop, handle);
109
+ return;
110
+
111
+ case UV_CHECK:
112
+ uv_check_stop((uv_check_t*)handle);
113
+ uv__handle_closing(handle);
114
+ uv__want_endgame(loop, handle);
115
+ return;
116
+
117
+ case UV_IDLE:
118
+ uv_idle_stop((uv_idle_t*)handle);
119
+ uv__handle_closing(handle);
120
+ uv__want_endgame(loop, handle);
121
+ return;
122
+
123
+ case UV_ASYNC:
124
+ uv__async_close(loop, (uv_async_t*) handle);
125
+ return;
126
+
127
+ case UV_SIGNAL:
128
+ uv__signal_close(loop, (uv_signal_t*) handle);
129
+ return;
130
+
131
+ case UV_PROCESS:
132
+ uv__process_close(loop, (uv_process_t*) handle);
133
+ return;
134
+
135
+ case UV_FS_EVENT:
136
+ uv__fs_event_close(loop, (uv_fs_event_t*) handle);
137
+ return;
138
+
139
+ case UV_FS_POLL:
140
+ uv__fs_poll_close((uv_fs_poll_t*) handle);
141
+ uv__handle_closing(handle);
142
+ return;
143
+
144
+ default:
145
+ /* Not supported */
146
+ abort();
147
+ }
148
+ }
149
+
150
+
151
+ int uv_is_closing(const uv_handle_t* handle) {
152
+ return !!(handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED));
153
+ }
154
+
155
+
156
+ uv_os_fd_t uv_get_osfhandle(int fd) {
157
+ return uv__get_osfhandle(fd);
158
+ }
159
+
160
+ int uv_open_osfhandle(uv_os_fd_t os_fd) {
161
+ return _open_osfhandle((intptr_t) os_fd, 0);
162
+ }
@@ -0,0 +1,335 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ #ifndef UV_WIN_INTERNAL_H_
23
+ #define UV_WIN_INTERNAL_H_
24
+
25
+ #include "uv.h"
26
+ #include "../uv-common.h"
27
+
28
+ #include "uv/tree.h"
29
+ #include "winapi.h"
30
+ #include "winsock.h"
31
+
32
+ #ifdef _MSC_VER
33
+ # define INLINE __inline
34
+ # define UV_THREAD_LOCAL __declspec( thread )
35
+ #else
36
+ # define INLINE inline
37
+ # define UV_THREAD_LOCAL __thread
38
+ #endif
39
+
40
+
41
+ #ifdef _DEBUG
42
+
43
+ extern UV_THREAD_LOCAL int uv__crt_assert_enabled;
44
+
45
+ #define UV_BEGIN_DISABLE_CRT_ASSERT() \
46
+ { \
47
+ int uv__saved_crt_assert_enabled = uv__crt_assert_enabled; \
48
+ uv__crt_assert_enabled = FALSE;
49
+
50
+
51
+ #define UV_END_DISABLE_CRT_ASSERT() \
52
+ uv__crt_assert_enabled = uv__saved_crt_assert_enabled; \
53
+ }
54
+
55
+ #else
56
+ #define UV_BEGIN_DISABLE_CRT_ASSERT()
57
+ #define UV_END_DISABLE_CRT_ASSERT()
58
+ #endif
59
+
60
+ /*
61
+ * TCP
62
+ */
63
+
64
+ typedef enum {
65
+ UV__IPC_SOCKET_XFER_NONE = 0,
66
+ UV__IPC_SOCKET_XFER_TCP_CONNECTION,
67
+ UV__IPC_SOCKET_XFER_TCP_SERVER
68
+ } uv__ipc_socket_xfer_type_t;
69
+
70
+ typedef struct {
71
+ WSAPROTOCOL_INFOW socket_info;
72
+ uint32_t delayed_error;
73
+ } uv__ipc_socket_xfer_info_t;
74
+
75
+ int uv__tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
76
+ int uv__tcp_accept(uv_tcp_t* server, uv_tcp_t* client);
77
+ int uv__tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
78
+ uv_read_cb read_cb);
79
+ int uv__tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle,
80
+ const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb);
81
+ int uv__tcp_try_write(uv_tcp_t* handle, const uv_buf_t bufs[],
82
+ unsigned int nbufs);
83
+
84
+ void uv__process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, uv_req_t* req);
85
+ void uv__process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle,
86
+ uv_write_t* req);
87
+ void uv__process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
88
+ uv_req_t* req);
89
+ void uv__process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
90
+ uv_connect_t* req);
91
+ void uv__process_tcp_shutdown_req(uv_loop_t* loop,
92
+ uv_tcp_t* stream,
93
+ uv_shutdown_t* req);
94
+
95
+ void uv__tcp_close(uv_loop_t* loop, uv_tcp_t* tcp);
96
+ void uv__tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle);
97
+
98
+ int uv__tcp_xfer_export(uv_tcp_t* handle,
99
+ int pid,
100
+ uv__ipc_socket_xfer_type_t* xfer_type,
101
+ uv__ipc_socket_xfer_info_t* xfer_info);
102
+ int uv__tcp_xfer_import(uv_tcp_t* tcp,
103
+ uv__ipc_socket_xfer_type_t xfer_type,
104
+ uv__ipc_socket_xfer_info_t* xfer_info);
105
+
106
+
107
+ /*
108
+ * UDP
109
+ */
110
+ void uv__process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req);
111
+ void uv__process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle,
112
+ uv_udp_send_t* req);
113
+
114
+ void uv__udp_close(uv_loop_t* loop, uv_udp_t* handle);
115
+ void uv__udp_endgame(uv_loop_t* loop, uv_udp_t* handle);
116
+
117
+
118
+ /*
119
+ * Pipes
120
+ */
121
+ int uv__create_stdio_pipe_pair(uv_loop_t* loop,
122
+ uv_pipe_t* parent_pipe, HANDLE* child_pipe_ptr, unsigned int flags);
123
+
124
+ int uv__pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
125
+ int uv__pipe_accept(uv_pipe_t* server, uv_stream_t* client);
126
+ int uv__pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
127
+ uv_read_cb read_cb);
128
+ void uv__pipe_read_stop(uv_pipe_t* handle);
129
+ int uv__pipe_write(uv_loop_t* loop,
130
+ uv_write_t* req,
131
+ uv_pipe_t* handle,
132
+ const uv_buf_t bufs[],
133
+ size_t nbufs,
134
+ uv_stream_t* send_handle,
135
+ uv_write_cb cb);
136
+ void uv__pipe_shutdown(uv_loop_t* loop, uv_pipe_t* handle, uv_shutdown_t* req);
137
+
138
+ void uv__process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
139
+ uv_req_t* req);
140
+ void uv__process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
141
+ uv_write_t* req);
142
+ void uv__process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle,
143
+ uv_req_t* raw_req);
144
+ void uv__process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle,
145
+ uv_connect_t* req);
146
+ void uv__process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle,
147
+ uv_shutdown_t* req);
148
+
149
+ void uv__pipe_close(uv_loop_t* loop, uv_pipe_t* handle);
150
+ void uv__pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle);
151
+
152
+
153
+ /*
154
+ * TTY
155
+ */
156
+ void uv__console_init(void);
157
+
158
+ int uv__tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
159
+ uv_read_cb read_cb);
160
+ int uv__tty_read_stop(uv_tty_t* handle);
161
+ int uv__tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle,
162
+ const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb);
163
+ int uv__tty_try_write(uv_tty_t* handle, const uv_buf_t bufs[],
164
+ unsigned int nbufs);
165
+ void uv__tty_close(uv_tty_t* handle);
166
+
167
+ void uv__process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle,
168
+ uv_req_t* req);
169
+ void uv__process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
170
+ uv_write_t* req);
171
+ #define uv__process_tty_accept_req(loop, handle, req) abort()
172
+ #define uv__process_tty_connect_req(loop, handle, req) abort()
173
+ void uv__process_tty_shutdown_req(uv_loop_t* loop,
174
+ uv_tty_t* stream,
175
+ uv_shutdown_t* req);
176
+ void uv__tty_endgame(uv_loop_t* loop, uv_tty_t* handle);
177
+
178
+
179
+ /*
180
+ * Poll watchers
181
+ */
182
+ void uv__process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
183
+ uv_req_t* req);
184
+
185
+ int uv__poll_close(uv_loop_t* loop, uv_poll_t* handle);
186
+ void uv__poll_endgame(uv_loop_t* loop, uv_poll_t* handle);
187
+
188
+
189
+ /*
190
+ * Loop watchers
191
+ */
192
+ void uv__loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle);
193
+
194
+ void uv__prepare_invoke(uv_loop_t* loop);
195
+ void uv__check_invoke(uv_loop_t* loop);
196
+ void uv__idle_invoke(uv_loop_t* loop);
197
+
198
+ void uv__once_init(void);
199
+
200
+
201
+ /*
202
+ * Async watcher
203
+ */
204
+ void uv__async_close(uv_loop_t* loop, uv_async_t* handle);
205
+ void uv__async_endgame(uv_loop_t* loop, uv_async_t* handle);
206
+
207
+ void uv__process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle,
208
+ uv_req_t* req);
209
+
210
+
211
+ /*
212
+ * Signal watcher
213
+ */
214
+ void uv__signals_init(void);
215
+ int uv__signal_dispatch(int signum);
216
+
217
+ void uv__signal_close(uv_loop_t* loop, uv_signal_t* handle);
218
+ void uv__signal_endgame(uv_loop_t* loop, uv_signal_t* handle);
219
+
220
+ void uv__process_signal_req(uv_loop_t* loop, uv_signal_t* handle,
221
+ uv_req_t* req);
222
+
223
+
224
+ /*
225
+ * Spawn
226
+ */
227
+ void uv__process_proc_exit(uv_loop_t* loop, uv_process_t* handle);
228
+ void uv__process_close(uv_loop_t* loop, uv_process_t* handle);
229
+ void uv__process_endgame(uv_loop_t* loop, uv_process_t* handle);
230
+
231
+
232
+ /*
233
+ * FS
234
+ */
235
+ void uv__fs_init(void);
236
+
237
+
238
+ /*
239
+ * FS Event
240
+ */
241
+ void uv__process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
242
+ uv_fs_event_t* handle);
243
+ void uv__fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle);
244
+ void uv__fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle);
245
+
246
+
247
+ /*
248
+ * Stat poller.
249
+ */
250
+ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle);
251
+
252
+
253
+ /*
254
+ * Utilities.
255
+ */
256
+ void uv__util_init(void);
257
+
258
+ uint64_t uv__hrtime(unsigned int scale);
259
+ __declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall);
260
+ int uv__convert_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char** utf8);
261
+ int uv__copy_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char* utf8, size_t *size);
262
+ int uv__convert_utf8_to_utf16(const char* utf8, WCHAR** utf16);
263
+
264
+ typedef int (WINAPI *uv__peersockfunc)(SOCKET, struct sockaddr*, int*);
265
+
266
+ int uv__getsockpeername(const uv_handle_t* handle,
267
+ uv__peersockfunc func,
268
+ struct sockaddr* name,
269
+ int* namelen,
270
+ int delayed_error);
271
+
272
+ int uv__random_rtlgenrandom(void* buf, size_t buflen);
273
+
274
+
275
+ /*
276
+ * Process stdio handles.
277
+ */
278
+ int uv__stdio_create(uv_loop_t* loop,
279
+ const uv_process_options_t* options,
280
+ BYTE** buffer_ptr);
281
+ void uv__stdio_destroy(BYTE* buffer);
282
+ void uv__stdio_noinherit(BYTE* buffer);
283
+ int uv__stdio_verify(BYTE* buffer, WORD size);
284
+ WORD uv__stdio_size(BYTE* buffer);
285
+ HANDLE uv__stdio_handle(BYTE* buffer, int fd);
286
+
287
+
288
+ /*
289
+ * Winapi and ntapi utility functions
290
+ */
291
+ void uv__winapi_init(void);
292
+
293
+
294
+ /*
295
+ * Winsock utility functions
296
+ */
297
+ void uv__winsock_init(void);
298
+
299
+ int uv__ntstatus_to_winsock_error(NTSTATUS status);
300
+
301
+ BOOL uv__get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target);
302
+ BOOL uv__get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target);
303
+
304
+ int WSAAPI uv__wsarecv_workaround(SOCKET socket, WSABUF* buffers,
305
+ DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped,
306
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
307
+ int WSAAPI uv__wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers,
308
+ DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr,
309
+ int* addr_len, WSAOVERLAPPED *overlapped,
310
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
311
+
312
+ int WSAAPI uv__msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in,
313
+ AFD_POLL_INFO* info_out, OVERLAPPED* overlapped);
314
+
315
+ /* Whether there are any non-IFS LSPs stacked on TCP */
316
+ extern int uv_tcp_non_ifs_lsp_ipv4;
317
+ extern int uv_tcp_non_ifs_lsp_ipv6;
318
+
319
+ /* Ip address used to bind to any port at any interface */
320
+ extern struct sockaddr_in uv_addr_ip4_any_;
321
+ extern struct sockaddr_in6 uv_addr_ip6_any_;
322
+
323
+ /*
324
+ * Wake all loops with fake message
325
+ */
326
+ void uv__wake_all_loops(void);
327
+
328
+ /*
329
+ * Init system wake-up detection
330
+ */
331
+ void uv__init_detect_system_wakeup(void);
332
+
333
+ int uv_translate_write_sys_error(int sys_errno);
334
+
335
+ #endif /* UV_WIN_INTERNAL_H_ */
@@ -0,0 +1,122 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ #include <assert.h>
23
+
24
+ #include "uv.h"
25
+ #include "internal.h"
26
+ #include "handle-inl.h"
27
+
28
+
29
+ void uv__loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) {
30
+ if (handle->flags & UV_HANDLE_CLOSING) {
31
+ assert(!(handle->flags & UV_HANDLE_CLOSED));
32
+ handle->flags |= UV_HANDLE_CLOSED;
33
+ uv__handle_close(handle);
34
+ }
35
+ }
36
+
37
+
38
+ #define UV_LOOP_WATCHER_DEFINE(name, NAME) \
39
+ int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
40
+ uv__handle_init(loop, (uv_handle_t*) handle, UV_##NAME); \
41
+ \
42
+ return 0; \
43
+ } \
44
+ \
45
+ \
46
+ int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \
47
+ uv_loop_t* loop = handle->loop; \
48
+ uv_##name##_t* old_head; \
49
+ \
50
+ assert(handle->type == UV_##NAME); \
51
+ \
52
+ if (uv__is_active(handle)) \
53
+ return 0; \
54
+ \
55
+ if (cb == NULL) \
56
+ return UV_EINVAL; \
57
+ \
58
+ old_head = loop->name##_handles; \
59
+ \
60
+ handle->name##_next = old_head; \
61
+ handle->name##_prev = NULL; \
62
+ \
63
+ if (old_head) { \
64
+ old_head->name##_prev = handle; \
65
+ } \
66
+ \
67
+ loop->name##_handles = handle; \
68
+ \
69
+ handle->name##_cb = cb; \
70
+ uv__handle_start(handle); \
71
+ \
72
+ return 0; \
73
+ } \
74
+ \
75
+ \
76
+ int uv_##name##_stop(uv_##name##_t* handle) { \
77
+ uv_loop_t* loop = handle->loop; \
78
+ \
79
+ assert(handle->type == UV_##NAME); \
80
+ \
81
+ if (!uv__is_active(handle)) \
82
+ return 0; \
83
+ \
84
+ /* Update loop head if needed */ \
85
+ if (loop->name##_handles == handle) { \
86
+ loop->name##_handles = handle->name##_next; \
87
+ } \
88
+ \
89
+ /* Update the iterator-next pointer of needed */ \
90
+ if (loop->next_##name##_handle == handle) { \
91
+ loop->next_##name##_handle = handle->name##_next; \
92
+ } \
93
+ \
94
+ if (handle->name##_prev) { \
95
+ handle->name##_prev->name##_next = handle->name##_next; \
96
+ } \
97
+ if (handle->name##_next) { \
98
+ handle->name##_next->name##_prev = handle->name##_prev; \
99
+ } \
100
+ \
101
+ uv__handle_stop(handle); \
102
+ \
103
+ return 0; \
104
+ } \
105
+ \
106
+ \
107
+ void uv__##name##_invoke(uv_loop_t* loop) { \
108
+ uv_##name##_t* handle; \
109
+ \
110
+ (loop)->next_##name##_handle = (loop)->name##_handles; \
111
+ \
112
+ while ((loop)->next_##name##_handle != NULL) { \
113
+ handle = (loop)->next_##name##_handle; \
114
+ (loop)->next_##name##_handle = handle->name##_next; \
115
+ \
116
+ handle->name##_cb(handle); \
117
+ } \
118
+ }
119
+
120
+ UV_LOOP_WATCHER_DEFINE(prepare, PREPARE)
121
+ UV_LOOP_WATCHER_DEFINE(check, CHECK)
122
+ UV_LOOP_WATCHER_DEFINE(idle, IDLE)