Rizin
unix-like reverse engineering framework and cli tools
handle.c File Reference
#include <assert.h>
#include <io.h>
#include <stdlib.h>
#include "uv.h"
#include "internal.h"
#include "handle-inl.h"

Go to the source code of this file.

Functions

uv_handle_type uv_guess_handle (uv_file file)
 
int uv_is_active (const uv_handle_t *handle)
 
void uv_close (uv_handle_t *handle, uv_close_cb cb)
 
int uv_is_closing (const uv_handle_t *handle)
 
uv_os_fd_t uv_get_osfhandle (int fd)
 
int uv_open_osfhandle (uv_os_fd_t os_fd)
 

Function Documentation

◆ uv_close()

void uv_close ( uv_handle_t handle,
uv_close_cb  cb 
)

Definition at line 67 of file handle.c.

67  {
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:
81  return;
82 
83  case UV_NAMED_PIPE:
85  return;
86 
87  case UV_TTY:
89  return;
90 
91  case UV_UDP:
93  return;
94 
95  case UV_POLL:
97  return;
98 
99  case UV_TIMER:
103  return;
104 
105  case UV_PREPARE:
109  return;
110 
111  case UV_CHECK:
115  return;
116 
117  case UV_IDLE:
121  return;
122 
123  case UV_ASYNC:
125  return;
126 
127  case UV_SIGNAL:
129  return;
130 
131  case UV_PROCESS:
133  return;
134 
135  case UV_FS_EVENT:
137  return;
138 
139  case UV_FS_POLL:
142  return;
143 
144  default:
145  /* Not supported */
146  abort();
147  }
148 }
static mcore_handle handle
Definition: asm_mcore.c:8
void uv_fs_event_close(uv_loop_t *loop, uv_fs_event_t *handle)
Definition: fs-event.c:585
void uv__fs_poll_close(uv_fs_poll_t *handle)
Definition: fs-poll.c:164
static INLINE void uv_want_endgame(uv_loop_t *loop, uv_handle_t *handle)
Definition: handle-inl.h:88
#define uv__handle_closing(handle)
Definition: handle-inl.h:63
assert(limit<=UINT32_MAX/2)
Definition: uv.h:844
Definition: uv.h:824
Definition: uv.h:834
Definition: uv.h:1780
Definition: uv.h:767
Definition: uv.h:793
Definition: uv.h:547
Definition: uv.h:860
Definition: uv.h:714
Definition: uv.h:638
uv_loop_t * loop
Definition: main.c:7
void uv_pipe_close(uv_loop_t *loop, uv_pipe_t *handle)
Definition: pipe.c:818
void uv_process_close(uv_loop_t *loop, uv_process_t *handle)
Definition: process.c:903
void uv_signal_close(uv_loop_t *loop, uv_signal_t *handle)
Definition: signal.c:262
void uv_tcp_close(uv_loop_t *loop, uv_tcp_t *tcp)
Definition: tcp.c:1426
int uv_poll_close(uv_loop_t *loop, uv_poll_t *handle)
Definition: poll.c:535
void uv_udp_close(uv_loop_t *loop, uv_udp_t *handle)
Definition: udp.c:170
void uv_tty_close(uv_tty_t *handle)
Definition: tty.c:2249
@ UV_HANDLE_CLOSING
Definition: uv-common.h:74
UV_EXTERN int uv_idle_stop(uv_idle_t *idle)
UV_EXTERN int uv_timer_stop(uv_timer_t *handle)
Definition: timer.c:97
UV_EXTERN int uv_check_stop(uv_check_t *check)
UV_EXTERN int uv_prepare_stop(uv_prepare_t *prepare)
void uv_async_close(uv_loop_t *loop, uv_async_t *handle)
Definition: async.c:57
static const char * cb[]
Definition: z80_tab.h:176

References assert(), cb, handle, loop, uv__async_close(), uv__check_close(), uv__fs_event_close(), uv__fs_poll_close(), uv__handle_closing, uv__idle_close(), uv__is_closing, uv__make_close_pending(), uv__pipe_close(), uv__poll_close(), uv__prepare_close(), uv__process_close(), uv__signal_close(), uv__stream_close(), uv__tcp_close(), uv__timer_close(), uv__udp_close(), uv_async_close(), uv_check_stop(), uv_fs_event_close(), UV_HANDLE_CLOSING, uv_idle_stop(), uv_pipe_close(), uv_poll_close(), uv_prepare_stop(), uv_process_close(), uv_signal_close(), uv_tcp_close(), uv_timer_stop(), uv_tty_close(), uv_udp_close(), and uv_want_endgame().

Referenced by after(), cleanup_handles(), close_process_handle(), destroy_curl_context(), echo_read(), eof_timer_destroy(), on_exit(), on_new_connection(), on_read(), poll_cb(), read_stdin(), uv__stream_close(), uv_fs_poll_stop(), and uv_tcp_close_reset().

◆ uv_get_osfhandle()

uv_os_fd_t uv_get_osfhandle ( int  fd)

Definition at line 156 of file handle.c.

156  {
157  return uv__get_osfhandle(fd);
158 }
static INLINE HANDLE uv__get_osfhandle(int fd)
Definition: handle-inl.h:166
static const z80_opcode fd[]
Definition: z80_tab.h:997

References fd, and uv__get_osfhandle().

◆ uv_guess_handle()

uv_handle_type uv_guess_handle ( uv_file  file)

Definition at line 31 of file handle.c.

31  {
32  HANDLE handle;
33  DWORD mode;
34 
35  if (file < 0) {
36  return UV_UNKNOWN_HANDLE;
37  }
38 
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 }
const char int mode
Definition: ioapi.h:137
Definition: gzappend.c:170
@ UV_FILE
Definition: uv.h:194
@ UV_UNKNOWN_HANDLE
Definition: uv.h:190
DWORD * HANDLE
DWORD

References AF_INET, AF_INET6, AF_UNIX, DWORD, fstat, handle, HANDLE, len, s, S_ISREG, SO_TYPE, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, type, uv__get_osfhandle(), UV_FILE, and UV_UNKNOWN_HANDLE.

Referenced by main().

◆ uv_is_active()

int uv_is_active ( const uv_handle_t handle)

Definition at line 61 of file handle.c.

61  {
62  return (handle->flags & UV_HANDLE_ACTIVE) &&
63  !(handle->flags & UV_HANDLE_CLOSING);
64 }
@ UV_HANDLE_ACTIVE
Definition: uv-common.h:76

References handle, uv__is_active, UV_HANDLE_ACTIVE, and UV_HANDLE_CLOSING.

Referenced by poll_cb(), uv_fs_poll_getpath(), uv_fs_poll_start(), and uv_fs_poll_stop().

◆ uv_is_closing()

int uv_is_closing ( const uv_handle_t handle)

Definition at line 151 of file handle.c.

151  {
152  return !!(handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED));
153 }
@ UV_HANDLE_CLOSED
Definition: uv-common.h:75

References handle, uv__is_closing, UV_HANDLE_CLOSED, and UV_HANDLE_CLOSING.

◆ uv_open_osfhandle()

int uv_open_osfhandle ( uv_os_fd_t  os_fd)

Definition at line 160 of file handle.c.

160  {
161  return _open_osfhandle((intptr_t) os_fd, 0);
162 }
_W64 signed int intptr_t