• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright libuv project contributors. All rights reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19  * IN THE SOFTWARE.
20  */
21 
22 #include "uv.h"
23 
uv_handle_type_name(uv_handle_type type)24 const char* uv_handle_type_name(uv_handle_type type) {
25   switch (type) {
26 #define XX(uc,lc) case UV_##uc: return #lc;
27   UV_HANDLE_TYPE_MAP(XX)
28 #undef XX
29   case UV_FILE: return "file";
30   case UV_HANDLE_TYPE_MAX:
31   case UV_UNKNOWN_HANDLE: return NULL;
32   }
33   return NULL;
34 }
35 
uv_handle_get_type(const uv_handle_t * handle)36 uv_handle_type uv_handle_get_type(const uv_handle_t* handle) {
37   return handle->type;
38 }
39 
uv_handle_get_data(const uv_handle_t * handle)40 void* uv_handle_get_data(const uv_handle_t* handle) {
41   return handle->data;
42 }
43 
uv_handle_get_loop(const uv_handle_t * handle)44 uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle) {
45   return handle->loop;
46 }
47 
uv_handle_set_data(uv_handle_t * handle,void * data)48 void uv_handle_set_data(uv_handle_t* handle, void* data) {
49   handle->data = data;
50 }
51 
uv_req_type_name(uv_req_type type)52 const char* uv_req_type_name(uv_req_type type) {
53   switch (type) {
54 #define XX(uc,lc) case UV_##uc: return #lc;
55   UV_REQ_TYPE_MAP(XX)
56 #undef XX
57   case UV_REQ_TYPE_MAX:
58   case UV_UNKNOWN_REQ:
59   default: /* UV_REQ_TYPE_PRIVATE */
60     break;
61   }
62   return NULL;
63 }
64 
uv_req_get_type(const uv_req_t * req)65 uv_req_type uv_req_get_type(const uv_req_t* req) {
66   return req->type;
67 }
68 
uv_req_get_data(const uv_req_t * req)69 void* uv_req_get_data(const uv_req_t* req) {
70   return req->data;
71 }
72 
uv_req_set_data(uv_req_t * req,void * data)73 void uv_req_set_data(uv_req_t* req, void* data) {
74   req->data = data;
75 }
76 
uv_stream_get_write_queue_size(const uv_stream_t * stream)77 size_t uv_stream_get_write_queue_size(const uv_stream_t* stream) {
78   return stream->write_queue_size;
79 }
80 
uv_udp_get_send_queue_size(const uv_udp_t * handle)81 size_t uv_udp_get_send_queue_size(const uv_udp_t* handle) {
82   return handle->send_queue_size;
83 }
84 
uv_udp_get_send_queue_count(const uv_udp_t * handle)85 size_t uv_udp_get_send_queue_count(const uv_udp_t* handle) {
86   return handle->send_queue_count;
87 }
88 
uv_process_get_pid(const uv_process_t * proc)89 uv_pid_t uv_process_get_pid(const uv_process_t* proc) {
90   return proc->pid;
91 }
92 
uv_fs_get_type(const uv_fs_t * req)93 uv_fs_type uv_fs_get_type(const uv_fs_t* req) {
94   return req->fs_type;
95 }
96 
uv_fs_get_result(const uv_fs_t * req)97 ssize_t uv_fs_get_result(const uv_fs_t* req) {
98   return req->result;
99 }
100 
uv_fs_get_ptr(const uv_fs_t * req)101 void* uv_fs_get_ptr(const uv_fs_t* req) {
102   return req->ptr;
103 }
104 
uv_fs_get_path(const uv_fs_t * req)105 const char* uv_fs_get_path(const uv_fs_t* req) {
106   return req->path;
107 }
108 
uv_fs_get_statbuf(uv_fs_t * req)109 uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req) {
110   return &req->statbuf;
111 }
112 
uv_loop_get_data(const uv_loop_t * loop)113 void* uv_loop_get_data(const uv_loop_t* loop) {
114   return loop->data;
115 }
116 
uv_loop_set_data(uv_loop_t * loop,void * data)117 void uv_loop_set_data(uv_loop_t* loop, void* data) {
118   loop->data = data;
119 }
120