| 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 | /* See https://github.com/libuv/libuv#documentation for documentation. */ | 
|---|
| 23 |  | 
|---|
| 24 | #ifndef UV_H | 
|---|
| 25 | #define UV_H | 
|---|
| 26 | #ifdef __cplusplus | 
|---|
| 27 | extern "C"{ | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | #if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) | 
|---|
| 31 | #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." | 
|---|
| 32 | #endif | 
|---|
| 33 |  | 
|---|
| 34 | #ifdef _WIN32 | 
|---|
| 35 | /* Windows - set up dll import/export decorators. */ | 
|---|
| 36 | # if defined(BUILDING_UV_SHARED) | 
|---|
| 37 | /* Building shared library. */ | 
|---|
| 38 | #   define UV_EXTERN __declspec(dllexport) | 
|---|
| 39 | # elif defined(USING_UV_SHARED) | 
|---|
| 40 | /* Using shared library. */ | 
|---|
| 41 | #   define UV_EXTERN __declspec(dllimport) | 
|---|
| 42 | # else | 
|---|
| 43 | /* Building static library. */ | 
|---|
| 44 | #   define UV_EXTERN /* nothing */ | 
|---|
| 45 | # endif | 
|---|
| 46 | #elif __GNUC__ >= 4 | 
|---|
| 47 | # define UV_EXTERN __attribute__((visibility("default"))) | 
|---|
| 48 | #else | 
|---|
| 49 | # define UV_EXTERN /* nothing */ | 
|---|
| 50 | #endif | 
|---|
| 51 |  | 
|---|
| 52 | #include "uv/errno.h" | 
|---|
| 53 | #include "uv/version.h" | 
|---|
| 54 | #include <stddef.h> | 
|---|
| 55 | #include <stdio.h> | 
|---|
| 56 |  | 
|---|
| 57 | #if defined(_MSC_VER) && _MSC_VER < 1600 | 
|---|
| 58 | # include "uv/stdint-msvc2008.h" | 
|---|
| 59 | #else | 
|---|
| 60 | # include <stdint.h> | 
|---|
| 61 | #endif | 
|---|
| 62 |  | 
|---|
| 63 | #if defined(_WIN32) | 
|---|
| 64 | # include "uv/win.h" | 
|---|
| 65 | #else | 
|---|
| 66 | # include "uv/unix.h" | 
|---|
| 67 | #endif | 
|---|
| 68 |  | 
|---|
| 69 | /* Expand this list if necessary. */ | 
|---|
| 70 | #define UV_ERRNO_MAP(XX)                                                      \ | 
|---|
| 71 | XX(E2BIG, "argument list too long")                                         \ | 
|---|
| 72 | XX(EACCES, "permission denied")                                             \ | 
|---|
| 73 | XX(EADDRINUSE, "address already in use")                                    \ | 
|---|
| 74 | XX(EADDRNOTAVAIL, "address not available")                                  \ | 
|---|
| 75 | XX(EAFNOSUPPORT, "address family not supported")                            \ | 
|---|
| 76 | XX(EAGAIN, "resource temporarily unavailable")                              \ | 
|---|
| 77 | XX(EAI_ADDRFAMILY, "address family not supported")                          \ | 
|---|
| 78 | XX(EAI_AGAIN, "temporary failure")                                          \ | 
|---|
| 79 | XX(EAI_BADFLAGS, "bad ai_flags value")                                      \ | 
|---|
| 80 | XX(EAI_BADHINTS, "invalid value for hints")                                 \ | 
|---|
| 81 | XX(EAI_CANCELED, "request canceled")                                        \ | 
|---|
| 82 | XX(EAI_FAIL, "permanent failure")                                           \ | 
|---|
| 83 | XX(EAI_FAMILY, "ai_family not supported")                                   \ | 
|---|
| 84 | XX(EAI_MEMORY, "out of memory")                                             \ | 
|---|
| 85 | XX(EAI_NODATA, "no address")                                                \ | 
|---|
| 86 | XX(EAI_NONAME, "unknown node or service")                                   \ | 
|---|
| 87 | XX(EAI_OVERFLOW, "argument buffer overflow")                                \ | 
|---|
| 88 | XX(EAI_PROTOCOL, "resolved protocol is unknown")                            \ | 
|---|
| 89 | XX(EAI_SERVICE, "service not available for socket type")                    \ | 
|---|
| 90 | XX(EAI_SOCKTYPE, "socket type not supported")                               \ | 
|---|
| 91 | XX(EALREADY, "connection already in progress")                              \ | 
|---|
| 92 | XX(EBADF, "bad file descriptor")                                            \ | 
|---|
| 93 | XX(EBUSY, "resource busy or locked")                                        \ | 
|---|
| 94 | XX(ECANCELED, "operation canceled")                                         \ | 
|---|
| 95 | XX(ECHARSET, "invalid Unicode character")                                   \ | 
|---|
| 96 | XX(ECONNABORTED, "software caused connection abort")                        \ | 
|---|
| 97 | XX(ECONNREFUSED, "connection refused")                                      \ | 
|---|
| 98 | XX(ECONNRESET, "connection reset by peer")                                  \ | 
|---|
| 99 | XX(EDESTADDRREQ, "destination address required")                            \ | 
|---|
| 100 | XX(EEXIST, "file already exists")                                           \ | 
|---|
| 101 | XX(EFAULT, "bad address in system call argument")                           \ | 
|---|
| 102 | XX(EFBIG, "file too large")                                                 \ | 
|---|
| 103 | XX(EHOSTUNREACH, "host is unreachable")                                     \ | 
|---|
| 104 | XX(EINTR, "interrupted system call")                                        \ | 
|---|
| 105 | XX(EINVAL, "invalid argument")                                              \ | 
|---|
| 106 | XX(EIO, "i/o error")                                                        \ | 
|---|
| 107 | XX(EISCONN, "socket is already connected")                                  \ | 
|---|
| 108 | XX(EISDIR, "illegal operation on a directory")                              \ | 
|---|
| 109 | XX(ELOOP, "too many symbolic links encountered")                            \ | 
|---|
| 110 | XX(EMFILE, "too many open files")                                           \ | 
|---|
| 111 | XX(EMSGSIZE, "message too long")                                            \ | 
|---|
| 112 | XX(ENAMETOOLONG, "name too long")                                           \ | 
|---|
| 113 | XX(ENETDOWN, "network is down")                                             \ | 
|---|
| 114 | XX(ENETUNREACH, "network is unreachable")                                   \ | 
|---|
| 115 | XX(ENFILE, "file table overflow")                                           \ | 
|---|
| 116 | XX(ENOBUFS, "no buffer space available")                                    \ | 
|---|
| 117 | XX(ENODEV, "no such device")                                                \ | 
|---|
| 118 | XX(ENOENT, "no such file or directory")                                     \ | 
|---|
| 119 | XX(ENOMEM, "not enough memory")                                             \ | 
|---|
| 120 | XX(ENONET, "machine is not on the network")                                 \ | 
|---|
| 121 | XX(ENOPROTOOPT, "protocol not available")                                   \ | 
|---|
| 122 | XX(ENOSPC, "no space left on device")                                       \ | 
|---|
| 123 | XX(ENOSYS, "function not implemented")                                      \ | 
|---|
| 124 | XX(ENOTCONN, "socket is not connected")                                     \ | 
|---|
| 125 | XX(ENOTDIR, "not a directory")                                              \ | 
|---|
| 126 | XX(ENOTEMPTY, "directory not empty")                                        \ | 
|---|
| 127 | XX(ENOTSOCK, "socket operation on non-socket")                              \ | 
|---|
| 128 | XX(ENOTSUP, "operation not supported on socket")                            \ | 
|---|
| 129 | XX(EPERM, "operation not permitted")                                        \ | 
|---|
| 130 | XX(EPIPE, "broken pipe")                                                    \ | 
|---|
| 131 | XX(EPROTO, "protocol error")                                                \ | 
|---|
| 132 | XX(EPROTONOSUPPORT, "protocol not supported")                               \ | 
|---|
| 133 | XX(EPROTOTYPE, "protocol wrong type for socket")                            \ | 
|---|
| 134 | XX(ERANGE, "result too large")                                              \ | 
|---|
| 135 | XX(EROFS, "read-only file system")                                          \ | 
|---|
| 136 | XX(ESHUTDOWN, "cannot send after transport endpoint shutdown")              \ | 
|---|
| 137 | XX(ESPIPE, "invalid seek")                                                  \ | 
|---|
| 138 | XX(ESRCH, "no such process")                                                \ | 
|---|
| 139 | XX(ETIMEDOUT, "connection timed out")                                       \ | 
|---|
| 140 | XX(ETXTBSY, "text file is busy")                                            \ | 
|---|
| 141 | XX(EXDEV, "cross-device link not permitted")                                \ | 
|---|
| 142 | XX(UNKNOWN, "unknown error")                                                \ | 
|---|
| 143 | XX(EOF, "end of file")                                                      \ | 
|---|
| 144 | XX(ENXIO, "no such device or address")                                      \ | 
|---|
| 145 | XX(EMLINK, "too many links")                                                \ | 
|---|
| 146 | XX(EHOSTDOWN, "host is down")                                               \ | 
|---|
| 147 | XX(EREMOTEIO, "remote I/O error")                                           \ | 
|---|
| 148 | XX(ENOTTY, "inappropriate ioctl for device")                                \ | 
|---|
| 149 | XX(EFTYPE, "inappropriate file type or format")                             \ | 
|---|
| 150 | XX(EILSEQ, "illegal byte sequence")                                         \ | 
|---|
| 151 |  | 
|---|
| 152 | #define UV_HANDLE_TYPE_MAP(XX)                                                \ | 
|---|
| 153 | XX(ASYNC, async)                                                            \ | 
|---|
| 154 | XX(CHECK, check)                                                            \ | 
|---|
| 155 | XX(FS_EVENT, fs_event)                                                      \ | 
|---|
| 156 | XX(FS_POLL, fs_poll)                                                        \ | 
|---|
| 157 | XX(HANDLE, handle)                                                          \ | 
|---|
| 158 | XX(IDLE, idle)                                                              \ | 
|---|
| 159 | XX(NAMED_PIPE, pipe)                                                        \ | 
|---|
| 160 | XX(POLL, poll)                                                              \ | 
|---|
| 161 | XX(PREPARE, prepare)                                                        \ | 
|---|
| 162 | XX(PROCESS, process)                                                        \ | 
|---|
| 163 | XX(STREAM, stream)                                                          \ | 
|---|
| 164 | XX(TCP, tcp)                                                                \ | 
|---|
| 165 | XX(TIMER, timer)                                                            \ | 
|---|
| 166 | XX(TTY, tty)                                                                \ | 
|---|
| 167 | XX(UDP, udp)                                                                \ | 
|---|
| 168 | XX(SIGNAL, signal)                                                          \ | 
|---|
| 169 |  | 
|---|
| 170 | #define UV_REQ_TYPE_MAP(XX)                                                   \ | 
|---|
| 171 | XX(REQ, req)                                                                \ | 
|---|
| 172 | XX(CONNECT, connect)                                                        \ | 
|---|
| 173 | XX(WRITE, write)                                                            \ | 
|---|
| 174 | XX(SHUTDOWN, shutdown)                                                      \ | 
|---|
| 175 | XX(UDP_SEND, udp_send)                                                      \ | 
|---|
| 176 | XX(FS, fs)                                                                  \ | 
|---|
| 177 | XX(WORK, work)                                                              \ | 
|---|
| 178 | XX(GETADDRINFO, getaddrinfo)                                                \ | 
|---|
| 179 | XX(GETNAMEINFO, getnameinfo)                                                \ | 
|---|
| 180 | XX(RANDOM, random)                                                          \ | 
|---|
| 181 |  | 
|---|
| 182 | typedef enum { | 
|---|
| 183 | #define XX(code, _) UV_ ## code = UV__ ## code, | 
|---|
| 184 | UV_ERRNO_MAP(XX) | 
|---|
| 185 | #undef XX | 
|---|
| 186 | UV_ERRNO_MAX = UV__EOF - 1 | 
|---|
| 187 | } uv_errno_t; | 
|---|
| 188 |  | 
|---|
| 189 | typedef enum { | 
|---|
| 190 | UV_UNKNOWN_HANDLE = 0, | 
|---|
| 191 | #define XX(uc, lc) UV_##uc, | 
|---|
| 192 | UV_HANDLE_TYPE_MAP(XX) | 
|---|
| 193 | #undef XX | 
|---|
| 194 | UV_FILE, | 
|---|
| 195 | UV_HANDLE_TYPE_MAX | 
|---|
| 196 | } uv_handle_type; | 
|---|
| 197 |  | 
|---|
| 198 | typedef enum { | 
|---|
| 199 | UV_UNKNOWN_REQ = 0, | 
|---|
| 200 | #define XX(uc, lc) UV_##uc, | 
|---|
| 201 | UV_REQ_TYPE_MAP(XX) | 
|---|
| 202 | #undef XX | 
|---|
| 203 | UV_REQ_TYPE_PRIVATE | 
|---|
| 204 | UV_REQ_TYPE_MAX | 
|---|
| 205 | } uv_req_type; | 
|---|
| 206 |  | 
|---|
| 207 |  | 
|---|
| 208 | /* Handle types. */ | 
|---|
| 209 | typedef struct uv_loop_s uv_loop_t; | 
|---|
| 210 | typedef struct uv_handle_s uv_handle_t; | 
|---|
| 211 | typedef struct uv_dir_s uv_dir_t; | 
|---|
| 212 | typedef struct uv_stream_s uv_stream_t; | 
|---|
| 213 | typedef struct uv_tcp_s uv_tcp_t; | 
|---|
| 214 | typedef struct uv_udp_s uv_udp_t; | 
|---|
| 215 | typedef struct uv_pipe_s uv_pipe_t; | 
|---|
| 216 | typedef struct uv_tty_s uv_tty_t; | 
|---|
| 217 | typedef struct uv_poll_s uv_poll_t; | 
|---|
| 218 | typedef struct uv_timer_s uv_timer_t; | 
|---|
| 219 | typedef struct uv_prepare_s uv_prepare_t; | 
|---|
| 220 | typedef struct uv_check_s uv_check_t; | 
|---|
| 221 | typedef struct uv_idle_s uv_idle_t; | 
|---|
| 222 | typedef struct uv_async_s uv_async_t; | 
|---|
| 223 | typedef struct uv_process_s uv_process_t; | 
|---|
| 224 | typedef struct uv_fs_event_s uv_fs_event_t; | 
|---|
| 225 | typedef struct uv_fs_poll_s uv_fs_poll_t; | 
|---|
| 226 | typedef struct uv_signal_s uv_signal_t; | 
|---|
| 227 |  | 
|---|
| 228 | /* Request types. */ | 
|---|
| 229 | typedef struct uv_req_s uv_req_t; | 
|---|
| 230 | typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; | 
|---|
| 231 | typedef struct uv_getnameinfo_s uv_getnameinfo_t; | 
|---|
| 232 | typedef struct uv_shutdown_s uv_shutdown_t; | 
|---|
| 233 | typedef struct uv_write_s uv_write_t; | 
|---|
| 234 | typedef struct uv_connect_s uv_connect_t; | 
|---|
| 235 | typedef struct uv_udp_send_s uv_udp_send_t; | 
|---|
| 236 | typedef struct uv_fs_s uv_fs_t; | 
|---|
| 237 | typedef struct uv_work_s uv_work_t; | 
|---|
| 238 | typedef struct uv_random_s uv_random_t; | 
|---|
| 239 |  | 
|---|
| 240 | /* None of the above. */ | 
|---|
| 241 | typedef struct uv_env_item_s uv_env_item_t; | 
|---|
| 242 | typedef struct uv_cpu_info_s uv_cpu_info_t; | 
|---|
| 243 | typedef struct uv_interface_address_s uv_interface_address_t; | 
|---|
| 244 | typedef struct uv_dirent_s uv_dirent_t; | 
|---|
| 245 | typedef struct uv_passwd_s uv_passwd_t; | 
|---|
| 246 | typedef struct uv_utsname_s uv_utsname_t; | 
|---|
| 247 | typedef struct uv_statfs_s uv_statfs_t; | 
|---|
| 248 |  | 
|---|
| 249 | typedef enum { | 
|---|
| 250 | UV_LOOP_BLOCK_SIGNAL = 0, | 
|---|
| 251 | UV_METRICS_IDLE_TIME | 
|---|
| 252 | } uv_loop_option; | 
|---|
| 253 |  | 
|---|
| 254 | typedef enum { | 
|---|
| 255 | UV_RUN_DEFAULT = 0, | 
|---|
| 256 | UV_RUN_ONCE, | 
|---|
| 257 | UV_RUN_NOWAIT | 
|---|
| 258 | } uv_run_mode; | 
|---|
| 259 |  | 
|---|
| 260 |  | 
|---|
| 261 | UV_EXTERN unsigned int uv_version(void); | 
|---|
| 262 | UV_EXTERN const char* uv_version_string(void); | 
|---|
| 263 |  | 
|---|
| 264 | typedef void* (*uv_malloc_func)(size_t size); | 
|---|
| 265 | typedef void* (*uv_realloc_func)(void* ptr, size_t size); | 
|---|
| 266 | typedef void* (*uv_calloc_func)(size_t count, size_t size); | 
|---|
| 267 | typedef void (*uv_free_func)(void* ptr); | 
|---|
| 268 |  | 
|---|
| 269 | UV_EXTERN void uv_library_shutdown(void); | 
|---|
| 270 |  | 
|---|
| 271 | UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, | 
|---|
| 272 | uv_realloc_func realloc_func, | 
|---|
| 273 | uv_calloc_func calloc_func, | 
|---|
| 274 | uv_free_func free_func); | 
|---|
| 275 |  | 
|---|
| 276 | UV_EXTERN uv_loop_t* uv_default_loop(void); | 
|---|
| 277 | UV_EXTERN int uv_loop_init(uv_loop_t* loop); | 
|---|
| 278 | UV_EXTERN int uv_loop_close(uv_loop_t* loop); | 
|---|
| 279 | /* | 
|---|
| 280 | * NOTE: | 
|---|
| 281 | *  This function is DEPRECATED (to be removed after 0.12), users should | 
|---|
| 282 | *  allocate the loop manually and use uv_loop_init instead. | 
|---|
| 283 | */ | 
|---|
| 284 | UV_EXTERN uv_loop_t* uv_loop_new(void); | 
|---|
| 285 | /* | 
|---|
| 286 | * NOTE: | 
|---|
| 287 | *  This function is DEPRECATED (to be removed after 0.12). Users should use | 
|---|
| 288 | *  uv_loop_close and free the memory manually instead. | 
|---|
| 289 | */ | 
|---|
| 290 | UV_EXTERN void uv_loop_delete(uv_loop_t*); | 
|---|
| 291 | UV_EXTERN size_t uv_loop_size(void); | 
|---|
| 292 | UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); | 
|---|
| 293 | UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); | 
|---|
| 294 | UV_EXTERN int uv_loop_fork(uv_loop_t* loop); | 
|---|
| 295 |  | 
|---|
| 296 | UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); | 
|---|
| 297 | UV_EXTERN void uv_stop(uv_loop_t*); | 
|---|
| 298 |  | 
|---|
| 299 | UV_EXTERN void uv_ref(uv_handle_t*); | 
|---|
| 300 | UV_EXTERN void uv_unref(uv_handle_t*); | 
|---|
| 301 | UV_EXTERN int uv_has_ref(const uv_handle_t*); | 
|---|
| 302 |  | 
|---|
| 303 | UV_EXTERN void uv_update_time(uv_loop_t*); | 
|---|
| 304 | UV_EXTERN uint64_t uv_now(const uv_loop_t*); | 
|---|
| 305 |  | 
|---|
| 306 | UV_EXTERN int uv_backend_fd(const uv_loop_t*); | 
|---|
| 307 | UV_EXTERN int uv_backend_timeout(const uv_loop_t*); | 
|---|
| 308 |  | 
|---|
| 309 | typedef void (*uv_alloc_cb)(uv_handle_t* handle, | 
|---|
| 310 | size_t suggested_size, | 
|---|
| 311 | uv_buf_t* buf); | 
|---|
| 312 | typedef void (*uv_read_cb)(uv_stream_t* stream, | 
|---|
| 313 | ssize_t nread, | 
|---|
| 314 | const uv_buf_t* buf); | 
|---|
| 315 | typedef void (*uv_write_cb)(uv_write_t* req, int status); | 
|---|
| 316 | typedef void (*uv_connect_cb)(uv_connect_t* req, int status); | 
|---|
| 317 | typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); | 
|---|
| 318 | typedef void (*uv_connection_cb)(uv_stream_t* server, int status); | 
|---|
| 319 | typedef void (*uv_close_cb)(uv_handle_t* handle); | 
|---|
| 320 | typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); | 
|---|
| 321 | typedef void (*uv_timer_cb)(uv_timer_t* handle); | 
|---|
| 322 | typedef void (*uv_async_cb)(uv_async_t* handle); | 
|---|
| 323 | typedef void (*uv_prepare_cb)(uv_prepare_t* handle); | 
|---|
| 324 | typedef void (*uv_check_cb)(uv_check_t* handle); | 
|---|
| 325 | typedef void (*uv_idle_cb)(uv_idle_t* handle); | 
|---|
| 326 | typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); | 
|---|
| 327 | typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); | 
|---|
| 328 | typedef void (*uv_fs_cb)(uv_fs_t* req); | 
|---|
| 329 | typedef void (*uv_work_cb)(uv_work_t* req); | 
|---|
| 330 | typedef void (*uv_after_work_cb)(uv_work_t* req, int status); | 
|---|
| 331 | typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, | 
|---|
| 332 | int status, | 
|---|
| 333 | struct addrinfo* res); | 
|---|
| 334 | typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, | 
|---|
| 335 | int status, | 
|---|
| 336 | const char* hostname, | 
|---|
| 337 | const char* service); | 
|---|
| 338 | typedef void (*uv_random_cb)(uv_random_t* req, | 
|---|
| 339 | int status, | 
|---|
| 340 | void* buf, | 
|---|
| 341 | size_t buflen); | 
|---|
| 342 |  | 
|---|
| 343 | typedef struct { | 
|---|
| 344 | long tv_sec; | 
|---|
| 345 | long tv_nsec; | 
|---|
| 346 | } uv_timespec_t; | 
|---|
| 347 |  | 
|---|
| 348 |  | 
|---|
| 349 | typedef struct { | 
|---|
| 350 | uint64_t st_dev; | 
|---|
| 351 | uint64_t st_mode; | 
|---|
| 352 | uint64_t st_nlink; | 
|---|
| 353 | uint64_t st_uid; | 
|---|
| 354 | uint64_t st_gid; | 
|---|
| 355 | uint64_t st_rdev; | 
|---|
| 356 | uint64_t st_ino; | 
|---|
| 357 | uint64_t st_size; | 
|---|
| 358 | uint64_t st_blksize; | 
|---|
| 359 | uint64_t st_blocks; | 
|---|
| 360 | uint64_t st_flags; | 
|---|
| 361 | uint64_t st_gen; | 
|---|
| 362 | uv_timespec_t st_atim; | 
|---|
| 363 | uv_timespec_t st_mtim; | 
|---|
| 364 | uv_timespec_t st_ctim; | 
|---|
| 365 | uv_timespec_t st_birthtim; | 
|---|
| 366 | } uv_stat_t; | 
|---|
| 367 |  | 
|---|
| 368 |  | 
|---|
| 369 | typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, | 
|---|
| 370 | const char* filename, | 
|---|
| 371 | int events, | 
|---|
| 372 | int status); | 
|---|
| 373 |  | 
|---|
| 374 | typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, | 
|---|
| 375 | int status, | 
|---|
| 376 | const uv_stat_t* prev, | 
|---|
| 377 | const uv_stat_t* curr); | 
|---|
| 378 |  | 
|---|
| 379 | typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); | 
|---|
| 380 |  | 
|---|
| 381 |  | 
|---|
| 382 | typedef enum { | 
|---|
| 383 | UV_LEAVE_GROUP = 0, | 
|---|
| 384 | UV_JOIN_GROUP | 
|---|
| 385 | } uv_membership; | 
|---|
| 386 |  | 
|---|
| 387 |  | 
|---|
| 388 | UV_EXTERN int uv_translate_sys_error(int sys_errno); | 
|---|
| 389 |  | 
|---|
| 390 | UV_EXTERN const char* uv_strerror(int err); | 
|---|
| 391 | UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); | 
|---|
| 392 |  | 
|---|
| 393 | UV_EXTERN const char* uv_err_name(int err); | 
|---|
| 394 | UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); | 
|---|
| 395 |  | 
|---|
| 396 |  | 
|---|
| 397 | #define UV_REQ_FIELDS                                                         \ | 
|---|
| 398 | /* public */                                                                \ | 
|---|
| 399 | void* data;                                                                 \ | 
|---|
| 400 | /* read-only */                                                             \ | 
|---|
| 401 | uv_req_type type;                                                           \ | 
|---|
| 402 | /* private */                                                               \ | 
|---|
| 403 | void* reserved[6];                                                          \ | 
|---|
| 404 | UV_REQ_PRIVATE_FIELDS                                                       \ | 
|---|
| 405 |  | 
|---|
| 406 | /* Abstract base class of all requests. */ | 
|---|
| 407 | struct uv_req_s { | 
|---|
| 408 | UV_REQ_FIELDS | 
|---|
| 409 | }; | 
|---|
| 410 |  | 
|---|
| 411 |  | 
|---|
| 412 | /* Platform-specific request types. */ | 
|---|
| 413 | UV_PRIVATE_REQ_TYPES | 
|---|
| 414 |  | 
|---|
| 415 |  | 
|---|
| 416 | UV_EXTERN int uv_shutdown(uv_shutdown_t* req, | 
|---|
| 417 | uv_stream_t* handle, | 
|---|
| 418 | uv_shutdown_cb cb); | 
|---|
| 419 |  | 
|---|
| 420 | struct uv_shutdown_s { | 
|---|
| 421 | UV_REQ_FIELDS | 
|---|
| 422 | uv_stream_t* handle; | 
|---|
| 423 | uv_shutdown_cb cb; | 
|---|
| 424 | UV_SHUTDOWN_PRIVATE_FIELDS | 
|---|
| 425 | }; | 
|---|
| 426 |  | 
|---|
| 427 |  | 
|---|
| 428 | #define UV_HANDLE_FIELDS                                                      \ | 
|---|
| 429 | /* public */                                                                \ | 
|---|
| 430 | void* data;                                                                 \ | 
|---|
| 431 | /* read-only */                                                             \ | 
|---|
| 432 | uv_loop_t* loop;                                                            \ | 
|---|
| 433 | uv_handle_type type;                                                        \ | 
|---|
| 434 | /* private */                                                               \ | 
|---|
| 435 | uv_close_cb close_cb;                                                       \ | 
|---|
| 436 | void* handle_queue[2];                                                      \ | 
|---|
| 437 | union {                                                                     \ | 
|---|
| 438 | int fd;                                                                   \ | 
|---|
| 439 | void* reserved[4];                                                        \ | 
|---|
| 440 | } u;                                                                        \ | 
|---|
| 441 | UV_HANDLE_PRIVATE_FIELDS                                                    \ | 
|---|
| 442 |  | 
|---|
| 443 | /* The abstract base class of all handles. */ | 
|---|
| 444 | struct uv_handle_s { | 
|---|
| 445 | UV_HANDLE_FIELDS | 
|---|
| 446 | }; | 
|---|
| 447 |  | 
|---|
| 448 | UV_EXTERN size_t uv_handle_size(uv_handle_type type); | 
|---|
| 449 | UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); | 
|---|
| 450 | UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); | 
|---|
| 451 | UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); | 
|---|
| 452 | UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); | 
|---|
| 453 | UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); | 
|---|
| 454 |  | 
|---|
| 455 | UV_EXTERN size_t uv_req_size(uv_req_type type); | 
|---|
| 456 | UV_EXTERN void* uv_req_get_data(const uv_req_t* req); | 
|---|
| 457 | UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); | 
|---|
| 458 | UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); | 
|---|
| 459 | UV_EXTERN const char* uv_req_type_name(uv_req_type type); | 
|---|
| 460 |  | 
|---|
| 461 | UV_EXTERN int uv_is_active(const uv_handle_t* handle); | 
|---|
| 462 |  | 
|---|
| 463 | UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); | 
|---|
| 464 |  | 
|---|
| 465 | /* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ | 
|---|
| 466 | UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); | 
|---|
| 467 | UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); | 
|---|
| 468 |  | 
|---|
| 469 | UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); | 
|---|
| 470 |  | 
|---|
| 471 | UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); | 
|---|
| 472 | UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); | 
|---|
| 473 |  | 
|---|
| 474 | UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); | 
|---|
| 475 |  | 
|---|
| 476 | UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); | 
|---|
| 477 |  | 
|---|
| 478 | UV_EXTERN int uv_pipe(uv_file fds[2], int read_flags, int write_flags); | 
|---|
| 479 | UV_EXTERN int uv_socketpair(int type, | 
|---|
| 480 | int protocol, | 
|---|
| 481 | uv_os_sock_t socket_vector[2], | 
|---|
| 482 | int flags0, | 
|---|
| 483 | int flags1); | 
|---|
| 484 |  | 
|---|
| 485 | #define UV_STREAM_FIELDS                                                      \ | 
|---|
| 486 | /* number of bytes queued for writing */                                    \ | 
|---|
| 487 | size_t write_queue_size;                                                    \ | 
|---|
| 488 | uv_alloc_cb alloc_cb;                                                       \ | 
|---|
| 489 | uv_read_cb read_cb;                                                         \ | 
|---|
| 490 | /* private */                                                               \ | 
|---|
| 491 | UV_STREAM_PRIVATE_FIELDS | 
|---|
| 492 |  | 
|---|
| 493 | /* | 
|---|
| 494 | * uv_stream_t is a subclass of uv_handle_t. | 
|---|
| 495 | * | 
|---|
| 496 | * uv_stream is an abstract class. | 
|---|
| 497 | * | 
|---|
| 498 | * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. | 
|---|
| 499 | */ | 
|---|
| 500 | struct uv_stream_s { | 
|---|
| 501 | UV_HANDLE_FIELDS | 
|---|
| 502 | UV_STREAM_FIELDS | 
|---|
| 503 | }; | 
|---|
| 504 |  | 
|---|
| 505 | UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); | 
|---|
| 506 |  | 
|---|
| 507 | UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); | 
|---|
| 508 | UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); | 
|---|
| 509 |  | 
|---|
| 510 | UV_EXTERN int uv_read_start(uv_stream_t*, | 
|---|
| 511 | uv_alloc_cb alloc_cb, | 
|---|
| 512 | uv_read_cb read_cb); | 
|---|
| 513 | UV_EXTERN int uv_read_stop(uv_stream_t*); | 
|---|
| 514 |  | 
|---|
| 515 | UV_EXTERN int uv_write(uv_write_t* req, | 
|---|
| 516 | uv_stream_t* handle, | 
|---|
| 517 | const uv_buf_t bufs[], | 
|---|
| 518 | unsigned int nbufs, | 
|---|
| 519 | uv_write_cb cb); | 
|---|
| 520 | UV_EXTERN int uv_write2(uv_write_t* req, | 
|---|
| 521 | uv_stream_t* handle, | 
|---|
| 522 | const uv_buf_t bufs[], | 
|---|
| 523 | unsigned int nbufs, | 
|---|
| 524 | uv_stream_t* send_handle, | 
|---|
| 525 | uv_write_cb cb); | 
|---|
| 526 | UV_EXTERN int uv_try_write(uv_stream_t* handle, | 
|---|
| 527 | const uv_buf_t bufs[], | 
|---|
| 528 | unsigned int nbufs); | 
|---|
| 529 |  | 
|---|
| 530 | /* uv_write_t is a subclass of uv_req_t. */ | 
|---|
| 531 | struct uv_write_s { | 
|---|
| 532 | UV_REQ_FIELDS | 
|---|
| 533 | uv_write_cb cb; | 
|---|
| 534 | uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ | 
|---|
| 535 | uv_stream_t* handle; | 
|---|
| 536 | UV_WRITE_PRIVATE_FIELDS | 
|---|
| 537 | }; | 
|---|
| 538 |  | 
|---|
| 539 |  | 
|---|
| 540 | UV_EXTERN int uv_is_readable(const uv_stream_t* handle); | 
|---|
| 541 | UV_EXTERN int uv_is_writable(const uv_stream_t* handle); | 
|---|
| 542 |  | 
|---|
| 543 | UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); | 
|---|
| 544 |  | 
|---|
| 545 | UV_EXTERN int uv_is_closing(const uv_handle_t* handle); | 
|---|
| 546 |  | 
|---|
| 547 |  | 
|---|
| 548 | /* | 
|---|
| 549 | * uv_tcp_t is a subclass of uv_stream_t. | 
|---|
| 550 | * | 
|---|
| 551 | * Represents a TCP stream or TCP server. | 
|---|
| 552 | */ | 
|---|
| 553 | struct uv_tcp_s { | 
|---|
| 554 | UV_HANDLE_FIELDS | 
|---|
| 555 | UV_STREAM_FIELDS | 
|---|
| 556 | UV_TCP_PRIVATE_FIELDS | 
|---|
| 557 | }; | 
|---|
| 558 |  | 
|---|
| 559 | UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); | 
|---|
| 560 | UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); | 
|---|
| 561 | UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); | 
|---|
| 562 | UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); | 
|---|
| 563 | UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, | 
|---|
| 564 | int enable, | 
|---|
| 565 | unsigned int delay); | 
|---|
| 566 | UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); | 
|---|
| 567 |  | 
|---|
| 568 | enum uv_tcp_flags { | 
|---|
| 569 | /* Used with uv_tcp_bind, when an IPv6 address is used. */ | 
|---|
| 570 | UV_TCP_IPV6ONLY = 1 | 
|---|
| 571 | }; | 
|---|
| 572 |  | 
|---|
| 573 | UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, | 
|---|
| 574 | const struct sockaddr* addr, | 
|---|
| 575 | unsigned int flags); | 
|---|
| 576 | UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, | 
|---|
| 577 | struct sockaddr* name, | 
|---|
| 578 | int* namelen); | 
|---|
| 579 | UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, | 
|---|
| 580 | struct sockaddr* name, | 
|---|
| 581 | int* namelen); | 
|---|
| 582 | UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); | 
|---|
| 583 | UV_EXTERN int uv_tcp_connect(uv_connect_t* req, | 
|---|
| 584 | uv_tcp_t* handle, | 
|---|
| 585 | const struct sockaddr* addr, | 
|---|
| 586 | uv_connect_cb cb); | 
|---|
| 587 |  | 
|---|
| 588 | /* uv_connect_t is a subclass of uv_req_t. */ | 
|---|
| 589 | struct uv_connect_s { | 
|---|
| 590 | UV_REQ_FIELDS | 
|---|
| 591 | uv_connect_cb cb; | 
|---|
| 592 | uv_stream_t* handle; | 
|---|
| 593 | UV_CONNECT_PRIVATE_FIELDS | 
|---|
| 594 | }; | 
|---|
| 595 |  | 
|---|
| 596 |  | 
|---|
| 597 | /* | 
|---|
| 598 | * UDP support. | 
|---|
| 599 | */ | 
|---|
| 600 |  | 
|---|
| 601 | enum uv_udp_flags { | 
|---|
| 602 | /* Disables dual stack mode. */ | 
|---|
| 603 | UV_UDP_IPV6ONLY = 1, | 
|---|
| 604 | /* | 
|---|
| 605 | * Indicates message was truncated because read buffer was too small. The | 
|---|
| 606 | * remainder was discarded by the OS. Used in uv_udp_recv_cb. | 
|---|
| 607 | */ | 
|---|
| 608 | UV_UDP_PARTIAL = 2, | 
|---|
| 609 | /* | 
|---|
| 610 | * Indicates if SO_REUSEADDR will be set when binding the handle. | 
|---|
| 611 | * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other | 
|---|
| 612 | * Unix platforms, it sets the SO_REUSEADDR flag.  What that means is that | 
|---|
| 613 | * multiple threads or processes can bind to the same address without error | 
|---|
| 614 | * (provided they all set the flag) but only the last one to bind will receive | 
|---|
| 615 | * any traffic, in effect "stealing" the port from the previous listener. | 
|---|
| 616 | */ | 
|---|
| 617 | UV_UDP_REUSEADDR = 4, | 
|---|
| 618 | /* | 
|---|
| 619 | * Indicates that the message was received by recvmmsg, so the buffer provided | 
|---|
| 620 | * must not be freed by the recv_cb callback. | 
|---|
| 621 | */ | 
|---|
| 622 | UV_UDP_MMSG_CHUNK = 8, | 
|---|
| 623 | /* | 
|---|
| 624 | * Indicates that the buffer provided has been fully utilized by recvmmsg and | 
|---|
| 625 | * that it should now be freed by the recv_cb callback. When this flag is set | 
|---|
| 626 | * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. | 
|---|
| 627 | */ | 
|---|
| 628 | UV_UDP_MMSG_FREE = 16, | 
|---|
| 629 |  | 
|---|
| 630 | /* | 
|---|
| 631 | * Indicates that recvmmsg should be used, if available. | 
|---|
| 632 | */ | 
|---|
| 633 | UV_UDP_RECVMMSG = 256 | 
|---|
| 634 | }; | 
|---|
| 635 |  | 
|---|
| 636 | typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); | 
|---|
| 637 | typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, | 
|---|
| 638 | ssize_t nread, | 
|---|
| 639 | const uv_buf_t* buf, | 
|---|
| 640 | const struct sockaddr* addr, | 
|---|
| 641 | unsigned flags); | 
|---|
| 642 |  | 
|---|
| 643 | /* uv_udp_t is a subclass of uv_handle_t. */ | 
|---|
| 644 | struct uv_udp_s { | 
|---|
| 645 | UV_HANDLE_FIELDS | 
|---|
| 646 | /* read-only */ | 
|---|
| 647 | /* | 
|---|
| 648 | * Number of bytes queued for sending. This field strictly shows how much | 
|---|
| 649 | * information is currently queued. | 
|---|
| 650 | */ | 
|---|
| 651 | size_t send_queue_size; | 
|---|
| 652 | /* | 
|---|
| 653 | * Number of send requests currently in the queue awaiting to be processed. | 
|---|
| 654 | */ | 
|---|
| 655 | size_t send_queue_count; | 
|---|
| 656 | UV_UDP_PRIVATE_FIELDS | 
|---|
| 657 | }; | 
|---|
| 658 |  | 
|---|
| 659 | /* uv_udp_send_t is a subclass of uv_req_t. */ | 
|---|
| 660 | struct uv_udp_send_s { | 
|---|
| 661 | UV_REQ_FIELDS | 
|---|
| 662 | uv_udp_t* handle; | 
|---|
| 663 | uv_udp_send_cb cb; | 
|---|
| 664 | UV_UDP_SEND_PRIVATE_FIELDS | 
|---|
| 665 | }; | 
|---|
| 666 |  | 
|---|
| 667 | UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); | 
|---|
| 668 | UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); | 
|---|
| 669 | UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); | 
|---|
| 670 | UV_EXTERN int uv_udp_bind(uv_udp_t* handle, | 
|---|
| 671 | const struct sockaddr* addr, | 
|---|
| 672 | unsigned int flags); | 
|---|
| 673 | UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr); | 
|---|
| 674 |  | 
|---|
| 675 | UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle, | 
|---|
| 676 | struct sockaddr* name, | 
|---|
| 677 | int* namelen); | 
|---|
| 678 | UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, | 
|---|
| 679 | struct sockaddr* name, | 
|---|
| 680 | int* namelen); | 
|---|
| 681 | UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, | 
|---|
| 682 | const char* multicast_addr, | 
|---|
| 683 | const char* interface_addr, | 
|---|
| 684 | uv_membership membership); | 
|---|
| 685 | UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, | 
|---|
| 686 | const char* multicast_addr, | 
|---|
| 687 | const char* interface_addr, | 
|---|
| 688 | const char* source_addr, | 
|---|
| 689 | uv_membership membership); | 
|---|
| 690 | UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); | 
|---|
| 691 | UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); | 
|---|
| 692 | UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, | 
|---|
| 693 | const char* interface_addr); | 
|---|
| 694 | UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); | 
|---|
| 695 | UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); | 
|---|
| 696 | UV_EXTERN int uv_udp_send(uv_udp_send_t* req, | 
|---|
| 697 | uv_udp_t* handle, | 
|---|
| 698 | const uv_buf_t bufs[], | 
|---|
| 699 | unsigned int nbufs, | 
|---|
| 700 | const struct sockaddr* addr, | 
|---|
| 701 | uv_udp_send_cb send_cb); | 
|---|
| 702 | UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, | 
|---|
| 703 | const uv_buf_t bufs[], | 
|---|
| 704 | unsigned int nbufs, | 
|---|
| 705 | const struct sockaddr* addr); | 
|---|
| 706 | UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, | 
|---|
| 707 | uv_alloc_cb alloc_cb, | 
|---|
| 708 | uv_udp_recv_cb recv_cb); | 
|---|
| 709 | UV_EXTERN int uv_udp_using_recvmmsg(const uv_udp_t* handle); | 
|---|
| 710 | UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); | 
|---|
| 711 | UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); | 
|---|
| 712 | UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); | 
|---|
| 713 |  | 
|---|
| 714 |  | 
|---|
| 715 | /* | 
|---|
| 716 | * uv_tty_t is a subclass of uv_stream_t. | 
|---|
| 717 | * | 
|---|
| 718 | * Representing a stream for the console. | 
|---|
| 719 | */ | 
|---|
| 720 | struct uv_tty_s { | 
|---|
| 721 | UV_HANDLE_FIELDS | 
|---|
| 722 | UV_STREAM_FIELDS | 
|---|
| 723 | UV_TTY_PRIVATE_FIELDS | 
|---|
| 724 | }; | 
|---|
| 725 |  | 
|---|
| 726 | typedef enum { | 
|---|
| 727 | /* Initial/normal terminal mode */ | 
|---|
| 728 | UV_TTY_MODE_NORMAL, | 
|---|
| 729 | /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ | 
|---|
| 730 | UV_TTY_MODE_RAW, | 
|---|
| 731 | /* Binary-safe I/O mode for IPC (Unix-only) */ | 
|---|
| 732 | UV_TTY_MODE_IO | 
|---|
| 733 | } uv_tty_mode_t; | 
|---|
| 734 |  | 
|---|
| 735 | typedef enum { | 
|---|
| 736 | /* | 
|---|
| 737 | * The console supports handling of virtual terminal sequences | 
|---|
| 738 | * (Windows10 new console, ConEmu) | 
|---|
| 739 | */ | 
|---|
| 740 | UV_TTY_SUPPORTED, | 
|---|
| 741 | /* The console cannot process the virtual terminal sequence.  (Legacy | 
|---|
| 742 | * console) | 
|---|
| 743 | */ | 
|---|
| 744 | UV_TTY_UNSUPPORTED | 
|---|
| 745 | } uv_tty_vtermstate_t; | 
|---|
| 746 |  | 
|---|
| 747 |  | 
|---|
| 748 | UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); | 
|---|
| 749 | UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); | 
|---|
| 750 | UV_EXTERN int uv_tty_reset_mode(void); | 
|---|
| 751 | UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); | 
|---|
| 752 | UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); | 
|---|
| 753 | UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); | 
|---|
| 754 |  | 
|---|
| 755 | #ifdef __cplusplus | 
|---|
| 756 | extern "C++"{ | 
|---|
| 757 |  | 
|---|
| 758 | inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { | 
|---|
| 759 | return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode)); | 
|---|
| 760 | } | 
|---|
| 761 |  | 
|---|
| 762 | } | 
|---|
| 763 | #endif | 
|---|
| 764 |  | 
|---|
| 765 | UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); | 
|---|
| 766 |  | 
|---|
| 767 | /* | 
|---|
| 768 | * uv_pipe_t is a subclass of uv_stream_t. | 
|---|
| 769 | * | 
|---|
| 770 | * Representing a pipe stream or pipe server. On Windows this is a Named | 
|---|
| 771 | * Pipe. On Unix this is a Unix domain socket. | 
|---|
| 772 | */ | 
|---|
| 773 | struct uv_pipe_s { | 
|---|
| 774 | UV_HANDLE_FIELDS | 
|---|
| 775 | UV_STREAM_FIELDS | 
|---|
| 776 | int ipc; /* non-zero if this pipe is used for passing handles */ | 
|---|
| 777 | UV_PIPE_PRIVATE_FIELDS | 
|---|
| 778 | }; | 
|---|
| 779 |  | 
|---|
| 780 | UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); | 
|---|
| 781 | UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); | 
|---|
| 782 | UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); | 
|---|
| 783 | UV_EXTERN void uv_pipe_connect(uv_connect_t* req, | 
|---|
| 784 | uv_pipe_t* handle, | 
|---|
| 785 | const char* name, | 
|---|
| 786 | uv_connect_cb cb); | 
|---|
| 787 | UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, | 
|---|
| 788 | char* buffer, | 
|---|
| 789 | size_t* size); | 
|---|
| 790 | UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, | 
|---|
| 791 | char* buffer, | 
|---|
| 792 | size_t* size); | 
|---|
| 793 | UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); | 
|---|
| 794 | UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); | 
|---|
| 795 | UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); | 
|---|
| 796 | UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); | 
|---|
| 797 |  | 
|---|
| 798 |  | 
|---|
| 799 | struct uv_poll_s { | 
|---|
| 800 | UV_HANDLE_FIELDS | 
|---|
| 801 | uv_poll_cb poll_cb; | 
|---|
| 802 | UV_POLL_PRIVATE_FIELDS | 
|---|
| 803 | }; | 
|---|
| 804 |  | 
|---|
| 805 | enum uv_poll_event { | 
|---|
| 806 | UV_READABLE = 1, | 
|---|
| 807 | UV_WRITABLE = 2, | 
|---|
| 808 | UV_DISCONNECT = 4, | 
|---|
| 809 | UV_PRIORITIZED = 8 | 
|---|
| 810 | }; | 
|---|
| 811 |  | 
|---|
| 812 | UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); | 
|---|
| 813 | UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, | 
|---|
| 814 | uv_poll_t* handle, | 
|---|
| 815 | uv_os_sock_t socket); | 
|---|
| 816 | UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); | 
|---|
| 817 | UV_EXTERN int uv_poll_stop(uv_poll_t* handle); | 
|---|
| 818 |  | 
|---|
| 819 |  | 
|---|
| 820 | struct uv_prepare_s { | 
|---|
| 821 | UV_HANDLE_FIELDS | 
|---|
| 822 | UV_PREPARE_PRIVATE_FIELDS | 
|---|
| 823 | }; | 
|---|
| 824 |  | 
|---|
| 825 | UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); | 
|---|
| 826 | UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); | 
|---|
| 827 | UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); | 
|---|
| 828 |  | 
|---|
| 829 |  | 
|---|
| 830 | struct uv_check_s { | 
|---|
| 831 | UV_HANDLE_FIELDS | 
|---|
| 832 | UV_CHECK_PRIVATE_FIELDS | 
|---|
| 833 | }; | 
|---|
| 834 |  | 
|---|
| 835 | UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); | 
|---|
| 836 | UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); | 
|---|
| 837 | UV_EXTERN int uv_check_stop(uv_check_t* check); | 
|---|
| 838 |  | 
|---|
| 839 |  | 
|---|
| 840 | struct uv_idle_s { | 
|---|
| 841 | UV_HANDLE_FIELDS | 
|---|
| 842 | UV_IDLE_PRIVATE_FIELDS | 
|---|
| 843 | }; | 
|---|
| 844 |  | 
|---|
| 845 | UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); | 
|---|
| 846 | UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); | 
|---|
| 847 | UV_EXTERN int uv_idle_stop(uv_idle_t* idle); | 
|---|
| 848 |  | 
|---|
| 849 |  | 
|---|
| 850 | struct uv_async_s { | 
|---|
| 851 | UV_HANDLE_FIELDS | 
|---|
| 852 | UV_ASYNC_PRIVATE_FIELDS | 
|---|
| 853 | }; | 
|---|
| 854 |  | 
|---|
| 855 | UV_EXTERN int uv_async_init(uv_loop_t*, | 
|---|
| 856 | uv_async_t* async, | 
|---|
| 857 | uv_async_cb async_cb); | 
|---|
| 858 | UV_EXTERN int uv_async_send(uv_async_t* async); | 
|---|
| 859 |  | 
|---|
| 860 |  | 
|---|
| 861 | /* | 
|---|
| 862 | * uv_timer_t is a subclass of uv_handle_t. | 
|---|
| 863 | * | 
|---|
| 864 | * Used to get woken up at a specified time in the future. | 
|---|
| 865 | */ | 
|---|
| 866 | struct uv_timer_s { | 
|---|
| 867 | UV_HANDLE_FIELDS | 
|---|
| 868 | UV_TIMER_PRIVATE_FIELDS | 
|---|
| 869 | }; | 
|---|
| 870 |  | 
|---|
| 871 | UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); | 
|---|
| 872 | UV_EXTERN int uv_timer_start(uv_timer_t* handle, | 
|---|
| 873 | uv_timer_cb cb, | 
|---|
| 874 | uint64_t timeout, | 
|---|
| 875 | uint64_t repeat); | 
|---|
| 876 | UV_EXTERN int uv_timer_stop(uv_timer_t* handle); | 
|---|
| 877 | UV_EXTERN int uv_timer_again(uv_timer_t* handle); | 
|---|
| 878 | UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); | 
|---|
| 879 | UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); | 
|---|
| 880 | UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle); | 
|---|
| 881 |  | 
|---|
| 882 |  | 
|---|
| 883 | /* | 
|---|
| 884 | * uv_getaddrinfo_t is a subclass of uv_req_t. | 
|---|
| 885 | * | 
|---|
| 886 | * Request object for uv_getaddrinfo. | 
|---|
| 887 | */ | 
|---|
| 888 | struct uv_getaddrinfo_s { | 
|---|
| 889 | UV_REQ_FIELDS | 
|---|
| 890 | /* read-only */ | 
|---|
| 891 | uv_loop_t* loop; | 
|---|
| 892 | /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ | 
|---|
| 893 | UV_GETADDRINFO_PRIVATE_FIELDS | 
|---|
| 894 | }; | 
|---|
| 895 |  | 
|---|
| 896 |  | 
|---|
| 897 | UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, | 
|---|
| 898 | uv_getaddrinfo_t* req, | 
|---|
| 899 | uv_getaddrinfo_cb getaddrinfo_cb, | 
|---|
| 900 | const char* node, | 
|---|
| 901 | const char* service, | 
|---|
| 902 | const struct addrinfo* hints); | 
|---|
| 903 | UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); | 
|---|
| 904 |  | 
|---|
| 905 |  | 
|---|
| 906 | /* | 
|---|
| 907 | * uv_getnameinfo_t is a subclass of uv_req_t. | 
|---|
| 908 | * | 
|---|
| 909 | * Request object for uv_getnameinfo. | 
|---|
| 910 | */ | 
|---|
| 911 | struct uv_getnameinfo_s { | 
|---|
| 912 | UV_REQ_FIELDS | 
|---|
| 913 | /* read-only */ | 
|---|
| 914 | uv_loop_t* loop; | 
|---|
| 915 | /* host and service are marked as private, but they really aren't. */ | 
|---|
| 916 | UV_GETNAMEINFO_PRIVATE_FIELDS | 
|---|
| 917 | }; | 
|---|
| 918 |  | 
|---|
| 919 | UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, | 
|---|
| 920 | uv_getnameinfo_t* req, | 
|---|
| 921 | uv_getnameinfo_cb getnameinfo_cb, | 
|---|
| 922 | const struct sockaddr* addr, | 
|---|
| 923 | int flags); | 
|---|
| 924 |  | 
|---|
| 925 |  | 
|---|
| 926 | /* uv_spawn() options. */ | 
|---|
| 927 | typedef enum { | 
|---|
| 928 | UV_IGNORE         = 0x00, | 
|---|
| 929 | UV_CREATE_PIPE    = 0x01, | 
|---|
| 930 | UV_INHERIT_FD     = 0x02, | 
|---|
| 931 | UV_INHERIT_STREAM = 0x04, | 
|---|
| 932 |  | 
|---|
| 933 | /* | 
|---|
| 934 | * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE | 
|---|
| 935 | * determine the direction of flow, from the child process' perspective. Both | 
|---|
| 936 | * flags may be specified to create a duplex data stream. | 
|---|
| 937 | */ | 
|---|
| 938 | UV_READABLE_PIPE  = 0x10, | 
|---|
| 939 | UV_WRITABLE_PIPE  = 0x20, | 
|---|
| 940 |  | 
|---|
| 941 | /* | 
|---|
| 942 | * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the | 
|---|
| 943 | * handle in non-blocking mode in the child. This may cause loss of data, | 
|---|
| 944 | * if the child is not designed to handle to encounter this mode, | 
|---|
| 945 | * but can also be significantly more efficient. | 
|---|
| 946 | */ | 
|---|
| 947 | UV_NONBLOCK_PIPE  = 0x40, | 
|---|
| 948 | UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */ | 
|---|
| 949 | } uv_stdio_flags; | 
|---|
| 950 |  | 
|---|
| 951 | typedef struct uv_stdio_container_s { | 
|---|
| 952 | uv_stdio_flags flags; | 
|---|
| 953 |  | 
|---|
| 954 | union { | 
|---|
| 955 | uv_stream_t* stream; | 
|---|
| 956 | int fd; | 
|---|
| 957 | } data; | 
|---|
| 958 | } uv_stdio_container_t; | 
|---|
| 959 |  | 
|---|
| 960 | typedef struct uv_process_options_s { | 
|---|
| 961 | uv_exit_cb exit_cb; /* Called after the process exits. */ | 
|---|
| 962 | const char* file;   /* Path to program to execute. */ | 
|---|
| 963 | /* | 
|---|
| 964 | * Command line arguments. args[0] should be the path to the program. On | 
|---|
| 965 | * Windows this uses CreateProcess which concatenates the arguments into a | 
|---|
| 966 | * string this can cause some strange errors. See the note at | 
|---|
| 967 | * windows_verbatim_arguments. | 
|---|
| 968 | */ | 
|---|
| 969 | char** args; | 
|---|
| 970 | /* | 
|---|
| 971 | * This will be set as the environ variable in the subprocess. If this is | 
|---|
| 972 | * NULL then the parents environ will be used. | 
|---|
| 973 | */ | 
|---|
| 974 | char** env; | 
|---|
| 975 | /* | 
|---|
| 976 | * If non-null this represents a directory the subprocess should execute | 
|---|
| 977 | * in. Stands for current working directory. | 
|---|
| 978 | */ | 
|---|
| 979 | const char* cwd; | 
|---|
| 980 | /* | 
|---|
| 981 | * Various flags that control how uv_spawn() behaves. See the definition of | 
|---|
| 982 | * `enum uv_process_flags` below. | 
|---|
| 983 | */ | 
|---|
| 984 | unsigned int flags; | 
|---|
| 985 | /* | 
|---|
| 986 | * The `stdio` field points to an array of uv_stdio_container_t structs that | 
|---|
| 987 | * describe the file descriptors that will be made available to the child | 
|---|
| 988 | * process. The convention is that stdio[0] points to stdin, fd 1 is used for | 
|---|
| 989 | * stdout, and fd 2 is stderr. | 
|---|
| 990 | * | 
|---|
| 991 | * Note that on windows file descriptors greater than 2 are available to the | 
|---|
| 992 | * child process only if the child processes uses the MSVCRT runtime. | 
|---|
| 993 | */ | 
|---|
| 994 | int stdio_count; | 
|---|
| 995 | uv_stdio_container_t* stdio; | 
|---|
| 996 | /* | 
|---|
| 997 | * Libuv can change the child process' user/group id. This happens only when | 
|---|
| 998 | * the appropriate bits are set in the flags fields. This is not supported on | 
|---|
| 999 | * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. | 
|---|
| 1000 | */ | 
|---|
| 1001 | uv_uid_t uid; | 
|---|
| 1002 | uv_gid_t gid; | 
|---|
| 1003 | } uv_process_options_t; | 
|---|
| 1004 |  | 
|---|
| 1005 | /* | 
|---|
| 1006 | * These are the flags that can be used for the uv_process_options.flags field. | 
|---|
| 1007 | */ | 
|---|
| 1008 | enum uv_process_flags { | 
|---|
| 1009 | /* | 
|---|
| 1010 | * Set the child process' user id. The user id is supplied in the `uid` field | 
|---|
| 1011 | * of the options struct. This does not work on windows; setting this flag | 
|---|
| 1012 | * will cause uv_spawn() to fail. | 
|---|
| 1013 | */ | 
|---|
| 1014 | UV_PROCESS_SETUID = (1 << 0), | 
|---|
| 1015 | /* | 
|---|
| 1016 | * Set the child process' group id. The user id is supplied in the `gid` | 
|---|
| 1017 | * field of the options struct. This does not work on windows; setting this | 
|---|
| 1018 | * flag will cause uv_spawn() to fail. | 
|---|
| 1019 | */ | 
|---|
| 1020 | UV_PROCESS_SETGID = (1 << 1), | 
|---|
| 1021 | /* | 
|---|
| 1022 | * Do not wrap any arguments in quotes, or perform any other escaping, when | 
|---|
| 1023 | * converting the argument list into a command line string. This option is | 
|---|
| 1024 | * only meaningful on Windows systems. On Unix it is silently ignored. | 
|---|
| 1025 | */ | 
|---|
| 1026 | UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), | 
|---|
| 1027 | /* | 
|---|
| 1028 | * Spawn the child process in a detached state - this will make it a process | 
|---|
| 1029 | * group leader, and will effectively enable the child to keep running after | 
|---|
| 1030 | * the parent exits.  Note that the child process will still keep the | 
|---|
| 1031 | * parent's event loop alive unless the parent process calls uv_unref() on | 
|---|
| 1032 | * the child's process handle. | 
|---|
| 1033 | */ | 
|---|
| 1034 | UV_PROCESS_DETACHED = (1 << 3), | 
|---|
| 1035 | /* | 
|---|
| 1036 | * Hide the subprocess window that would normally be created. This option is | 
|---|
| 1037 | * only meaningful on Windows systems. On Unix it is silently ignored. | 
|---|
| 1038 | */ | 
|---|
| 1039 | UV_PROCESS_WINDOWS_HIDE = (1 << 4), | 
|---|
| 1040 | /* | 
|---|
| 1041 | * Hide the subprocess console window that would normally be created. This | 
|---|
| 1042 | * option is only meaningful on Windows systems. On Unix it is silently | 
|---|
| 1043 | * ignored. | 
|---|
| 1044 | */ | 
|---|
| 1045 | UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), | 
|---|
| 1046 | /* | 
|---|
| 1047 | * Hide the subprocess GUI window that would normally be created. This | 
|---|
| 1048 | * option is only meaningful on Windows systems. On Unix it is silently | 
|---|
| 1049 | * ignored. | 
|---|
| 1050 | */ | 
|---|
| 1051 | UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) | 
|---|
| 1052 | }; | 
|---|
| 1053 |  | 
|---|
| 1054 | /* | 
|---|
| 1055 | * uv_process_t is a subclass of uv_handle_t. | 
|---|
| 1056 | */ | 
|---|
| 1057 | struct uv_process_s { | 
|---|
| 1058 | UV_HANDLE_FIELDS | 
|---|
| 1059 | uv_exit_cb exit_cb; | 
|---|
| 1060 | int pid; | 
|---|
| 1061 | UV_PROCESS_PRIVATE_FIELDS | 
|---|
| 1062 | }; | 
|---|
| 1063 |  | 
|---|
| 1064 | UV_EXTERN int uv_spawn(uv_loop_t* loop, | 
|---|
| 1065 | uv_process_t* handle, | 
|---|
| 1066 | const uv_process_options_t* options); | 
|---|
| 1067 | UV_EXTERN int uv_process_kill(uv_process_t*, int signum); | 
|---|
| 1068 | UV_EXTERN int uv_kill(int pid, int signum); | 
|---|
| 1069 | UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); | 
|---|
| 1070 |  | 
|---|
| 1071 |  | 
|---|
| 1072 | /* | 
|---|
| 1073 | * uv_work_t is a subclass of uv_req_t. | 
|---|
| 1074 | */ | 
|---|
| 1075 | struct uv_work_s { | 
|---|
| 1076 | UV_REQ_FIELDS | 
|---|
| 1077 | uv_loop_t* loop; | 
|---|
| 1078 | uv_work_cb work_cb; | 
|---|
| 1079 | uv_after_work_cb after_work_cb; | 
|---|
| 1080 | UV_WORK_PRIVATE_FIELDS | 
|---|
| 1081 | }; | 
|---|
| 1082 |  | 
|---|
| 1083 | UV_EXTERN int uv_queue_work(uv_loop_t* loop, | 
|---|
| 1084 | uv_work_t* req, | 
|---|
| 1085 | uv_work_cb work_cb, | 
|---|
| 1086 | uv_after_work_cb after_work_cb); | 
|---|
| 1087 |  | 
|---|
| 1088 | UV_EXTERN int uv_cancel(uv_req_t* req); | 
|---|
| 1089 |  | 
|---|
| 1090 |  | 
|---|
| 1091 | struct uv_cpu_times_s { | 
|---|
| 1092 | uint64_t user; /* milliseconds */ | 
|---|
| 1093 | uint64_t nice; /* milliseconds */ | 
|---|
| 1094 | uint64_t sys; /* milliseconds */ | 
|---|
| 1095 | uint64_t idle; /* milliseconds */ | 
|---|
| 1096 | uint64_t irq; /* milliseconds */ | 
|---|
| 1097 | }; | 
|---|
| 1098 |  | 
|---|
| 1099 | struct uv_cpu_info_s { | 
|---|
| 1100 | char* model; | 
|---|
| 1101 | int speed; | 
|---|
| 1102 | struct uv_cpu_times_s cpu_times; | 
|---|
| 1103 | }; | 
|---|
| 1104 |  | 
|---|
| 1105 | struct uv_interface_address_s { | 
|---|
| 1106 | char* name; | 
|---|
| 1107 | char phys_addr[6]; | 
|---|
| 1108 | int is_internal; | 
|---|
| 1109 | union { | 
|---|
| 1110 | struct sockaddr_in address4; | 
|---|
| 1111 | struct sockaddr_in6 address6; | 
|---|
| 1112 | } address; | 
|---|
| 1113 | union { | 
|---|
| 1114 | struct sockaddr_in netmask4; | 
|---|
| 1115 | struct sockaddr_in6 netmask6; | 
|---|
| 1116 | } netmask; | 
|---|
| 1117 | }; | 
|---|
| 1118 |  | 
|---|
| 1119 | struct uv_passwd_s { | 
|---|
| 1120 | char* username; | 
|---|
| 1121 | long uid; | 
|---|
| 1122 | long gid; | 
|---|
| 1123 | char* shell; | 
|---|
| 1124 | char* homedir; | 
|---|
| 1125 | }; | 
|---|
| 1126 |  | 
|---|
| 1127 | struct uv_utsname_s { | 
|---|
| 1128 | char sysname[256]; | 
|---|
| 1129 | char release[256]; | 
|---|
| 1130 | char version[256]; | 
|---|
| 1131 | char machine[256]; | 
|---|
| 1132 | /* This struct does not contain the nodename and domainname fields present in | 
|---|
| 1133 | the utsname type. domainname is a GNU extension. Both fields are referred | 
|---|
| 1134 | to as meaningless in the docs. */ | 
|---|
| 1135 | }; | 
|---|
| 1136 |  | 
|---|
| 1137 | struct uv_statfs_s { | 
|---|
| 1138 | uint64_t f_type; | 
|---|
| 1139 | uint64_t f_bsize; | 
|---|
| 1140 | uint64_t f_blocks; | 
|---|
| 1141 | uint64_t f_bfree; | 
|---|
| 1142 | uint64_t f_bavail; | 
|---|
| 1143 | uint64_t f_files; | 
|---|
| 1144 | uint64_t f_ffree; | 
|---|
| 1145 | uint64_t f_spare[4]; | 
|---|
| 1146 | }; | 
|---|
| 1147 |  | 
|---|
| 1148 | typedef enum { | 
|---|
| 1149 | UV_DIRENT_UNKNOWN, | 
|---|
| 1150 | UV_DIRENT_FILE, | 
|---|
| 1151 | UV_DIRENT_DIR, | 
|---|
| 1152 | UV_DIRENT_LINK, | 
|---|
| 1153 | UV_DIRENT_FIFO, | 
|---|
| 1154 | UV_DIRENT_SOCKET, | 
|---|
| 1155 | UV_DIRENT_CHAR, | 
|---|
| 1156 | UV_DIRENT_BLOCK | 
|---|
| 1157 | } uv_dirent_type_t; | 
|---|
| 1158 |  | 
|---|
| 1159 | struct uv_dirent_s { | 
|---|
| 1160 | const char* name; | 
|---|
| 1161 | uv_dirent_type_t type; | 
|---|
| 1162 | }; | 
|---|
| 1163 |  | 
|---|
| 1164 | UV_EXTERN char** uv_setup_args(int argc, char** argv); | 
|---|
| 1165 | UV_EXTERN int uv_get_process_title(char* buffer, size_t size); | 
|---|
| 1166 | UV_EXTERN int uv_set_process_title(const char* title); | 
|---|
| 1167 | UV_EXTERN int uv_resident_set_memory(size_t* ); | 
|---|
| 1168 | UV_EXTERN int uv_uptime(double* uptime); | 
|---|
| 1169 | UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); | 
|---|
| 1170 | UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); | 
|---|
| 1171 |  | 
|---|
| 1172 | typedef struct { | 
|---|
| 1173 | long tv_sec; | 
|---|
| 1174 | long tv_usec; | 
|---|
| 1175 | } uv_timeval_t; | 
|---|
| 1176 |  | 
|---|
| 1177 | typedef struct { | 
|---|
| 1178 | int64_t tv_sec; | 
|---|
| 1179 | int32_t tv_usec; | 
|---|
| 1180 | } uv_timeval64_t; | 
|---|
| 1181 |  | 
|---|
| 1182 | typedef struct { | 
|---|
| 1183 | uv_timeval_t ru_utime; /* user CPU time used */ | 
|---|
| 1184 | uv_timeval_t ru_stime; /* system CPU time used */ | 
|---|
| 1185 | uint64_t ;    /* maximum resident set size */ | 
|---|
| 1186 | uint64_t ;     /* integral shared memory size */ | 
|---|
| 1187 | uint64_t ;     /* integral unshared data size */ | 
|---|
| 1188 | uint64_t ;     /* integral unshared stack size */ | 
|---|
| 1189 | uint64_t ru_minflt;    /* page reclaims (soft page faults) */ | 
|---|
| 1190 | uint64_t ru_majflt;    /* page faults (hard page faults) */ | 
|---|
| 1191 | uint64_t ru_nswap;     /* swaps */ | 
|---|
| 1192 | uint64_t ru_inblock;   /* block input operations */ | 
|---|
| 1193 | uint64_t ru_oublock;   /* block output operations */ | 
|---|
| 1194 | uint64_t ru_msgsnd;    /* IPC messages sent */ | 
|---|
| 1195 | uint64_t ru_msgrcv;    /* IPC messages received */ | 
|---|
| 1196 | uint64_t ru_nsignals;  /* signals received */ | 
|---|
| 1197 | uint64_t ru_nvcsw;     /* voluntary context switches */ | 
|---|
| 1198 | uint64_t ru_nivcsw;    /* involuntary context switches */ | 
|---|
| 1199 | } uv_rusage_t; | 
|---|
| 1200 |  | 
|---|
| 1201 | UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); | 
|---|
| 1202 |  | 
|---|
| 1203 | UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); | 
|---|
| 1204 | UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); | 
|---|
| 1205 | UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); | 
|---|
| 1206 | UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); | 
|---|
| 1207 | UV_EXTERN uv_pid_t uv_os_getpid(void); | 
|---|
| 1208 | UV_EXTERN uv_pid_t uv_os_getppid(void); | 
|---|
| 1209 |  | 
|---|
| 1210 | #if defined(__PASE__) | 
|---|
| 1211 | /* On IBM i PASE, the highest process priority is -10 */ | 
|---|
| 1212 | # define UV_PRIORITY_LOW 39          /* RUNPTY(99) */ | 
|---|
| 1213 | # define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ | 
|---|
| 1214 | # define UV_PRIORITY_NORMAL 0        /* RUNPTY(20) */ | 
|---|
| 1215 | # define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ | 
|---|
| 1216 | # define UV_PRIORITY_HIGH -7         /* RUNPTY(6) */ | 
|---|
| 1217 | # define UV_PRIORITY_HIGHEST -10     /* RUNPTY(1) */ | 
|---|
| 1218 | #else | 
|---|
| 1219 | # define UV_PRIORITY_LOW 19 | 
|---|
| 1220 | # define UV_PRIORITY_BELOW_NORMAL 10 | 
|---|
| 1221 | # define UV_PRIORITY_NORMAL 0 | 
|---|
| 1222 | # define UV_PRIORITY_ABOVE_NORMAL -7 | 
|---|
| 1223 | # define UV_PRIORITY_HIGH -14 | 
|---|
| 1224 | # define UV_PRIORITY_HIGHEST -20 | 
|---|
| 1225 | #endif | 
|---|
| 1226 |  | 
|---|
| 1227 | UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); | 
|---|
| 1228 | UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); | 
|---|
| 1229 |  | 
|---|
| 1230 | UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); | 
|---|
| 1231 | UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); | 
|---|
| 1232 |  | 
|---|
| 1233 | UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, | 
|---|
| 1234 | int* count); | 
|---|
| 1235 | UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, | 
|---|
| 1236 | int count); | 
|---|
| 1237 |  | 
|---|
| 1238 | struct uv_env_item_s { | 
|---|
| 1239 | char* name; | 
|---|
| 1240 | char* value; | 
|---|
| 1241 | }; | 
|---|
| 1242 |  | 
|---|
| 1243 | UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); | 
|---|
| 1244 | UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); | 
|---|
| 1245 | UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); | 
|---|
| 1246 | UV_EXTERN int uv_os_setenv(const char* name, const char* value); | 
|---|
| 1247 | UV_EXTERN int uv_os_unsetenv(const char* name); | 
|---|
| 1248 |  | 
|---|
| 1249 | #ifdef MAXHOSTNAMELEN | 
|---|
| 1250 | # define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1) | 
|---|
| 1251 | #else | 
|---|
| 1252 | /* | 
|---|
| 1253 | Fallback for the maximum hostname size, including the null terminator. The | 
|---|
| 1254 | Windows gethostname() documentation states that 256 bytes will always be | 
|---|
| 1255 | large enough to hold the null-terminated hostname. | 
|---|
| 1256 | */ | 
|---|
| 1257 | # define UV_MAXHOSTNAMESIZE 256 | 
|---|
| 1258 | #endif | 
|---|
| 1259 |  | 
|---|
| 1260 | UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); | 
|---|
| 1261 |  | 
|---|
| 1262 | UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); | 
|---|
| 1263 |  | 
|---|
| 1264 | UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop); | 
|---|
| 1265 |  | 
|---|
| 1266 | typedef enum { | 
|---|
| 1267 | UV_FS_UNKNOWN = -1, | 
|---|
| 1268 | UV_FS_CUSTOM, | 
|---|
| 1269 | UV_FS_OPEN, | 
|---|
| 1270 | UV_FS_CLOSE, | 
|---|
| 1271 | UV_FS_READ, | 
|---|
| 1272 | UV_FS_WRITE, | 
|---|
| 1273 | UV_FS_SENDFILE, | 
|---|
| 1274 | UV_FS_STAT, | 
|---|
| 1275 | UV_FS_LSTAT, | 
|---|
| 1276 | UV_FS_FSTAT, | 
|---|
| 1277 | UV_FS_FTRUNCATE, | 
|---|
| 1278 | UV_FS_UTIME, | 
|---|
| 1279 | UV_FS_FUTIME, | 
|---|
| 1280 | UV_FS_ACCESS, | 
|---|
| 1281 | UV_FS_CHMOD, | 
|---|
| 1282 | UV_FS_FCHMOD, | 
|---|
| 1283 | UV_FS_FSYNC, | 
|---|
| 1284 | UV_FS_FDATASYNC, | 
|---|
| 1285 | UV_FS_UNLINK, | 
|---|
| 1286 | UV_FS_RMDIR, | 
|---|
| 1287 | UV_FS_MKDIR, | 
|---|
| 1288 | UV_FS_MKDTEMP, | 
|---|
| 1289 | UV_FS_RENAME, | 
|---|
| 1290 | UV_FS_SCANDIR, | 
|---|
| 1291 | UV_FS_LINK, | 
|---|
| 1292 | UV_FS_SYMLINK, | 
|---|
| 1293 | UV_FS_READLINK, | 
|---|
| 1294 | UV_FS_CHOWN, | 
|---|
| 1295 | UV_FS_FCHOWN, | 
|---|
| 1296 | UV_FS_REALPATH, | 
|---|
| 1297 | UV_FS_COPYFILE, | 
|---|
| 1298 | UV_FS_LCHOWN, | 
|---|
| 1299 | UV_FS_OPENDIR, | 
|---|
| 1300 | UV_FS_READDIR, | 
|---|
| 1301 | UV_FS_CLOSEDIR, | 
|---|
| 1302 | UV_FS_STATFS, | 
|---|
| 1303 | UV_FS_MKSTEMP, | 
|---|
| 1304 | UV_FS_LUTIME | 
|---|
| 1305 | } uv_fs_type; | 
|---|
| 1306 |  | 
|---|
| 1307 | struct uv_dir_s { | 
|---|
| 1308 | uv_dirent_t* dirents; | 
|---|
| 1309 | size_t nentries; | 
|---|
| 1310 | void* reserved[4]; | 
|---|
| 1311 | UV_DIR_PRIVATE_FIELDS | 
|---|
| 1312 | }; | 
|---|
| 1313 |  | 
|---|
| 1314 | /* uv_fs_t is a subclass of uv_req_t. */ | 
|---|
| 1315 | struct uv_fs_s { | 
|---|
| 1316 | UV_REQ_FIELDS | 
|---|
| 1317 | uv_fs_type fs_type; | 
|---|
| 1318 | uv_loop_t* loop; | 
|---|
| 1319 | uv_fs_cb cb; | 
|---|
| 1320 | ssize_t result; | 
|---|
| 1321 | void* ptr; | 
|---|
| 1322 | const char* path; | 
|---|
| 1323 | uv_stat_t statbuf;  /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ | 
|---|
| 1324 | UV_FS_PRIVATE_FIELDS | 
|---|
| 1325 | }; | 
|---|
| 1326 |  | 
|---|
| 1327 | UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); | 
|---|
| 1328 | UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); | 
|---|
| 1329 | UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*); | 
|---|
| 1330 | UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); | 
|---|
| 1331 | UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); | 
|---|
| 1332 | UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); | 
|---|
| 1333 |  | 
|---|
| 1334 | UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); | 
|---|
| 1335 | UV_EXTERN int uv_fs_close(uv_loop_t* loop, | 
|---|
| 1336 | uv_fs_t* req, | 
|---|
| 1337 | uv_file file, | 
|---|
| 1338 | uv_fs_cb cb); | 
|---|
| 1339 | UV_EXTERN int uv_fs_open(uv_loop_t* loop, | 
|---|
| 1340 | uv_fs_t* req, | 
|---|
| 1341 | const char* path, | 
|---|
| 1342 | int flags, | 
|---|
| 1343 | int mode, | 
|---|
| 1344 | uv_fs_cb cb); | 
|---|
| 1345 | UV_EXTERN int uv_fs_read(uv_loop_t* loop, | 
|---|
| 1346 | uv_fs_t* req, | 
|---|
| 1347 | uv_file file, | 
|---|
| 1348 | const uv_buf_t bufs[], | 
|---|
| 1349 | unsigned int nbufs, | 
|---|
| 1350 | int64_t offset, | 
|---|
| 1351 | uv_fs_cb cb); | 
|---|
| 1352 | UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, | 
|---|
| 1353 | uv_fs_t* req, | 
|---|
| 1354 | const char* path, | 
|---|
| 1355 | uv_fs_cb cb); | 
|---|
| 1356 | UV_EXTERN int uv_fs_write(uv_loop_t* loop, | 
|---|
| 1357 | uv_fs_t* req, | 
|---|
| 1358 | uv_file file, | 
|---|
| 1359 | const uv_buf_t bufs[], | 
|---|
| 1360 | unsigned int nbufs, | 
|---|
| 1361 | int64_t offset, | 
|---|
| 1362 | uv_fs_cb cb); | 
|---|
| 1363 | /* | 
|---|
| 1364 | * This flag can be used with uv_fs_copyfile() to return an error if the | 
|---|
| 1365 | * destination already exists. | 
|---|
| 1366 | */ | 
|---|
| 1367 | #define UV_FS_COPYFILE_EXCL   0x0001 | 
|---|
| 1368 |  | 
|---|
| 1369 | /* | 
|---|
| 1370 | * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. | 
|---|
| 1371 | * If copy-on-write is not supported, a fallback copy mechanism is used. | 
|---|
| 1372 | */ | 
|---|
| 1373 | #define UV_FS_COPYFILE_FICLONE 0x0002 | 
|---|
| 1374 |  | 
|---|
| 1375 | /* | 
|---|
| 1376 | * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. | 
|---|
| 1377 | * If copy-on-write is not supported, an error is returned. | 
|---|
| 1378 | */ | 
|---|
| 1379 | #define UV_FS_COPYFILE_FICLONE_FORCE 0x0004 | 
|---|
| 1380 |  | 
|---|
| 1381 | UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, | 
|---|
| 1382 | uv_fs_t* req, | 
|---|
| 1383 | const char* path, | 
|---|
| 1384 | const char* new_path, | 
|---|
| 1385 | int flags, | 
|---|
| 1386 | uv_fs_cb cb); | 
|---|
| 1387 | UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, | 
|---|
| 1388 | uv_fs_t* req, | 
|---|
| 1389 | const char* path, | 
|---|
| 1390 | int mode, | 
|---|
| 1391 | uv_fs_cb cb); | 
|---|
| 1392 | UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, | 
|---|
| 1393 | uv_fs_t* req, | 
|---|
| 1394 | const char* tpl, | 
|---|
| 1395 | uv_fs_cb cb); | 
|---|
| 1396 | UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, | 
|---|
| 1397 | uv_fs_t* req, | 
|---|
| 1398 | const char* tpl, | 
|---|
| 1399 | uv_fs_cb cb); | 
|---|
| 1400 | UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, | 
|---|
| 1401 | uv_fs_t* req, | 
|---|
| 1402 | const char* path, | 
|---|
| 1403 | uv_fs_cb cb); | 
|---|
| 1404 | UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, | 
|---|
| 1405 | uv_fs_t* req, | 
|---|
| 1406 | const char* path, | 
|---|
| 1407 | int flags, | 
|---|
| 1408 | uv_fs_cb cb); | 
|---|
| 1409 | UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, | 
|---|
| 1410 | uv_dirent_t* ent); | 
|---|
| 1411 | UV_EXTERN int uv_fs_opendir(uv_loop_t* loop, | 
|---|
| 1412 | uv_fs_t* req, | 
|---|
| 1413 | const char* path, | 
|---|
| 1414 | uv_fs_cb cb); | 
|---|
| 1415 | UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, | 
|---|
| 1416 | uv_fs_t* req, | 
|---|
| 1417 | uv_dir_t* dir, | 
|---|
| 1418 | uv_fs_cb cb); | 
|---|
| 1419 | UV_EXTERN int uv_fs_closedir(uv_loop_t* loop, | 
|---|
| 1420 | uv_fs_t* req, | 
|---|
| 1421 | uv_dir_t* dir, | 
|---|
| 1422 | uv_fs_cb cb); | 
|---|
| 1423 | UV_EXTERN int uv_fs_stat(uv_loop_t* loop, | 
|---|
| 1424 | uv_fs_t* req, | 
|---|
| 1425 | const char* path, | 
|---|
| 1426 | uv_fs_cb cb); | 
|---|
| 1427 | UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, | 
|---|
| 1428 | uv_fs_t* req, | 
|---|
| 1429 | uv_file file, | 
|---|
| 1430 | uv_fs_cb cb); | 
|---|
| 1431 | UV_EXTERN int uv_fs_rename(uv_loop_t* loop, | 
|---|
| 1432 | uv_fs_t* req, | 
|---|
| 1433 | const char* path, | 
|---|
| 1434 | const char* new_path, | 
|---|
| 1435 | uv_fs_cb cb); | 
|---|
| 1436 | UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, | 
|---|
| 1437 | uv_fs_t* req, | 
|---|
| 1438 | uv_file file, | 
|---|
| 1439 | uv_fs_cb cb); | 
|---|
| 1440 | UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, | 
|---|
| 1441 | uv_fs_t* req, | 
|---|
| 1442 | uv_file file, | 
|---|
| 1443 | uv_fs_cb cb); | 
|---|
| 1444 | UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, | 
|---|
| 1445 | uv_fs_t* req, | 
|---|
| 1446 | uv_file file, | 
|---|
| 1447 | int64_t offset, | 
|---|
| 1448 | uv_fs_cb cb); | 
|---|
| 1449 | UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, | 
|---|
| 1450 | uv_fs_t* req, | 
|---|
| 1451 | uv_file out_fd, | 
|---|
| 1452 | uv_file in_fd, | 
|---|
| 1453 | int64_t in_offset, | 
|---|
| 1454 | size_t length, | 
|---|
| 1455 | uv_fs_cb cb); | 
|---|
| 1456 | UV_EXTERN int uv_fs_access(uv_loop_t* loop, | 
|---|
| 1457 | uv_fs_t* req, | 
|---|
| 1458 | const char* path, | 
|---|
| 1459 | int mode, | 
|---|
| 1460 | uv_fs_cb cb); | 
|---|
| 1461 | UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, | 
|---|
| 1462 | uv_fs_t* req, | 
|---|
| 1463 | const char* path, | 
|---|
| 1464 | int mode, | 
|---|
| 1465 | uv_fs_cb cb); | 
|---|
| 1466 | UV_EXTERN int uv_fs_utime(uv_loop_t* loop, | 
|---|
| 1467 | uv_fs_t* req, | 
|---|
| 1468 | const char* path, | 
|---|
| 1469 | double atime, | 
|---|
| 1470 | double mtime, | 
|---|
| 1471 | uv_fs_cb cb); | 
|---|
| 1472 | UV_EXTERN int uv_fs_futime(uv_loop_t* loop, | 
|---|
| 1473 | uv_fs_t* req, | 
|---|
| 1474 | uv_file file, | 
|---|
| 1475 | double atime, | 
|---|
| 1476 | double mtime, | 
|---|
| 1477 | uv_fs_cb cb); | 
|---|
| 1478 | UV_EXTERN int uv_fs_lutime(uv_loop_t* loop, | 
|---|
| 1479 | uv_fs_t* req, | 
|---|
| 1480 | const char* path, | 
|---|
| 1481 | double atime, | 
|---|
| 1482 | double mtime, | 
|---|
| 1483 | uv_fs_cb cb); | 
|---|
| 1484 | UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, | 
|---|
| 1485 | uv_fs_t* req, | 
|---|
| 1486 | const char* path, | 
|---|
| 1487 | uv_fs_cb cb); | 
|---|
| 1488 | UV_EXTERN int uv_fs_link(uv_loop_t* loop, | 
|---|
| 1489 | uv_fs_t* req, | 
|---|
| 1490 | const char* path, | 
|---|
| 1491 | const char* new_path, | 
|---|
| 1492 | uv_fs_cb cb); | 
|---|
| 1493 |  | 
|---|
| 1494 | /* | 
|---|
| 1495 | * This flag can be used with uv_fs_symlink() on Windows to specify whether | 
|---|
| 1496 | * path argument points to a directory. | 
|---|
| 1497 | */ | 
|---|
| 1498 | #define UV_FS_SYMLINK_DIR          0x0001 | 
|---|
| 1499 |  | 
|---|
| 1500 | /* | 
|---|
| 1501 | * This flag can be used with uv_fs_symlink() on Windows to specify whether | 
|---|
| 1502 | * the symlink is to be created using junction points. | 
|---|
| 1503 | */ | 
|---|
| 1504 | #define UV_FS_SYMLINK_JUNCTION     0x0002 | 
|---|
| 1505 |  | 
|---|
| 1506 | UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, | 
|---|
| 1507 | uv_fs_t* req, | 
|---|
| 1508 | const char* path, | 
|---|
| 1509 | const char* new_path, | 
|---|
| 1510 | int flags, | 
|---|
| 1511 | uv_fs_cb cb); | 
|---|
| 1512 | UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, | 
|---|
| 1513 | uv_fs_t* req, | 
|---|
| 1514 | const char* path, | 
|---|
| 1515 | uv_fs_cb cb); | 
|---|
| 1516 | UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, | 
|---|
| 1517 | uv_fs_t* req, | 
|---|
| 1518 | const char* path, | 
|---|
| 1519 | uv_fs_cb cb); | 
|---|
| 1520 | UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, | 
|---|
| 1521 | uv_fs_t* req, | 
|---|
| 1522 | uv_file file, | 
|---|
| 1523 | int mode, | 
|---|
| 1524 | uv_fs_cb cb); | 
|---|
| 1525 | UV_EXTERN int uv_fs_chown(uv_loop_t* loop, | 
|---|
| 1526 | uv_fs_t* req, | 
|---|
| 1527 | const char* path, | 
|---|
| 1528 | uv_uid_t uid, | 
|---|
| 1529 | uv_gid_t gid, | 
|---|
| 1530 | uv_fs_cb cb); | 
|---|
| 1531 | UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, | 
|---|
| 1532 | uv_fs_t* req, | 
|---|
| 1533 | uv_file file, | 
|---|
| 1534 | uv_uid_t uid, | 
|---|
| 1535 | uv_gid_t gid, | 
|---|
| 1536 | uv_fs_cb cb); | 
|---|
| 1537 | UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, | 
|---|
| 1538 | uv_fs_t* req, | 
|---|
| 1539 | const char* path, | 
|---|
| 1540 | uv_uid_t uid, | 
|---|
| 1541 | uv_gid_t gid, | 
|---|
| 1542 | uv_fs_cb cb); | 
|---|
| 1543 | UV_EXTERN int uv_fs_statfs(uv_loop_t* loop, | 
|---|
| 1544 | uv_fs_t* req, | 
|---|
| 1545 | const char* path, | 
|---|
| 1546 | uv_fs_cb cb); | 
|---|
| 1547 |  | 
|---|
| 1548 |  | 
|---|
| 1549 | enum uv_fs_event { | 
|---|
| 1550 | UV_RENAME = 1, | 
|---|
| 1551 | UV_CHANGE = 2 | 
|---|
| 1552 | }; | 
|---|
| 1553 |  | 
|---|
| 1554 |  | 
|---|
| 1555 | struct uv_fs_event_s { | 
|---|
| 1556 | UV_HANDLE_FIELDS | 
|---|
| 1557 | /* private */ | 
|---|
| 1558 | char* path; | 
|---|
| 1559 | UV_FS_EVENT_PRIVATE_FIELDS | 
|---|
| 1560 | }; | 
|---|
| 1561 |  | 
|---|
| 1562 |  | 
|---|
| 1563 | /* | 
|---|
| 1564 | * uv_fs_stat() based polling file watcher. | 
|---|
| 1565 | */ | 
|---|
| 1566 | struct uv_fs_poll_s { | 
|---|
| 1567 | UV_HANDLE_FIELDS | 
|---|
| 1568 | /* Private, don't touch. */ | 
|---|
| 1569 | void* poll_ctx; | 
|---|
| 1570 | }; | 
|---|
| 1571 |  | 
|---|
| 1572 | UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); | 
|---|
| 1573 | UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, | 
|---|
| 1574 | uv_fs_poll_cb poll_cb, | 
|---|
| 1575 | const char* path, | 
|---|
| 1576 | unsigned int interval); | 
|---|
| 1577 | UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); | 
|---|
| 1578 | UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, | 
|---|
| 1579 | char* buffer, | 
|---|
| 1580 | size_t* size); | 
|---|
| 1581 |  | 
|---|
| 1582 |  | 
|---|
| 1583 | struct uv_signal_s { | 
|---|
| 1584 | UV_HANDLE_FIELDS | 
|---|
| 1585 | uv_signal_cb signal_cb; | 
|---|
| 1586 | int signum; | 
|---|
| 1587 | UV_SIGNAL_PRIVATE_FIELDS | 
|---|
| 1588 | }; | 
|---|
| 1589 |  | 
|---|
| 1590 | UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); | 
|---|
| 1591 | UV_EXTERN int uv_signal_start(uv_signal_t* handle, | 
|---|
| 1592 | uv_signal_cb signal_cb, | 
|---|
| 1593 | int signum); | 
|---|
| 1594 | UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, | 
|---|
| 1595 | uv_signal_cb signal_cb, | 
|---|
| 1596 | int signum); | 
|---|
| 1597 | UV_EXTERN int uv_signal_stop(uv_signal_t* handle); | 
|---|
| 1598 |  | 
|---|
| 1599 | UV_EXTERN void uv_loadavg(double avg[3]); | 
|---|
| 1600 |  | 
|---|
| 1601 |  | 
|---|
| 1602 | /* | 
|---|
| 1603 | * Flags to be passed to uv_fs_event_start(). | 
|---|
| 1604 | */ | 
|---|
| 1605 | enum uv_fs_event_flags { | 
|---|
| 1606 | /* | 
|---|
| 1607 | * By default, if the fs event watcher is given a directory name, we will | 
|---|
| 1608 | * watch for all events in that directory. This flags overrides this behavior | 
|---|
| 1609 | * and makes fs_event report only changes to the directory entry itself. This | 
|---|
| 1610 | * flag does not affect individual files watched. | 
|---|
| 1611 | * This flag is currently not implemented yet on any backend. | 
|---|
| 1612 | */ | 
|---|
| 1613 | UV_FS_EVENT_WATCH_ENTRY = 1, | 
|---|
| 1614 |  | 
|---|
| 1615 | /* | 
|---|
| 1616 | * By default uv_fs_event will try to use a kernel interface such as inotify | 
|---|
| 1617 | * or kqueue to detect events. This may not work on remote filesystems such | 
|---|
| 1618 | * as NFS mounts. This flag makes fs_event fall back to calling stat() on a | 
|---|
| 1619 | * regular interval. | 
|---|
| 1620 | * This flag is currently not implemented yet on any backend. | 
|---|
| 1621 | */ | 
|---|
| 1622 | UV_FS_EVENT_STAT = 2, | 
|---|
| 1623 |  | 
|---|
| 1624 | /* | 
|---|
| 1625 | * By default, event watcher, when watching directory, is not registering | 
|---|
| 1626 | * (is ignoring) changes in it's subdirectories. | 
|---|
| 1627 | * This flag will override this behaviour on platforms that support it. | 
|---|
| 1628 | */ | 
|---|
| 1629 | UV_FS_EVENT_RECURSIVE = 4 | 
|---|
| 1630 | }; | 
|---|
| 1631 |  | 
|---|
| 1632 |  | 
|---|
| 1633 | UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); | 
|---|
| 1634 | UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, | 
|---|
| 1635 | uv_fs_event_cb cb, | 
|---|
| 1636 | const char* path, | 
|---|
| 1637 | unsigned int flags); | 
|---|
| 1638 | UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); | 
|---|
| 1639 | UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, | 
|---|
| 1640 | char* buffer, | 
|---|
| 1641 | size_t* size); | 
|---|
| 1642 |  | 
|---|
| 1643 | UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); | 
|---|
| 1644 | UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); | 
|---|
| 1645 |  | 
|---|
| 1646 | UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); | 
|---|
| 1647 | UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); | 
|---|
| 1648 |  | 
|---|
| 1649 | UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); | 
|---|
| 1650 | UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); | 
|---|
| 1651 |  | 
|---|
| 1652 |  | 
|---|
| 1653 | struct uv_random_s { | 
|---|
| 1654 | UV_REQ_FIELDS | 
|---|
| 1655 | /* read-only */ | 
|---|
| 1656 | uv_loop_t* loop; | 
|---|
| 1657 | /* private */ | 
|---|
| 1658 | int status; | 
|---|
| 1659 | void* buf; | 
|---|
| 1660 | size_t buflen; | 
|---|
| 1661 | uv_random_cb cb; | 
|---|
| 1662 | struct uv__work work_req; | 
|---|
| 1663 | }; | 
|---|
| 1664 |  | 
|---|
| 1665 | UV_EXTERN int uv_random(uv_loop_t* loop, | 
|---|
| 1666 | uv_random_t* req, | 
|---|
| 1667 | void *buf, | 
|---|
| 1668 | size_t buflen, | 
|---|
| 1669 | unsigned flags,  /* For future extension; must be 0. */ | 
|---|
| 1670 | uv_random_cb cb); | 
|---|
| 1671 |  | 
|---|
| 1672 | #if defined(IF_NAMESIZE) | 
|---|
| 1673 | # define UV_IF_NAMESIZE (IF_NAMESIZE + 1) | 
|---|
| 1674 | #elif defined(IFNAMSIZ) | 
|---|
| 1675 | # define UV_IF_NAMESIZE (IFNAMSIZ + 1) | 
|---|
| 1676 | #else | 
|---|
| 1677 | # define UV_IF_NAMESIZE (16 + 1) | 
|---|
| 1678 | #endif | 
|---|
| 1679 |  | 
|---|
| 1680 | UV_EXTERN int uv_if_indextoname(unsigned int ifindex, | 
|---|
| 1681 | char* buffer, | 
|---|
| 1682 | size_t* size); | 
|---|
| 1683 | UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, | 
|---|
| 1684 | char* buffer, | 
|---|
| 1685 | size_t* size); | 
|---|
| 1686 |  | 
|---|
| 1687 | UV_EXTERN int uv_exepath(char* buffer, size_t* size); | 
|---|
| 1688 |  | 
|---|
| 1689 | UV_EXTERN int uv_cwd(char* buffer, size_t* size); | 
|---|
| 1690 |  | 
|---|
| 1691 | UV_EXTERN int uv_chdir(const char* dir); | 
|---|
| 1692 |  | 
|---|
| 1693 | UV_EXTERN uint64_t uv_get_free_memory(void); | 
|---|
| 1694 | UV_EXTERN uint64_t uv_get_total_memory(void); | 
|---|
| 1695 | UV_EXTERN uint64_t uv_get_constrained_memory(void); | 
|---|
| 1696 |  | 
|---|
| 1697 | UV_EXTERN uint64_t uv_hrtime(void); | 
|---|
| 1698 | UV_EXTERN void uv_sleep(unsigned int msec); | 
|---|
| 1699 |  | 
|---|
| 1700 | UV_EXTERN void uv_disable_stdio_inheritance(void); | 
|---|
| 1701 |  | 
|---|
| 1702 | UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); | 
|---|
| 1703 | UV_EXTERN void uv_dlclose(uv_lib_t* lib); | 
|---|
| 1704 | UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); | 
|---|
| 1705 | UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); | 
|---|
| 1706 |  | 
|---|
| 1707 | UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); | 
|---|
| 1708 | UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); | 
|---|
| 1709 | UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); | 
|---|
| 1710 | UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); | 
|---|
| 1711 | UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); | 
|---|
| 1712 | UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); | 
|---|
| 1713 |  | 
|---|
| 1714 | UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); | 
|---|
| 1715 | UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); | 
|---|
| 1716 | UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); | 
|---|
| 1717 | UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); | 
|---|
| 1718 | UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); | 
|---|
| 1719 | UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); | 
|---|
| 1720 | UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); | 
|---|
| 1721 | UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); | 
|---|
| 1722 |  | 
|---|
| 1723 | UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); | 
|---|
| 1724 | UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); | 
|---|
| 1725 | UV_EXTERN void uv_sem_post(uv_sem_t* sem); | 
|---|
| 1726 | UV_EXTERN void uv_sem_wait(uv_sem_t* sem); | 
|---|
| 1727 | UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); | 
|---|
| 1728 |  | 
|---|
| 1729 | UV_EXTERN int uv_cond_init(uv_cond_t* cond); | 
|---|
| 1730 | UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); | 
|---|
| 1731 | UV_EXTERN void uv_cond_signal(uv_cond_t* cond); | 
|---|
| 1732 | UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); | 
|---|
| 1733 |  | 
|---|
| 1734 | UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); | 
|---|
| 1735 | UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); | 
|---|
| 1736 | UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); | 
|---|
| 1737 |  | 
|---|
| 1738 | UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); | 
|---|
| 1739 | UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, | 
|---|
| 1740 | uv_mutex_t* mutex, | 
|---|
| 1741 | uint64_t timeout); | 
|---|
| 1742 |  | 
|---|
| 1743 | UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); | 
|---|
| 1744 |  | 
|---|
| 1745 | UV_EXTERN int uv_key_create(uv_key_t* key); | 
|---|
| 1746 | UV_EXTERN void uv_key_delete(uv_key_t* key); | 
|---|
| 1747 | UV_EXTERN void* uv_key_get(uv_key_t* key); | 
|---|
| 1748 | UV_EXTERN void uv_key_set(uv_key_t* key, void* value); | 
|---|
| 1749 |  | 
|---|
| 1750 | UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv); | 
|---|
| 1751 |  | 
|---|
| 1752 | typedef void (*uv_thread_cb)(void* arg); | 
|---|
| 1753 |  | 
|---|
| 1754 | UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); | 
|---|
| 1755 |  | 
|---|
| 1756 | typedef enum { | 
|---|
| 1757 | UV_THREAD_NO_FLAGS = 0x00, | 
|---|
| 1758 | UV_THREAD_HAS_STACK_SIZE = 0x01 | 
|---|
| 1759 | } uv_thread_create_flags; | 
|---|
| 1760 |  | 
|---|
| 1761 | struct uv_thread_options_s { | 
|---|
| 1762 | unsigned int flags; | 
|---|
| 1763 | size_t stack_size; | 
|---|
| 1764 | /* More fields may be added at any time. */ | 
|---|
| 1765 | }; | 
|---|
| 1766 |  | 
|---|
| 1767 | typedef struct uv_thread_options_s uv_thread_options_t; | 
|---|
| 1768 |  | 
|---|
| 1769 | UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid, | 
|---|
| 1770 | const uv_thread_options_t* params, | 
|---|
| 1771 | uv_thread_cb entry, | 
|---|
| 1772 | void* arg); | 
|---|
| 1773 | UV_EXTERN uv_thread_t uv_thread_self(void); | 
|---|
| 1774 | UV_EXTERN int uv_thread_join(uv_thread_t *tid); | 
|---|
| 1775 | UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); | 
|---|
| 1776 |  | 
|---|
| 1777 | /* The presence of these unions force similar struct layout. */ | 
|---|
| 1778 | #define XX(_, name) uv_ ## name ## _t name; | 
|---|
| 1779 | union uv_any_handle { | 
|---|
| 1780 | UV_HANDLE_TYPE_MAP(XX) | 
|---|
| 1781 | }; | 
|---|
| 1782 |  | 
|---|
| 1783 | union uv_any_req { | 
|---|
| 1784 | UV_REQ_TYPE_MAP(XX) | 
|---|
| 1785 | }; | 
|---|
| 1786 | #undef XX | 
|---|
| 1787 |  | 
|---|
| 1788 |  | 
|---|
| 1789 | struct uv_loop_s { | 
|---|
| 1790 | /* User data - use this for whatever. */ | 
|---|
| 1791 | void* data; | 
|---|
| 1792 | /* Loop reference counting. */ | 
|---|
| 1793 | unsigned int active_handles; | 
|---|
| 1794 | void* handle_queue[2]; | 
|---|
| 1795 | union { | 
|---|
| 1796 | void* unused; | 
|---|
| 1797 | unsigned int count; | 
|---|
| 1798 | } active_reqs; | 
|---|
| 1799 | /* Internal storage for future extensions. */ | 
|---|
| 1800 | void* internal_fields; | 
|---|
| 1801 | /* Internal flag to signal loop stop. */ | 
|---|
| 1802 | unsigned int stop_flag; | 
|---|
| 1803 | UV_LOOP_PRIVATE_FIELDS | 
|---|
| 1804 | }; | 
|---|
| 1805 |  | 
|---|
| 1806 | UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); | 
|---|
| 1807 | UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); | 
|---|
| 1808 |  | 
|---|
| 1809 | /* Don't export the private CPP symbols. */ | 
|---|
| 1810 | #undef UV_HANDLE_TYPE_PRIVATE | 
|---|
| 1811 | #undef UV_REQ_TYPE_PRIVATE | 
|---|
| 1812 | #undef UV_REQ_PRIVATE_FIELDS | 
|---|
| 1813 | #undef UV_STREAM_PRIVATE_FIELDS | 
|---|
| 1814 | #undef UV_TCP_PRIVATE_FIELDS | 
|---|
| 1815 | #undef UV_PREPARE_PRIVATE_FIELDS | 
|---|
| 1816 | #undef UV_CHECK_PRIVATE_FIELDS | 
|---|
| 1817 | #undef UV_IDLE_PRIVATE_FIELDS | 
|---|
| 1818 | #undef UV_ASYNC_PRIVATE_FIELDS | 
|---|
| 1819 | #undef UV_TIMER_PRIVATE_FIELDS | 
|---|
| 1820 | #undef UV_GETADDRINFO_PRIVATE_FIELDS | 
|---|
| 1821 | #undef UV_GETNAMEINFO_PRIVATE_FIELDS | 
|---|
| 1822 | #undef UV_FS_REQ_PRIVATE_FIELDS | 
|---|
| 1823 | #undef UV_WORK_PRIVATE_FIELDS | 
|---|
| 1824 | #undef UV_FS_EVENT_PRIVATE_FIELDS | 
|---|
| 1825 | #undef UV_SIGNAL_PRIVATE_FIELDS | 
|---|
| 1826 | #undef UV_LOOP_PRIVATE_FIELDS | 
|---|
| 1827 | #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS | 
|---|
| 1828 | #undef UV__ERR | 
|---|
| 1829 |  | 
|---|
| 1830 | #ifdef __cplusplus | 
|---|
| 1831 | } | 
|---|
| 1832 | #endif | 
|---|
| 1833 | #endif /* UV_H */ | 
|---|
| 1834 |  | 
|---|