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