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.
- package/README.md +3 -1
- package/cli.js +155 -27
- package/node/include/js_node.h +2 -0
- package/node/prelude/async_hooks.js +0 -0
- package/node/prelude/buffer.js +0 -0
- package/node/prelude/events.js +0 -0
- package/node/prelude/fs.js +0 -0
- package/node/prelude/http2.js +0 -0
- package/node/prelude/internal/crypto/asym.js +0 -0
- package/node/prelude/internal/crypto/cipher.js +0 -0
- package/node/prelude/internal/crypto/kdf.js +0 -0
- package/node/prelude/internal/crypto/keys.js +0 -0
- package/node/prelude/internal/crypto/random.js +0 -0
- package/node/prelude/internal/crypto/util.js +0 -0
- package/node/prelude/internal/errors.js +0 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/tls/wrap.js +5 -2
- package/node/prelude/module.js +0 -0
- package/node/prelude/net.js +1 -2
- package/node/prelude/os.js +2 -2
- package/node/prelude/path.js +0 -0
- package/node/prelude/process.js +0 -0
- package/node/prelude/querystring.js +0 -0
- package/node/prelude/stream.js +0 -0
- package/node/prelude/stream_promises.js +0 -0
- package/node/prelude/stream_web.js +0 -0
- package/node/prelude/string_decoder.js +0 -0
- package/node/prelude/tty.js +0 -0
- package/node/prelude/url.js +0 -0
- package/node/prelude/util.js +0 -0
- package/node/prelude/zlib.js +0 -0
- package/node/src/host_fs.c +10 -2
- package/node/src/host_os.c +0 -0
- package/node/src/host_sys.c +44 -32
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/libuv/src/win/async.c +98 -0
- package/node/third_party/libuv/src/win/atomicops-inl.h +61 -0
- package/node/third_party/libuv/src/win/core.c +683 -0
- package/node/third_party/libuv/src/win/detect-wakeup.c +56 -0
- package/node/third_party/libuv/src/win/dl.c +135 -0
- package/node/third_party/libuv/src/win/error.c +183 -0
- package/node/third_party/libuv/src/win/fs-event.c +620 -0
- package/node/third_party/libuv/src/win/fs-fd-hash-inl.h +200 -0
- package/node/third_party/libuv/src/win/fs.c +3774 -0
- package/node/third_party/libuv/src/win/getaddrinfo.c +388 -0
- package/node/third_party/libuv/src/win/getnameinfo.c +146 -0
- package/node/third_party/libuv/src/win/handle-inl.h +180 -0
- package/node/third_party/libuv/src/win/handle.c +162 -0
- package/node/third_party/libuv/src/win/internal.h +335 -0
- package/node/third_party/libuv/src/win/loop-watcher.c +122 -0
- package/node/third_party/libuv/src/win/pipe.c +2725 -0
- package/node/third_party/libuv/src/win/poll.c +586 -0
- package/node/third_party/libuv/src/win/process-stdio.c +419 -0
- package/node/third_party/libuv/src/win/process.c +1407 -0
- package/node/third_party/libuv/src/win/req-inl.h +214 -0
- package/node/third_party/libuv/src/win/signal.c +282 -0
- package/node/third_party/libuv/src/win/snprintf.c +42 -0
- package/node/third_party/libuv/src/win/stream-inl.h +54 -0
- package/node/third_party/libuv/src/win/stream.c +252 -0
- package/node/third_party/libuv/src/win/tcp.c +1674 -0
- package/node/third_party/libuv/src/win/thread.c +568 -0
- package/node/third_party/libuv/src/win/tty.c +2460 -0
- package/node/third_party/libuv/src/win/udp.c +1162 -0
- package/node/third_party/libuv/src/win/util.c +1750 -0
- package/node/third_party/libuv/src/win/winapi.c +144 -0
- package/node/third_party/libuv/src/win/winapi.h +4831 -0
- package/node/third_party/libuv/src/win/winsock.c +575 -0
- package/node/third_party/libuv/src/win/winsock.h +160 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/package.json +3 -2
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +0 -0
- package/runtime/include/js_bigint.h +0 -0
- package/runtime/include/js_buffer.h +0 -0
- package/runtime/include/js_builtins.h +0 -0
- package/runtime/include/js_console.h +0 -0
- package/runtime/include/js_convert.h +0 -0
- package/runtime/include/js_core.def +0 -0
- package/runtime/include/js_error.h +0 -0
- package/runtime/include/js_exception.h +0 -0
- package/runtime/include/js_function.h +0 -0
- package/runtime/include/js_gc.h +0 -0
- package/runtime/include/js_generator.h +0 -0
- package/runtime/include/js_host.h +0 -0
- package/runtime/include/js_jobs.h +0 -0
- package/runtime/include/js_module.h +0 -0
- package/runtime/include/js_object.h +0 -0
- package/runtime/include/js_ops.h +0 -0
- package/runtime/include/js_promise.h +0 -0
- package/runtime/include/js_regexp.h +0 -0
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +0 -0
- package/runtime/include/js_web.h +0 -0
- package/runtime/include/jscell.h +0 -0
- package/runtime/include/jscontext.h +0 -0
- package/runtime/include/jsnum.h +0 -0
- package/runtime/include/jsstring.h +0 -0
- package/runtime/include/jsvalue.h +0 -0
- package/runtime/src/arguments.c +0 -0
- package/runtime/src/array.c +0 -0
- package/runtime/src/arraybuffer.c +0 -0
- package/runtime/src/async_iter.c +0 -0
- package/runtime/src/atoms.c +0 -0
- package/runtime/src/base64.c +0 -0
- package/runtime/src/bigint.c +0 -0
- package/runtime/src/blob.c +0 -0
- package/runtime/src/boringssl_support.cc +4 -1
- package/runtime/src/buffer.c +0 -0
- package/runtime/src/builtin_table.c +0 -0
- package/runtime/src/builtins.c +0 -0
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +0 -0
- package/runtime/src/components.c +0 -0
- package/runtime/src/console.c +0 -0
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +0 -0
- package/runtime/src/crypto.c +0 -0
- package/runtime/src/crypto_host.c +0 -0
- package/runtime/src/crypto_kdf.c +0 -0
- package/runtime/src/crypto_key.c +0 -0
- package/runtime/src/date.c +0 -0
- package/runtime/src/domexception.c +0 -0
- package/runtime/src/elements.c +0 -0
- package/runtime/src/elements.h +0 -0
- package/runtime/src/encoding.c +0 -0
- package/runtime/src/error.c +0 -0
- package/runtime/src/events.c +0 -0
- package/runtime/src/exception.c +0 -0
- package/runtime/src/fetch.c +0 -0
- package/runtime/src/function.c +0 -0
- package/runtime/src/gc.c +0 -0
- package/runtime/src/generator.c +0 -0
- package/runtime/src/global.c +0 -0
- package/runtime/src/headers.c +0 -0
- package/runtime/src/inspect.c +0 -0
- package/runtime/src/internal.h +0 -0
- package/runtime/src/iterate.c +0 -0
- package/runtime/src/iterator.c +0 -0
- package/runtime/src/jobs.c +0 -0
- package/runtime/src/jsnum.c +0 -0
- package/runtime/src/json.c +0 -0
- package/runtime/src/math.c +0 -0
- package/runtime/src/module.c +0 -0
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +0 -0
- package/runtime/src/ops.c +0 -0
- package/runtime/src/os.c +0 -0
- package/runtime/src/os.h +0 -0
- package/runtime/src/process.c +7 -0
- package/runtime/src/promise.c +0 -0
- package/runtime/src/proxy.c +0 -0
- package/runtime/src/reflect.c +0 -0
- package/runtime/src/regexp.c +0 -0
- package/runtime/src/regexp_anchor.h +0 -0
- package/runtime/src/regexp_message.h +0 -0
- package/runtime/src/shape.c +0 -0
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +0 -0
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +0 -0
- package/runtime/src/string_builtins.c +0 -0
- package/runtime/src/symbol.c +0 -0
- package/runtime/src/test_host.c +0 -0
- package/runtime/src/typedarray.c +0 -0
- package/runtime/src/tznames.gen.h +0 -0
- package/runtime/src/uri.c +0 -0
- package/runtime/src/url.c +0 -0
- package/runtime/src/weak.c +0 -0
- package/runtime/src/web.c +0 -0
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +0 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +0 -0
- package/runtime/third_party/ada-idna/convert.mjs +0 -0
- package/runtime/third_party/ada-idna/idna.c +0 -0
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +0 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/README.md +0 -0
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +0 -0
|
@@ -0,0 +1,252 @@
|
|
|
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
|
+
#include "req-inl.h"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {
|
|
31
|
+
int err;
|
|
32
|
+
if (uv__is_closing(stream)) {
|
|
33
|
+
return UV_EINVAL;
|
|
34
|
+
}
|
|
35
|
+
err = ERROR_INVALID_PARAMETER;
|
|
36
|
+
switch (stream->type) {
|
|
37
|
+
case UV_TCP:
|
|
38
|
+
err = uv__tcp_listen((uv_tcp_t*)stream, backlog, cb);
|
|
39
|
+
break;
|
|
40
|
+
case UV_NAMED_PIPE:
|
|
41
|
+
err = uv__pipe_listen((uv_pipe_t*)stream, backlog, cb);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
assert(0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return uv_translate_sys_error(err);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
int uv_accept(uv_stream_t* server, uv_stream_t* client) {
|
|
52
|
+
int err;
|
|
53
|
+
|
|
54
|
+
err = ERROR_INVALID_PARAMETER;
|
|
55
|
+
switch (server->type) {
|
|
56
|
+
case UV_TCP:
|
|
57
|
+
err = uv__tcp_accept((uv_tcp_t*)server, (uv_tcp_t*)client);
|
|
58
|
+
break;
|
|
59
|
+
case UV_NAMED_PIPE:
|
|
60
|
+
err = uv__pipe_accept((uv_pipe_t*)server, client);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
assert(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return uv_translate_sys_error(err);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
int uv__read_start(uv_stream_t* handle,
|
|
71
|
+
uv_alloc_cb alloc_cb,
|
|
72
|
+
uv_read_cb read_cb) {
|
|
73
|
+
int err;
|
|
74
|
+
|
|
75
|
+
err = ERROR_INVALID_PARAMETER;
|
|
76
|
+
switch (handle->type) {
|
|
77
|
+
case UV_TCP:
|
|
78
|
+
err = uv__tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb);
|
|
79
|
+
break;
|
|
80
|
+
case UV_NAMED_PIPE:
|
|
81
|
+
err = uv__pipe_read_start((uv_pipe_t*)handle, alloc_cb, read_cb);
|
|
82
|
+
break;
|
|
83
|
+
case UV_TTY:
|
|
84
|
+
err = uv__tty_read_start((uv_tty_t*) handle, alloc_cb, read_cb);
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
assert(0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return uv_translate_sys_error(err);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
int uv_read_stop(uv_stream_t* handle) {
|
|
95
|
+
int err;
|
|
96
|
+
|
|
97
|
+
if (!(handle->flags & UV_HANDLE_READING))
|
|
98
|
+
return 0;
|
|
99
|
+
|
|
100
|
+
err = 0;
|
|
101
|
+
if (handle->type == UV_TTY) {
|
|
102
|
+
err = uv__tty_read_stop((uv_tty_t*) handle);
|
|
103
|
+
} else if (handle->type == UV_NAMED_PIPE) {
|
|
104
|
+
uv__pipe_read_stop((uv_pipe_t*) handle);
|
|
105
|
+
} else {
|
|
106
|
+
handle->flags &= ~UV_HANDLE_READING;
|
|
107
|
+
DECREASE_ACTIVE_COUNT(handle->loop, handle);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return uv_translate_sys_error(err);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
int uv_write(uv_write_t* req,
|
|
115
|
+
uv_stream_t* handle,
|
|
116
|
+
const uv_buf_t bufs[],
|
|
117
|
+
unsigned int nbufs,
|
|
118
|
+
uv_write_cb cb) {
|
|
119
|
+
uv_loop_t* loop = handle->loop;
|
|
120
|
+
int err;
|
|
121
|
+
|
|
122
|
+
if (!(handle->flags & UV_HANDLE_WRITABLE)) {
|
|
123
|
+
return UV_EPIPE;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
err = ERROR_INVALID_PARAMETER;
|
|
127
|
+
switch (handle->type) {
|
|
128
|
+
case UV_TCP:
|
|
129
|
+
err = uv__tcp_write(loop, req, (uv_tcp_t*) handle, bufs, nbufs, cb);
|
|
130
|
+
break;
|
|
131
|
+
case UV_NAMED_PIPE:
|
|
132
|
+
err = uv__pipe_write(
|
|
133
|
+
loop, req, (uv_pipe_t*) handle, bufs, nbufs, NULL, cb);
|
|
134
|
+
return uv_translate_write_sys_error(err);
|
|
135
|
+
case UV_TTY:
|
|
136
|
+
err = uv__tty_write(loop, req, (uv_tty_t*) handle, bufs, nbufs, cb);
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
assert(0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return uv_translate_sys_error(err);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
int uv_write2(uv_write_t* req,
|
|
147
|
+
uv_stream_t* handle,
|
|
148
|
+
const uv_buf_t bufs[],
|
|
149
|
+
unsigned int nbufs,
|
|
150
|
+
uv_stream_t* send_handle,
|
|
151
|
+
uv_write_cb cb) {
|
|
152
|
+
uv_loop_t* loop = handle->loop;
|
|
153
|
+
int err;
|
|
154
|
+
|
|
155
|
+
if (send_handle == NULL) {
|
|
156
|
+
return uv_write(req, handle, bufs, nbufs, cb);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (handle->type != UV_NAMED_PIPE || !((uv_pipe_t*) handle)->ipc) {
|
|
160
|
+
return UV_EINVAL;
|
|
161
|
+
} else if (!(handle->flags & UV_HANDLE_WRITABLE)) {
|
|
162
|
+
return UV_EPIPE;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
err = uv__pipe_write(
|
|
166
|
+
loop, req, (uv_pipe_t*) handle, bufs, nbufs, send_handle, cb);
|
|
167
|
+
return uv_translate_write_sys_error(err);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
int uv_try_write(uv_stream_t* stream,
|
|
172
|
+
const uv_buf_t bufs[],
|
|
173
|
+
unsigned int nbufs) {
|
|
174
|
+
if (stream->flags & UV_HANDLE_CLOSING)
|
|
175
|
+
return UV_EBADF;
|
|
176
|
+
if (!(stream->flags & UV_HANDLE_WRITABLE))
|
|
177
|
+
return UV_EPIPE;
|
|
178
|
+
|
|
179
|
+
switch (stream->type) {
|
|
180
|
+
case UV_TCP:
|
|
181
|
+
return uv__tcp_try_write((uv_tcp_t*) stream, bufs, nbufs);
|
|
182
|
+
case UV_TTY:
|
|
183
|
+
return uv__tty_try_write((uv_tty_t*) stream, bufs, nbufs);
|
|
184
|
+
case UV_NAMED_PIPE:
|
|
185
|
+
return UV_EAGAIN;
|
|
186
|
+
default:
|
|
187
|
+
assert(0);
|
|
188
|
+
return UV_ENOSYS;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
int uv_try_write2(uv_stream_t* stream,
|
|
194
|
+
const uv_buf_t bufs[],
|
|
195
|
+
unsigned int nbufs,
|
|
196
|
+
uv_stream_t* send_handle) {
|
|
197
|
+
if (send_handle != NULL)
|
|
198
|
+
return UV_EAGAIN;
|
|
199
|
+
return uv_try_write(stream, bufs, nbufs);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) {
|
|
204
|
+
uv_loop_t* loop = handle->loop;
|
|
205
|
+
|
|
206
|
+
if (!(handle->flags & UV_HANDLE_WRITABLE) ||
|
|
207
|
+
uv__is_stream_shutting(handle) ||
|
|
208
|
+
uv__is_closing(handle)) {
|
|
209
|
+
return UV_ENOTCONN;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
UV_REQ_INIT(req, UV_SHUTDOWN);
|
|
213
|
+
req->handle = handle;
|
|
214
|
+
req->cb = cb;
|
|
215
|
+
|
|
216
|
+
handle->flags &= ~UV_HANDLE_WRITABLE;
|
|
217
|
+
handle->stream.conn.shutdown_req = req;
|
|
218
|
+
handle->reqs_pending++;
|
|
219
|
+
REGISTER_HANDLE_REQ(loop, handle);
|
|
220
|
+
|
|
221
|
+
if (handle->stream.conn.write_reqs_pending == 0) {
|
|
222
|
+
if (handle->type == UV_NAMED_PIPE)
|
|
223
|
+
uv__pipe_shutdown(loop, (uv_pipe_t*) handle, req);
|
|
224
|
+
else
|
|
225
|
+
uv__insert_pending_req(loop, (uv_req_t*) req);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
int uv_is_readable(const uv_stream_t* handle) {
|
|
233
|
+
return !!(handle->flags & UV_HANDLE_READABLE);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
int uv_is_writable(const uv_stream_t* handle) {
|
|
238
|
+
return !!(handle->flags & UV_HANDLE_WRITABLE);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
int uv_stream_set_blocking(uv_stream_t* handle, int blocking) {
|
|
243
|
+
if (handle->type != UV_NAMED_PIPE)
|
|
244
|
+
return UV_EINVAL;
|
|
245
|
+
|
|
246
|
+
if (blocking != 0)
|
|
247
|
+
handle->flags |= UV_HANDLE_BLOCKING_WRITES;
|
|
248
|
+
else
|
|
249
|
+
handle->flags &= ~UV_HANDLE_BLOCKING_WRITES;
|
|
250
|
+
|
|
251
|
+
return 0;
|
|
252
|
+
}
|