view release on metacpan or search on metacpan
libuv/configure.ac view on Meta::CPAN
LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32"
])
AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])])
AS_CASE([$host_os], [kfreebsd*], [
LIBS="$LIBS -lfreebsd-glue"
])
AC_CHECK_HEADERS([sys/ahafs_evProds.h])
AC_CONFIG_FILES([Makefile libuv.pc])
AC_CONFIG_LINKS([test/fixtures/empty_file:test/fixtures/empty_file])
AC_CONFIG_LINKS([test/fixtures/load_error.node:test/fixtures/load_error.node])
AC_OUTPUT
libuv/docs/src/tty.rst view on Meta::CPAN
.. versionadded:: 1.2.0
TTY mode type:
::
typedef enum {
/* Initial/normal terminal mode */
UV_TTY_MODE_NORMAL,
/* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */
UV_TTY_MODE_RAW,
/* Binary-safe I/O mode for IPC (Unix-only) */
UV_TTY_MODE_IO
} uv_tty_mode_t;
Public members
^^^^^^^^^^^^^^
libuv/include/uv.h view on Meta::CPAN
*/
struct uv_tty_s {
UV_HANDLE_FIELDS
UV_STREAM_FIELDS
UV_TTY_PRIVATE_FIELDS
};
typedef enum {
/* Initial/normal terminal mode */
UV_TTY_MODE_NORMAL,
/* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */
UV_TTY_MODE_RAW,
/* Binary-safe I/O mode for IPC (Unix-only) */
UV_TTY_MODE_IO
} uv_tty_mode_t;
UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode);
UV_EXTERN int uv_tty_reset_mode(void);
UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
libuv/include/uv/win.h view on Meta::CPAN
/* Used for readable TTY handles */ \
/* TODO: remove me in v2.x. */ \
HANDLE unused_; \
uv_buf_t read_line_buffer; \
HANDLE read_raw_wait; \
/* Fields used for translating win keystrokes into vt100 characters */ \
char last_key[8]; \
unsigned char last_key_offset; \
unsigned char last_key_len; \
WCHAR last_utf16_high_surrogate; \
INPUT_RECORD last_input_record; \
} rd; \
struct { \
/* Used for writable TTY handles */ \
/* utf8-to-utf16 conversion state */ \
unsigned int utf8_codepoint; \
unsigned char utf8_bytes_left; \
/* eol conversion state */ \
unsigned char previous_eol; \
/* ansi parser state */ \
unsigned char ansi_parser_state; \
libuv/src/win/process-stdio.c view on Meta::CPAN
* Clear the HANDLE_FLAG_INHERIT flag from all HANDLEs that were inherited
* the parent process. Don't check for errors - the stdio handles may not be
* valid, or may be closed already. There is no guarantee that this function
* does a perfect job.
*/
void uv_disable_stdio_inheritance(void) {
HANDLE handle;
STARTUPINFOW si;
/* Make the windows stdio handles non-inheritable. */
handle = GetStdHandle(STD_INPUT_HANDLE);
if (handle != NULL && handle != INVALID_HANDLE_VALUE)
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0);
handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle != NULL && handle != INVALID_HANDLE_VALUE)
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0);
handle = GetStdHandle(STD_ERROR_HANDLE);
if (handle != NULL && handle != INVALID_HANDLE_VALUE)
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0);
/* Make inherited CRT FDs non-inheritable. */
GetStartupInfoW(&si);
if (uv__stdio_verify(si.lpReserved2, si.cbReserved2))
libuv/src/win/tty.c view on Meta::CPAN
#define ANSI_NORMAL 0x00
#define ANSI_ESCAPE_SEEN 0x02
#define ANSI_CSI 0x04
#define ANSI_ST_CONTROL 0x08
#define ANSI_IGNORE 0x10
#define ANSI_IN_ARG 0x20
#define ANSI_IN_STRING 0x40
#define ANSI_BACKSLASH_SEEN 0x80
#define MAX_INPUT_BUFFER_LENGTH 8192
#define MAX_CONSOLE_CHAR 8192
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info);
static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info);
static int uv__cancel_read_console(uv_tty_t* handle);
libuv/src/win/tty.c view on Meta::CPAN
if (!(tty->flags & UV_HANDLE_TTY_READABLE)) {
return UV_EINVAL;
}
if (!!mode == !!(tty->flags & UV_HANDLE_TTY_RAW)) {
return 0;
}
switch (mode) {
case UV_TTY_MODE_NORMAL:
flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
break;
case UV_TTY_MODE_RAW:
flags = ENABLE_WINDOW_INPUT;
break;
case UV_TTY_MODE_IO:
return UV_ENOTSUP;
default:
return UV_EINVAL;
}
/* If currently reading, stop, and restart reading. */
if (tty->flags & UV_HANDLE_READING) {
was_reading = 1;
libuv/src/win/tty.c view on Meta::CPAN
handle->flags |= UV_HANDLE_READ_PENDING;
handle->reqs_pending++;
}
static DWORD CALLBACK uv_tty_line_read_thread(void* data) {
uv_loop_t* loop;
uv_tty_t* handle;
uv_req_t* req;
DWORD bytes, read_bytes;
WCHAR utf16[MAX_INPUT_BUFFER_LENGTH / 3];
DWORD chars, read_chars;
LONG status;
COORD pos;
BOOL read_console_success;
assert(data);
req = (uv_req_t*) data;
handle = (uv_tty_t*) req->data;
loop = handle->loop;
assert(handle->tty.rd.read_line_buffer.base != NULL);
assert(handle->tty.rd.read_line_buffer.len > 0);
/* ReadConsole can't handle big buffers. */
if (handle->tty.rd.read_line_buffer.len < MAX_INPUT_BUFFER_LENGTH) {
bytes = handle->tty.rd.read_line_buffer.len;
} else {
bytes = MAX_INPUT_BUFFER_LENGTH;
}
/* At last, unicode! One utf-16 codeunit never takes more than 3 utf-8
* codeunits to encode. */
chars = bytes / 3;
status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS);
if (status == TRAP_REQUESTED) {
SET_REQ_SUCCESS(req);
req->u.io.overlapped.InternalHigh = 0;
libuv/src/win/tty.c view on Meta::CPAN
return 0;
}
uv_tty_queue_read(loop, handle);
return 0;
}
int uv_tty_read_stop(uv_tty_t* handle) {
INPUT_RECORD record;
DWORD written, err;
handle->flags &= ~UV_HANDLE_READING;
DECREASE_ACTIVE_COUNT(handle->loop, handle);
if (!(handle->flags & UV_HANDLE_READ_PENDING))
return 0;
if (handle->flags & UV_HANDLE_TTY_RAW) {
/* Cancel raw read. Write some bullshit event to force the console wait to
libuv/src/win/tty.c view on Meta::CPAN
return err;
handle->flags |= UV_HANDLE_CANCELLATION_PENDING;
}
return 0;
}
static int uv__cancel_read_console(uv_tty_t* handle) {
HANDLE active_screen_buffer = INVALID_HANDLE_VALUE;
INPUT_RECORD record;
DWORD written;
DWORD err = 0;
LONG status;
assert(!(handle->flags & UV_HANDLE_CANCELLATION_PENDING));
/* Hold the output lock during the cancellation, to ensure that further
writes don't interfere with the screen state. It will be the ReadConsole
thread's responsibility to release the lock. */
uv_sem_wait(&uv_tty_output_lock);
libuv/src/win/winapi.h view on Meta::CPAN
#endif
#ifndef STATUS_CANCELLED
# define STATUS_CANCELLED ((NTSTATUS) 0xC0000120L)
#endif
#ifndef STATUS_CANNOT_DELETE
# define STATUS_CANNOT_DELETE ((NTSTATUS) 0xC0000121L)
#endif
#ifndef STATUS_INVALID_COMPUTER_NAME
# define STATUS_INVALID_COMPUTER_NAME ((NTSTATUS) 0xC0000122L)
#endif
#ifndef STATUS_FILE_DELETED
# define STATUS_FILE_DELETED ((NTSTATUS) 0xC0000123L)
#endif
#ifndef STATUS_SPECIAL_ACCOUNT
# define STATUS_SPECIAL_ACCOUNT ((NTSTATUS) 0xC0000124L)
#endif
libuv/test/benchmark-spawn.c view on Meta::CPAN
static int N = 1000;
static int done;
static uv_process_t process;
static uv_process_options_t options;
static char exepath[1024];
static size_t exepath_size = 1024;
static char* args[3];
static uv_pipe_t out;
#define OUTPUT_SIZE 1024
static char output[OUTPUT_SIZE];
static int output_used;
static int process_open;
static int pipe_open;
static void spawn(void);
static void maybe_spawn(void) {
libuv/test/benchmark-spawn.c view on Meta::CPAN
ASSERT(exit_status == 42);
ASSERT(term_signal == 0);
uv_close((uv_handle_t*)process, process_close_cb);
}
static void on_alloc(uv_handle_t* handle,
size_t suggested_size,
uv_buf_t* buf) {
buf->base = output + output_used;
buf->len = OUTPUT_SIZE - output_used;
}
static void pipe_close_cb(uv_handle_t* pipe) {
ASSERT(pipe_open == 1);
pipe_open = 0;
maybe_spawn();
}
libuv/test/test-spawn.c view on Meta::CPAN
static uv_process_options_t options;
static char exepath[1024];
static size_t exepath_size = 1024;
static char* args[5];
static int no_term_signal;
#ifndef _WIN32
static int timer_counter;
#endif
static uv_tcp_t tcp_server;
#define OUTPUT_SIZE 1024
static char output[OUTPUT_SIZE];
static int output_used;
static void close_cb(uv_handle_t* handle) {
printf("close_cb\n");
close_cb_called++;
}
static void exit_cb(uv_process_t* process,
int64_t exit_status,
libuv/test/test-spawn.c view on Meta::CPAN
int64_t exit_status,
int term_signal) {
printf("detach_cb\n");
exit_cb_called++;
}
static void on_alloc(uv_handle_t* handle,
size_t suggested_size,
uv_buf_t* buf) {
buf->base = output + output_used;
buf->len = OUTPUT_SIZE - output_used;
}
static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
if (nread > 0) {
output_used += nread;
} else if (nread < 0) {
ASSERT(nread == UV_EOF);
uv_close((uv_handle_t*)tcp, close_cb);
}
libuv/test/test-spawn.c view on Meta::CPAN
TEST_IMPL(spawn_inherit_streams) {
uv_process_t child_req;
uv_stdio_container_t child_stdio[2];
int fds_stdin[2];
int fds_stdout[2];
uv_pipe_t pipe_stdin_child;
uv_pipe_t pipe_stdout_child;
uv_pipe_t pipe_stdin_parent;
uv_pipe_t pipe_stdout_parent;
unsigned char ubuf[OUTPUT_SIZE - 1];
uv_buf_t buf;
unsigned int i;
int r;
int bidir;
uv_write_t write_req;
uv_loop_t* loop;
init_process_options("spawn_helper9", exit_cb);
loop = uv_default_loop();
libuv/test/test-spawn.c view on Meta::CPAN
ASSERT(w >= 0);
pbuf = pbuf + w;
c = c - w;
}
}
}
#else
void spawn_stdin_stdout(void) {
char buf[1024];
char* pbuf;
HANDLE h_stdin = GetStdHandle(STD_INPUT_HANDLE);
HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
ASSERT(h_stdin != INVALID_HANDLE_VALUE);
ASSERT(h_stdout != INVALID_HANDLE_VALUE);
for (;;) {
DWORD n_read;
DWORD n_written;
DWORD to_write;
if (!ReadFile(h_stdin, buf, sizeof buf, &n_read, NULL)) {
ASSERT(GetLastError() == ERROR_BROKEN_PIPE);
return;
}
libuv/test/test-stdio-over-pipes.c view on Meta::CPAN
static size_t exepath_size = 1024;
static char* args[3];
static uv_process_options_t options;
static int close_cb_called;
static int exit_cb_called;
static int on_read_cb_called;
static int after_write_cb_called;
static uv_pipe_t in;
static uv_pipe_t out;
static uv_loop_t* loop;
#define OUTPUT_SIZE 1024
static char output[OUTPUT_SIZE];
static int output_used;
static void close_cb(uv_handle_t* handle) {
close_cb_called++;
}
static void exit_cb(uv_process_t* process,
int64_t exit_status,
libuv/test/test-stdio-over-pipes.c view on Meta::CPAN
options.file = exepath;
options.args = args;
options.exit_cb = exit_cb;
}
static void on_alloc(uv_handle_t* handle,
size_t suggested_size,
uv_buf_t* buf) {
buf->base = output + output_used;
buf->len = OUTPUT_SIZE - output_used;
}
static void after_write(uv_write_t* req, int status) {
if (status) {
fprintf(stderr, "uv_write error: %s\n", uv_strerror(status));
ASSERT(0);
}
/* Free the read/write buffer and the request */
libuv/test/test-tty-duplicate-key.c view on Meta::CPAN
print_err_msg(expect_str, expect_nread, buf->base, nread);
ASSERT(FALSE);
}
uv_close((uv_handle_t*) tty_in, NULL);
} else {
ASSERT(nread == 0);
}
}
static void make_key_event_records(WORD virt_key, DWORD ctr_key_state,
BOOL is_wsl, INPUT_RECORD* records) {
# define KEV(I) records[(I)].Event.KeyEvent
BYTE kb_state[256] = {0};
WCHAR buf[2];
int ret;
records[0].EventType = records[1].EventType = KEY_EVENT;
KEV(0).bKeyDown = TRUE;
KEV(1).bKeyDown = FALSE;
KEV(0).wVirtualKeyCode = KEV(1).wVirtualKeyCode = virt_key;
KEV(0).wRepeatCount = KEV(1).wRepeatCount = 1;
libuv/test/test-tty-duplicate-key.c view on Meta::CPAN
}
# undef KEV
}
TEST_IMPL(tty_duplicate_vt100_fn_key) {
int r;
int ttyin_fd;
uv_tty_t tty_in;
uv_loop_t* loop;
HANDLE handle;
INPUT_RECORD records[2];
DWORD written;
loop = uv_default_loop();
/* Make sure we have an FD that refers to a tty */
handle = CreateFileA("conin$",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
libuv/test/test-tty-duplicate-key.c view on Meta::CPAN
MAKE_VALGRIND_HAPPY();
return 0;
}
TEST_IMPL(tty_duplicate_alt_modifier_key) {
int r;
int ttyin_fd;
uv_tty_t tty_in;
uv_loop_t* loop;
HANDLE handle;
INPUT_RECORD records[2];
INPUT_RECORD alt_records[2];
DWORD written;
loop = uv_default_loop();
/* Make sure we have an FD that refers to a tty */
handle = CreateFileA("conin$",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
libuv/test/test-tty-duplicate-key.c view on Meta::CPAN
MAKE_VALGRIND_HAPPY();
return 0;
}
TEST_IMPL(tty_composing_character) {
int r;
int ttyin_fd;
uv_tty_t tty_in;
uv_loop_t* loop;
HANDLE handle;
INPUT_RECORD records[2];
INPUT_RECORD alt_records[2];
DWORD written;
loop = uv_default_loop();
/* Make sure we have an FD that refers to a tty */
handle = CreateFileA("conin$",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
libuv/test/test-tty.c view on Meta::CPAN
ASSERT(nread == 0);
}
}
TEST_IMPL(tty_raw) {
int r;
int ttyin_fd;
uv_tty_t tty_in;
uv_loop_t* loop = uv_default_loop();
HANDLE handle;
INPUT_RECORD record;
DWORD written;
/* Make sure we have an FD that refers to a tty */
handle = CreateFileA("conin$",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);