17777dab0Sopenharmony_ci/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 27777dab0Sopenharmony_ci * 37777dab0Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 47777dab0Sopenharmony_ci * of this software and associated documentation files (the "Software"), to 57777dab0Sopenharmony_ci * deal in the Software without restriction, including without limitation the 67777dab0Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 77777dab0Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is 87777dab0Sopenharmony_ci * furnished to do so, subject to the following conditions: 97777dab0Sopenharmony_ci * 107777dab0Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 117777dab0Sopenharmony_ci * all copies or substantial portions of the Software. 127777dab0Sopenharmony_ci * 137777dab0Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 147777dab0Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 157777dab0Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 167777dab0Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 177777dab0Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 187777dab0Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 197777dab0Sopenharmony_ci * IN THE SOFTWARE. 207777dab0Sopenharmony_ci */ 217777dab0Sopenharmony_ci 227777dab0Sopenharmony_ci/* See https://github.com/libuv/libuv#documentation for documentation. */ 237777dab0Sopenharmony_ci 247777dab0Sopenharmony_ci#ifndef UV_H 257777dab0Sopenharmony_ci#define UV_H 267777dab0Sopenharmony_ci#ifdef __cplusplus 277777dab0Sopenharmony_ciextern "C" { 287777dab0Sopenharmony_ci#endif 297777dab0Sopenharmony_ci 307777dab0Sopenharmony_ci#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) 317777dab0Sopenharmony_ci#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." 327777dab0Sopenharmony_ci#endif 337777dab0Sopenharmony_ci 347777dab0Sopenharmony_ci#ifdef _WIN32 357777dab0Sopenharmony_ci /* Windows - set up dll import/export decorators. */ 367777dab0Sopenharmony_ci# if defined(BUILDING_UV_SHARED) 377777dab0Sopenharmony_ci /* Building shared library. */ 387777dab0Sopenharmony_ci# define UV_EXTERN __declspec(dllexport) 397777dab0Sopenharmony_ci# elif defined(USING_UV_SHARED) 407777dab0Sopenharmony_ci /* Using shared library. */ 417777dab0Sopenharmony_ci# define UV_EXTERN __declspec(dllimport) 427777dab0Sopenharmony_ci# else 437777dab0Sopenharmony_ci /* Building static library. */ 447777dab0Sopenharmony_ci# define UV_EXTERN /* nothing */ 457777dab0Sopenharmony_ci# endif 467777dab0Sopenharmony_ci#elif __GNUC__ >= 4 477777dab0Sopenharmony_ci# define UV_EXTERN __attribute__((visibility("default"))) 487777dab0Sopenharmony_ci#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */ 497777dab0Sopenharmony_ci# define UV_EXTERN __global 507777dab0Sopenharmony_ci#else 517777dab0Sopenharmony_ci# define UV_EXTERN /* nothing */ 527777dab0Sopenharmony_ci#endif 537777dab0Sopenharmony_ci 547777dab0Sopenharmony_ci#include "uv/errno.h" 557777dab0Sopenharmony_ci#include "uv/version.h" 567777dab0Sopenharmony_ci#include <stddef.h> 577777dab0Sopenharmony_ci#include <stdio.h> 587777dab0Sopenharmony_ci 597777dab0Sopenharmony_ci#if defined(_MSC_VER) && _MSC_VER < 1600 607777dab0Sopenharmony_ci# include "uv/stdint-msvc2008.h" 617777dab0Sopenharmony_ci#else 627777dab0Sopenharmony_ci# include <stdint.h> 637777dab0Sopenharmony_ci#endif 647777dab0Sopenharmony_ci 657777dab0Sopenharmony_ci#if defined(_WIN32) 667777dab0Sopenharmony_ci# include "uv/win.h" 677777dab0Sopenharmony_ci#else 687777dab0Sopenharmony_ci# include "uv/unix.h" 697777dab0Sopenharmony_ci#endif 707777dab0Sopenharmony_ci 717777dab0Sopenharmony_ci/* Expand this list if necessary. */ 727777dab0Sopenharmony_ci#define UV_ERRNO_MAP(XX) \ 737777dab0Sopenharmony_ci XX(E2BIG, "argument list too long") \ 747777dab0Sopenharmony_ci XX(EACCES, "permission denied") \ 757777dab0Sopenharmony_ci XX(EADDRINUSE, "address already in use") \ 767777dab0Sopenharmony_ci XX(EADDRNOTAVAIL, "address not available") \ 777777dab0Sopenharmony_ci XX(EAFNOSUPPORT, "address family not supported") \ 787777dab0Sopenharmony_ci XX(EAGAIN, "resource temporarily unavailable") \ 797777dab0Sopenharmony_ci XX(EAI_ADDRFAMILY, "address family not supported") \ 807777dab0Sopenharmony_ci XX(EAI_AGAIN, "temporary failure") \ 817777dab0Sopenharmony_ci XX(EAI_BADFLAGS, "bad ai_flags value") \ 827777dab0Sopenharmony_ci XX(EAI_BADHINTS, "invalid value for hints") \ 837777dab0Sopenharmony_ci XX(EAI_CANCELED, "request canceled") \ 847777dab0Sopenharmony_ci XX(EAI_FAIL, "permanent failure") \ 857777dab0Sopenharmony_ci XX(EAI_FAMILY, "ai_family not supported") \ 867777dab0Sopenharmony_ci XX(EAI_MEMORY, "out of memory") \ 877777dab0Sopenharmony_ci XX(EAI_NODATA, "no address") \ 887777dab0Sopenharmony_ci XX(EAI_NONAME, "unknown node or service") \ 897777dab0Sopenharmony_ci XX(EAI_OVERFLOW, "argument buffer overflow") \ 907777dab0Sopenharmony_ci XX(EAI_PROTOCOL, "resolved protocol is unknown") \ 917777dab0Sopenharmony_ci XX(EAI_SERVICE, "service not available for socket type") \ 927777dab0Sopenharmony_ci XX(EAI_SOCKTYPE, "socket type not supported") \ 937777dab0Sopenharmony_ci XX(EALREADY, "connection already in progress") \ 947777dab0Sopenharmony_ci XX(EBADF, "bad file descriptor") \ 957777dab0Sopenharmony_ci XX(EBUSY, "resource busy or locked") \ 967777dab0Sopenharmony_ci XX(ECANCELED, "operation canceled") \ 977777dab0Sopenharmony_ci XX(ECHARSET, "invalid Unicode character") \ 987777dab0Sopenharmony_ci XX(ECONNABORTED, "software caused connection abort") \ 997777dab0Sopenharmony_ci XX(ECONNREFUSED, "connection refused") \ 1007777dab0Sopenharmony_ci XX(ECONNRESET, "connection reset by peer") \ 1017777dab0Sopenharmony_ci XX(EDESTADDRREQ, "destination address required") \ 1027777dab0Sopenharmony_ci XX(EEXIST, "file already exists") \ 1037777dab0Sopenharmony_ci XX(EFAULT, "bad address in system call argument") \ 1047777dab0Sopenharmony_ci XX(EFBIG, "file too large") \ 1057777dab0Sopenharmony_ci XX(EHOSTUNREACH, "host is unreachable") \ 1067777dab0Sopenharmony_ci XX(EINTR, "interrupted system call") \ 1077777dab0Sopenharmony_ci XX(EINVAL, "invalid argument") \ 1087777dab0Sopenharmony_ci XX(EIO, "i/o error") \ 1097777dab0Sopenharmony_ci XX(EISCONN, "socket is already connected") \ 1107777dab0Sopenharmony_ci XX(EISDIR, "illegal operation on a directory") \ 1117777dab0Sopenharmony_ci XX(ELOOP, "too many symbolic links encountered") \ 1127777dab0Sopenharmony_ci XX(EMFILE, "too many open files") \ 1137777dab0Sopenharmony_ci XX(EMSGSIZE, "message too long") \ 1147777dab0Sopenharmony_ci XX(ENAMETOOLONG, "name too long") \ 1157777dab0Sopenharmony_ci XX(ENETDOWN, "network is down") \ 1167777dab0Sopenharmony_ci XX(ENETUNREACH, "network is unreachable") \ 1177777dab0Sopenharmony_ci XX(ENFILE, "file table overflow") \ 1187777dab0Sopenharmony_ci XX(ENOBUFS, "no buffer space available") \ 1197777dab0Sopenharmony_ci XX(ENODEV, "no such device") \ 1207777dab0Sopenharmony_ci XX(ENOENT, "no such file or directory") \ 1217777dab0Sopenharmony_ci XX(ENOMEM, "not enough memory") \ 1227777dab0Sopenharmony_ci XX(ENONET, "machine is not on the network") \ 1237777dab0Sopenharmony_ci XX(ENOPROTOOPT, "protocol not available") \ 1247777dab0Sopenharmony_ci XX(ENOSPC, "no space left on device") \ 1257777dab0Sopenharmony_ci XX(ENOSYS, "function not implemented") \ 1267777dab0Sopenharmony_ci XX(ENOTCONN, "socket is not connected") \ 1277777dab0Sopenharmony_ci XX(ENOTDIR, "not a directory") \ 1287777dab0Sopenharmony_ci XX(ENOTEMPTY, "directory not empty") \ 1297777dab0Sopenharmony_ci XX(ENOTSOCK, "socket operation on non-socket") \ 1307777dab0Sopenharmony_ci XX(ENOTSUP, "operation not supported on socket") \ 1317777dab0Sopenharmony_ci XX(EOVERFLOW, "value too large for defined data type") \ 1327777dab0Sopenharmony_ci XX(EPERM, "operation not permitted") \ 1337777dab0Sopenharmony_ci XX(EPIPE, "broken pipe") \ 1347777dab0Sopenharmony_ci XX(EPROTO, "protocol error") \ 1357777dab0Sopenharmony_ci XX(EPROTONOSUPPORT, "protocol not supported") \ 1367777dab0Sopenharmony_ci XX(EPROTOTYPE, "protocol wrong type for socket") \ 1377777dab0Sopenharmony_ci XX(ERANGE, "result too large") \ 1387777dab0Sopenharmony_ci XX(EROFS, "read-only file system") \ 1397777dab0Sopenharmony_ci XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ 1407777dab0Sopenharmony_ci XX(ESPIPE, "invalid seek") \ 1417777dab0Sopenharmony_ci XX(ESRCH, "no such process") \ 1427777dab0Sopenharmony_ci XX(ETIMEDOUT, "connection timed out") \ 1437777dab0Sopenharmony_ci XX(ETXTBSY, "text file is busy") \ 1447777dab0Sopenharmony_ci XX(EXDEV, "cross-device link not permitted") \ 1457777dab0Sopenharmony_ci XX(UNKNOWN, "unknown error") \ 1467777dab0Sopenharmony_ci XX(EOF, "end of file") \ 1477777dab0Sopenharmony_ci XX(ENXIO, "no such device or address") \ 1487777dab0Sopenharmony_ci XX(EMLINK, "too many links") \ 1497777dab0Sopenharmony_ci XX(EHOSTDOWN, "host is down") \ 1507777dab0Sopenharmony_ci XX(EREMOTEIO, "remote I/O error") \ 1517777dab0Sopenharmony_ci XX(ENOTTY, "inappropriate ioctl for device") \ 1527777dab0Sopenharmony_ci XX(EFTYPE, "inappropriate file type or format") \ 1537777dab0Sopenharmony_ci XX(EILSEQ, "illegal byte sequence") \ 1547777dab0Sopenharmony_ci XX(ESOCKTNOSUPPORT, "socket type not supported") \ 1557777dab0Sopenharmony_ci 1567777dab0Sopenharmony_ci#define UV_HANDLE_TYPE_MAP(XX) \ 1577777dab0Sopenharmony_ci XX(ASYNC, async) \ 1587777dab0Sopenharmony_ci XX(CHECK, check) \ 1597777dab0Sopenharmony_ci XX(FS_EVENT, fs_event) \ 1607777dab0Sopenharmony_ci XX(FS_POLL, fs_poll) \ 1617777dab0Sopenharmony_ci XX(HANDLE, handle) \ 1627777dab0Sopenharmony_ci XX(IDLE, idle) \ 1637777dab0Sopenharmony_ci XX(NAMED_PIPE, pipe) \ 1647777dab0Sopenharmony_ci XX(POLL, poll) \ 1657777dab0Sopenharmony_ci XX(PREPARE, prepare) \ 1667777dab0Sopenharmony_ci XX(PROCESS, process) \ 1677777dab0Sopenharmony_ci XX(STREAM, stream) \ 1687777dab0Sopenharmony_ci XX(TCP, tcp) \ 1697777dab0Sopenharmony_ci XX(TIMER, timer) \ 1707777dab0Sopenharmony_ci XX(TTY, tty) \ 1717777dab0Sopenharmony_ci XX(UDP, udp) \ 1727777dab0Sopenharmony_ci XX(SIGNAL, signal) \ 1737777dab0Sopenharmony_ci 1747777dab0Sopenharmony_ci#define UV_REQ_TYPE_MAP(XX) \ 1757777dab0Sopenharmony_ci XX(REQ, req) \ 1767777dab0Sopenharmony_ci XX(CONNECT, connect) \ 1777777dab0Sopenharmony_ci XX(WRITE, write) \ 1787777dab0Sopenharmony_ci XX(SHUTDOWN, shutdown) \ 1797777dab0Sopenharmony_ci XX(UDP_SEND, udp_send) \ 1807777dab0Sopenharmony_ci XX(FS, fs) \ 1817777dab0Sopenharmony_ci XX(WORK, work) \ 1827777dab0Sopenharmony_ci XX(GETADDRINFO, getaddrinfo) \ 1837777dab0Sopenharmony_ci XX(GETNAMEINFO, getnameinfo) \ 1847777dab0Sopenharmony_ci XX(RANDOM, random) \ 1857777dab0Sopenharmony_ci 1867777dab0Sopenharmony_citypedef enum { 1877777dab0Sopenharmony_ci#define XX(code, _) UV_ ## code = UV__ ## code, 1887777dab0Sopenharmony_ci UV_ERRNO_MAP(XX) 1897777dab0Sopenharmony_ci#undef XX 1907777dab0Sopenharmony_ci UV_ERRNO_MAX = UV__EOF - 1 1917777dab0Sopenharmony_ci} uv_errno_t; 1927777dab0Sopenharmony_ci 1937777dab0Sopenharmony_citypedef enum { 1947777dab0Sopenharmony_ci UV_UNKNOWN_HANDLE = 0, 1957777dab0Sopenharmony_ci#define XX(uc, lc) UV_##uc, 1967777dab0Sopenharmony_ci UV_HANDLE_TYPE_MAP(XX) 1977777dab0Sopenharmony_ci#undef XX 1987777dab0Sopenharmony_ci UV_FILE, 1997777dab0Sopenharmony_ci UV_HANDLE_TYPE_MAX 2007777dab0Sopenharmony_ci} uv_handle_type; 2017777dab0Sopenharmony_ci 2027777dab0Sopenharmony_citypedef enum { 2037777dab0Sopenharmony_ci UV_UNKNOWN_REQ = 0, 2047777dab0Sopenharmony_ci#define XX(uc, lc) UV_##uc, 2057777dab0Sopenharmony_ci UV_REQ_TYPE_MAP(XX) 2067777dab0Sopenharmony_ci#undef XX 2077777dab0Sopenharmony_ci UV_REQ_TYPE_PRIVATE 2087777dab0Sopenharmony_ci UV_REQ_TYPE_MAX 2097777dab0Sopenharmony_ci} uv_req_type; 2107777dab0Sopenharmony_ci 2117777dab0Sopenharmony_ci 2127777dab0Sopenharmony_ci/* Handle types. */ 2137777dab0Sopenharmony_citypedef struct uv_loop_s uv_loop_t; 2147777dab0Sopenharmony_citypedef struct uv_handle_s uv_handle_t; 2157777dab0Sopenharmony_citypedef struct uv_dir_s uv_dir_t; 2167777dab0Sopenharmony_citypedef struct uv_stream_s uv_stream_t; 2177777dab0Sopenharmony_citypedef struct uv_tcp_s uv_tcp_t; 2187777dab0Sopenharmony_citypedef struct uv_udp_s uv_udp_t; 2197777dab0Sopenharmony_citypedef struct uv_pipe_s uv_pipe_t; 2207777dab0Sopenharmony_citypedef struct uv_tty_s uv_tty_t; 2217777dab0Sopenharmony_citypedef struct uv_poll_s uv_poll_t; 2227777dab0Sopenharmony_citypedef struct uv_timer_s uv_timer_t; 2237777dab0Sopenharmony_citypedef struct uv_prepare_s uv_prepare_t; 2247777dab0Sopenharmony_citypedef struct uv_check_s uv_check_t; 2257777dab0Sopenharmony_citypedef struct uv_idle_s uv_idle_t; 2267777dab0Sopenharmony_citypedef struct uv_async_s uv_async_t; 2277777dab0Sopenharmony_citypedef struct uv_process_s uv_process_t; 2287777dab0Sopenharmony_citypedef struct uv_fs_event_s uv_fs_event_t; 2297777dab0Sopenharmony_citypedef struct uv_fs_poll_s uv_fs_poll_t; 2307777dab0Sopenharmony_citypedef struct uv_signal_s uv_signal_t; 2317777dab0Sopenharmony_ci 2327777dab0Sopenharmony_ci/* Request types. */ 2337777dab0Sopenharmony_citypedef struct uv_req_s uv_req_t; 2347777dab0Sopenharmony_citypedef struct uv_getaddrinfo_s uv_getaddrinfo_t; 2357777dab0Sopenharmony_citypedef struct uv_getnameinfo_s uv_getnameinfo_t; 2367777dab0Sopenharmony_citypedef struct uv_shutdown_s uv_shutdown_t; 2377777dab0Sopenharmony_citypedef struct uv_write_s uv_write_t; 2387777dab0Sopenharmony_citypedef struct uv_connect_s uv_connect_t; 2397777dab0Sopenharmony_citypedef struct uv_udp_send_s uv_udp_send_t; 2407777dab0Sopenharmony_citypedef struct uv_fs_s uv_fs_t; 2417777dab0Sopenharmony_citypedef struct uv_work_s uv_work_t; 2427777dab0Sopenharmony_citypedef struct uv_random_s uv_random_t; 2437777dab0Sopenharmony_ci 2447777dab0Sopenharmony_ci/* None of the above. */ 2457777dab0Sopenharmony_citypedef struct uv_env_item_s uv_env_item_t; 2467777dab0Sopenharmony_citypedef struct uv_cpu_info_s uv_cpu_info_t; 2477777dab0Sopenharmony_citypedef struct uv_interface_address_s uv_interface_address_t; 2487777dab0Sopenharmony_citypedef struct uv_dirent_s uv_dirent_t; 2497777dab0Sopenharmony_citypedef struct uv_passwd_s uv_passwd_t; 2507777dab0Sopenharmony_citypedef struct uv_utsname_s uv_utsname_t; 2517777dab0Sopenharmony_citypedef struct uv_statfs_s uv_statfs_t; 2527777dab0Sopenharmony_ci 2537777dab0Sopenharmony_citypedef enum { 2547777dab0Sopenharmony_ci UV_LOOP_BLOCK_SIGNAL = 0, 2557777dab0Sopenharmony_ci UV_METRICS_IDLE_TIME 2567777dab0Sopenharmony_ci} uv_loop_option; 2577777dab0Sopenharmony_ci 2587777dab0Sopenharmony_citypedef enum { 2597777dab0Sopenharmony_ci UV_RUN_DEFAULT = 0, 2607777dab0Sopenharmony_ci UV_RUN_ONCE, 2617777dab0Sopenharmony_ci UV_RUN_NOWAIT 2627777dab0Sopenharmony_ci} uv_run_mode; 2637777dab0Sopenharmony_ci 2647777dab0Sopenharmony_ci 2657777dab0Sopenharmony_ciUV_EXTERN unsigned int uv_version(void); 2667777dab0Sopenharmony_ciUV_EXTERN const char* uv_version_string(void); 2677777dab0Sopenharmony_ci 2687777dab0Sopenharmony_citypedef void* (*uv_malloc_func)(size_t size); 2697777dab0Sopenharmony_citypedef void* (*uv_realloc_func)(void* ptr, size_t size); 2707777dab0Sopenharmony_citypedef void* (*uv_calloc_func)(size_t count, size_t size); 2717777dab0Sopenharmony_citypedef void (*uv_free_func)(void* ptr); 2727777dab0Sopenharmony_ci 2737777dab0Sopenharmony_ciUV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, 2747777dab0Sopenharmony_ci uv_realloc_func realloc_func, 2757777dab0Sopenharmony_ci uv_calloc_func calloc_func, 2767777dab0Sopenharmony_ci uv_free_func free_func); 2777777dab0Sopenharmony_ci 2787777dab0Sopenharmony_ciUV_EXTERN uv_loop_t* uv_default_loop(void); 2797777dab0Sopenharmony_ciUV_EXTERN int uv_loop_init(uv_loop_t* loop); 2807777dab0Sopenharmony_ciUV_EXTERN int uv_loop_close(uv_loop_t* loop); 2817777dab0Sopenharmony_ci/* 2827777dab0Sopenharmony_ci * NOTE: 2837777dab0Sopenharmony_ci * This function is DEPRECATED (to be removed after 0.12), users should 2847777dab0Sopenharmony_ci * allocate the loop manually and use uv_loop_init instead. 2857777dab0Sopenharmony_ci */ 2867777dab0Sopenharmony_ciUV_EXTERN uv_loop_t* uv_loop_new(void); 2877777dab0Sopenharmony_ci/* 2887777dab0Sopenharmony_ci * NOTE: 2897777dab0Sopenharmony_ci * This function is DEPRECATED (to be removed after 0.12). Users should use 2907777dab0Sopenharmony_ci * uv_loop_close and free the memory manually instead. 2917777dab0Sopenharmony_ci */ 2927777dab0Sopenharmony_ciUV_EXTERN void uv_loop_delete(uv_loop_t*); 2937777dab0Sopenharmony_ciUV_EXTERN size_t uv_loop_size(void); 2947777dab0Sopenharmony_ciUV_EXTERN int uv_loop_alive(const uv_loop_t* loop); 2957777dab0Sopenharmony_ciUV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); 2967777dab0Sopenharmony_ciUV_EXTERN int uv_loop_fork(uv_loop_t* loop); 2977777dab0Sopenharmony_ci 2987777dab0Sopenharmony_ciUV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); 2997777dab0Sopenharmony_ciUV_EXTERN void uv_stop(uv_loop_t*); 3007777dab0Sopenharmony_ci 3017777dab0Sopenharmony_ciUV_EXTERN void uv_ref(uv_handle_t*); 3027777dab0Sopenharmony_ciUV_EXTERN void uv_unref(uv_handle_t*); 3037777dab0Sopenharmony_ciUV_EXTERN int uv_has_ref(const uv_handle_t*); 3047777dab0Sopenharmony_ci 3057777dab0Sopenharmony_ciUV_EXTERN void uv_update_time(uv_loop_t*); 3067777dab0Sopenharmony_ciUV_EXTERN uint64_t uv_now(const uv_loop_t*); 3077777dab0Sopenharmony_ci 3087777dab0Sopenharmony_ciUV_EXTERN int uv_backend_fd(const uv_loop_t*); 3097777dab0Sopenharmony_ciUV_EXTERN int uv_backend_timeout(const uv_loop_t*); 3107777dab0Sopenharmony_ci 3117777dab0Sopenharmony_citypedef void (*uv_alloc_cb)(uv_handle_t* handle, 3127777dab0Sopenharmony_ci size_t suggested_size, 3137777dab0Sopenharmony_ci uv_buf_t* buf); 3147777dab0Sopenharmony_citypedef void (*uv_read_cb)(uv_stream_t* stream, 3157777dab0Sopenharmony_ci ssize_t nread, 3167777dab0Sopenharmony_ci const uv_buf_t* buf); 3177777dab0Sopenharmony_citypedef void (*uv_write_cb)(uv_write_t* req, int status); 3187777dab0Sopenharmony_citypedef void (*uv_connect_cb)(uv_connect_t* req, int status); 3197777dab0Sopenharmony_citypedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); 3207777dab0Sopenharmony_citypedef void (*uv_connection_cb)(uv_stream_t* server, int status); 3217777dab0Sopenharmony_citypedef void (*uv_close_cb)(uv_handle_t* handle); 3227777dab0Sopenharmony_citypedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); 3237777dab0Sopenharmony_citypedef void (*uv_timer_cb)(uv_timer_t* handle); 3247777dab0Sopenharmony_citypedef void (*uv_async_cb)(uv_async_t* handle); 3257777dab0Sopenharmony_citypedef void (*uv_prepare_cb)(uv_prepare_t* handle); 3267777dab0Sopenharmony_citypedef void (*uv_check_cb)(uv_check_t* handle); 3277777dab0Sopenharmony_citypedef void (*uv_idle_cb)(uv_idle_t* handle); 3287777dab0Sopenharmony_citypedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); 3297777dab0Sopenharmony_citypedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); 3307777dab0Sopenharmony_citypedef void (*uv_fs_cb)(uv_fs_t* req); 3317777dab0Sopenharmony_citypedef void (*uv_work_cb)(uv_work_t* req); 3327777dab0Sopenharmony_citypedef void (*uv_after_work_cb)(uv_work_t* req, int status); 3337777dab0Sopenharmony_citypedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, 3347777dab0Sopenharmony_ci int status, 3357777dab0Sopenharmony_ci struct addrinfo* res); 3367777dab0Sopenharmony_citypedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, 3377777dab0Sopenharmony_ci int status, 3387777dab0Sopenharmony_ci const char* hostname, 3397777dab0Sopenharmony_ci const char* service); 3407777dab0Sopenharmony_citypedef void (*uv_random_cb)(uv_random_t* req, 3417777dab0Sopenharmony_ci int status, 3427777dab0Sopenharmony_ci void* buf, 3437777dab0Sopenharmony_ci size_t buflen); 3447777dab0Sopenharmony_ci 3457777dab0Sopenharmony_citypedef struct { 3467777dab0Sopenharmony_ci long tv_sec; 3477777dab0Sopenharmony_ci long tv_nsec; 3487777dab0Sopenharmony_ci} uv_timespec_t; 3497777dab0Sopenharmony_ci 3507777dab0Sopenharmony_ci 3517777dab0Sopenharmony_citypedef struct { 3527777dab0Sopenharmony_ci uint64_t st_dev; 3537777dab0Sopenharmony_ci uint64_t st_mode; 3547777dab0Sopenharmony_ci uint64_t st_nlink; 3557777dab0Sopenharmony_ci uint64_t st_uid; 3567777dab0Sopenharmony_ci uint64_t st_gid; 3577777dab0Sopenharmony_ci uint64_t st_rdev; 3587777dab0Sopenharmony_ci uint64_t st_ino; 3597777dab0Sopenharmony_ci uint64_t st_size; 3607777dab0Sopenharmony_ci uint64_t st_blksize; 3617777dab0Sopenharmony_ci uint64_t st_blocks; 3627777dab0Sopenharmony_ci uint64_t st_flags; 3637777dab0Sopenharmony_ci uint64_t st_gen; 3647777dab0Sopenharmony_ci uv_timespec_t st_atim; 3657777dab0Sopenharmony_ci uv_timespec_t st_mtim; 3667777dab0Sopenharmony_ci uv_timespec_t st_ctim; 3677777dab0Sopenharmony_ci uv_timespec_t st_birthtim; 3687777dab0Sopenharmony_ci} uv_stat_t; 3697777dab0Sopenharmony_ci 3707777dab0Sopenharmony_ci 3717777dab0Sopenharmony_citypedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, 3727777dab0Sopenharmony_ci const char* filename, 3737777dab0Sopenharmony_ci int events, 3747777dab0Sopenharmony_ci int status); 3757777dab0Sopenharmony_ci 3767777dab0Sopenharmony_citypedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, 3777777dab0Sopenharmony_ci int status, 3787777dab0Sopenharmony_ci const uv_stat_t* prev, 3797777dab0Sopenharmony_ci const uv_stat_t* curr); 3807777dab0Sopenharmony_ci 3817777dab0Sopenharmony_citypedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); 3827777dab0Sopenharmony_ci 3837777dab0Sopenharmony_ci 3847777dab0Sopenharmony_citypedef enum { 3857777dab0Sopenharmony_ci UV_LEAVE_GROUP = 0, 3867777dab0Sopenharmony_ci UV_JOIN_GROUP 3877777dab0Sopenharmony_ci} uv_membership; 3887777dab0Sopenharmony_ci 3897777dab0Sopenharmony_ci 3907777dab0Sopenharmony_ciUV_EXTERN int uv_translate_sys_error(int sys_errno); 3917777dab0Sopenharmony_ci 3927777dab0Sopenharmony_ciUV_EXTERN const char* uv_strerror(int err); 3937777dab0Sopenharmony_ciUV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); 3947777dab0Sopenharmony_ci 3957777dab0Sopenharmony_ciUV_EXTERN const char* uv_err_name(int err); 3967777dab0Sopenharmony_ciUV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); 3977777dab0Sopenharmony_ci 3987777dab0Sopenharmony_ci 3997777dab0Sopenharmony_ci#define UV_REQ_FIELDS \ 4007777dab0Sopenharmony_ci /* public */ \ 4017777dab0Sopenharmony_ci void* data; \ 4027777dab0Sopenharmony_ci /* read-only */ \ 4037777dab0Sopenharmony_ci uv_req_type type; \ 4047777dab0Sopenharmony_ci /* private */ \ 4057777dab0Sopenharmony_ci void* reserved[6]; \ 4067777dab0Sopenharmony_ci UV_REQ_PRIVATE_FIELDS \ 4077777dab0Sopenharmony_ci 4087777dab0Sopenharmony_ci/* Abstract base class of all requests. */ 4097777dab0Sopenharmony_cistruct uv_req_s { 4107777dab0Sopenharmony_ci UV_REQ_FIELDS 4117777dab0Sopenharmony_ci}; 4127777dab0Sopenharmony_ci 4137777dab0Sopenharmony_ci 4147777dab0Sopenharmony_ci/* Platform-specific request types. */ 4157777dab0Sopenharmony_ciUV_PRIVATE_REQ_TYPES 4167777dab0Sopenharmony_ci 4177777dab0Sopenharmony_ci 4187777dab0Sopenharmony_ciUV_EXTERN int uv_shutdown(uv_shutdown_t* req, 4197777dab0Sopenharmony_ci uv_stream_t* handle, 4207777dab0Sopenharmony_ci uv_shutdown_cb cb); 4217777dab0Sopenharmony_ci 4227777dab0Sopenharmony_cistruct uv_shutdown_s { 4237777dab0Sopenharmony_ci UV_REQ_FIELDS 4247777dab0Sopenharmony_ci uv_stream_t* handle; 4257777dab0Sopenharmony_ci uv_shutdown_cb cb; 4267777dab0Sopenharmony_ci UV_SHUTDOWN_PRIVATE_FIELDS 4277777dab0Sopenharmony_ci}; 4287777dab0Sopenharmony_ci 4297777dab0Sopenharmony_ci 4307777dab0Sopenharmony_ci#define UV_HANDLE_FIELDS \ 4317777dab0Sopenharmony_ci /* public */ \ 4327777dab0Sopenharmony_ci void* data; \ 4337777dab0Sopenharmony_ci /* read-only */ \ 4347777dab0Sopenharmony_ci uv_loop_t* loop; \ 4357777dab0Sopenharmony_ci uv_handle_type type; \ 4367777dab0Sopenharmony_ci /* private */ \ 4377777dab0Sopenharmony_ci uv_close_cb close_cb; \ 4387777dab0Sopenharmony_ci void* handle_queue[2]; \ 4397777dab0Sopenharmony_ci union { \ 4407777dab0Sopenharmony_ci int fd; \ 4417777dab0Sopenharmony_ci void* reserved[4]; \ 4427777dab0Sopenharmony_ci } u; \ 4437777dab0Sopenharmony_ci UV_HANDLE_PRIVATE_FIELDS \ 4447777dab0Sopenharmony_ci 4457777dab0Sopenharmony_ci/* The abstract base class of all handles. */ 4467777dab0Sopenharmony_cistruct uv_handle_s { 4477777dab0Sopenharmony_ci UV_HANDLE_FIELDS 4487777dab0Sopenharmony_ci}; 4497777dab0Sopenharmony_ci 4507777dab0Sopenharmony_ciUV_EXTERN size_t uv_handle_size(uv_handle_type type); 4517777dab0Sopenharmony_ciUV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); 4527777dab0Sopenharmony_ciUV_EXTERN const char* uv_handle_type_name(uv_handle_type type); 4537777dab0Sopenharmony_ciUV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); 4547777dab0Sopenharmony_ciUV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); 4557777dab0Sopenharmony_ciUV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); 4567777dab0Sopenharmony_ci 4577777dab0Sopenharmony_ciUV_EXTERN size_t uv_req_size(uv_req_type type); 4587777dab0Sopenharmony_ciUV_EXTERN void* uv_req_get_data(const uv_req_t* req); 4597777dab0Sopenharmony_ciUV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); 4607777dab0Sopenharmony_ciUV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); 4617777dab0Sopenharmony_ciUV_EXTERN const char* uv_req_type_name(uv_req_type type); 4627777dab0Sopenharmony_ci 4637777dab0Sopenharmony_ciUV_EXTERN int uv_is_active(const uv_handle_t* handle); 4647777dab0Sopenharmony_ci 4657777dab0Sopenharmony_ciUV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); 4667777dab0Sopenharmony_ci 4677777dab0Sopenharmony_ci/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ 4687777dab0Sopenharmony_ciUV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); 4697777dab0Sopenharmony_ciUV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); 4707777dab0Sopenharmony_ci 4717777dab0Sopenharmony_ciUV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); 4727777dab0Sopenharmony_ci 4737777dab0Sopenharmony_ciUV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); 4747777dab0Sopenharmony_ciUV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); 4757777dab0Sopenharmony_ci 4767777dab0Sopenharmony_ciUV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); 4777777dab0Sopenharmony_ci 4787777dab0Sopenharmony_ciUV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); 4797777dab0Sopenharmony_ci 4807777dab0Sopenharmony_ci 4817777dab0Sopenharmony_ci#define UV_STREAM_FIELDS \ 4827777dab0Sopenharmony_ci /* number of bytes queued for writing */ \ 4837777dab0Sopenharmony_ci size_t write_queue_size; \ 4847777dab0Sopenharmony_ci uv_alloc_cb alloc_cb; \ 4857777dab0Sopenharmony_ci uv_read_cb read_cb; \ 4867777dab0Sopenharmony_ci /* private */ \ 4877777dab0Sopenharmony_ci UV_STREAM_PRIVATE_FIELDS 4887777dab0Sopenharmony_ci 4897777dab0Sopenharmony_ci/* 4907777dab0Sopenharmony_ci * uv_stream_t is a subclass of uv_handle_t. 4917777dab0Sopenharmony_ci * 4927777dab0Sopenharmony_ci * uv_stream is an abstract class. 4937777dab0Sopenharmony_ci * 4947777dab0Sopenharmony_ci * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. 4957777dab0Sopenharmony_ci */ 4967777dab0Sopenharmony_cistruct uv_stream_s { 4977777dab0Sopenharmony_ci UV_HANDLE_FIELDS 4987777dab0Sopenharmony_ci UV_STREAM_FIELDS 4997777dab0Sopenharmony_ci}; 5007777dab0Sopenharmony_ci 5017777dab0Sopenharmony_ciUV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); 5027777dab0Sopenharmony_ci 5037777dab0Sopenharmony_ciUV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); 5047777dab0Sopenharmony_ciUV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); 5057777dab0Sopenharmony_ci 5067777dab0Sopenharmony_ciUV_EXTERN int uv_read_start(uv_stream_t*, 5077777dab0Sopenharmony_ci uv_alloc_cb alloc_cb, 5087777dab0Sopenharmony_ci uv_read_cb read_cb); 5097777dab0Sopenharmony_ciUV_EXTERN int uv_read_stop(uv_stream_t*); 5107777dab0Sopenharmony_ci 5117777dab0Sopenharmony_ciUV_EXTERN int uv_write(uv_write_t* req, 5127777dab0Sopenharmony_ci uv_stream_t* handle, 5137777dab0Sopenharmony_ci const uv_buf_t bufs[], 5147777dab0Sopenharmony_ci unsigned int nbufs, 5157777dab0Sopenharmony_ci uv_write_cb cb); 5167777dab0Sopenharmony_ciUV_EXTERN int uv_write2(uv_write_t* req, 5177777dab0Sopenharmony_ci uv_stream_t* handle, 5187777dab0Sopenharmony_ci const uv_buf_t bufs[], 5197777dab0Sopenharmony_ci unsigned int nbufs, 5207777dab0Sopenharmony_ci uv_stream_t* send_handle, 5217777dab0Sopenharmony_ci uv_write_cb cb); 5227777dab0Sopenharmony_ciUV_EXTERN int uv_try_write(uv_stream_t* handle, 5237777dab0Sopenharmony_ci const uv_buf_t bufs[], 5247777dab0Sopenharmony_ci unsigned int nbufs); 5257777dab0Sopenharmony_ci 5267777dab0Sopenharmony_ci/* uv_write_t is a subclass of uv_req_t. */ 5277777dab0Sopenharmony_cistruct uv_write_s { 5287777dab0Sopenharmony_ci UV_REQ_FIELDS 5297777dab0Sopenharmony_ci uv_write_cb cb; 5307777dab0Sopenharmony_ci uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ 5317777dab0Sopenharmony_ci uv_stream_t* handle; 5327777dab0Sopenharmony_ci UV_WRITE_PRIVATE_FIELDS 5337777dab0Sopenharmony_ci}; 5347777dab0Sopenharmony_ci 5357777dab0Sopenharmony_ci 5367777dab0Sopenharmony_ciUV_EXTERN int uv_is_readable(const uv_stream_t* handle); 5377777dab0Sopenharmony_ciUV_EXTERN int uv_is_writable(const uv_stream_t* handle); 5387777dab0Sopenharmony_ci 5397777dab0Sopenharmony_ciUV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); 5407777dab0Sopenharmony_ci 5417777dab0Sopenharmony_ciUV_EXTERN int uv_is_closing(const uv_handle_t* handle); 5427777dab0Sopenharmony_ci 5437777dab0Sopenharmony_ci 5447777dab0Sopenharmony_ci/* 5457777dab0Sopenharmony_ci * uv_tcp_t is a subclass of uv_stream_t. 5467777dab0Sopenharmony_ci * 5477777dab0Sopenharmony_ci * Represents a TCP stream or TCP server. 5487777dab0Sopenharmony_ci */ 5497777dab0Sopenharmony_cistruct uv_tcp_s { 5507777dab0Sopenharmony_ci UV_HANDLE_FIELDS 5517777dab0Sopenharmony_ci UV_STREAM_FIELDS 5527777dab0Sopenharmony_ci UV_TCP_PRIVATE_FIELDS 5537777dab0Sopenharmony_ci}; 5547777dab0Sopenharmony_ci 5557777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); 5567777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); 5577777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); 5587777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); 5597777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, 5607777dab0Sopenharmony_ci int enable, 5617777dab0Sopenharmony_ci unsigned int delay); 5627777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); 5637777dab0Sopenharmony_ci 5647777dab0Sopenharmony_cienum uv_tcp_flags { 5657777dab0Sopenharmony_ci /* Used with uv_tcp_bind, when an IPv6 address is used. */ 5667777dab0Sopenharmony_ci UV_TCP_IPV6ONLY = 1 5677777dab0Sopenharmony_ci}; 5687777dab0Sopenharmony_ci 5697777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, 5707777dab0Sopenharmony_ci const struct sockaddr* addr, 5717777dab0Sopenharmony_ci unsigned int flags); 5727777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, 5737777dab0Sopenharmony_ci struct sockaddr* name, 5747777dab0Sopenharmony_ci int* namelen); 5757777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, 5767777dab0Sopenharmony_ci struct sockaddr* name, 5777777dab0Sopenharmony_ci int* namelen); 5787777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); 5797777dab0Sopenharmony_ciUV_EXTERN int uv_tcp_connect(uv_connect_t* req, 5807777dab0Sopenharmony_ci uv_tcp_t* handle, 5817777dab0Sopenharmony_ci const struct sockaddr* addr, 5827777dab0Sopenharmony_ci uv_connect_cb cb); 5837777dab0Sopenharmony_ci 5847777dab0Sopenharmony_ci/* uv_connect_t is a subclass of uv_req_t. */ 5857777dab0Sopenharmony_cistruct uv_connect_s { 5867777dab0Sopenharmony_ci UV_REQ_FIELDS 5877777dab0Sopenharmony_ci uv_connect_cb cb; 5887777dab0Sopenharmony_ci uv_stream_t* handle; 5897777dab0Sopenharmony_ci UV_CONNECT_PRIVATE_FIELDS 5907777dab0Sopenharmony_ci}; 5917777dab0Sopenharmony_ci 5927777dab0Sopenharmony_ci 5937777dab0Sopenharmony_ci/* 5947777dab0Sopenharmony_ci * UDP support. 5957777dab0Sopenharmony_ci */ 5967777dab0Sopenharmony_ci 5977777dab0Sopenharmony_cienum uv_udp_flags { 5987777dab0Sopenharmony_ci /* Disables dual stack mode. */ 5997777dab0Sopenharmony_ci UV_UDP_IPV6ONLY = 1, 6007777dab0Sopenharmony_ci /* 6017777dab0Sopenharmony_ci * Indicates message was truncated because read buffer was too small. The 6027777dab0Sopenharmony_ci * remainder was discarded by the OS. Used in uv_udp_recv_cb. 6037777dab0Sopenharmony_ci */ 6047777dab0Sopenharmony_ci UV_UDP_PARTIAL = 2, 6057777dab0Sopenharmony_ci /* 6067777dab0Sopenharmony_ci * Indicates if SO_REUSEADDR will be set when binding the handle. 6077777dab0Sopenharmony_ci * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other 6087777dab0Sopenharmony_ci * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that 6097777dab0Sopenharmony_ci * multiple threads or processes can bind to the same address without error 6107777dab0Sopenharmony_ci * (provided they all set the flag) but only the last one to bind will receive 6117777dab0Sopenharmony_ci * any traffic, in effect "stealing" the port from the previous listener. 6127777dab0Sopenharmony_ci */ 6137777dab0Sopenharmony_ci UV_UDP_REUSEADDR = 4, 6147777dab0Sopenharmony_ci /* 6157777dab0Sopenharmony_ci * Indicates that the message was received by recvmmsg, so the buffer provided 6167777dab0Sopenharmony_ci * must not be freed by the recv_cb callback. 6177777dab0Sopenharmony_ci */ 6187777dab0Sopenharmony_ci UV_UDP_MMSG_CHUNK = 8, 6197777dab0Sopenharmony_ci /* 6207777dab0Sopenharmony_ci * Indicates that the buffer provided has been fully utilized by recvmmsg and 6217777dab0Sopenharmony_ci * that it should now be freed by the recv_cb callback. When this flag is set 6227777dab0Sopenharmony_ci * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. 6237777dab0Sopenharmony_ci */ 6247777dab0Sopenharmony_ci UV_UDP_MMSG_FREE = 16, 6257777dab0Sopenharmony_ci /* 6267777dab0Sopenharmony_ci * Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle. 6277777dab0Sopenharmony_ci * This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on 6287777dab0Sopenharmony_ci * Linux. This stops the Linux kernel from suppressing some ICMP error 6297777dab0Sopenharmony_ci * messages and enables full ICMP error reporting for faster failover. 6307777dab0Sopenharmony_ci * This flag is no-op on platforms other than Linux. 6317777dab0Sopenharmony_ci */ 6327777dab0Sopenharmony_ci UV_UDP_LINUX_RECVERR = 32, 6337777dab0Sopenharmony_ci /* 6347777dab0Sopenharmony_ci * Indicates that recvmmsg should be used, if available. 6357777dab0Sopenharmony_ci */ 6367777dab0Sopenharmony_ci UV_UDP_RECVMMSG = 256 6377777dab0Sopenharmony_ci}; 6387777dab0Sopenharmony_ci 6397777dab0Sopenharmony_citypedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); 6407777dab0Sopenharmony_citypedef void (*uv_udp_recv_cb)(uv_udp_t* handle, 6417777dab0Sopenharmony_ci ssize_t nread, 6427777dab0Sopenharmony_ci const uv_buf_t* buf, 6437777dab0Sopenharmony_ci const struct sockaddr* addr, 6447777dab0Sopenharmony_ci unsigned flags); 6457777dab0Sopenharmony_ci 6467777dab0Sopenharmony_ci/* uv_udp_t is a subclass of uv_handle_t. */ 6477777dab0Sopenharmony_cistruct uv_udp_s { 6487777dab0Sopenharmony_ci UV_HANDLE_FIELDS 6497777dab0Sopenharmony_ci /* read-only */ 6507777dab0Sopenharmony_ci /* 6517777dab0Sopenharmony_ci * Number of bytes queued for sending. This field strictly shows how much 6527777dab0Sopenharmony_ci * information is currently queued. 6537777dab0Sopenharmony_ci */ 6547777dab0Sopenharmony_ci size_t send_queue_size; 6557777dab0Sopenharmony_ci /* 6567777dab0Sopenharmony_ci * Number of send requests currently in the queue awaiting to be processed. 6577777dab0Sopenharmony_ci */ 6587777dab0Sopenharmony_ci size_t send_queue_count; 6597777dab0Sopenharmony_ci UV_UDP_PRIVATE_FIELDS 6607777dab0Sopenharmony_ci}; 6617777dab0Sopenharmony_ci 6627777dab0Sopenharmony_ci/* uv_udp_send_t is a subclass of uv_req_t. */ 6637777dab0Sopenharmony_cistruct uv_udp_send_s { 6647777dab0Sopenharmony_ci UV_REQ_FIELDS 6657777dab0Sopenharmony_ci uv_udp_t* handle; 6667777dab0Sopenharmony_ci uv_udp_send_cb cb; 6677777dab0Sopenharmony_ci UV_UDP_SEND_PRIVATE_FIELDS 6687777dab0Sopenharmony_ci}; 6697777dab0Sopenharmony_ci 6707777dab0Sopenharmony_ciUV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); 6717777dab0Sopenharmony_ciUV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); 6727777dab0Sopenharmony_ciUV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); 6737777dab0Sopenharmony_ciUV_EXTERN int uv_udp_bind(uv_udp_t* handle, 6747777dab0Sopenharmony_ci const struct sockaddr* addr, 6757777dab0Sopenharmony_ci unsigned int flags); 6767777dab0Sopenharmony_ciUV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr); 6777777dab0Sopenharmony_ci 6787777dab0Sopenharmony_ciUV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle, 6797777dab0Sopenharmony_ci struct sockaddr* name, 6807777dab0Sopenharmony_ci int* namelen); 6817777dab0Sopenharmony_ciUV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, 6827777dab0Sopenharmony_ci struct sockaddr* name, 6837777dab0Sopenharmony_ci int* namelen); 6847777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, 6857777dab0Sopenharmony_ci const char* multicast_addr, 6867777dab0Sopenharmony_ci const char* interface_addr, 6877777dab0Sopenharmony_ci uv_membership membership); 6887777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, 6897777dab0Sopenharmony_ci const char* multicast_addr, 6907777dab0Sopenharmony_ci const char* interface_addr, 6917777dab0Sopenharmony_ci const char* source_addr, 6927777dab0Sopenharmony_ci uv_membership membership); 6937777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); 6947777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); 6957777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, 6967777dab0Sopenharmony_ci const char* interface_addr); 6977777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); 6987777dab0Sopenharmony_ciUV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); 6997777dab0Sopenharmony_ciUV_EXTERN int uv_udp_send(uv_udp_send_t* req, 7007777dab0Sopenharmony_ci uv_udp_t* handle, 7017777dab0Sopenharmony_ci const uv_buf_t bufs[], 7027777dab0Sopenharmony_ci unsigned int nbufs, 7037777dab0Sopenharmony_ci const struct sockaddr* addr, 7047777dab0Sopenharmony_ci uv_udp_send_cb send_cb); 7057777dab0Sopenharmony_ciUV_EXTERN int uv_udp_try_send(uv_udp_t* handle, 7067777dab0Sopenharmony_ci const uv_buf_t bufs[], 7077777dab0Sopenharmony_ci unsigned int nbufs, 7087777dab0Sopenharmony_ci const struct sockaddr* addr); 7097777dab0Sopenharmony_ciUV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, 7107777dab0Sopenharmony_ci uv_alloc_cb alloc_cb, 7117777dab0Sopenharmony_ci uv_udp_recv_cb recv_cb); 7127777dab0Sopenharmony_ciUV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); 7137777dab0Sopenharmony_ciUV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); 7147777dab0Sopenharmony_ciUV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); 7157777dab0Sopenharmony_ci 7167777dab0Sopenharmony_ci 7177777dab0Sopenharmony_ci/* 7187777dab0Sopenharmony_ci * uv_tty_t is a subclass of uv_stream_t. 7197777dab0Sopenharmony_ci * 7207777dab0Sopenharmony_ci * Representing a stream for the console. 7217777dab0Sopenharmony_ci */ 7227777dab0Sopenharmony_cistruct uv_tty_s { 7237777dab0Sopenharmony_ci UV_HANDLE_FIELDS 7247777dab0Sopenharmony_ci UV_STREAM_FIELDS 7257777dab0Sopenharmony_ci UV_TTY_PRIVATE_FIELDS 7267777dab0Sopenharmony_ci}; 7277777dab0Sopenharmony_ci 7287777dab0Sopenharmony_citypedef enum { 7297777dab0Sopenharmony_ci /* Initial/normal terminal mode */ 7307777dab0Sopenharmony_ci UV_TTY_MODE_NORMAL, 7317777dab0Sopenharmony_ci /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ 7327777dab0Sopenharmony_ci UV_TTY_MODE_RAW, 7337777dab0Sopenharmony_ci /* Binary-safe I/O mode for IPC (Unix-only) */ 7347777dab0Sopenharmony_ci UV_TTY_MODE_IO 7357777dab0Sopenharmony_ci} uv_tty_mode_t; 7367777dab0Sopenharmony_ci 7377777dab0Sopenharmony_citypedef enum { 7387777dab0Sopenharmony_ci /* 7397777dab0Sopenharmony_ci * The console supports handling of virtual terminal sequences 7407777dab0Sopenharmony_ci * (Windows10 new console, ConEmu) 7417777dab0Sopenharmony_ci */ 7427777dab0Sopenharmony_ci UV_TTY_SUPPORTED, 7437777dab0Sopenharmony_ci /* The console cannot process the virtual terminal sequence. (Legacy 7447777dab0Sopenharmony_ci * console) 7457777dab0Sopenharmony_ci */ 7467777dab0Sopenharmony_ci UV_TTY_UNSUPPORTED 7477777dab0Sopenharmony_ci} uv_tty_vtermstate_t; 7487777dab0Sopenharmony_ci 7497777dab0Sopenharmony_ci 7507777dab0Sopenharmony_ciUV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); 7517777dab0Sopenharmony_ciUV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); 7527777dab0Sopenharmony_ciUV_EXTERN int uv_tty_reset_mode(void); 7537777dab0Sopenharmony_ciUV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); 7547777dab0Sopenharmony_ciUV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); 7557777dab0Sopenharmony_ciUV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); 7567777dab0Sopenharmony_ci 7577777dab0Sopenharmony_ci#ifdef __cplusplus 7587777dab0Sopenharmony_ciextern "C++" { 7597777dab0Sopenharmony_ci 7607777dab0Sopenharmony_ciinline int uv_tty_set_mode(uv_tty_t* handle, int mode) { 7617777dab0Sopenharmony_ci return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode)); 7627777dab0Sopenharmony_ci} 7637777dab0Sopenharmony_ci 7647777dab0Sopenharmony_ci} 7657777dab0Sopenharmony_ci#endif 7667777dab0Sopenharmony_ci 7677777dab0Sopenharmony_ciUV_EXTERN uv_handle_type uv_guess_handle(uv_file file); 7687777dab0Sopenharmony_ci 7697777dab0Sopenharmony_ci/* 7707777dab0Sopenharmony_ci * uv_pipe_t is a subclass of uv_stream_t. 7717777dab0Sopenharmony_ci * 7727777dab0Sopenharmony_ci * Representing a pipe stream or pipe server. On Windows this is a Named 7737777dab0Sopenharmony_ci * Pipe. On Unix this is a Unix domain socket. 7747777dab0Sopenharmony_ci */ 7757777dab0Sopenharmony_cistruct uv_pipe_s { 7767777dab0Sopenharmony_ci UV_HANDLE_FIELDS 7777777dab0Sopenharmony_ci UV_STREAM_FIELDS 7787777dab0Sopenharmony_ci int ipc; /* non-zero if this pipe is used for passing handles */ 7797777dab0Sopenharmony_ci UV_PIPE_PRIVATE_FIELDS 7807777dab0Sopenharmony_ci}; 7817777dab0Sopenharmony_ci 7827777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); 7837777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); 7847777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); 7857777dab0Sopenharmony_ciUV_EXTERN void uv_pipe_connect(uv_connect_t* req, 7867777dab0Sopenharmony_ci uv_pipe_t* handle, 7877777dab0Sopenharmony_ci const char* name, 7887777dab0Sopenharmony_ci uv_connect_cb cb); 7897777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, 7907777dab0Sopenharmony_ci char* buffer, 7917777dab0Sopenharmony_ci size_t* size); 7927777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, 7937777dab0Sopenharmony_ci char* buffer, 7947777dab0Sopenharmony_ci size_t* size); 7957777dab0Sopenharmony_ciUV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); 7967777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); 7977777dab0Sopenharmony_ciUV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); 7987777dab0Sopenharmony_ciUV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); 7997777dab0Sopenharmony_ci 8007777dab0Sopenharmony_ci 8017777dab0Sopenharmony_cistruct uv_poll_s { 8027777dab0Sopenharmony_ci UV_HANDLE_FIELDS 8037777dab0Sopenharmony_ci uv_poll_cb poll_cb; 8047777dab0Sopenharmony_ci UV_POLL_PRIVATE_FIELDS 8057777dab0Sopenharmony_ci}; 8067777dab0Sopenharmony_ci 8077777dab0Sopenharmony_cienum uv_poll_event { 8087777dab0Sopenharmony_ci UV_READABLE = 1, 8097777dab0Sopenharmony_ci UV_WRITABLE = 2, 8107777dab0Sopenharmony_ci UV_DISCONNECT = 4, 8117777dab0Sopenharmony_ci UV_PRIORITIZED = 8 8127777dab0Sopenharmony_ci}; 8137777dab0Sopenharmony_ci 8147777dab0Sopenharmony_ciUV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); 8157777dab0Sopenharmony_ciUV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, 8167777dab0Sopenharmony_ci uv_poll_t* handle, 8177777dab0Sopenharmony_ci uv_os_sock_t socket); 8187777dab0Sopenharmony_ciUV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); 8197777dab0Sopenharmony_ciUV_EXTERN int uv_poll_stop(uv_poll_t* handle); 8207777dab0Sopenharmony_ci 8217777dab0Sopenharmony_ci 8227777dab0Sopenharmony_cistruct uv_prepare_s { 8237777dab0Sopenharmony_ci UV_HANDLE_FIELDS 8247777dab0Sopenharmony_ci UV_PREPARE_PRIVATE_FIELDS 8257777dab0Sopenharmony_ci}; 8267777dab0Sopenharmony_ci 8277777dab0Sopenharmony_ciUV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); 8287777dab0Sopenharmony_ciUV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); 8297777dab0Sopenharmony_ciUV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); 8307777dab0Sopenharmony_ci 8317777dab0Sopenharmony_ci 8327777dab0Sopenharmony_cistruct uv_check_s { 8337777dab0Sopenharmony_ci UV_HANDLE_FIELDS 8347777dab0Sopenharmony_ci UV_CHECK_PRIVATE_FIELDS 8357777dab0Sopenharmony_ci}; 8367777dab0Sopenharmony_ci 8377777dab0Sopenharmony_ciUV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); 8387777dab0Sopenharmony_ciUV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); 8397777dab0Sopenharmony_ciUV_EXTERN int uv_check_stop(uv_check_t* check); 8407777dab0Sopenharmony_ci 8417777dab0Sopenharmony_ci 8427777dab0Sopenharmony_cistruct uv_idle_s { 8437777dab0Sopenharmony_ci UV_HANDLE_FIELDS 8447777dab0Sopenharmony_ci UV_IDLE_PRIVATE_FIELDS 8457777dab0Sopenharmony_ci}; 8467777dab0Sopenharmony_ci 8477777dab0Sopenharmony_ciUV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); 8487777dab0Sopenharmony_ciUV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); 8497777dab0Sopenharmony_ciUV_EXTERN int uv_idle_stop(uv_idle_t* idle); 8507777dab0Sopenharmony_ci 8517777dab0Sopenharmony_ci 8527777dab0Sopenharmony_cistruct uv_async_s { 8537777dab0Sopenharmony_ci UV_HANDLE_FIELDS 8547777dab0Sopenharmony_ci UV_ASYNC_PRIVATE_FIELDS 8557777dab0Sopenharmony_ci}; 8567777dab0Sopenharmony_ci 8577777dab0Sopenharmony_ciUV_EXTERN int uv_async_init(uv_loop_t*, 8587777dab0Sopenharmony_ci uv_async_t* async, 8597777dab0Sopenharmony_ci uv_async_cb async_cb); 8607777dab0Sopenharmony_ciUV_EXTERN int uv_async_send(uv_async_t* async); 8617777dab0Sopenharmony_ci 8627777dab0Sopenharmony_ci 8637777dab0Sopenharmony_ci/* 8647777dab0Sopenharmony_ci * uv_timer_t is a subclass of uv_handle_t. 8657777dab0Sopenharmony_ci * 8667777dab0Sopenharmony_ci * Used to get woken up at a specified time in the future. 8677777dab0Sopenharmony_ci */ 8687777dab0Sopenharmony_cistruct uv_timer_s { 8697777dab0Sopenharmony_ci UV_HANDLE_FIELDS 8707777dab0Sopenharmony_ci UV_TIMER_PRIVATE_FIELDS 8717777dab0Sopenharmony_ci}; 8727777dab0Sopenharmony_ci 8737777dab0Sopenharmony_ciUV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); 8747777dab0Sopenharmony_ciUV_EXTERN int uv_timer_start(uv_timer_t* handle, 8757777dab0Sopenharmony_ci uv_timer_cb cb, 8767777dab0Sopenharmony_ci uint64_t timeout, 8777777dab0Sopenharmony_ci uint64_t repeat); 8787777dab0Sopenharmony_ciUV_EXTERN int uv_timer_stop(uv_timer_t* handle); 8797777dab0Sopenharmony_ciUV_EXTERN int uv_timer_again(uv_timer_t* handle); 8807777dab0Sopenharmony_ciUV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); 8817777dab0Sopenharmony_ciUV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); 8827777dab0Sopenharmony_ci 8837777dab0Sopenharmony_ci 8847777dab0Sopenharmony_ci/* 8857777dab0Sopenharmony_ci * uv_getaddrinfo_t is a subclass of uv_req_t. 8867777dab0Sopenharmony_ci * 8877777dab0Sopenharmony_ci * Request object for uv_getaddrinfo. 8887777dab0Sopenharmony_ci */ 8897777dab0Sopenharmony_cistruct uv_getaddrinfo_s { 8907777dab0Sopenharmony_ci UV_REQ_FIELDS 8917777dab0Sopenharmony_ci /* read-only */ 8927777dab0Sopenharmony_ci uv_loop_t* loop; 8937777dab0Sopenharmony_ci /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ 8947777dab0Sopenharmony_ci UV_GETADDRINFO_PRIVATE_FIELDS 8957777dab0Sopenharmony_ci}; 8967777dab0Sopenharmony_ci 8977777dab0Sopenharmony_ci 8987777dab0Sopenharmony_ciUV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, 8997777dab0Sopenharmony_ci uv_getaddrinfo_t* req, 9007777dab0Sopenharmony_ci uv_getaddrinfo_cb getaddrinfo_cb, 9017777dab0Sopenharmony_ci const char* node, 9027777dab0Sopenharmony_ci const char* service, 9037777dab0Sopenharmony_ci const struct addrinfo* hints); 9047777dab0Sopenharmony_ciUV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); 9057777dab0Sopenharmony_ci 9067777dab0Sopenharmony_ci 9077777dab0Sopenharmony_ci/* 9087777dab0Sopenharmony_ci* uv_getnameinfo_t is a subclass of uv_req_t. 9097777dab0Sopenharmony_ci* 9107777dab0Sopenharmony_ci* Request object for uv_getnameinfo. 9117777dab0Sopenharmony_ci*/ 9127777dab0Sopenharmony_cistruct uv_getnameinfo_s { 9137777dab0Sopenharmony_ci UV_REQ_FIELDS 9147777dab0Sopenharmony_ci /* read-only */ 9157777dab0Sopenharmony_ci uv_loop_t* loop; 9167777dab0Sopenharmony_ci /* host and service are marked as private, but they really aren't. */ 9177777dab0Sopenharmony_ci UV_GETNAMEINFO_PRIVATE_FIELDS 9187777dab0Sopenharmony_ci}; 9197777dab0Sopenharmony_ci 9207777dab0Sopenharmony_ciUV_EXTERN int uv_getnameinfo(uv_loop_t* loop, 9217777dab0Sopenharmony_ci uv_getnameinfo_t* req, 9227777dab0Sopenharmony_ci uv_getnameinfo_cb getnameinfo_cb, 9237777dab0Sopenharmony_ci const struct sockaddr* addr, 9247777dab0Sopenharmony_ci int flags); 9257777dab0Sopenharmony_ci 9267777dab0Sopenharmony_ci 9277777dab0Sopenharmony_ci/* uv_spawn() options. */ 9287777dab0Sopenharmony_citypedef enum { 9297777dab0Sopenharmony_ci UV_IGNORE = 0x00, 9307777dab0Sopenharmony_ci UV_CREATE_PIPE = 0x01, 9317777dab0Sopenharmony_ci UV_INHERIT_FD = 0x02, 9327777dab0Sopenharmony_ci UV_INHERIT_STREAM = 0x04, 9337777dab0Sopenharmony_ci 9347777dab0Sopenharmony_ci /* 9357777dab0Sopenharmony_ci * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE 9367777dab0Sopenharmony_ci * determine the direction of flow, from the child process' perspective. Both 9377777dab0Sopenharmony_ci * flags may be specified to create a duplex data stream. 9387777dab0Sopenharmony_ci */ 9397777dab0Sopenharmony_ci UV_READABLE_PIPE = 0x10, 9407777dab0Sopenharmony_ci UV_WRITABLE_PIPE = 0x20, 9417777dab0Sopenharmony_ci 9427777dab0Sopenharmony_ci /* 9437777dab0Sopenharmony_ci * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the 9447777dab0Sopenharmony_ci * handle in non-blocking mode in the child. This may cause loss of data, 9457777dab0Sopenharmony_ci * if the child is not designed to handle to encounter this mode, 9467777dab0Sopenharmony_ci * but can also be significantly more efficient. 9477777dab0Sopenharmony_ci */ 9487777dab0Sopenharmony_ci UV_NONBLOCK_PIPE = 0x40, 9497777dab0Sopenharmony_ci UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */ 9507777dab0Sopenharmony_ci} uv_stdio_flags; 9517777dab0Sopenharmony_ci 9527777dab0Sopenharmony_citypedef struct uv_stdio_container_s { 9537777dab0Sopenharmony_ci uv_stdio_flags flags; 9547777dab0Sopenharmony_ci 9557777dab0Sopenharmony_ci union { 9567777dab0Sopenharmony_ci uv_stream_t* stream; 9577777dab0Sopenharmony_ci int fd; 9587777dab0Sopenharmony_ci } data; 9597777dab0Sopenharmony_ci} uv_stdio_container_t; 9607777dab0Sopenharmony_ci 9617777dab0Sopenharmony_citypedef struct uv_process_options_s { 9627777dab0Sopenharmony_ci uv_exit_cb exit_cb; /* Called after the process exits. */ 9637777dab0Sopenharmony_ci const char* file; /* Path to program to execute. */ 9647777dab0Sopenharmony_ci /* 9657777dab0Sopenharmony_ci * Command line arguments. args[0] should be the path to the program. On 9667777dab0Sopenharmony_ci * Windows this uses CreateProcess which concatenates the arguments into a 9677777dab0Sopenharmony_ci * string this can cause some strange errors. See the note at 9687777dab0Sopenharmony_ci * windows_verbatim_arguments. 9697777dab0Sopenharmony_ci */ 9707777dab0Sopenharmony_ci char** args; 9717777dab0Sopenharmony_ci /* 9727777dab0Sopenharmony_ci * This will be set as the environ variable in the subprocess. If this is 9737777dab0Sopenharmony_ci * NULL then the parents environ will be used. 9747777dab0Sopenharmony_ci */ 9757777dab0Sopenharmony_ci char** env; 9767777dab0Sopenharmony_ci /* 9777777dab0Sopenharmony_ci * If non-null this represents a directory the subprocess should execute 9787777dab0Sopenharmony_ci * in. Stands for current working directory. 9797777dab0Sopenharmony_ci */ 9807777dab0Sopenharmony_ci const char* cwd; 9817777dab0Sopenharmony_ci /* 9827777dab0Sopenharmony_ci * Various flags that control how uv_spawn() behaves. See the definition of 9837777dab0Sopenharmony_ci * `enum uv_process_flags` below. 9847777dab0Sopenharmony_ci */ 9857777dab0Sopenharmony_ci unsigned int flags; 9867777dab0Sopenharmony_ci /* 9877777dab0Sopenharmony_ci * The `stdio` field points to an array of uv_stdio_container_t structs that 9887777dab0Sopenharmony_ci * describe the file descriptors that will be made available to the child 9897777dab0Sopenharmony_ci * process. The convention is that stdio[0] points to stdin, fd 1 is used for 9907777dab0Sopenharmony_ci * stdout, and fd 2 is stderr. 9917777dab0Sopenharmony_ci * 9927777dab0Sopenharmony_ci * Note that on windows file descriptors greater than 2 are available to the 9937777dab0Sopenharmony_ci * child process only if the child processes uses the MSVCRT runtime. 9947777dab0Sopenharmony_ci */ 9957777dab0Sopenharmony_ci int stdio_count; 9967777dab0Sopenharmony_ci uv_stdio_container_t* stdio; 9977777dab0Sopenharmony_ci /* 9987777dab0Sopenharmony_ci * Libuv can change the child process' user/group id. This happens only when 9997777dab0Sopenharmony_ci * the appropriate bits are set in the flags fields. This is not supported on 10007777dab0Sopenharmony_ci * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. 10017777dab0Sopenharmony_ci */ 10027777dab0Sopenharmony_ci uv_uid_t uid; 10037777dab0Sopenharmony_ci uv_gid_t gid; 10047777dab0Sopenharmony_ci} uv_process_options_t; 10057777dab0Sopenharmony_ci 10067777dab0Sopenharmony_ci/* 10077777dab0Sopenharmony_ci * These are the flags that can be used for the uv_process_options.flags field. 10087777dab0Sopenharmony_ci */ 10097777dab0Sopenharmony_cienum uv_process_flags { 10107777dab0Sopenharmony_ci /* 10117777dab0Sopenharmony_ci * Set the child process' user id. The user id is supplied in the `uid` field 10127777dab0Sopenharmony_ci * of the options struct. This does not work on windows; setting this flag 10137777dab0Sopenharmony_ci * will cause uv_spawn() to fail. 10147777dab0Sopenharmony_ci */ 10157777dab0Sopenharmony_ci UV_PROCESS_SETUID = (1 << 0), 10167777dab0Sopenharmony_ci /* 10177777dab0Sopenharmony_ci * Set the child process' group id. The user id is supplied in the `gid` 10187777dab0Sopenharmony_ci * field of the options struct. This does not work on windows; setting this 10197777dab0Sopenharmony_ci * flag will cause uv_spawn() to fail. 10207777dab0Sopenharmony_ci */ 10217777dab0Sopenharmony_ci UV_PROCESS_SETGID = (1 << 1), 10227777dab0Sopenharmony_ci /* 10237777dab0Sopenharmony_ci * Do not wrap any arguments in quotes, or perform any other escaping, when 10247777dab0Sopenharmony_ci * converting the argument list into a command line string. This option is 10257777dab0Sopenharmony_ci * only meaningful on Windows systems. On Unix it is silently ignored. 10267777dab0Sopenharmony_ci */ 10277777dab0Sopenharmony_ci UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), 10287777dab0Sopenharmony_ci /* 10297777dab0Sopenharmony_ci * Spawn the child process in a detached state - this will make it a process 10307777dab0Sopenharmony_ci * group leader, and will effectively enable the child to keep running after 10317777dab0Sopenharmony_ci * the parent exits. Note that the child process will still keep the 10327777dab0Sopenharmony_ci * parent's event loop alive unless the parent process calls uv_unref() on 10337777dab0Sopenharmony_ci * the child's process handle. 10347777dab0Sopenharmony_ci */ 10357777dab0Sopenharmony_ci UV_PROCESS_DETACHED = (1 << 3), 10367777dab0Sopenharmony_ci /* 10377777dab0Sopenharmony_ci * Hide the subprocess window that would normally be created. This option is 10387777dab0Sopenharmony_ci * only meaningful on Windows systems. On Unix it is silently ignored. 10397777dab0Sopenharmony_ci */ 10407777dab0Sopenharmony_ci UV_PROCESS_WINDOWS_HIDE = (1 << 4), 10417777dab0Sopenharmony_ci /* 10427777dab0Sopenharmony_ci * Hide the subprocess console window that would normally be created. This 10437777dab0Sopenharmony_ci * option is only meaningful on Windows systems. On Unix it is silently 10447777dab0Sopenharmony_ci * ignored. 10457777dab0Sopenharmony_ci */ 10467777dab0Sopenharmony_ci UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), 10477777dab0Sopenharmony_ci /* 10487777dab0Sopenharmony_ci * Hide the subprocess GUI window that would normally be created. This 10497777dab0Sopenharmony_ci * option is only meaningful on Windows systems. On Unix it is silently 10507777dab0Sopenharmony_ci * ignored. 10517777dab0Sopenharmony_ci */ 10527777dab0Sopenharmony_ci UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) 10537777dab0Sopenharmony_ci}; 10547777dab0Sopenharmony_ci 10557777dab0Sopenharmony_ci/* 10567777dab0Sopenharmony_ci * uv_process_t is a subclass of uv_handle_t. 10577777dab0Sopenharmony_ci */ 10587777dab0Sopenharmony_cistruct uv_process_s { 10597777dab0Sopenharmony_ci UV_HANDLE_FIELDS 10607777dab0Sopenharmony_ci uv_exit_cb exit_cb; 10617777dab0Sopenharmony_ci int pid; 10627777dab0Sopenharmony_ci UV_PROCESS_PRIVATE_FIELDS 10637777dab0Sopenharmony_ci}; 10647777dab0Sopenharmony_ci 10657777dab0Sopenharmony_ciUV_EXTERN int uv_spawn(uv_loop_t* loop, 10667777dab0Sopenharmony_ci uv_process_t* handle, 10677777dab0Sopenharmony_ci const uv_process_options_t* options); 10687777dab0Sopenharmony_ciUV_EXTERN int uv_process_kill(uv_process_t*, int signum); 10697777dab0Sopenharmony_ciUV_EXTERN int uv_kill(int pid, int signum); 10707777dab0Sopenharmony_ciUV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); 10717777dab0Sopenharmony_ci 10727777dab0Sopenharmony_ci 10737777dab0Sopenharmony_ci/* 10747777dab0Sopenharmony_ci * uv_work_t is a subclass of uv_req_t. 10757777dab0Sopenharmony_ci */ 10767777dab0Sopenharmony_cistruct uv_work_s { 10777777dab0Sopenharmony_ci UV_REQ_FIELDS 10787777dab0Sopenharmony_ci uv_loop_t* loop; 10797777dab0Sopenharmony_ci uv_work_cb work_cb; 10807777dab0Sopenharmony_ci uv_after_work_cb after_work_cb; 10817777dab0Sopenharmony_ci UV_WORK_PRIVATE_FIELDS 10827777dab0Sopenharmony_ci}; 10837777dab0Sopenharmony_ci 10847777dab0Sopenharmony_ciUV_EXTERN int uv_queue_work(uv_loop_t* loop, 10857777dab0Sopenharmony_ci uv_work_t* req, 10867777dab0Sopenharmony_ci uv_work_cb work_cb, 10877777dab0Sopenharmony_ci uv_after_work_cb after_work_cb); 10887777dab0Sopenharmony_ci 10897777dab0Sopenharmony_ciUV_EXTERN int uv_cancel(uv_req_t* req); 10907777dab0Sopenharmony_ci 10917777dab0Sopenharmony_ci 10927777dab0Sopenharmony_cistruct uv_cpu_times_s { 10937777dab0Sopenharmony_ci uint64_t user; /* milliseconds */ 10947777dab0Sopenharmony_ci uint64_t nice; /* milliseconds */ 10957777dab0Sopenharmony_ci uint64_t sys; /* milliseconds */ 10967777dab0Sopenharmony_ci uint64_t idle; /* milliseconds */ 10977777dab0Sopenharmony_ci uint64_t irq; /* milliseconds */ 10987777dab0Sopenharmony_ci}; 10997777dab0Sopenharmony_ci 11007777dab0Sopenharmony_cistruct uv_cpu_info_s { 11017777dab0Sopenharmony_ci char* model; 11027777dab0Sopenharmony_ci int speed; 11037777dab0Sopenharmony_ci struct uv_cpu_times_s cpu_times; 11047777dab0Sopenharmony_ci}; 11057777dab0Sopenharmony_ci 11067777dab0Sopenharmony_cistruct uv_interface_address_s { 11077777dab0Sopenharmony_ci char* name; 11087777dab0Sopenharmony_ci char phys_addr[6]; 11097777dab0Sopenharmony_ci int is_internal; 11107777dab0Sopenharmony_ci union { 11117777dab0Sopenharmony_ci struct sockaddr_in address4; 11127777dab0Sopenharmony_ci struct sockaddr_in6 address6; 11137777dab0Sopenharmony_ci } address; 11147777dab0Sopenharmony_ci union { 11157777dab0Sopenharmony_ci struct sockaddr_in netmask4; 11167777dab0Sopenharmony_ci struct sockaddr_in6 netmask6; 11177777dab0Sopenharmony_ci } netmask; 11187777dab0Sopenharmony_ci}; 11197777dab0Sopenharmony_ci 11207777dab0Sopenharmony_cistruct uv_passwd_s { 11217777dab0Sopenharmony_ci char* username; 11227777dab0Sopenharmony_ci unsigned long uid; 11237777dab0Sopenharmony_ci unsigned long gid; 11247777dab0Sopenharmony_ci char* shell; 11257777dab0Sopenharmony_ci char* homedir; 11267777dab0Sopenharmony_ci}; 11277777dab0Sopenharmony_ci 11287777dab0Sopenharmony_cistruct uv_utsname_s { 11297777dab0Sopenharmony_ci char sysname[256]; 11307777dab0Sopenharmony_ci char release[256]; 11317777dab0Sopenharmony_ci char version[256]; 11327777dab0Sopenharmony_ci char machine[256]; 11337777dab0Sopenharmony_ci /* This struct does not contain the nodename and domainname fields present in 11347777dab0Sopenharmony_ci the utsname type. domainname is a GNU extension. Both fields are referred 11357777dab0Sopenharmony_ci to as meaningless in the docs. */ 11367777dab0Sopenharmony_ci}; 11377777dab0Sopenharmony_ci 11387777dab0Sopenharmony_cistruct uv_statfs_s { 11397777dab0Sopenharmony_ci uint64_t f_type; 11407777dab0Sopenharmony_ci uint64_t f_bsize; 11417777dab0Sopenharmony_ci uint64_t f_blocks; 11427777dab0Sopenharmony_ci uint64_t f_bfree; 11437777dab0Sopenharmony_ci uint64_t f_bavail; 11447777dab0Sopenharmony_ci uint64_t f_files; 11457777dab0Sopenharmony_ci uint64_t f_ffree; 11467777dab0Sopenharmony_ci uint64_t f_spare[4]; 11477777dab0Sopenharmony_ci}; 11487777dab0Sopenharmony_ci 11497777dab0Sopenharmony_citypedef enum { 11507777dab0Sopenharmony_ci UV_DIRENT_UNKNOWN, 11517777dab0Sopenharmony_ci UV_DIRENT_FILE, 11527777dab0Sopenharmony_ci UV_DIRENT_DIR, 11537777dab0Sopenharmony_ci UV_DIRENT_LINK, 11547777dab0Sopenharmony_ci UV_DIRENT_FIFO, 11557777dab0Sopenharmony_ci UV_DIRENT_SOCKET, 11567777dab0Sopenharmony_ci UV_DIRENT_CHAR, 11577777dab0Sopenharmony_ci UV_DIRENT_BLOCK 11587777dab0Sopenharmony_ci} uv_dirent_type_t; 11597777dab0Sopenharmony_ci 11607777dab0Sopenharmony_cistruct uv_dirent_s { 11617777dab0Sopenharmony_ci const char* name; 11627777dab0Sopenharmony_ci uv_dirent_type_t type; 11637777dab0Sopenharmony_ci}; 11647777dab0Sopenharmony_ci 11657777dab0Sopenharmony_ciUV_EXTERN char** uv_setup_args(int argc, char** argv); 11667777dab0Sopenharmony_ciUV_EXTERN int uv_get_process_title(char* buffer, size_t size); 11677777dab0Sopenharmony_ciUV_EXTERN int uv_set_process_title(const char* title); 11687777dab0Sopenharmony_ciUV_EXTERN int uv_resident_set_memory(size_t* rss); 11697777dab0Sopenharmony_ciUV_EXTERN int uv_uptime(double* uptime); 11707777dab0Sopenharmony_ciUV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); 11717777dab0Sopenharmony_ciUV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); 11727777dab0Sopenharmony_ci 11737777dab0Sopenharmony_citypedef struct { 11747777dab0Sopenharmony_ci long tv_sec; 11757777dab0Sopenharmony_ci long tv_usec; 11767777dab0Sopenharmony_ci} uv_timeval_t; 11777777dab0Sopenharmony_ci 11787777dab0Sopenharmony_citypedef struct { 11797777dab0Sopenharmony_ci int64_t tv_sec; 11807777dab0Sopenharmony_ci int32_t tv_usec; 11817777dab0Sopenharmony_ci} uv_timeval64_t; 11827777dab0Sopenharmony_ci 11837777dab0Sopenharmony_citypedef struct { 11847777dab0Sopenharmony_ci uv_timeval_t ru_utime; /* user CPU time used */ 11857777dab0Sopenharmony_ci uv_timeval_t ru_stime; /* system CPU time used */ 11867777dab0Sopenharmony_ci uint64_t ru_maxrss; /* maximum resident set size */ 11877777dab0Sopenharmony_ci uint64_t ru_ixrss; /* integral shared memory size */ 11887777dab0Sopenharmony_ci uint64_t ru_idrss; /* integral unshared data size */ 11897777dab0Sopenharmony_ci uint64_t ru_isrss; /* integral unshared stack size */ 11907777dab0Sopenharmony_ci uint64_t ru_minflt; /* page reclaims (soft page faults) */ 11917777dab0Sopenharmony_ci uint64_t ru_majflt; /* page faults (hard page faults) */ 11927777dab0Sopenharmony_ci uint64_t ru_nswap; /* swaps */ 11937777dab0Sopenharmony_ci uint64_t ru_inblock; /* block input operations */ 11947777dab0Sopenharmony_ci uint64_t ru_oublock; /* block output operations */ 11957777dab0Sopenharmony_ci uint64_t ru_msgsnd; /* IPC messages sent */ 11967777dab0Sopenharmony_ci uint64_t ru_msgrcv; /* IPC messages received */ 11977777dab0Sopenharmony_ci uint64_t ru_nsignals; /* signals received */ 11987777dab0Sopenharmony_ci uint64_t ru_nvcsw; /* voluntary context switches */ 11997777dab0Sopenharmony_ci uint64_t ru_nivcsw; /* involuntary context switches */ 12007777dab0Sopenharmony_ci} uv_rusage_t; 12017777dab0Sopenharmony_ci 12027777dab0Sopenharmony_ciUV_EXTERN int uv_getrusage(uv_rusage_t* rusage); 12037777dab0Sopenharmony_ci 12047777dab0Sopenharmony_ciUV_EXTERN int uv_os_homedir(char* buffer, size_t* size); 12057777dab0Sopenharmony_ciUV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); 12067777dab0Sopenharmony_ciUV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); 12077777dab0Sopenharmony_ciUV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); 12087777dab0Sopenharmony_ciUV_EXTERN uv_pid_t uv_os_getpid(void); 12097777dab0Sopenharmony_ciUV_EXTERN uv_pid_t uv_os_getppid(void); 12107777dab0Sopenharmony_ci 12117777dab0Sopenharmony_ci#if defined(__PASE__) 12127777dab0Sopenharmony_ci/* On IBM i PASE, the highest process priority is -10 */ 12137777dab0Sopenharmony_ci# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */ 12147777dab0Sopenharmony_ci# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ 12157777dab0Sopenharmony_ci# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */ 12167777dab0Sopenharmony_ci# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ 12177777dab0Sopenharmony_ci# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */ 12187777dab0Sopenharmony_ci# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */ 12197777dab0Sopenharmony_ci#else 12207777dab0Sopenharmony_ci# define UV_PRIORITY_LOW 19 12217777dab0Sopenharmony_ci# define UV_PRIORITY_BELOW_NORMAL 10 12227777dab0Sopenharmony_ci# define UV_PRIORITY_NORMAL 0 12237777dab0Sopenharmony_ci# define UV_PRIORITY_ABOVE_NORMAL -7 12247777dab0Sopenharmony_ci# define UV_PRIORITY_HIGH -14 12257777dab0Sopenharmony_ci# define UV_PRIORITY_HIGHEST -20 12267777dab0Sopenharmony_ci#endif 12277777dab0Sopenharmony_ci 12287777dab0Sopenharmony_ciUV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); 12297777dab0Sopenharmony_ciUV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); 12307777dab0Sopenharmony_ci 12317777dab0Sopenharmony_ciUV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); 12327777dab0Sopenharmony_ciUV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); 12337777dab0Sopenharmony_ci 12347777dab0Sopenharmony_ciUV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, 12357777dab0Sopenharmony_ci int* count); 12367777dab0Sopenharmony_ciUV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, 12377777dab0Sopenharmony_ci int count); 12387777dab0Sopenharmony_ci 12397777dab0Sopenharmony_cistruct uv_env_item_s { 12407777dab0Sopenharmony_ci char* name; 12417777dab0Sopenharmony_ci char* value; 12427777dab0Sopenharmony_ci}; 12437777dab0Sopenharmony_ci 12447777dab0Sopenharmony_ciUV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); 12457777dab0Sopenharmony_ciUV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); 12467777dab0Sopenharmony_ciUV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); 12477777dab0Sopenharmony_ciUV_EXTERN int uv_os_setenv(const char* name, const char* value); 12487777dab0Sopenharmony_ciUV_EXTERN int uv_os_unsetenv(const char* name); 12497777dab0Sopenharmony_ci 12507777dab0Sopenharmony_ci#ifdef MAXHOSTNAMELEN 12517777dab0Sopenharmony_ci# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1) 12527777dab0Sopenharmony_ci#else 12537777dab0Sopenharmony_ci /* 12547777dab0Sopenharmony_ci Fallback for the maximum hostname size, including the null terminator. The 12557777dab0Sopenharmony_ci Windows gethostname() documentation states that 256 bytes will always be 12567777dab0Sopenharmony_ci large enough to hold the null-terminated hostname. 12577777dab0Sopenharmony_ci */ 12587777dab0Sopenharmony_ci# define UV_MAXHOSTNAMESIZE 256 12597777dab0Sopenharmony_ci#endif 12607777dab0Sopenharmony_ci 12617777dab0Sopenharmony_ciUV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); 12627777dab0Sopenharmony_ci 12637777dab0Sopenharmony_ciUV_EXTERN int uv_os_uname(uv_utsname_t* buffer); 12647777dab0Sopenharmony_ci 12657777dab0Sopenharmony_ci 12667777dab0Sopenharmony_citypedef enum { 12677777dab0Sopenharmony_ci UV_FS_UNKNOWN = -1, 12687777dab0Sopenharmony_ci UV_FS_CUSTOM, 12697777dab0Sopenharmony_ci UV_FS_OPEN, 12707777dab0Sopenharmony_ci UV_FS_CLOSE, 12717777dab0Sopenharmony_ci UV_FS_READ, 12727777dab0Sopenharmony_ci UV_FS_WRITE, 12737777dab0Sopenharmony_ci UV_FS_SENDFILE, 12747777dab0Sopenharmony_ci UV_FS_STAT, 12757777dab0Sopenharmony_ci UV_FS_LSTAT, 12767777dab0Sopenharmony_ci UV_FS_FSTAT, 12777777dab0Sopenharmony_ci UV_FS_FTRUNCATE, 12787777dab0Sopenharmony_ci UV_FS_UTIME, 12797777dab0Sopenharmony_ci UV_FS_FUTIME, 12807777dab0Sopenharmony_ci UV_FS_ACCESS, 12817777dab0Sopenharmony_ci UV_FS_CHMOD, 12827777dab0Sopenharmony_ci UV_FS_FCHMOD, 12837777dab0Sopenharmony_ci UV_FS_FSYNC, 12847777dab0Sopenharmony_ci UV_FS_FDATASYNC, 12857777dab0Sopenharmony_ci UV_FS_UNLINK, 12867777dab0Sopenharmony_ci UV_FS_RMDIR, 12877777dab0Sopenharmony_ci UV_FS_MKDIR, 12887777dab0Sopenharmony_ci UV_FS_MKDTEMP, 12897777dab0Sopenharmony_ci UV_FS_RENAME, 12907777dab0Sopenharmony_ci UV_FS_SCANDIR, 12917777dab0Sopenharmony_ci UV_FS_LINK, 12927777dab0Sopenharmony_ci UV_FS_SYMLINK, 12937777dab0Sopenharmony_ci UV_FS_READLINK, 12947777dab0Sopenharmony_ci UV_FS_CHOWN, 12957777dab0Sopenharmony_ci UV_FS_FCHOWN, 12967777dab0Sopenharmony_ci UV_FS_REALPATH, 12977777dab0Sopenharmony_ci UV_FS_COPYFILE, 12987777dab0Sopenharmony_ci UV_FS_LCHOWN, 12997777dab0Sopenharmony_ci UV_FS_OPENDIR, 13007777dab0Sopenharmony_ci UV_FS_READDIR, 13017777dab0Sopenharmony_ci UV_FS_CLOSEDIR, 13027777dab0Sopenharmony_ci UV_FS_STATFS, 13037777dab0Sopenharmony_ci UV_FS_MKSTEMP, 13047777dab0Sopenharmony_ci UV_FS_LUTIME 13057777dab0Sopenharmony_ci} uv_fs_type; 13067777dab0Sopenharmony_ci 13077777dab0Sopenharmony_cistruct uv_dir_s { 13087777dab0Sopenharmony_ci uv_dirent_t* dirents; 13097777dab0Sopenharmony_ci size_t nentries; 13107777dab0Sopenharmony_ci void* reserved[4]; 13117777dab0Sopenharmony_ci UV_DIR_PRIVATE_FIELDS 13127777dab0Sopenharmony_ci}; 13137777dab0Sopenharmony_ci 13147777dab0Sopenharmony_ci/* uv_fs_t is a subclass of uv_req_t. */ 13157777dab0Sopenharmony_cistruct uv_fs_s { 13167777dab0Sopenharmony_ci UV_REQ_FIELDS 13177777dab0Sopenharmony_ci uv_fs_type fs_type; 13187777dab0Sopenharmony_ci uv_loop_t* loop; 13197777dab0Sopenharmony_ci uv_fs_cb cb; 13207777dab0Sopenharmony_ci ssize_t result; 13217777dab0Sopenharmony_ci void* ptr; 13227777dab0Sopenharmony_ci const char* path; 13237777dab0Sopenharmony_ci uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ 13247777dab0Sopenharmony_ci UV_FS_PRIVATE_FIELDS 13257777dab0Sopenharmony_ci}; 13267777dab0Sopenharmony_ci 13277777dab0Sopenharmony_ciUV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); 13287777dab0Sopenharmony_ciUV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); 13297777dab0Sopenharmony_ciUV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); 13307777dab0Sopenharmony_ciUV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); 13317777dab0Sopenharmony_ciUV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); 13327777dab0Sopenharmony_ci 13337777dab0Sopenharmony_ciUV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); 13347777dab0Sopenharmony_ciUV_EXTERN int uv_fs_close(uv_loop_t* loop, 13357777dab0Sopenharmony_ci uv_fs_t* req, 13367777dab0Sopenharmony_ci uv_file file, 13377777dab0Sopenharmony_ci uv_fs_cb cb); 13387777dab0Sopenharmony_ciUV_EXTERN int uv_fs_open(uv_loop_t* loop, 13397777dab0Sopenharmony_ci uv_fs_t* req, 13407777dab0Sopenharmony_ci const char* path, 13417777dab0Sopenharmony_ci int flags, 13427777dab0Sopenharmony_ci int mode, 13437777dab0Sopenharmony_ci uv_fs_cb cb); 13447777dab0Sopenharmony_ciUV_EXTERN int uv_fs_read(uv_loop_t* loop, 13457777dab0Sopenharmony_ci uv_fs_t* req, 13467777dab0Sopenharmony_ci uv_file file, 13477777dab0Sopenharmony_ci const uv_buf_t bufs[], 13487777dab0Sopenharmony_ci unsigned int nbufs, 13497777dab0Sopenharmony_ci int64_t offset, 13507777dab0Sopenharmony_ci uv_fs_cb cb); 13517777dab0Sopenharmony_ciUV_EXTERN int uv_fs_unlink(uv_loop_t* loop, 13527777dab0Sopenharmony_ci uv_fs_t* req, 13537777dab0Sopenharmony_ci const char* path, 13547777dab0Sopenharmony_ci uv_fs_cb cb); 13557777dab0Sopenharmony_ciUV_EXTERN int uv_fs_write(uv_loop_t* loop, 13567777dab0Sopenharmony_ci uv_fs_t* req, 13577777dab0Sopenharmony_ci uv_file file, 13587777dab0Sopenharmony_ci const uv_buf_t bufs[], 13597777dab0Sopenharmony_ci unsigned int nbufs, 13607777dab0Sopenharmony_ci int64_t offset, 13617777dab0Sopenharmony_ci uv_fs_cb cb); 13627777dab0Sopenharmony_ci/* 13637777dab0Sopenharmony_ci * This flag can be used with uv_fs_copyfile() to return an error if the 13647777dab0Sopenharmony_ci * destination already exists. 13657777dab0Sopenharmony_ci */ 13667777dab0Sopenharmony_ci#define UV_FS_COPYFILE_EXCL 0x0001 13677777dab0Sopenharmony_ci 13687777dab0Sopenharmony_ci/* 13697777dab0Sopenharmony_ci * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. 13707777dab0Sopenharmony_ci * If copy-on-write is not supported, a fallback copy mechanism is used. 13717777dab0Sopenharmony_ci */ 13727777dab0Sopenharmony_ci#define UV_FS_COPYFILE_FICLONE 0x0002 13737777dab0Sopenharmony_ci 13747777dab0Sopenharmony_ci/* 13757777dab0Sopenharmony_ci * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. 13767777dab0Sopenharmony_ci * If copy-on-write is not supported, an error is returned. 13777777dab0Sopenharmony_ci */ 13787777dab0Sopenharmony_ci#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004 13797777dab0Sopenharmony_ci 13807777dab0Sopenharmony_ciUV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, 13817777dab0Sopenharmony_ci uv_fs_t* req, 13827777dab0Sopenharmony_ci const char* path, 13837777dab0Sopenharmony_ci const char* new_path, 13847777dab0Sopenharmony_ci int flags, 13857777dab0Sopenharmony_ci uv_fs_cb cb); 13867777dab0Sopenharmony_ciUV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, 13877777dab0Sopenharmony_ci uv_fs_t* req, 13887777dab0Sopenharmony_ci const char* path, 13897777dab0Sopenharmony_ci int mode, 13907777dab0Sopenharmony_ci uv_fs_cb cb); 13917777dab0Sopenharmony_ciUV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, 13927777dab0Sopenharmony_ci uv_fs_t* req, 13937777dab0Sopenharmony_ci const char* tpl, 13947777dab0Sopenharmony_ci uv_fs_cb cb); 13957777dab0Sopenharmony_ciUV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, 13967777dab0Sopenharmony_ci uv_fs_t* req, 13977777dab0Sopenharmony_ci const char* tpl, 13987777dab0Sopenharmony_ci uv_fs_cb cb); 13997777dab0Sopenharmony_ciUV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, 14007777dab0Sopenharmony_ci uv_fs_t* req, 14017777dab0Sopenharmony_ci const char* path, 14027777dab0Sopenharmony_ci uv_fs_cb cb); 14037777dab0Sopenharmony_ciUV_EXTERN int uv_fs_scandir(uv_loop_t* loop, 14047777dab0Sopenharmony_ci uv_fs_t* req, 14057777dab0Sopenharmony_ci const char* path, 14067777dab0Sopenharmony_ci int flags, 14077777dab0Sopenharmony_ci uv_fs_cb cb); 14087777dab0Sopenharmony_ciUV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, 14097777dab0Sopenharmony_ci uv_dirent_t* ent); 14107777dab0Sopenharmony_ciUV_EXTERN int uv_fs_opendir(uv_loop_t* loop, 14117777dab0Sopenharmony_ci uv_fs_t* req, 14127777dab0Sopenharmony_ci const char* path, 14137777dab0Sopenharmony_ci uv_fs_cb cb); 14147777dab0Sopenharmony_ciUV_EXTERN int uv_fs_readdir(uv_loop_t* loop, 14157777dab0Sopenharmony_ci uv_fs_t* req, 14167777dab0Sopenharmony_ci uv_dir_t* dir, 14177777dab0Sopenharmony_ci uv_fs_cb cb); 14187777dab0Sopenharmony_ciUV_EXTERN int uv_fs_closedir(uv_loop_t* loop, 14197777dab0Sopenharmony_ci uv_fs_t* req, 14207777dab0Sopenharmony_ci uv_dir_t* dir, 14217777dab0Sopenharmony_ci uv_fs_cb cb); 14227777dab0Sopenharmony_ciUV_EXTERN int uv_fs_stat(uv_loop_t* loop, 14237777dab0Sopenharmony_ci uv_fs_t* req, 14247777dab0Sopenharmony_ci const char* path, 14257777dab0Sopenharmony_ci uv_fs_cb cb); 14267777dab0Sopenharmony_ciUV_EXTERN int uv_fs_fstat(uv_loop_t* loop, 14277777dab0Sopenharmony_ci uv_fs_t* req, 14287777dab0Sopenharmony_ci uv_file file, 14297777dab0Sopenharmony_ci uv_fs_cb cb); 14307777dab0Sopenharmony_ciUV_EXTERN int uv_fs_rename(uv_loop_t* loop, 14317777dab0Sopenharmony_ci uv_fs_t* req, 14327777dab0Sopenharmony_ci const char* path, 14337777dab0Sopenharmony_ci const char* new_path, 14347777dab0Sopenharmony_ci uv_fs_cb cb); 14357777dab0Sopenharmony_ciUV_EXTERN int uv_fs_fsync(uv_loop_t* loop, 14367777dab0Sopenharmony_ci uv_fs_t* req, 14377777dab0Sopenharmony_ci uv_file file, 14387777dab0Sopenharmony_ci uv_fs_cb cb); 14397777dab0Sopenharmony_ciUV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, 14407777dab0Sopenharmony_ci uv_fs_t* req, 14417777dab0Sopenharmony_ci uv_file file, 14427777dab0Sopenharmony_ci uv_fs_cb cb); 14437777dab0Sopenharmony_ciUV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, 14447777dab0Sopenharmony_ci uv_fs_t* req, 14457777dab0Sopenharmony_ci uv_file file, 14467777dab0Sopenharmony_ci int64_t offset, 14477777dab0Sopenharmony_ci uv_fs_cb cb); 14487777dab0Sopenharmony_ciUV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, 14497777dab0Sopenharmony_ci uv_fs_t* req, 14507777dab0Sopenharmony_ci uv_file out_fd, 14517777dab0Sopenharmony_ci uv_file in_fd, 14527777dab0Sopenharmony_ci int64_t in_offset, 14537777dab0Sopenharmony_ci size_t length, 14547777dab0Sopenharmony_ci uv_fs_cb cb); 14557777dab0Sopenharmony_ciUV_EXTERN int uv_fs_access(uv_loop_t* loop, 14567777dab0Sopenharmony_ci uv_fs_t* req, 14577777dab0Sopenharmony_ci const char* path, 14587777dab0Sopenharmony_ci int mode, 14597777dab0Sopenharmony_ci uv_fs_cb cb); 14607777dab0Sopenharmony_ciUV_EXTERN int uv_fs_chmod(uv_loop_t* loop, 14617777dab0Sopenharmony_ci uv_fs_t* req, 14627777dab0Sopenharmony_ci const char* path, 14637777dab0Sopenharmony_ci int mode, 14647777dab0Sopenharmony_ci uv_fs_cb cb); 14657777dab0Sopenharmony_ciUV_EXTERN int uv_fs_utime(uv_loop_t* loop, 14667777dab0Sopenharmony_ci uv_fs_t* req, 14677777dab0Sopenharmony_ci const char* path, 14687777dab0Sopenharmony_ci double atime, 14697777dab0Sopenharmony_ci double mtime, 14707777dab0Sopenharmony_ci uv_fs_cb cb); 14717777dab0Sopenharmony_ciUV_EXTERN int uv_fs_futime(uv_loop_t* loop, 14727777dab0Sopenharmony_ci uv_fs_t* req, 14737777dab0Sopenharmony_ci uv_file file, 14747777dab0Sopenharmony_ci double atime, 14757777dab0Sopenharmony_ci double mtime, 14767777dab0Sopenharmony_ci uv_fs_cb cb); 14777777dab0Sopenharmony_ciUV_EXTERN int uv_fs_lstat(uv_loop_t* loop, 14787777dab0Sopenharmony_ci uv_fs_t* req, 14797777dab0Sopenharmony_ci const char* path, 14807777dab0Sopenharmony_ci uv_fs_cb cb); 14817777dab0Sopenharmony_ciUV_EXTERN int uv_fs_link(uv_loop_t* loop, 14827777dab0Sopenharmony_ci uv_fs_t* req, 14837777dab0Sopenharmony_ci const char* path, 14847777dab0Sopenharmony_ci const char* new_path, 14857777dab0Sopenharmony_ci uv_fs_cb cb); 14867777dab0Sopenharmony_ci 14877777dab0Sopenharmony_ci/* 14887777dab0Sopenharmony_ci * This flag can be used with uv_fs_symlink() on Windows to specify whether 14897777dab0Sopenharmony_ci * path argument points to a directory. 14907777dab0Sopenharmony_ci */ 14917777dab0Sopenharmony_ci#define UV_FS_SYMLINK_DIR 0x0001 14927777dab0Sopenharmony_ci 14937777dab0Sopenharmony_ci/* 14947777dab0Sopenharmony_ci * This flag can be used with uv_fs_symlink() on Windows to specify whether 14957777dab0Sopenharmony_ci * the symlink is to be created using junction points. 14967777dab0Sopenharmony_ci */ 14977777dab0Sopenharmony_ci#define UV_FS_SYMLINK_JUNCTION 0x0002 14987777dab0Sopenharmony_ci 14997777dab0Sopenharmony_ciUV_EXTERN int uv_fs_symlink(uv_loop_t* loop, 15007777dab0Sopenharmony_ci uv_fs_t* req, 15017777dab0Sopenharmony_ci const char* path, 15027777dab0Sopenharmony_ci const char* new_path, 15037777dab0Sopenharmony_ci int flags, 15047777dab0Sopenharmony_ci uv_fs_cb cb); 15057777dab0Sopenharmony_ciUV_EXTERN int uv_fs_readlink(uv_loop_t* loop, 15067777dab0Sopenharmony_ci uv_fs_t* req, 15077777dab0Sopenharmony_ci const char* path, 15087777dab0Sopenharmony_ci uv_fs_cb cb); 15097777dab0Sopenharmony_ciUV_EXTERN int uv_fs_realpath(uv_loop_t* loop, 15107777dab0Sopenharmony_ci uv_fs_t* req, 15117777dab0Sopenharmony_ci const char* path, 15127777dab0Sopenharmony_ci uv_fs_cb cb); 15137777dab0Sopenharmony_ciUV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, 15147777dab0Sopenharmony_ci uv_fs_t* req, 15157777dab0Sopenharmony_ci uv_file file, 15167777dab0Sopenharmony_ci int mode, 15177777dab0Sopenharmony_ci uv_fs_cb cb); 15187777dab0Sopenharmony_ciUV_EXTERN int uv_fs_chown(uv_loop_t* loop, 15197777dab0Sopenharmony_ci uv_fs_t* req, 15207777dab0Sopenharmony_ci const char* path, 15217777dab0Sopenharmony_ci uv_uid_t uid, 15227777dab0Sopenharmony_ci uv_gid_t gid, 15237777dab0Sopenharmony_ci uv_fs_cb cb); 15247777dab0Sopenharmony_ciUV_EXTERN int uv_fs_fchown(uv_loop_t* loop, 15257777dab0Sopenharmony_ci uv_fs_t* req, 15267777dab0Sopenharmony_ci uv_file file, 15277777dab0Sopenharmony_ci uv_uid_t uid, 15287777dab0Sopenharmony_ci uv_gid_t gid, 15297777dab0Sopenharmony_ci uv_fs_cb cb); 15307777dab0Sopenharmony_ciUV_EXTERN int uv_fs_lchown(uv_loop_t* loop, 15317777dab0Sopenharmony_ci uv_fs_t* req, 15327777dab0Sopenharmony_ci const char* path, 15337777dab0Sopenharmony_ci uv_uid_t uid, 15347777dab0Sopenharmony_ci uv_gid_t gid, 15357777dab0Sopenharmony_ci uv_fs_cb cb); 15367777dab0Sopenharmony_ciUV_EXTERN int uv_fs_statfs(uv_loop_t* loop, 15377777dab0Sopenharmony_ci uv_fs_t* req, 15387777dab0Sopenharmony_ci const char* path, 15397777dab0Sopenharmony_ci uv_fs_cb cb); 15407777dab0Sopenharmony_ci 15417777dab0Sopenharmony_ci 15427777dab0Sopenharmony_cienum uv_fs_event { 15437777dab0Sopenharmony_ci UV_RENAME = 1, 15447777dab0Sopenharmony_ci UV_CHANGE = 2 15457777dab0Sopenharmony_ci}; 15467777dab0Sopenharmony_ci 15477777dab0Sopenharmony_ci 15487777dab0Sopenharmony_cistruct uv_fs_event_s { 15497777dab0Sopenharmony_ci UV_HANDLE_FIELDS 15507777dab0Sopenharmony_ci /* private */ 15517777dab0Sopenharmony_ci char* path; 15527777dab0Sopenharmony_ci UV_FS_EVENT_PRIVATE_FIELDS 15537777dab0Sopenharmony_ci}; 15547777dab0Sopenharmony_ci 15557777dab0Sopenharmony_ci 15567777dab0Sopenharmony_ci/* 15577777dab0Sopenharmony_ci * uv_fs_stat() based polling file watcher. 15587777dab0Sopenharmony_ci */ 15597777dab0Sopenharmony_cistruct uv_fs_poll_s { 15607777dab0Sopenharmony_ci UV_HANDLE_FIELDS 15617777dab0Sopenharmony_ci /* Private, don't touch. */ 15627777dab0Sopenharmony_ci void* poll_ctx; 15637777dab0Sopenharmony_ci}; 15647777dab0Sopenharmony_ci 15657777dab0Sopenharmony_ciUV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); 15667777dab0Sopenharmony_ciUV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, 15677777dab0Sopenharmony_ci uv_fs_poll_cb poll_cb, 15687777dab0Sopenharmony_ci const char* path, 15697777dab0Sopenharmony_ci unsigned int interval); 15707777dab0Sopenharmony_ciUV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); 15717777dab0Sopenharmony_ciUV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, 15727777dab0Sopenharmony_ci char* buffer, 15737777dab0Sopenharmony_ci size_t* size); 15747777dab0Sopenharmony_ci 15757777dab0Sopenharmony_ci 15767777dab0Sopenharmony_cistruct uv_signal_s { 15777777dab0Sopenharmony_ci UV_HANDLE_FIELDS 15787777dab0Sopenharmony_ci uv_signal_cb signal_cb; 15797777dab0Sopenharmony_ci int signum; 15807777dab0Sopenharmony_ci UV_SIGNAL_PRIVATE_FIELDS 15817777dab0Sopenharmony_ci}; 15827777dab0Sopenharmony_ci 15837777dab0Sopenharmony_ciUV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); 15847777dab0Sopenharmony_ciUV_EXTERN int uv_signal_start(uv_signal_t* handle, 15857777dab0Sopenharmony_ci uv_signal_cb signal_cb, 15867777dab0Sopenharmony_ci int signum); 15877777dab0Sopenharmony_ciUV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, 15887777dab0Sopenharmony_ci uv_signal_cb signal_cb, 15897777dab0Sopenharmony_ci int signum); 15907777dab0Sopenharmony_ciUV_EXTERN int uv_signal_stop(uv_signal_t* handle); 15917777dab0Sopenharmony_ci 15927777dab0Sopenharmony_ciUV_EXTERN void uv_loadavg(double avg[3]); 15937777dab0Sopenharmony_ci 15947777dab0Sopenharmony_ci 15957777dab0Sopenharmony_ci/* 15967777dab0Sopenharmony_ci * Flags to be passed to uv_fs_event_start(). 15977777dab0Sopenharmony_ci */ 15987777dab0Sopenharmony_cienum uv_fs_event_flags { 15997777dab0Sopenharmony_ci /* 16007777dab0Sopenharmony_ci * By default, if the fs event watcher is given a directory name, we will 16017777dab0Sopenharmony_ci * watch for all events in that directory. This flags overrides this behavior 16027777dab0Sopenharmony_ci * and makes fs_event report only changes to the directory entry itself. This 16037777dab0Sopenharmony_ci * flag does not affect individual files watched. 16047777dab0Sopenharmony_ci * This flag is currently not implemented yet on any backend. 16057777dab0Sopenharmony_ci */ 16067777dab0Sopenharmony_ci UV_FS_EVENT_WATCH_ENTRY = 1, 16077777dab0Sopenharmony_ci 16087777dab0Sopenharmony_ci /* 16097777dab0Sopenharmony_ci * By default uv_fs_event will try to use a kernel interface such as inotify 16107777dab0Sopenharmony_ci * or kqueue to detect events. This may not work on remote filesystems such 16117777dab0Sopenharmony_ci * as NFS mounts. This flag makes fs_event fall back to calling stat() on a 16127777dab0Sopenharmony_ci * regular interval. 16137777dab0Sopenharmony_ci * This flag is currently not implemented yet on any backend. 16147777dab0Sopenharmony_ci */ 16157777dab0Sopenharmony_ci UV_FS_EVENT_STAT = 2, 16167777dab0Sopenharmony_ci 16177777dab0Sopenharmony_ci /* 16187777dab0Sopenharmony_ci * By default, event watcher, when watching directory, is not registering 16197777dab0Sopenharmony_ci * (is ignoring) changes in it's subdirectories. 16207777dab0Sopenharmony_ci * This flag will override this behaviour on platforms that support it. 16217777dab0Sopenharmony_ci */ 16227777dab0Sopenharmony_ci UV_FS_EVENT_RECURSIVE = 4 16237777dab0Sopenharmony_ci}; 16247777dab0Sopenharmony_ci 16257777dab0Sopenharmony_ci 16267777dab0Sopenharmony_ciUV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); 16277777dab0Sopenharmony_ciUV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, 16287777dab0Sopenharmony_ci uv_fs_event_cb cb, 16297777dab0Sopenharmony_ci const char* path, 16307777dab0Sopenharmony_ci unsigned int flags); 16317777dab0Sopenharmony_ciUV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); 16327777dab0Sopenharmony_ciUV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, 16337777dab0Sopenharmony_ci char* buffer, 16347777dab0Sopenharmony_ci size_t* size); 16357777dab0Sopenharmony_ci 16367777dab0Sopenharmony_ciUV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); 16377777dab0Sopenharmony_ciUV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); 16387777dab0Sopenharmony_ci 16397777dab0Sopenharmony_ciUV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); 16407777dab0Sopenharmony_ciUV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); 16417777dab0Sopenharmony_ci 16427777dab0Sopenharmony_ciUV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); 16437777dab0Sopenharmony_ciUV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); 16447777dab0Sopenharmony_ci 16457777dab0Sopenharmony_ci 16467777dab0Sopenharmony_cistruct uv_random_s { 16477777dab0Sopenharmony_ci UV_REQ_FIELDS 16487777dab0Sopenharmony_ci /* read-only */ 16497777dab0Sopenharmony_ci uv_loop_t* loop; 16507777dab0Sopenharmony_ci /* private */ 16517777dab0Sopenharmony_ci int status; 16527777dab0Sopenharmony_ci void* buf; 16537777dab0Sopenharmony_ci size_t buflen; 16547777dab0Sopenharmony_ci uv_random_cb cb; 16557777dab0Sopenharmony_ci struct uv__work work_req; 16567777dab0Sopenharmony_ci}; 16577777dab0Sopenharmony_ci 16587777dab0Sopenharmony_ciUV_EXTERN int uv_random(uv_loop_t* loop, 16597777dab0Sopenharmony_ci uv_random_t* req, 16607777dab0Sopenharmony_ci void *buf, 16617777dab0Sopenharmony_ci size_t buflen, 16627777dab0Sopenharmony_ci unsigned flags, /* For future extension; must be 0. */ 16637777dab0Sopenharmony_ci uv_random_cb cb); 16647777dab0Sopenharmony_ci 16657777dab0Sopenharmony_ci#if defined(IF_NAMESIZE) 16667777dab0Sopenharmony_ci# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) 16677777dab0Sopenharmony_ci#elif defined(IFNAMSIZ) 16687777dab0Sopenharmony_ci# define UV_IF_NAMESIZE (IFNAMSIZ + 1) 16697777dab0Sopenharmony_ci#else 16707777dab0Sopenharmony_ci# define UV_IF_NAMESIZE (16 + 1) 16717777dab0Sopenharmony_ci#endif 16727777dab0Sopenharmony_ci 16737777dab0Sopenharmony_ciUV_EXTERN int uv_if_indextoname(unsigned int ifindex, 16747777dab0Sopenharmony_ci char* buffer, 16757777dab0Sopenharmony_ci size_t* size); 16767777dab0Sopenharmony_ciUV_EXTERN int uv_if_indextoiid(unsigned int ifindex, 16777777dab0Sopenharmony_ci char* buffer, 16787777dab0Sopenharmony_ci size_t* size); 16797777dab0Sopenharmony_ci 16807777dab0Sopenharmony_ciUV_EXTERN int uv_exepath(char* buffer, size_t* size); 16817777dab0Sopenharmony_ci 16827777dab0Sopenharmony_ciUV_EXTERN int uv_cwd(char* buffer, size_t* size); 16837777dab0Sopenharmony_ci 16847777dab0Sopenharmony_ciUV_EXTERN int uv_chdir(const char* dir); 16857777dab0Sopenharmony_ci 16867777dab0Sopenharmony_ciUV_EXTERN uint64_t uv_get_free_memory(void); 16877777dab0Sopenharmony_ciUV_EXTERN uint64_t uv_get_total_memory(void); 16887777dab0Sopenharmony_ciUV_EXTERN uint64_t uv_get_constrained_memory(void); 16897777dab0Sopenharmony_ci 16907777dab0Sopenharmony_ciUV_EXTERN uint64_t uv_hrtime(void); 16917777dab0Sopenharmony_ciUV_EXTERN void uv_sleep(unsigned int msec); 16927777dab0Sopenharmony_ci 16937777dab0Sopenharmony_ciUV_EXTERN void uv_disable_stdio_inheritance(void); 16947777dab0Sopenharmony_ci 16957777dab0Sopenharmony_ciUV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); 16967777dab0Sopenharmony_ciUV_EXTERN void uv_dlclose(uv_lib_t* lib); 16977777dab0Sopenharmony_ciUV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); 16987777dab0Sopenharmony_ciUV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); 16997777dab0Sopenharmony_ci 17007777dab0Sopenharmony_ciUV_EXTERN int uv_mutex_init(uv_mutex_t* handle); 17017777dab0Sopenharmony_ciUV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); 17027777dab0Sopenharmony_ciUV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); 17037777dab0Sopenharmony_ciUV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); 17047777dab0Sopenharmony_ciUV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); 17057777dab0Sopenharmony_ciUV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); 17067777dab0Sopenharmony_ci 17077777dab0Sopenharmony_ciUV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); 17087777dab0Sopenharmony_ciUV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); 17097777dab0Sopenharmony_ciUV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); 17107777dab0Sopenharmony_ciUV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); 17117777dab0Sopenharmony_ciUV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); 17127777dab0Sopenharmony_ciUV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); 17137777dab0Sopenharmony_ciUV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); 17147777dab0Sopenharmony_ciUV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); 17157777dab0Sopenharmony_ci 17167777dab0Sopenharmony_ciUV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); 17177777dab0Sopenharmony_ciUV_EXTERN void uv_sem_destroy(uv_sem_t* sem); 17187777dab0Sopenharmony_ciUV_EXTERN void uv_sem_post(uv_sem_t* sem); 17197777dab0Sopenharmony_ciUV_EXTERN void uv_sem_wait(uv_sem_t* sem); 17207777dab0Sopenharmony_ciUV_EXTERN int uv_sem_trywait(uv_sem_t* sem); 17217777dab0Sopenharmony_ci 17227777dab0Sopenharmony_ciUV_EXTERN int uv_cond_init(uv_cond_t* cond); 17237777dab0Sopenharmony_ciUV_EXTERN void uv_cond_destroy(uv_cond_t* cond); 17247777dab0Sopenharmony_ciUV_EXTERN void uv_cond_signal(uv_cond_t* cond); 17257777dab0Sopenharmony_ciUV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); 17267777dab0Sopenharmony_ci 17277777dab0Sopenharmony_ciUV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); 17287777dab0Sopenharmony_ciUV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); 17297777dab0Sopenharmony_ciUV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); 17307777dab0Sopenharmony_ci 17317777dab0Sopenharmony_ciUV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); 17327777dab0Sopenharmony_ciUV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, 17337777dab0Sopenharmony_ci uv_mutex_t* mutex, 17347777dab0Sopenharmony_ci uint64_t timeout); 17357777dab0Sopenharmony_ci 17367777dab0Sopenharmony_ciUV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); 17377777dab0Sopenharmony_ci 17387777dab0Sopenharmony_ciUV_EXTERN int uv_key_create(uv_key_t* key); 17397777dab0Sopenharmony_ciUV_EXTERN void uv_key_delete(uv_key_t* key); 17407777dab0Sopenharmony_ciUV_EXTERN void* uv_key_get(uv_key_t* key); 17417777dab0Sopenharmony_ciUV_EXTERN void uv_key_set(uv_key_t* key, void* value); 17427777dab0Sopenharmony_ci 17437777dab0Sopenharmony_ciUV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv); 17447777dab0Sopenharmony_ci 17457777dab0Sopenharmony_citypedef void (*uv_thread_cb)(void* arg); 17467777dab0Sopenharmony_ci 17477777dab0Sopenharmony_ciUV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); 17487777dab0Sopenharmony_ci 17497777dab0Sopenharmony_citypedef enum { 17507777dab0Sopenharmony_ci UV_THREAD_NO_FLAGS = 0x00, 17517777dab0Sopenharmony_ci UV_THREAD_HAS_STACK_SIZE = 0x01 17527777dab0Sopenharmony_ci} uv_thread_create_flags; 17537777dab0Sopenharmony_ci 17547777dab0Sopenharmony_cistruct uv_thread_options_s { 17557777dab0Sopenharmony_ci unsigned int flags; 17567777dab0Sopenharmony_ci size_t stack_size; 17577777dab0Sopenharmony_ci /* More fields may be added at any time. */ 17587777dab0Sopenharmony_ci}; 17597777dab0Sopenharmony_ci 17607777dab0Sopenharmony_citypedef struct uv_thread_options_s uv_thread_options_t; 17617777dab0Sopenharmony_ci 17627777dab0Sopenharmony_ciUV_EXTERN int uv_thread_create_ex(uv_thread_t* tid, 17637777dab0Sopenharmony_ci const uv_thread_options_t* params, 17647777dab0Sopenharmony_ci uv_thread_cb entry, 17657777dab0Sopenharmony_ci void* arg); 17667777dab0Sopenharmony_ciUV_EXTERN uv_thread_t uv_thread_self(void); 17677777dab0Sopenharmony_ciUV_EXTERN int uv_thread_join(uv_thread_t *tid); 17687777dab0Sopenharmony_ciUV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); 17697777dab0Sopenharmony_ci 17707777dab0Sopenharmony_ci/* The presence of these unions force similar struct layout. */ 17717777dab0Sopenharmony_ci#define XX(_, name) uv_ ## name ## _t name; 17727777dab0Sopenharmony_ciunion uv_any_handle { 17737777dab0Sopenharmony_ci UV_HANDLE_TYPE_MAP(XX) 17747777dab0Sopenharmony_ci}; 17757777dab0Sopenharmony_ci 17767777dab0Sopenharmony_ciunion uv_any_req { 17777777dab0Sopenharmony_ci UV_REQ_TYPE_MAP(XX) 17787777dab0Sopenharmony_ci}; 17797777dab0Sopenharmony_ci#undef XX 17807777dab0Sopenharmony_ci 17817777dab0Sopenharmony_ci 17827777dab0Sopenharmony_cistruct uv_loop_s { 17837777dab0Sopenharmony_ci /* User data - use this for whatever. */ 17847777dab0Sopenharmony_ci void* data; 17857777dab0Sopenharmony_ci /* Loop reference counting. */ 17867777dab0Sopenharmony_ci unsigned int active_handles; 17877777dab0Sopenharmony_ci void* handle_queue[2]; 17887777dab0Sopenharmony_ci union { 17897777dab0Sopenharmony_ci void* unused; 17907777dab0Sopenharmony_ci unsigned int count; 17917777dab0Sopenharmony_ci } active_reqs; 17927777dab0Sopenharmony_ci /* Internal storage for future extensions. */ 17937777dab0Sopenharmony_ci void* internal_fields; 17947777dab0Sopenharmony_ci /* Internal flag to signal loop stop. */ 17957777dab0Sopenharmony_ci unsigned int stop_flag; 17967777dab0Sopenharmony_ci UV_LOOP_PRIVATE_FIELDS 17977777dab0Sopenharmony_ci}; 17987777dab0Sopenharmony_ci 17997777dab0Sopenharmony_ciUV_EXTERN void* uv_loop_get_data(const uv_loop_t*); 18007777dab0Sopenharmony_ciUV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); 18017777dab0Sopenharmony_ci 18027777dab0Sopenharmony_ci/* Don't export the private CPP symbols. */ 18037777dab0Sopenharmony_ci#undef UV_HANDLE_TYPE_PRIVATE 18047777dab0Sopenharmony_ci#undef UV_REQ_TYPE_PRIVATE 18057777dab0Sopenharmony_ci#undef UV_REQ_PRIVATE_FIELDS 18067777dab0Sopenharmony_ci#undef UV_STREAM_PRIVATE_FIELDS 18077777dab0Sopenharmony_ci#undef UV_TCP_PRIVATE_FIELDS 18087777dab0Sopenharmony_ci#undef UV_PREPARE_PRIVATE_FIELDS 18097777dab0Sopenharmony_ci#undef UV_CHECK_PRIVATE_FIELDS 18107777dab0Sopenharmony_ci#undef UV_IDLE_PRIVATE_FIELDS 18117777dab0Sopenharmony_ci#undef UV_ASYNC_PRIVATE_FIELDS 18127777dab0Sopenharmony_ci#undef UV_TIMER_PRIVATE_FIELDS 18137777dab0Sopenharmony_ci#undef UV_GETADDRINFO_PRIVATE_FIELDS 18147777dab0Sopenharmony_ci#undef UV_GETNAMEINFO_PRIVATE_FIELDS 18157777dab0Sopenharmony_ci#undef UV_FS_REQ_PRIVATE_FIELDS 18167777dab0Sopenharmony_ci#undef UV_WORK_PRIVATE_FIELDS 18177777dab0Sopenharmony_ci#undef UV_FS_EVENT_PRIVATE_FIELDS 18187777dab0Sopenharmony_ci#undef UV_SIGNAL_PRIVATE_FIELDS 18197777dab0Sopenharmony_ci#undef UV_LOOP_PRIVATE_FIELDS 18207777dab0Sopenharmony_ci#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS 18217777dab0Sopenharmony_ci#undef UV__ERR 18227777dab0Sopenharmony_ci 18237777dab0Sopenharmony_ci#ifdef __cplusplus 18247777dab0Sopenharmony_ci} 18257777dab0Sopenharmony_ci#endif 18267777dab0Sopenharmony_ci#endif /* UV_H */ 1827