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