Path: blob/master/Utilities/cmlibuv/src/uv-data-getter-setters.c
3153 views
/* Copyright libuv project contributors. All rights reserved.1*2* Permission is hereby granted, free of charge, to any person obtaining a copy3* of this software and associated documentation files (the "Software"), to4* deal in the Software without restriction, including without limitation the5* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or6* sell copies of the Software, and to permit persons to whom the Software is7* furnished to do so, subject to the following conditions:8*9* The above copyright notice and this permission notice shall be included in10* all copies or substantial portions of the Software.11*12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE15* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER16* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING17* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS18* IN THE SOFTWARE.19*/2021#include "uv.h"2223const char* uv_handle_type_name(uv_handle_type type) {24switch (type) {25#define XX(uc,lc) case UV_##uc: return #lc;26UV_HANDLE_TYPE_MAP(XX)27#undef XX28case UV_FILE: return "file";29case UV_HANDLE_TYPE_MAX:30case UV_UNKNOWN_HANDLE: return NULL;31}32return NULL;33}3435uv_handle_type uv_handle_get_type(const uv_handle_t* handle) {36return handle->type;37}3839void* uv_handle_get_data(const uv_handle_t* handle) {40return handle->data;41}4243uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle) {44return handle->loop;45}4647void uv_handle_set_data(uv_handle_t* handle, void* data) {48handle->data = data;49}5051const char* uv_req_type_name(uv_req_type type) {52switch (type) {53#define XX(uc,lc) case UV_##uc: return #lc;54UV_REQ_TYPE_MAP(XX)55#undef XX56case UV_REQ_TYPE_MAX:57case UV_UNKNOWN_REQ:58default: /* UV_REQ_TYPE_PRIVATE */59break;60}61return NULL;62}6364uv_req_type uv_req_get_type(const uv_req_t* req) {65return req->type;66}6768void* uv_req_get_data(const uv_req_t* req) {69return req->data;70}7172void uv_req_set_data(uv_req_t* req, void* data) {73req->data = data;74}7576size_t uv_stream_get_write_queue_size(const uv_stream_t* stream) {77return stream->write_queue_size;78}7980size_t uv_udp_get_send_queue_size(const uv_udp_t* handle) {81return handle->send_queue_size;82}8384size_t uv_udp_get_send_queue_count(const uv_udp_t* handle) {85return handle->send_queue_count;86}8788uv_pid_t uv_process_get_pid(const uv_process_t* proc) {89return proc->pid;90}9192uv_fs_type uv_fs_get_type(const uv_fs_t* req) {93return req->fs_type;94}9596ssize_t uv_fs_get_result(const uv_fs_t* req) {97return req->result;98}99100void* uv_fs_get_ptr(const uv_fs_t* req) {101return req->ptr;102}103104const char* uv_fs_get_path(const uv_fs_t* req) {105return req->path;106}107108uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req) {109return &req->statbuf;110}111112void* uv_loop_get_data(const uv_loop_t* loop) {113return loop->data;114}115116void uv_loop_set_data(uv_loop_t* loop, void* data) {117loop->data = data;118}119120121