uv-data-getter-setters.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include "uv.h"
  2. const char* uv_handle_type_name(uv_handle_type type) {
  3. switch (type) {
  4. #define XX(uc,lc) case UV_##uc: return #lc;
  5. UV_HANDLE_TYPE_MAP(XX)
  6. #undef XX
  7. case UV_FILE: return "file";
  8. case UV_HANDLE_TYPE_MAX:
  9. case UV_UNKNOWN_HANDLE: return NULL;
  10. }
  11. return NULL;
  12. }
  13. uv_handle_type uv_handle_get_type(const uv_handle_t* handle) {
  14. return handle->type;
  15. }
  16. void* uv_handle_get_data(const uv_handle_t* handle) {
  17. return handle->data;
  18. }
  19. uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle) {
  20. return handle->loop;
  21. }
  22. void uv_handle_set_data(uv_handle_t* handle, void* data) {
  23. handle->data = data;
  24. }
  25. const char* uv_req_type_name(uv_req_type type) {
  26. switch (type) {
  27. #define XX(uc,lc) case UV_##uc: return #lc;
  28. UV_REQ_TYPE_MAP(XX)
  29. #undef XX
  30. case UV_REQ_TYPE_MAX:
  31. case UV_UNKNOWN_REQ:
  32. default: /* UV_REQ_TYPE_PRIVATE */
  33. break;
  34. }
  35. return NULL;
  36. }
  37. uv_req_type uv_req_get_type(const uv_req_t* req) {
  38. return req->type;
  39. }
  40. void* uv_req_get_data(const uv_req_t* req) {
  41. return req->data;
  42. }
  43. void uv_req_set_data(uv_req_t* req, void* data) {
  44. req->data = data;
  45. }
  46. size_t uv_stream_get_write_queue_size(const uv_stream_t* stream) {
  47. return stream->write_queue_size;
  48. }
  49. size_t uv_udp_get_send_queue_size(const uv_udp_t* handle) {
  50. return handle->send_queue_size;
  51. }
  52. size_t uv_udp_get_send_queue_count(const uv_udp_t* handle) {
  53. return handle->send_queue_count;
  54. }
  55. uv_pid_t uv_process_get_pid(const uv_process_t* proc) {
  56. return proc->pid;
  57. }
  58. uv_fs_type uv_fs_get_type(const uv_fs_t* req) {
  59. return req->fs_type;
  60. }
  61. ssize_t uv_fs_get_result(const uv_fs_t* req) {
  62. return req->result;
  63. }
  64. void* uv_fs_get_ptr(const uv_fs_t* req) {
  65. return req->ptr;
  66. }
  67. const char* uv_fs_get_path(const uv_fs_t* req) {
  68. return req->path;
  69. }
  70. uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req) {
  71. return &req->statbuf;
  72. }
  73. void* uv_loop_get_data(const uv_loop_t* loop) {
  74. return loop->data;
  75. }
  76. void uv_loop_set_data(uv_loop_t* loop, void* data) {
  77. loop->data = data;
  78. }