foolio 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/.gitignore +22 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +21 -0
  6. data/examples/timer.rb +20 -0
  7. data/ext/foolio/extconf.rb +34 -0
  8. data/ext/foolio/foolio_ext.c +921 -0
  9. data/ext/foolio/gen.rb +50 -0
  10. data/ext/foolio/make_table.rb +12 -0
  11. data/ext/foolio/templ +243 -0
  12. data/ext/libuv/.gitignore +33 -0
  13. data/ext/libuv/.mailmap +13 -0
  14. data/ext/libuv/.travis.yml +9 -0
  15. data/ext/libuv/AUTHORS +61 -0
  16. data/ext/libuv/LICENSE +44 -0
  17. data/ext/libuv/Makefile +71 -0
  18. data/ext/libuv/README.md +90 -0
  19. data/ext/libuv/common.gypi +178 -0
  20. data/ext/libuv/gyp_uv +73 -0
  21. data/ext/libuv/include/uv-private/eio.h +403 -0
  22. data/ext/libuv/include/uv-private/ev.h +838 -0
  23. data/ext/libuv/include/uv-private/ngx-queue.h +108 -0
  24. data/ext/libuv/include/uv-private/tree.h +768 -0
  25. data/ext/libuv/include/uv-private/uv-unix.h +324 -0
  26. data/ext/libuv/include/uv-private/uv-win.h +517 -0
  27. data/ext/libuv/include/uv.h +1838 -0
  28. data/ext/libuv/src/fs-poll.c +235 -0
  29. data/ext/libuv/src/inet.c +293 -0
  30. data/ext/libuv/src/unix/async.c +148 -0
  31. data/ext/libuv/src/unix/core.c +696 -0
  32. data/ext/libuv/src/unix/cygwin.c +83 -0
  33. data/ext/libuv/src/unix/darwin.c +342 -0
  34. data/ext/libuv/src/unix/dl.c +83 -0
  35. data/ext/libuv/src/unix/eio/Changes +63 -0
  36. data/ext/libuv/src/unix/eio/LICENSE +36 -0
  37. data/ext/libuv/src/unix/eio/Makefile.am +15 -0
  38. data/ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
  39. data/ext/libuv/src/unix/eio/autogen.sh +3 -0
  40. data/ext/libuv/src/unix/eio/config.h.in +86 -0
  41. data/ext/libuv/src/unix/eio/config_cygwin.h +80 -0
  42. data/ext/libuv/src/unix/eio/config_darwin.h +141 -0
  43. data/ext/libuv/src/unix/eio/config_freebsd.h +81 -0
  44. data/ext/libuv/src/unix/eio/config_linux.h +94 -0
  45. data/ext/libuv/src/unix/eio/config_netbsd.h +81 -0
  46. data/ext/libuv/src/unix/eio/config_openbsd.h +137 -0
  47. data/ext/libuv/src/unix/eio/config_sunos.h +84 -0
  48. data/ext/libuv/src/unix/eio/configure.ac +22 -0
  49. data/ext/libuv/src/unix/eio/demo.c +194 -0
  50. data/ext/libuv/src/unix/eio/ecb.h +370 -0
  51. data/ext/libuv/src/unix/eio/eio.3 +3428 -0
  52. data/ext/libuv/src/unix/eio/eio.c +2593 -0
  53. data/ext/libuv/src/unix/eio/eio.pod +969 -0
  54. data/ext/libuv/src/unix/eio/libeio.m4 +195 -0
  55. data/ext/libuv/src/unix/eio/xthread.h +164 -0
  56. data/ext/libuv/src/unix/error.c +105 -0
  57. data/ext/libuv/src/unix/ev/Changes +388 -0
  58. data/ext/libuv/src/unix/ev/LICENSE +36 -0
  59. data/ext/libuv/src/unix/ev/Makefile.am +18 -0
  60. data/ext/libuv/src/unix/ev/Makefile.in +771 -0
  61. data/ext/libuv/src/unix/ev/README +58 -0
  62. data/ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
  63. data/ext/libuv/src/unix/ev/autogen.sh +6 -0
  64. data/ext/libuv/src/unix/ev/config.guess +1526 -0
  65. data/ext/libuv/src/unix/ev/config.h.in +125 -0
  66. data/ext/libuv/src/unix/ev/config.sub +1658 -0
  67. data/ext/libuv/src/unix/ev/config_cygwin.h +123 -0
  68. data/ext/libuv/src/unix/ev/config_darwin.h +122 -0
  69. data/ext/libuv/src/unix/ev/config_freebsd.h +120 -0
  70. data/ext/libuv/src/unix/ev/config_linux.h +141 -0
  71. data/ext/libuv/src/unix/ev/config_netbsd.h +120 -0
  72. data/ext/libuv/src/unix/ev/config_openbsd.h +126 -0
  73. data/ext/libuv/src/unix/ev/config_sunos.h +122 -0
  74. data/ext/libuv/src/unix/ev/configure +13037 -0
  75. data/ext/libuv/src/unix/ev/configure.ac +18 -0
  76. data/ext/libuv/src/unix/ev/depcomp +630 -0
  77. data/ext/libuv/src/unix/ev/ev++.h +816 -0
  78. data/ext/libuv/src/unix/ev/ev.3 +5311 -0
  79. data/ext/libuv/src/unix/ev/ev.c +3925 -0
  80. data/ext/libuv/src/unix/ev/ev.pod +5243 -0
  81. data/ext/libuv/src/unix/ev/ev_epoll.c +266 -0
  82. data/ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
  83. data/ext/libuv/src/unix/ev/ev_poll.c +148 -0
  84. data/ext/libuv/src/unix/ev/ev_port.c +179 -0
  85. data/ext/libuv/src/unix/ev/ev_select.c +310 -0
  86. data/ext/libuv/src/unix/ev/ev_vars.h +203 -0
  87. data/ext/libuv/src/unix/ev/ev_win32.c +153 -0
  88. data/ext/libuv/src/unix/ev/ev_wrap.h +196 -0
  89. data/ext/libuv/src/unix/ev/event.c +402 -0
  90. data/ext/libuv/src/unix/ev/event.h +170 -0
  91. data/ext/libuv/src/unix/ev/install-sh +294 -0
  92. data/ext/libuv/src/unix/ev/libev.m4 +39 -0
  93. data/ext/libuv/src/unix/ev/ltmain.sh +8413 -0
  94. data/ext/libuv/src/unix/ev/missing +336 -0
  95. data/ext/libuv/src/unix/ev/mkinstalldirs +111 -0
  96. data/ext/libuv/src/unix/freebsd.c +326 -0
  97. data/ext/libuv/src/unix/fs.c +739 -0
  98. data/ext/libuv/src/unix/internal.h +188 -0
  99. data/ext/libuv/src/unix/kqueue.c +120 -0
  100. data/ext/libuv/src/unix/linux/inotify.c +239 -0
  101. data/ext/libuv/src/unix/linux/linux-core.c +557 -0
  102. data/ext/libuv/src/unix/linux/syscalls.c +388 -0
  103. data/ext/libuv/src/unix/linux/syscalls.h +124 -0
  104. data/ext/libuv/src/unix/loop-watcher.c +62 -0
  105. data/ext/libuv/src/unix/loop.c +94 -0
  106. data/ext/libuv/src/unix/netbsd.c +108 -0
  107. data/ext/libuv/src/unix/openbsd.c +295 -0
  108. data/ext/libuv/src/unix/pipe.c +259 -0
  109. data/ext/libuv/src/unix/poll.c +114 -0
  110. data/ext/libuv/src/unix/process.c +495 -0
  111. data/ext/libuv/src/unix/signal.c +269 -0
  112. data/ext/libuv/src/unix/stream.c +990 -0
  113. data/ext/libuv/src/unix/sunos.c +481 -0
  114. data/ext/libuv/src/unix/tcp.c +393 -0
  115. data/ext/libuv/src/unix/thread.c +251 -0
  116. data/ext/libuv/src/unix/timer.c +136 -0
  117. data/ext/libuv/src/unix/tty.c +145 -0
  118. data/ext/libuv/src/unix/udp.c +659 -0
  119. data/ext/libuv/src/unix/uv-eio.c +107 -0
  120. data/ext/libuv/src/unix/uv-eio.h +13 -0
  121. data/ext/libuv/src/uv-common.c +380 -0
  122. data/ext/libuv/src/uv-common.h +170 -0
  123. data/ext/libuv/src/win/async.c +100 -0
  124. data/ext/libuv/src/win/atomicops-inl.h +56 -0
  125. data/ext/libuv/src/win/core.c +278 -0
  126. data/ext/libuv/src/win/dl.c +86 -0
  127. data/ext/libuv/src/win/error.c +155 -0
  128. data/ext/libuv/src/win/fs-event.c +510 -0
  129. data/ext/libuv/src/win/fs.c +1948 -0
  130. data/ext/libuv/src/win/getaddrinfo.c +365 -0
  131. data/ext/libuv/src/win/handle-inl.h +149 -0
  132. data/ext/libuv/src/win/handle.c +154 -0
  133. data/ext/libuv/src/win/internal.h +343 -0
  134. data/ext/libuv/src/win/loop-watcher.c +122 -0
  135. data/ext/libuv/src/win/pipe.c +1672 -0
  136. data/ext/libuv/src/win/poll.c +616 -0
  137. data/ext/libuv/src/win/process-stdio.c +500 -0
  138. data/ext/libuv/src/win/process.c +1013 -0
  139. data/ext/libuv/src/win/req-inl.h +220 -0
  140. data/ext/libuv/src/win/req.c +25 -0
  141. data/ext/libuv/src/win/signal.c +57 -0
  142. data/ext/libuv/src/win/stream-inl.h +67 -0
  143. data/ext/libuv/src/win/stream.c +167 -0
  144. data/ext/libuv/src/win/tcp.c +1394 -0
  145. data/ext/libuv/src/win/thread.c +372 -0
  146. data/ext/libuv/src/win/threadpool.c +74 -0
  147. data/ext/libuv/src/win/timer.c +224 -0
  148. data/ext/libuv/src/win/tty.c +1799 -0
  149. data/ext/libuv/src/win/udp.c +716 -0
  150. data/ext/libuv/src/win/util.c +864 -0
  151. data/ext/libuv/src/win/winapi.c +132 -0
  152. data/ext/libuv/src/win/winapi.h +4452 -0
  153. data/ext/libuv/src/win/winsock.c +557 -0
  154. data/ext/libuv/src/win/winsock.h +171 -0
  155. data/ext/libuv/test/benchmark-async-pummel.c +97 -0
  156. data/ext/libuv/test/benchmark-async.c +137 -0
  157. data/ext/libuv/test/benchmark-fs-stat.c +135 -0
  158. data/ext/libuv/test/benchmark-getaddrinfo.c +94 -0
  159. data/ext/libuv/test/benchmark-list.h +127 -0
  160. data/ext/libuv/test/benchmark-loop-count.c +88 -0
  161. data/ext/libuv/test/benchmark-million-timers.c +65 -0
  162. data/ext/libuv/test/benchmark-ping-pongs.c +213 -0
  163. data/ext/libuv/test/benchmark-pound.c +324 -0
  164. data/ext/libuv/test/benchmark-pump.c +462 -0
  165. data/ext/libuv/test/benchmark-sizes.c +44 -0
  166. data/ext/libuv/test/benchmark-spawn.c +162 -0
  167. data/ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
  168. data/ext/libuv/test/benchmark-thread.c +64 -0
  169. data/ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
  170. data/ext/libuv/test/blackhole-server.c +118 -0
  171. data/ext/libuv/test/dns-server.c +321 -0
  172. data/ext/libuv/test/echo-server.c +378 -0
  173. data/ext/libuv/test/fixtures/empty_file +0 -0
  174. data/ext/libuv/test/fixtures/load_error.node +1 -0
  175. data/ext/libuv/test/run-benchmarks.c +64 -0
  176. data/ext/libuv/test/run-tests.c +138 -0
  177. data/ext/libuv/test/runner-unix.c +295 -0
  178. data/ext/libuv/test/runner-unix.h +36 -0
  179. data/ext/libuv/test/runner-win.c +285 -0
  180. data/ext/libuv/test/runner-win.h +42 -0
  181. data/ext/libuv/test/runner.c +355 -0
  182. data/ext/libuv/test/runner.h +159 -0
  183. data/ext/libuv/test/task.h +112 -0
  184. data/ext/libuv/test/test-async.c +118 -0
  185. data/ext/libuv/test/test-callback-order.c +76 -0
  186. data/ext/libuv/test/test-callback-stack.c +203 -0
  187. data/ext/libuv/test/test-connection-fail.c +148 -0
  188. data/ext/libuv/test/test-cwd-and-chdir.c +64 -0
  189. data/ext/libuv/test/test-delayed-accept.c +188 -0
  190. data/ext/libuv/test/test-dlerror.c +58 -0
  191. data/ext/libuv/test/test-error.c +59 -0
  192. data/ext/libuv/test/test-fail-always.c +29 -0
  193. data/ext/libuv/test/test-fs-event.c +474 -0
  194. data/ext/libuv/test/test-fs-poll.c +146 -0
  195. data/ext/libuv/test/test-fs.c +1843 -0
  196. data/ext/libuv/test/test-get-currentexe.c +63 -0
  197. data/ext/libuv/test/test-get-loadavg.c +36 -0
  198. data/ext/libuv/test/test-get-memory.c +38 -0
  199. data/ext/libuv/test/test-getaddrinfo.c +122 -0
  200. data/ext/libuv/test/test-getsockname.c +342 -0
  201. data/ext/libuv/test/test-hrtime.c +54 -0
  202. data/ext/libuv/test/test-idle.c +81 -0
  203. data/ext/libuv/test/test-ipc-send-recv.c +209 -0
  204. data/ext/libuv/test/test-ipc.c +620 -0
  205. data/ext/libuv/test/test-list.h +427 -0
  206. data/ext/libuv/test/test-loop-handles.c +336 -0
  207. data/ext/libuv/test/test-multiple-listen.c +102 -0
  208. data/ext/libuv/test/test-mutexes.c +63 -0
  209. data/ext/libuv/test/test-pass-always.c +28 -0
  210. data/ext/libuv/test/test-ping-pong.c +253 -0
  211. data/ext/libuv/test/test-pipe-bind-error.c +140 -0
  212. data/ext/libuv/test/test-pipe-connect-error.c +96 -0
  213. data/ext/libuv/test/test-platform-output.c +87 -0
  214. data/ext/libuv/test/test-poll-close.c +72 -0
  215. data/ext/libuv/test/test-poll.c +573 -0
  216. data/ext/libuv/test/test-process-title.c +49 -0
  217. data/ext/libuv/test/test-ref.c +338 -0
  218. data/ext/libuv/test/test-run-once.c +48 -0
  219. data/ext/libuv/test/test-semaphore.c +111 -0
  220. data/ext/libuv/test/test-shutdown-close.c +103 -0
  221. data/ext/libuv/test/test-shutdown-eof.c +183 -0
  222. data/ext/libuv/test/test-signal.c +162 -0
  223. data/ext/libuv/test/test-spawn.c +863 -0
  224. data/ext/libuv/test/test-stdio-over-pipes.c +246 -0
  225. data/ext/libuv/test/test-tcp-bind-error.c +191 -0
  226. data/ext/libuv/test/test-tcp-bind6-error.c +154 -0
  227. data/ext/libuv/test/test-tcp-close-while-connecting.c +80 -0
  228. data/ext/libuv/test/test-tcp-close.c +129 -0
  229. data/ext/libuv/test/test-tcp-connect-error-after-write.c +95 -0
  230. data/ext/libuv/test/test-tcp-connect-error.c +70 -0
  231. data/ext/libuv/test/test-tcp-connect-timeout.c +85 -0
  232. data/ext/libuv/test/test-tcp-connect6-error.c +68 -0
  233. data/ext/libuv/test/test-tcp-flags.c +51 -0
  234. data/ext/libuv/test/test-tcp-shutdown-after-write.c +131 -0
  235. data/ext/libuv/test/test-tcp-unexpected-read.c +113 -0
  236. data/ext/libuv/test/test-tcp-write-error.c +168 -0
  237. data/ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
  238. data/ext/libuv/test/test-tcp-writealot.c +170 -0
  239. data/ext/libuv/test/test-thread.c +183 -0
  240. data/ext/libuv/test/test-threadpool.c +57 -0
  241. data/ext/libuv/test/test-timer-again.c +141 -0
  242. data/ext/libuv/test/test-timer.c +152 -0
  243. data/ext/libuv/test/test-tty.c +110 -0
  244. data/ext/libuv/test/test-udp-dgram-too-big.c +86 -0
  245. data/ext/libuv/test/test-udp-ipv6.c +156 -0
  246. data/ext/libuv/test/test-udp-multicast-join.c +139 -0
  247. data/ext/libuv/test/test-udp-multicast-ttl.c +86 -0
  248. data/ext/libuv/test/test-udp-options.c +86 -0
  249. data/ext/libuv/test/test-udp-send-and-recv.c +208 -0
  250. data/ext/libuv/test/test-util.c +97 -0
  251. data/ext/libuv/test/test-walk-handles.c +77 -0
  252. data/ext/libuv/uv.gyp +375 -0
  253. data/ext/libuv/vcbuild.bat +105 -0
  254. data/foolio.gemspec +18 -0
  255. data/lib/foolio.rb +9 -0
  256. data/lib/foolio/handle.rb +27 -0
  257. data/lib/foolio/listener.rb +26 -0
  258. data/lib/foolio/loop.rb +79 -0
  259. data/lib/foolio/stream.rb +109 -0
  260. data/lib/foolio/version.rb +3 -0
  261. metadata +309 -0
@@ -0,0 +1,1838 @@
1
+ /* Copyright Joyent, Inc. and other Node 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
+ /* See http://nikhilm.github.com/uvbook/ for an introduction. */
23
+
24
+ #ifndef UV_H
25
+ #define UV_H
26
+ #ifdef __cplusplus
27
+ extern "C" {
28
+ #endif
29
+
30
+ #ifdef _WIN32
31
+ /* Windows - set up dll import/export decorators. */
32
+ # if defined(BUILDING_UV_SHARED)
33
+ /* Building shared library. */
34
+ # define UV_EXTERN __declspec(dllexport)
35
+ # elif defined(USING_UV_SHARED)
36
+ /* Using shared library. */
37
+ # define UV_EXTERN __declspec(dllimport)
38
+ # else
39
+ /* Building static library. */
40
+ # define UV_EXTERN /* nothing */
41
+ # endif
42
+ #elif __GNUC__ >= 4
43
+ # define UV_EXTERN __attribute__((visibility("default")))
44
+ #else
45
+ # define UV_EXTERN /* nothing */
46
+ #endif
47
+
48
+
49
+ #define UV_VERSION_MAJOR 0
50
+ #define UV_VERSION_MINOR 9
51
+
52
+
53
+ #include <stdint.h> /* int64_t */
54
+ #include <sys/types.h> /* size_t */
55
+
56
+ #if defined(__SVR4) && !defined(__unix__)
57
+ # define __unix__
58
+ #endif
59
+
60
+ #if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
61
+ # include "uv-private/uv-unix.h"
62
+ #else
63
+ # include "uv-private/uv-win.h"
64
+ #endif
65
+
66
+ /* Expand this list if necessary. */
67
+ #define UV_ERRNO_MAP(XX) \
68
+ XX( -1, UNKNOWN, "unknown error") \
69
+ XX( 0, OK, "success") \
70
+ XX( 1, EOF, "end of file") \
71
+ XX( 2, EADDRINFO, "getaddrinfo error") \
72
+ XX( 3, EACCES, "permission denied") \
73
+ XX( 4, EAGAIN, "no more processes") \
74
+ XX( 5, EADDRINUSE, "address already in use") \
75
+ XX( 6, EADDRNOTAVAIL, "") \
76
+ XX( 7, EAFNOSUPPORT, "") \
77
+ XX( 8, EALREADY, "") \
78
+ XX( 9, EBADF, "bad file descriptor") \
79
+ XX( 10, EBUSY, "resource busy or locked") \
80
+ XX( 11, ECONNABORTED, "software caused connection abort") \
81
+ XX( 12, ECONNREFUSED, "connection refused") \
82
+ XX( 13, ECONNRESET, "connection reset by peer") \
83
+ XX( 14, EDESTADDRREQ, "destination address required") \
84
+ XX( 15, EFAULT, "bad address in system call argument") \
85
+ XX( 16, EHOSTUNREACH, "host is unreachable") \
86
+ XX( 17, EINTR, "interrupted system call") \
87
+ XX( 18, EINVAL, "invalid argument") \
88
+ XX( 19, EISCONN, "socket is already connected") \
89
+ XX( 20, EMFILE, "too many open files") \
90
+ XX( 21, EMSGSIZE, "message too long") \
91
+ XX( 22, ENETDOWN, "network is down") \
92
+ XX( 23, ENETUNREACH, "network is unreachable") \
93
+ XX( 24, ENFILE, "file table overflow") \
94
+ XX( 25, ENOBUFS, "no buffer space available") \
95
+ XX( 26, ENOMEM, "not enough memory") \
96
+ XX( 27, ENOTDIR, "not a directory") \
97
+ XX( 28, EISDIR, "illegal operation on a directory") \
98
+ XX( 29, ENONET, "machine is not on the network") \
99
+ XX( 31, ENOTCONN, "socket is not connected") \
100
+ XX( 32, ENOTSOCK, "socket operation on non-socket") \
101
+ XX( 33, ENOTSUP, "operation not supported on socket") \
102
+ XX( 34, ENOENT, "no such file or directory") \
103
+ XX( 35, ENOSYS, "function not implemented") \
104
+ XX( 36, EPIPE, "broken pipe") \
105
+ XX( 37, EPROTO, "protocol error") \
106
+ XX( 38, EPROTONOSUPPORT, "protocol not supported") \
107
+ XX( 39, EPROTOTYPE, "protocol wrong type for socket") \
108
+ XX( 40, ETIMEDOUT, "connection timed out") \
109
+ XX( 41, ECHARSET, "") \
110
+ XX( 42, EAIFAMNOSUPPORT, "") \
111
+ XX( 44, EAISERVICE, "") \
112
+ XX( 45, EAISOCKTYPE, "") \
113
+ XX( 46, ESHUTDOWN, "") \
114
+ XX( 47, EEXIST, "file already exists") \
115
+ XX( 48, ESRCH, "no such process") \
116
+ XX( 49, ENAMETOOLONG, "name too long") \
117
+ XX( 50, EPERM, "operation not permitted") \
118
+ XX( 51, ELOOP, "too many symbolic links encountered") \
119
+ XX( 52, EXDEV, "cross-device link not permitted") \
120
+ XX( 53, ENOTEMPTY, "directory not empty") \
121
+ XX( 54, ENOSPC, "no space left on device") \
122
+ XX( 55, EIO, "i/o error") \
123
+ XX( 56, EROFS, "read-only file system" ) \
124
+ XX( 57, ENODEV, "no such device" ) \
125
+ XX( 58, ECANCELED, "operation canceled" )
126
+
127
+
128
+ #define UV_ERRNO_GEN(val, name, s) UV_##name = val,
129
+ typedef enum {
130
+ UV_ERRNO_MAP(UV_ERRNO_GEN)
131
+ UV_MAX_ERRORS
132
+ } uv_err_code;
133
+ #undef UV_ERRNO_GEN
134
+
135
+ #define UV_HANDLE_TYPE_MAP(XX) \
136
+ XX(ASYNC, async) \
137
+ XX(CHECK, check) \
138
+ XX(FS_EVENT, fs_event) \
139
+ XX(FS_POLL, fs_poll) \
140
+ XX(IDLE, idle) \
141
+ XX(NAMED_PIPE, pipe) \
142
+ XX(POLL, poll) \
143
+ XX(PREPARE, prepare) \
144
+ XX(PROCESS, process) \
145
+ XX(TCP, tcp) \
146
+ XX(TIMER, timer) \
147
+ XX(TTY, tty) \
148
+ XX(UDP, udp) \
149
+ XX(SIGNAL, signal) \
150
+
151
+ #define UV_REQ_TYPE_MAP(XX) \
152
+ XX(CONNECT, connect) \
153
+ XX(WRITE, write) \
154
+ XX(SHUTDOWN, shutdown) \
155
+ XX(UDP_SEND, udp_send) \
156
+ XX(FS, fs) \
157
+ XX(WORK, work) \
158
+ XX(GETADDRINFO, getaddrinfo) \
159
+
160
+ typedef enum {
161
+ UV_UNKNOWN_HANDLE = 0,
162
+ #define XX(uc, lc) UV_##uc,
163
+ UV_HANDLE_TYPE_MAP(XX)
164
+ #undef XX
165
+ UV_FILE,
166
+ UV_HANDLE_TYPE_MAX
167
+ } uv_handle_type;
168
+
169
+ typedef enum {
170
+ UV_UNKNOWN_REQ = 0,
171
+ #define XX(uc, lc) UV_##uc,
172
+ UV_REQ_TYPE_MAP(XX)
173
+ #undef XX
174
+ UV_REQ_TYPE_PRIVATE
175
+ UV_REQ_TYPE_MAX
176
+ } uv_req_type;
177
+
178
+
179
+ /* Handle types. */
180
+ typedef struct uv_loop_s uv_loop_t;
181
+ typedef struct uv_err_s uv_err_t;
182
+ typedef struct uv_handle_s uv_handle_t;
183
+ typedef struct uv_stream_s uv_stream_t;
184
+ typedef struct uv_tcp_s uv_tcp_t;
185
+ typedef struct uv_udp_s uv_udp_t;
186
+ typedef struct uv_pipe_s uv_pipe_t;
187
+ typedef struct uv_tty_s uv_tty_t;
188
+ typedef struct uv_poll_s uv_poll_t;
189
+ typedef struct uv_timer_s uv_timer_t;
190
+ typedef struct uv_prepare_s uv_prepare_t;
191
+ typedef struct uv_check_s uv_check_t;
192
+ typedef struct uv_idle_s uv_idle_t;
193
+ typedef struct uv_async_s uv_async_t;
194
+ typedef struct uv_process_s uv_process_t;
195
+ typedef struct uv_fs_event_s uv_fs_event_t;
196
+ typedef struct uv_fs_poll_s uv_fs_poll_t;
197
+ typedef struct uv_signal_s uv_signal_t;
198
+
199
+ /* Request types. */
200
+ typedef struct uv_req_s uv_req_t;
201
+ typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
202
+ typedef struct uv_shutdown_s uv_shutdown_t;
203
+ typedef struct uv_write_s uv_write_t;
204
+ typedef struct uv_connect_s uv_connect_t;
205
+ typedef struct uv_udp_send_s uv_udp_send_t;
206
+ typedef struct uv_fs_s uv_fs_t;
207
+ typedef struct uv_work_s uv_work_t;
208
+
209
+ /* None of the above. */
210
+ typedef struct uv_counters_s uv_counters_t;
211
+ typedef struct uv_cpu_info_s uv_cpu_info_t;
212
+ typedef struct uv_interface_address_s uv_interface_address_t;
213
+
214
+
215
+ /*
216
+ * This function must be called before any other functions in libuv.
217
+ *
218
+ * All functions besides uv_run() are non-blocking.
219
+ *
220
+ * All callbacks in libuv are made asynchronously. That is they are never
221
+ * made by the function that takes them as a parameter.
222
+ */
223
+ UV_EXTERN uv_loop_t* uv_loop_new(void);
224
+ UV_EXTERN void uv_loop_delete(uv_loop_t*);
225
+
226
+ /*
227
+ * Returns the default loop.
228
+ */
229
+ UV_EXTERN uv_loop_t* uv_default_loop(void);
230
+
231
+ /*
232
+ * This function starts the event loop. It blocks until the reference count
233
+ * of the loop drops to zero. Always returns zero.
234
+ */
235
+ UV_EXTERN int uv_run(uv_loop_t*);
236
+
237
+ /*
238
+ * Poll for new events once. Note that this function blocks if there are no
239
+ * pending events. Returns zero when done (no active handles or requests left),
240
+ * or non-zero if more events are expected (meaning you should call
241
+ * uv_run_once() again sometime in the future).
242
+ */
243
+ UV_EXTERN int uv_run_once(uv_loop_t*);
244
+
245
+ /*
246
+ * Manually modify the event loop's reference count. Useful if the user wants
247
+ * to have a handle or timeout that doesn't keep the loop alive.
248
+ */
249
+ UV_EXTERN void uv_ref(uv_handle_t*);
250
+ UV_EXTERN void uv_unref(uv_handle_t*);
251
+
252
+ UV_EXTERN void uv_update_time(uv_loop_t*);
253
+ UV_EXTERN int64_t uv_now(uv_loop_t*);
254
+
255
+
256
+ /*
257
+ * Should return a buffer that libuv can use to read data into.
258
+ *
259
+ * `suggested_size` is a hint. Returning a buffer that is smaller is perfectly
260
+ * okay as long as `buf.len > 0`.
261
+ */
262
+ typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
263
+
264
+ /*
265
+ * `nread` is > 0 if there is data available, 0 if libuv is done reading for now
266
+ * or -1 on error.
267
+ *
268
+ * Error details can be obtained by calling uv_last_error(). UV_EOF indicates
269
+ * that the stream has been closed.
270
+ *
271
+ * The callee is responsible for closing the stream when an error happens.
272
+ * Trying to read from the stream again is undefined.
273
+ *
274
+ * The callee is responsible for freeing the buffer, libuv does not reuse it.
275
+ */
276
+ typedef void (*uv_read_cb)(uv_stream_t* stream, ssize_t nread, uv_buf_t buf);
277
+
278
+ /*
279
+ * Just like the uv_read_cb except that if the pending parameter is true
280
+ * then you can use uv_accept() to pull the new handle into the process.
281
+ * If no handle is pending then pending will be UV_UNKNOWN_HANDLE.
282
+ */
283
+ typedef void (*uv_read2_cb)(uv_pipe_t* pipe, ssize_t nread, uv_buf_t buf,
284
+ uv_handle_type pending);
285
+
286
+ typedef void (*uv_write_cb)(uv_write_t* req, int status);
287
+ typedef void (*uv_connect_cb)(uv_connect_t* req, int status);
288
+ typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);
289
+ typedef void (*uv_connection_cb)(uv_stream_t* server, int status);
290
+ typedef void (*uv_close_cb)(uv_handle_t* handle);
291
+ typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events);
292
+ typedef void (*uv_timer_cb)(uv_timer_t* handle, int status);
293
+ /* TODO: do these really need a status argument? */
294
+ typedef void (*uv_async_cb)(uv_async_t* handle, int status);
295
+ typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status);
296
+ typedef void (*uv_check_cb)(uv_check_t* handle, int status);
297
+ typedef void (*uv_idle_cb)(uv_idle_t* handle, int status);
298
+ typedef void (*uv_exit_cb)(uv_process_t*, int exit_status, int term_signal);
299
+ typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg);
300
+ typedef void (*uv_fs_cb)(uv_fs_t* req);
301
+ typedef void (*uv_work_cb)(uv_work_t* req);
302
+ typedef void (*uv_after_work_cb)(uv_work_t* req);
303
+ typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req,
304
+ int status,
305
+ struct addrinfo* res);
306
+
307
+ /*
308
+ * This will be called repeatedly after the uv_fs_event_t is initialized.
309
+ * If uv_fs_event_t was initialized with a directory the filename parameter
310
+ * will be a relative path to a file contained in the directory.
311
+ * The events parameter is an ORed mask of enum uv_fs_event elements.
312
+ */
313
+ typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
314
+ int events, int status);
315
+
316
+ typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle,
317
+ int status,
318
+ const uv_statbuf_t* prev,
319
+ const uv_statbuf_t* curr);
320
+
321
+ typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum);
322
+
323
+
324
+ typedef enum {
325
+ UV_LEAVE_GROUP = 0,
326
+ UV_JOIN_GROUP
327
+ } uv_membership;
328
+
329
+
330
+ struct uv_err_s {
331
+ /* read-only */
332
+ uv_err_code code;
333
+ /* private */
334
+ int sys_errno_;
335
+ };
336
+
337
+
338
+ /*
339
+ * Most functions return boolean: 0 for success and -1 for failure.
340
+ * On error the user should then call uv_last_error() to determine
341
+ * the error code.
342
+ */
343
+ UV_EXTERN uv_err_t uv_last_error(uv_loop_t*);
344
+ UV_EXTERN const char* uv_strerror(uv_err_t err);
345
+ UV_EXTERN const char* uv_err_name(uv_err_t err);
346
+
347
+
348
+ #define UV_REQ_FIELDS \
349
+ /* public */ \
350
+ void* data; \
351
+ /* private */ \
352
+ ngx_queue_t active_queue; \
353
+ UV_REQ_PRIVATE_FIELDS \
354
+ /* read-only */ \
355
+ uv_req_type type; \
356
+
357
+ /* Abstract base class of all requests. */
358
+ struct uv_req_s {
359
+ UV_REQ_FIELDS
360
+ };
361
+
362
+
363
+ /* Platform-specific request types */
364
+ UV_PRIVATE_REQ_TYPES
365
+
366
+
367
+ /*
368
+ * uv_shutdown_t is a subclass of uv_req_t
369
+ *
370
+ * Shutdown the outgoing (write) side of a duplex stream. It waits for
371
+ * pending write requests to complete. The handle should refer to a
372
+ * initialized stream. req should be an uninitialized shutdown request
373
+ * struct. The cb is called after shutdown is complete.
374
+ */
375
+ UV_EXTERN int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle,
376
+ uv_shutdown_cb cb);
377
+
378
+ struct uv_shutdown_s {
379
+ UV_REQ_FIELDS
380
+ uv_stream_t* handle;
381
+ uv_shutdown_cb cb;
382
+ UV_SHUTDOWN_PRIVATE_FIELDS
383
+ };
384
+
385
+
386
+ #define UV_HANDLE_FIELDS \
387
+ /* read-only */ \
388
+ uv_loop_t* loop; \
389
+ /* public */ \
390
+ uv_close_cb close_cb; \
391
+ void* data; \
392
+ /* read-only */ \
393
+ uv_handle_type type; \
394
+ /* private */ \
395
+ ngx_queue_t handle_queue; \
396
+ UV_HANDLE_PRIVATE_FIELDS \
397
+
398
+ /* The abstract base class of all handles. */
399
+ struct uv_handle_s {
400
+ UV_HANDLE_FIELDS
401
+ };
402
+
403
+ /*
404
+ * Returns size of various handle types, useful for FFI
405
+ * bindings to allocate correct memory without copying struct
406
+ * definitions
407
+ */
408
+ UV_EXTERN size_t uv_handle_size(uv_handle_type type);
409
+
410
+ /*
411
+ * Returns size of request types, useful for dynamic lookup with FFI
412
+ */
413
+ UV_EXTERN size_t uv_req_size(uv_req_type type);
414
+
415
+ /*
416
+ * Returns 1 if the prepare/check/idle/timer handle has been started, 0
417
+ * otherwise. For other handle types this always returns 1.
418
+ */
419
+ UV_EXTERN int uv_is_active(const uv_handle_t* handle);
420
+
421
+ /*
422
+ * Walk the list of open handles.
423
+ */
424
+ UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg);
425
+
426
+
427
+ /*
428
+ * Request handle to be closed. close_cb will be called asynchronously after
429
+ * this call. This MUST be called on each handle before memory is released.
430
+ *
431
+ * Note that handles that wrap file descriptors are closed immediately but
432
+ * close_cb will still be deferred to the next iteration of the event loop.
433
+ * It gives you a chance to free up any resources associated with the handle.
434
+ *
435
+ * In-progress requests, like uv_connect_t or uv_write_t, are cancelled and
436
+ * have their callbacks called asynchronously with status=-1 and the error code
437
+ * set to UV_ECANCELED.
438
+ */
439
+ UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
440
+
441
+
442
+ /*
443
+ * Constructor for uv_buf_t.
444
+ * Due to platform differences the user cannot rely on the ordering of the
445
+ * base and len members of the uv_buf_t struct. The user is responsible for
446
+ * freeing base after the uv_buf_t is done. Return struct passed by value.
447
+ */
448
+ UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len);
449
+
450
+
451
+ /*
452
+ * Utility function. Copies up to `size` characters from `src` to `dst`
453
+ * and ensures that `dst` is properly NUL terminated unless `size` is zero.
454
+ */
455
+ UV_EXTERN size_t uv_strlcpy(char* dst, const char* src, size_t size);
456
+
457
+ /*
458
+ * Utility function. Appends `src` to `dst` and ensures that `dst` is
459
+ * properly NUL terminated unless `size` is zero or `dst` does not
460
+ * contain a NUL byte. `size` is the total length of `dst` so at most
461
+ * `size - strlen(dst) - 1` characters will be copied from `src`.
462
+ */
463
+ UV_EXTERN size_t uv_strlcat(char* dst, const char* src, size_t size);
464
+
465
+
466
+ #define UV_STREAM_FIELDS \
467
+ /* number of bytes queued for writing */ \
468
+ size_t write_queue_size; \
469
+ uv_alloc_cb alloc_cb; \
470
+ uv_read_cb read_cb; \
471
+ uv_read2_cb read2_cb; \
472
+ /* private */ \
473
+ UV_STREAM_PRIVATE_FIELDS
474
+
475
+ /*
476
+ * uv_stream_t is a subclass of uv_handle_t
477
+ *
478
+ * uv_stream is an abstract class.
479
+ *
480
+ * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t, uv_tty_t, and
481
+ * soon uv_file_t.
482
+ */
483
+ struct uv_stream_s {
484
+ UV_HANDLE_FIELDS
485
+ UV_STREAM_FIELDS
486
+ };
487
+
488
+ UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
489
+
490
+ /*
491
+ * This call is used in conjunction with uv_listen() to accept incoming
492
+ * connections. Call uv_accept after receiving a uv_connection_cb to accept
493
+ * the connection. Before calling uv_accept use uv_*_init() must be
494
+ * called on the client. Non-zero return value indicates an error.
495
+ *
496
+ * When the uv_connection_cb is called it is guaranteed that uv_accept will
497
+ * complete successfully the first time. If you attempt to use it more than
498
+ * once, it may fail. It is suggested to only call uv_accept once per
499
+ * uv_connection_cb call.
500
+ */
501
+ UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client);
502
+
503
+ /*
504
+ * Read data from an incoming stream. The callback will be made several
505
+ * several times until there is no more data to read or uv_read_stop is
506
+ * called. When we've reached EOF nread will be set to -1 and the error is
507
+ * set to UV_EOF. When nread == -1 the buf parameter might not point to a
508
+ * valid buffer; in that case buf.len and buf.base are both set to 0.
509
+ * Note that nread might also be 0, which does *not* indicate an error or
510
+ * eof; it happens when libuv requested a buffer through the alloc callback
511
+ * but then decided that it didn't need that buffer.
512
+ */
513
+ UV_EXTERN int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb,
514
+ uv_read_cb read_cb);
515
+
516
+ UV_EXTERN int uv_read_stop(uv_stream_t*);
517
+
518
+ /*
519
+ * Extended read methods for receiving handles over a pipe. The pipe must be
520
+ * initialized with ipc == 1.
521
+ */
522
+ UV_EXTERN int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb,
523
+ uv_read2_cb read_cb);
524
+
525
+
526
+ /*
527
+ * Write data to stream. Buffers are written in order. Example:
528
+ *
529
+ * uv_buf_t a[] = {
530
+ * { .base = "1", .len = 1 },
531
+ * { .base = "2", .len = 1 }
532
+ * };
533
+ *
534
+ * uv_buf_t b[] = {
535
+ * { .base = "3", .len = 1 },
536
+ * { .base = "4", .len = 1 }
537
+ * };
538
+ *
539
+ * uv_write_t req1;
540
+ * uv_write_t req2;
541
+ *
542
+ * // writes "1234"
543
+ * uv_write(&req1, stream, a, 2);
544
+ * uv_write(&req2, stream, b, 2);
545
+ *
546
+ */
547
+ UV_EXTERN int uv_write(uv_write_t* req, uv_stream_t* handle,
548
+ uv_buf_t bufs[], int bufcnt, uv_write_cb cb);
549
+
550
+ /*
551
+ * Extended write function for sending handles over a pipe. The pipe must be
552
+ * initialized with ipc == 1.
553
+ * send_handle must be a TCP socket or pipe, which is a server or a connection
554
+ * (listening or connected state). Bound sockets or pipes will be assumed to
555
+ * be servers.
556
+ */
557
+ UV_EXTERN int uv_write2(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[],
558
+ int bufcnt, uv_stream_t* send_handle, uv_write_cb cb);
559
+
560
+ /* uv_write_t is a subclass of uv_req_t */
561
+ struct uv_write_s {
562
+ UV_REQ_FIELDS
563
+ uv_write_cb cb;
564
+ uv_stream_t* send_handle;
565
+ uv_stream_t* handle;
566
+ UV_WRITE_PRIVATE_FIELDS
567
+ };
568
+
569
+
570
+ /*
571
+ * Used to determine whether a stream is readable or writable.
572
+ */
573
+ UV_EXTERN int uv_is_readable(const uv_stream_t* handle);
574
+ UV_EXTERN int uv_is_writable(const uv_stream_t* handle);
575
+
576
+
577
+ /*
578
+ * Used to determine whether a stream is closing or closed.
579
+ *
580
+ * N.B. is only valid between the initialization of the handle
581
+ * and the arrival of the close callback, and cannot be used
582
+ * to validate the handle.
583
+ */
584
+ UV_EXTERN int uv_is_closing(const uv_handle_t* handle);
585
+
586
+
587
+ /*
588
+ * uv_tcp_t is a subclass of uv_stream_t
589
+ *
590
+ * Represents a TCP stream or TCP server.
591
+ */
592
+ struct uv_tcp_s {
593
+ UV_HANDLE_FIELDS
594
+ UV_STREAM_FIELDS
595
+ UV_TCP_PRIVATE_FIELDS
596
+ };
597
+
598
+ UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
599
+
600
+ /* Enable/disable Nagle's algorithm. */
601
+ UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
602
+
603
+ /* Enable/disable TCP keep-alive.
604
+ *
605
+ * `ms` is the initial delay in seconds, ignored when `enable` is zero.
606
+ */
607
+ UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, int enable,
608
+ unsigned int delay);
609
+
610
+ /*
611
+ * This setting applies to Windows only.
612
+ * Enable/disable simultaneous asynchronous accept requests that are
613
+ * queued by the operating system when listening for new tcp connections.
614
+ * This setting is used to tune a tcp server for the desired performance.
615
+ * Having simultaneous accepts can significantly improve the rate of
616
+ * accepting connections (which is why it is enabled by default).
617
+ */
618
+ UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
619
+
620
+ UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in);
621
+ UV_EXTERN int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6);
622
+ UV_EXTERN int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
623
+ int* namelen);
624
+ UV_EXTERN int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
625
+ int* namelen);
626
+
627
+ /*
628
+ * uv_tcp_connect, uv_tcp_connect6
629
+ * These functions establish IPv4 and IPv6 TCP connections. Provide an
630
+ * initialized TCP handle and an uninitialized uv_connect_t*. The callback
631
+ * will be made when the connection is established.
632
+ */
633
+ UV_EXTERN int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
634
+ struct sockaddr_in address, uv_connect_cb cb);
635
+ UV_EXTERN int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
636
+ struct sockaddr_in6 address, uv_connect_cb cb);
637
+
638
+ /* uv_connect_t is a subclass of uv_req_t */
639
+ struct uv_connect_s {
640
+ UV_REQ_FIELDS
641
+ uv_connect_cb cb;
642
+ uv_stream_t* handle;
643
+ UV_CONNECT_PRIVATE_FIELDS
644
+ };
645
+
646
+
647
+ /*
648
+ * UDP support.
649
+ */
650
+
651
+ enum uv_udp_flags {
652
+ /* Disables dual stack mode. Used with uv_udp_bind6(). */
653
+ UV_UDP_IPV6ONLY = 1,
654
+ /*
655
+ * Indicates message was truncated because read buffer was too small. The
656
+ * remainder was discarded by the OS. Used in uv_udp_recv_cb.
657
+ */
658
+ UV_UDP_PARTIAL = 2
659
+ };
660
+
661
+ /*
662
+ * Called after a uv_udp_send() or uv_udp_send6(). status 0 indicates
663
+ * success otherwise error.
664
+ */
665
+ typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
666
+
667
+ /*
668
+ * Callback that is invoked when a new UDP datagram is received.
669
+ *
670
+ * handle UDP handle.
671
+ * nread Number of bytes that have been received.
672
+ * 0 if there is no more data to read. You may
673
+ * discard or repurpose the read buffer.
674
+ * -1 if a transmission error was detected.
675
+ * buf uv_buf_t with the received data.
676
+ * addr struct sockaddr_in or struct sockaddr_in6.
677
+ * Valid for the duration of the callback only.
678
+ * flags One or more OR'ed UV_UDP_* constants.
679
+ * Right now only UV_UDP_PARTIAL is used.
680
+ */
681
+ typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, ssize_t nread, uv_buf_t buf,
682
+ struct sockaddr* addr, unsigned flags);
683
+
684
+ /* uv_udp_t is a subclass of uv_handle_t */
685
+ struct uv_udp_s {
686
+ UV_HANDLE_FIELDS
687
+ UV_UDP_PRIVATE_FIELDS
688
+ };
689
+
690
+ /* uv_udp_send_t is a subclass of uv_req_t */
691
+ struct uv_udp_send_s {
692
+ UV_REQ_FIELDS
693
+ uv_udp_t* handle;
694
+ uv_udp_send_cb cb;
695
+ UV_UDP_SEND_PRIVATE_FIELDS
696
+ };
697
+
698
+ /*
699
+ * Initialize a new UDP handle. The actual socket is created lazily.
700
+ * Returns 0 on success.
701
+ */
702
+ UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
703
+
704
+ /*
705
+ * Bind to a IPv4 address and port.
706
+ *
707
+ * Arguments:
708
+ * handle UDP handle. Should have been initialized with `uv_udp_init`.
709
+ * addr struct sockaddr_in with the address and port to bind to.
710
+ * flags Unused.
711
+ *
712
+ * Returns:
713
+ * 0 on success, -1 on error.
714
+ */
715
+ UV_EXTERN int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
716
+ unsigned flags);
717
+
718
+ /*
719
+ * Bind to a IPv6 address and port.
720
+ *
721
+ * Arguments:
722
+ * handle UDP handle. Should have been initialized with `uv_udp_init`.
723
+ * addr struct sockaddr_in with the address and port to bind to.
724
+ * flags Should be 0 or UV_UDP_IPV6ONLY.
725
+ *
726
+ * Returns:
727
+ * 0 on success, -1 on error.
728
+ */
729
+ UV_EXTERN int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
730
+ unsigned flags);
731
+ UV_EXTERN int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
732
+ int* namelen);
733
+
734
+ /*
735
+ * Set membership for a multicast address
736
+ *
737
+ * Arguments:
738
+ * handle UDP handle. Should have been initialized with
739
+ * `uv_udp_init`.
740
+ * multicast_addr multicast address to set membership for
741
+ * interface_addr interface address
742
+ * membership Should be UV_JOIN_GROUP or UV_LEAVE_GROUP
743
+ *
744
+ * Returns:
745
+ * 0 on success, -1 on error.
746
+ */
747
+ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
748
+ const char* multicast_addr, const char* interface_addr,
749
+ uv_membership membership);
750
+
751
+ /*
752
+ * Set IP multicast loop flag. Makes multicast packets loop back to
753
+ * local sockets.
754
+ *
755
+ * Arguments:
756
+ * handle UDP handle. Should have been initialized with
757
+ * `uv_udp_init`.
758
+ * on 1 for on, 0 for off
759
+ *
760
+ * Returns:
761
+ * 0 on success, -1 on error.
762
+ */
763
+ UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
764
+
765
+ /*
766
+ * Set the multicast ttl
767
+ *
768
+ * Arguments:
769
+ * handle UDP handle. Should have been initialized with
770
+ * `uv_udp_init`.
771
+ * ttl 1 through 255
772
+ *
773
+ * Returns:
774
+ * 0 on success, -1 on error.
775
+ */
776
+ UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
777
+
778
+ /*
779
+ * Set broadcast on or off
780
+ *
781
+ * Arguments:
782
+ * handle UDP handle. Should have been initialized with
783
+ * `uv_udp_init`.
784
+ * on 1 for on, 0 for off
785
+ *
786
+ * Returns:
787
+ * 0 on success, -1 on error.
788
+ */
789
+ UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);
790
+
791
+ /*
792
+ * Set the time to live
793
+ *
794
+ * Arguments:
795
+ * handle UDP handle. Should have been initialized with
796
+ * `uv_udp_init`.
797
+ * ttl 1 through 255
798
+ *
799
+ * Returns:
800
+ * 0 on success, -1 on error.
801
+ */
802
+ UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);
803
+
804
+ /*
805
+ * Send data. If the socket has not previously been bound with `uv_udp_bind`
806
+ * or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
807
+ * and a random port number.
808
+ *
809
+ * Arguments:
810
+ * req UDP request handle. Need not be initialized.
811
+ * handle UDP handle. Should have been initialized with `uv_udp_init`.
812
+ * bufs List of buffers to send.
813
+ * bufcnt Number of buffers in `bufs`.
814
+ * addr Address of the remote peer. See `uv_ip4_addr`.
815
+ * send_cb Callback to invoke when the data has been sent out.
816
+ *
817
+ * Returns:
818
+ * 0 on success, -1 on error.
819
+ */
820
+ UV_EXTERN int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle,
821
+ uv_buf_t bufs[], int bufcnt, struct sockaddr_in addr,
822
+ uv_udp_send_cb send_cb);
823
+
824
+ /*
825
+ * Send data. If the socket has not previously been bound with `uv_udp_bind6`,
826
+ * it is bound to ::0 (the "all interfaces" address) and a random port number.
827
+ *
828
+ * Arguments:
829
+ * req UDP request handle. Need not be initialized.
830
+ * handle UDP handle. Should have been initialized with `uv_udp_init`.
831
+ * bufs List of buffers to send.
832
+ * bufcnt Number of buffers in `bufs`.
833
+ * addr Address of the remote peer. See `uv_ip6_addr`.
834
+ * send_cb Callback to invoke when the data has been sent out.
835
+ *
836
+ * Returns:
837
+ * 0 on success, -1 on error.
838
+ */
839
+ UV_EXTERN int uv_udp_send6(uv_udp_send_t* req, uv_udp_t* handle,
840
+ uv_buf_t bufs[], int bufcnt, struct sockaddr_in6 addr,
841
+ uv_udp_send_cb send_cb);
842
+
843
+ /*
844
+ * Receive data. If the socket has not previously been bound with `uv_udp_bind`
845
+ * or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
846
+ * and a random port number.
847
+ *
848
+ * Arguments:
849
+ * handle UDP handle. Should have been initialized with `uv_udp_init`.
850
+ * alloc_cb Callback to invoke when temporary storage is needed.
851
+ * recv_cb Callback to invoke with received data.
852
+ *
853
+ * Returns:
854
+ * 0 on success, -1 on error.
855
+ */
856
+ UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
857
+ uv_udp_recv_cb recv_cb);
858
+
859
+ /*
860
+ * Stop listening for incoming datagrams.
861
+ *
862
+ * Arguments:
863
+ * handle UDP handle. Should have been initialized with `uv_udp_init`.
864
+ *
865
+ * Returns:
866
+ * 0 on success, -1 on error.
867
+ */
868
+ UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
869
+
870
+
871
+ /*
872
+ * uv_tty_t is a subclass of uv_stream_t
873
+ *
874
+ * Representing a stream for the console.
875
+ */
876
+ struct uv_tty_s {
877
+ UV_HANDLE_FIELDS
878
+ UV_STREAM_FIELDS
879
+ UV_TTY_PRIVATE_FIELDS
880
+ };
881
+
882
+ /*
883
+ * Initialize a new TTY stream with the given file descriptor. Usually the
884
+ * file descriptor will be
885
+ * 0 = stdin
886
+ * 1 = stdout
887
+ * 2 = stderr
888
+ * The last argument, readable, specifies if you plan on calling
889
+ * uv_read_start with this stream. stdin is readable, stdout is not.
890
+ *
891
+ * TTY streams which are not readable have blocking writes.
892
+ */
893
+ UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
894
+
895
+ /*
896
+ * Set mode. 0 for normal, 1 for raw.
897
+ */
898
+ UV_EXTERN int uv_tty_set_mode(uv_tty_t*, int mode);
899
+
900
+ /*
901
+ * To be called when the program exits. Resets TTY settings to default
902
+ * values for the next process to take over.
903
+ */
904
+ UV_EXTERN void uv_tty_reset_mode(void);
905
+
906
+ /*
907
+ * Gets the current Window size. On success zero is returned.
908
+ */
909
+ UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
910
+
911
+ /*
912
+ * Used to detect what type of stream should be used with a given file
913
+ * descriptor. Usually this will be used during initialization to guess the
914
+ * type of the stdio streams.
915
+ * For isatty() functionality use this function and test for UV_TTY.
916
+ */
917
+ UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
918
+
919
+ /*
920
+ * uv_pipe_t is a subclass of uv_stream_t
921
+ *
922
+ * Representing a pipe stream or pipe server. On Windows this is a Named
923
+ * Pipe. On Unix this is a UNIX domain socket.
924
+ */
925
+ struct uv_pipe_s {
926
+ UV_HANDLE_FIELDS
927
+ UV_STREAM_FIELDS
928
+ UV_PIPE_PRIVATE_FIELDS
929
+ int ipc; /* non-zero if this pipe is used for passing handles */
930
+ };
931
+
932
+ /*
933
+ * Initialize a pipe. The last argument is a boolean to indicate if
934
+ * this pipe will be used for handle passing between processes.
935
+ */
936
+ UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
937
+
938
+ /*
939
+ * Opens an existing file descriptor or HANDLE as a pipe.
940
+ */
941
+ UV_EXTERN void uv_pipe_open(uv_pipe_t*, uv_file file);
942
+
943
+ UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
944
+
945
+ UV_EXTERN void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
946
+ const char* name, uv_connect_cb cb);
947
+
948
+ /*
949
+ * This setting applies to Windows only.
950
+ * Set the number of pending pipe instance handles when the pipe server
951
+ * is waiting for connections.
952
+ */
953
+ UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
954
+
955
+
956
+ /*
957
+ * uv_poll_t is a subclass of uv_handle_t.
958
+ *
959
+ * The uv_poll watcher is used to watch file descriptors for readability and
960
+ * writability, similar to the purpose of poll(2).
961
+ *
962
+ * The purpose of uv_poll is to enable integrating external libraries that
963
+ * rely on the event loop to signal it about the socket status changes, like
964
+ * c-ares or libssh2. Using uv_poll_t for any other other purpose is not
965
+ * recommended; uv_tcp_t, uv_udp_t, etc. provide an implementation that is
966
+ * much faster and more scalable than what can be achieved with uv_poll_t,
967
+ * especially on Windows.
968
+ *
969
+ * It is possible that uv_poll occasionally signals that a file descriptor is
970
+ * readable or writable even when it isn't. The user should therefore always
971
+ * be prepared to handle EAGAIN or equivalent when it attempts to read from or
972
+ * write to the fd.
973
+ *
974
+ * It is not okay to have multiple active uv_poll watchers for the same socket.
975
+ * This can cause libuv to busyloop or otherwise malfunction.
976
+ *
977
+ * The user should not close a file descriptor while it is being polled by an
978
+ * active uv_poll watcher. This can cause the poll watcher to report an error,
979
+ * but it might also start polling another socket. However the fd can be safely
980
+ * closed immediately after a call to uv_poll_stop() or uv_close().
981
+ *
982
+ * On windows only sockets can be polled with uv_poll. On unix any file
983
+ * descriptor that would be accepted by poll(2) can be used with uv_poll.
984
+ */
985
+ struct uv_poll_s {
986
+ UV_HANDLE_FIELDS
987
+ uv_poll_cb poll_cb;
988
+ UV_POLL_PRIVATE_FIELDS
989
+ };
990
+
991
+ enum uv_poll_event {
992
+ UV_READABLE = 1,
993
+ UV_WRITABLE = 2
994
+ };
995
+
996
+ /* Initialize the poll watcher using a file descriptor. */
997
+ UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
998
+
999
+ /* Initialize the poll watcher using a socket descriptor. On unix this is */
1000
+ /* identical to uv_poll_init. On windows it takes a SOCKET handle. */
1001
+ UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
1002
+ uv_os_sock_t socket);
1003
+
1004
+ /*
1005
+ * Starts polling the file descriptor. `events` is a bitmask consisting made up
1006
+ * of UV_READABLE and UV_WRITABLE. As soon as an event is detected the callback
1007
+ * will be called with `status` set to 0, and the detected events set en the
1008
+ * `events` field.
1009
+ *
1010
+ * If an error happens while polling status may be set to -1 and the error
1011
+ * code can be retrieved with uv_last_error. The user should not close the
1012
+ * socket while uv_poll is active. If the user does that anyway, the callback
1013
+ * *may* be called reporting an error status, but this is not guaranteed.
1014
+ *
1015
+ * Calling uv_poll_start on an uv_poll watcher that is already active is fine.
1016
+ * Doing so will update the events mask that is being watched for.
1017
+ */
1018
+ UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb);
1019
+
1020
+ /* Stops polling the file descriptor. */
1021
+ UV_EXTERN int uv_poll_stop(uv_poll_t* handle);
1022
+
1023
+
1024
+ /*
1025
+ * uv_prepare_t is a subclass of uv_handle_t.
1026
+ *
1027
+ * libev wrapper. Every active prepare handle gets its callback called
1028
+ * exactly once per loop iteration, just before the system blocks to wait
1029
+ * for completed i/o.
1030
+ */
1031
+ struct uv_prepare_s {
1032
+ UV_HANDLE_FIELDS
1033
+ UV_PREPARE_PRIVATE_FIELDS
1034
+ };
1035
+
1036
+ UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare);
1037
+
1038
+ UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb);
1039
+
1040
+ UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare);
1041
+
1042
+
1043
+ /*
1044
+ * uv_check_t is a subclass of uv_handle_t.
1045
+ *
1046
+ * libev wrapper. Every active check handle gets its callback called exactly
1047
+ * once per loop iteration, just after the system returns from blocking.
1048
+ */
1049
+ struct uv_check_s {
1050
+ UV_HANDLE_FIELDS
1051
+ UV_CHECK_PRIVATE_FIELDS
1052
+ };
1053
+
1054
+ UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check);
1055
+
1056
+ UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb);
1057
+
1058
+ UV_EXTERN int uv_check_stop(uv_check_t* check);
1059
+
1060
+
1061
+ /*
1062
+ * uv_idle_t is a subclass of uv_handle_t.
1063
+ *
1064
+ * libev wrapper. Every active idle handle gets its callback called
1065
+ * repeatedly until it is stopped. This happens after all other types of
1066
+ * callbacks are processed. When there are multiple "idle" handles active,
1067
+ * their callbacks are called in turn.
1068
+ */
1069
+ struct uv_idle_s {
1070
+ UV_HANDLE_FIELDS
1071
+ UV_IDLE_PRIVATE_FIELDS
1072
+ };
1073
+
1074
+ UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle);
1075
+
1076
+ UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb);
1077
+
1078
+ UV_EXTERN int uv_idle_stop(uv_idle_t* idle);
1079
+
1080
+
1081
+ /*
1082
+ * uv_async_t is a subclass of uv_handle_t.
1083
+ *
1084
+ * libev wrapper. uv_async_send wakes up the event
1085
+ * loop and calls the async handle's callback There is no guarantee that
1086
+ * every uv_async_send call leads to exactly one invocation of the callback;
1087
+ * The only guarantee is that the callback function is called at least once
1088
+ * after the call to async_send. Unlike all other libuv functions,
1089
+ * uv_async_send can be called from another thread.
1090
+ */
1091
+ struct uv_async_s {
1092
+ UV_HANDLE_FIELDS
1093
+ UV_ASYNC_PRIVATE_FIELDS
1094
+ };
1095
+
1096
+ UV_EXTERN int uv_async_init(uv_loop_t*, uv_async_t* async,
1097
+ uv_async_cb async_cb);
1098
+
1099
+ /*
1100
+ * This can be called from other threads to wake up a libuv thread.
1101
+ *
1102
+ * libuv is single threaded at the moment.
1103
+ */
1104
+ UV_EXTERN int uv_async_send(uv_async_t* async);
1105
+
1106
+
1107
+ /*
1108
+ * uv_timer_t is a subclass of uv_handle_t.
1109
+ *
1110
+ * Wraps libev's ev_timer watcher. Used to get woken up at a specified time
1111
+ * in the future.
1112
+ */
1113
+ struct uv_timer_s {
1114
+ UV_HANDLE_FIELDS
1115
+ UV_TIMER_PRIVATE_FIELDS
1116
+ };
1117
+
1118
+ UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* timer);
1119
+
1120
+ UV_EXTERN int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb,
1121
+ int64_t timeout, int64_t repeat);
1122
+
1123
+ UV_EXTERN int uv_timer_stop(uv_timer_t* timer);
1124
+
1125
+ /*
1126
+ * Stop the timer, and if it is repeating restart it using the repeat value
1127
+ * as the timeout. If the timer has never been started before it returns -1 and
1128
+ * sets the error to UV_EINVAL.
1129
+ */
1130
+ UV_EXTERN int uv_timer_again(uv_timer_t* timer);
1131
+
1132
+ /*
1133
+ * Set the repeat value. Note that if the repeat value is set from a timer
1134
+ * callback it does not immediately take effect. If the timer was non-repeating
1135
+ * before, it will have been stopped. If it was repeating, then the old repeat
1136
+ * value will have been used to schedule the next timeout.
1137
+ */
1138
+ UV_EXTERN void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat);
1139
+
1140
+ UV_EXTERN int64_t uv_timer_get_repeat(uv_timer_t* timer);
1141
+
1142
+
1143
+ /*
1144
+ * uv_getaddrinfo_t is a subclass of uv_req_t
1145
+ *
1146
+ * Request object for uv_getaddrinfo.
1147
+ */
1148
+ struct uv_getaddrinfo_s {
1149
+ UV_REQ_FIELDS
1150
+ /* read-only */
1151
+ uv_loop_t* loop;
1152
+ UV_GETADDRINFO_PRIVATE_FIELDS
1153
+ };
1154
+
1155
+
1156
+ /*
1157
+ * Asynchronous getaddrinfo(3).
1158
+ *
1159
+ * Either node or service may be NULL but not both.
1160
+ *
1161
+ * hints is a pointer to a struct addrinfo with additional address type
1162
+ * constraints, or NULL. Consult `man -s 3 getaddrinfo` for details.
1163
+ *
1164
+ * Returns 0 on success, -1 on error. Call uv_last_error() to get the error.
1165
+ *
1166
+ * If successful, your callback gets called sometime in the future with the
1167
+ * lookup result, which is either:
1168
+ *
1169
+ * a) status == 0, the res argument points to a valid struct addrinfo, or
1170
+ * b) status == -1, the res argument is NULL.
1171
+ *
1172
+ * On NXDOMAIN, the status code is -1 and uv_last_error() returns UV_ENOENT.
1173
+ *
1174
+ * Call uv_freeaddrinfo() to free the addrinfo structure.
1175
+ */
1176
+ UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop,
1177
+ uv_getaddrinfo_t* req,
1178
+ uv_getaddrinfo_cb getaddrinfo_cb,
1179
+ const char* node,
1180
+ const char* service,
1181
+ const struct addrinfo* hints);
1182
+
1183
+ /*
1184
+ * Free the struct addrinfo. Passing NULL is allowed and is a no-op.
1185
+ */
1186
+ UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);
1187
+
1188
+ /* uv_spawn() options */
1189
+ typedef enum {
1190
+ UV_IGNORE = 0x00,
1191
+ UV_CREATE_PIPE = 0x01,
1192
+ UV_INHERIT_FD = 0x02,
1193
+ UV_INHERIT_STREAM = 0x04,
1194
+
1195
+ /* When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
1196
+ * determine the direction of flow, from the child process' perspective. Both
1197
+ * flags may be specified to create a duplex data stream.
1198
+ */
1199
+ UV_READABLE_PIPE = 0x10,
1200
+ UV_WRITABLE_PIPE = 0x20
1201
+ } uv_stdio_flags;
1202
+
1203
+ typedef struct uv_stdio_container_s {
1204
+ uv_stdio_flags flags;
1205
+
1206
+ union {
1207
+ uv_stream_t* stream;
1208
+ int fd;
1209
+ } data;
1210
+ } uv_stdio_container_t;
1211
+
1212
+ typedef struct uv_process_options_s {
1213
+ uv_exit_cb exit_cb; /* Called after the process exits. */
1214
+ const char* file; /* Path to program to execute. */
1215
+ /*
1216
+ * Command line arguments. args[0] should be the path to the program. On
1217
+ * Windows this uses CreateProcess which concatenates the arguments into a
1218
+ * string this can cause some strange errors. See the note at
1219
+ * windows_verbatim_arguments.
1220
+ */
1221
+ char** args;
1222
+ /*
1223
+ * This will be set as the environ variable in the subprocess. If this is
1224
+ * NULL then the parents environ will be used.
1225
+ */
1226
+ char** env;
1227
+ /*
1228
+ * If non-null this represents a directory the subprocess should execute
1229
+ * in. Stands for current working directory.
1230
+ */
1231
+ char* cwd;
1232
+ /*
1233
+ * Various flags that control how uv_spawn() behaves. See the definition of
1234
+ * `enum uv_process_flags` below.
1235
+ */
1236
+ unsigned int flags;
1237
+ /*
1238
+ * Libuv can change the child process' user/group id. This happens only when
1239
+ * the appropriate bits are set in the flags fields. This is not supported on
1240
+ * windows; uv_spawn() will fail and set the error to UV_ENOTSUP.
1241
+ */
1242
+ uv_uid_t uid;
1243
+ uv_gid_t gid;
1244
+
1245
+ /*
1246
+ * The `stdio` field points to an array of uv_stdio_container_t structs that
1247
+ * describe the file descriptors that will be made available to the child
1248
+ * process. The convention is that stdio[0] points to stdin, fd 1 is used for
1249
+ * stdout, and fd 2 is stderr.
1250
+ *
1251
+ * Note that on windows file descriptors greater than 2 are available to the
1252
+ * child process only if the child processes uses the MSVCRT runtime.
1253
+ */
1254
+ int stdio_count;
1255
+ uv_stdio_container_t* stdio;
1256
+ } uv_process_options_t;
1257
+
1258
+ /*
1259
+ * These are the flags that can be used for the uv_process_options.flags field.
1260
+ */
1261
+ enum uv_process_flags {
1262
+ /*
1263
+ * Set the child process' user id. The user id is supplied in the `uid` field
1264
+ * of the options struct. This does not work on windows; setting this flag
1265
+ * will cause uv_spawn() to fail.
1266
+ */
1267
+ UV_PROCESS_SETUID = (1 << 0),
1268
+ /*
1269
+ * Set the child process' group id. The user id is supplied in the `gid`
1270
+ * field of the options struct. This does not work on windows; setting this
1271
+ * flag will cause uv_spawn() to fail.
1272
+ */
1273
+ UV_PROCESS_SETGID = (1 << 1),
1274
+ /*
1275
+ * Do not wrap any arguments in quotes, or perform any other escaping, when
1276
+ * converting the argument list into a command line string. This option is
1277
+ * only meaningful on Windows systems. On unix it is silently ignored.
1278
+ */
1279
+ UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
1280
+ /*
1281
+ * Spawn the child process in a detached state - this will make it a process
1282
+ * group leader, and will effectively enable the child to keep running after
1283
+ * the parent exits. Note that the child process will still keep the
1284
+ * parent's event loop alive unless the parent process calls uv_unref() on
1285
+ * the child's process handle.
1286
+ */
1287
+ UV_PROCESS_DETACHED = (1 << 3)
1288
+ };
1289
+
1290
+ /*
1291
+ * uv_process_t is a subclass of uv_handle_t
1292
+ */
1293
+ struct uv_process_s {
1294
+ UV_HANDLE_FIELDS
1295
+ uv_exit_cb exit_cb;
1296
+ int pid;
1297
+ UV_PROCESS_PRIVATE_FIELDS
1298
+ };
1299
+
1300
+ /* Initializes uv_process_t and starts the process. */
1301
+ UV_EXTERN int uv_spawn(uv_loop_t*, uv_process_t*,
1302
+ uv_process_options_t options);
1303
+
1304
+
1305
+ /*
1306
+ * Kills the process with the specified signal. The user must still
1307
+ * call uv_close on the process.
1308
+ */
1309
+ UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
1310
+
1311
+
1312
+ /* Kills the process with the specified signal. */
1313
+ UV_EXTERN uv_err_t uv_kill(int pid, int signum);
1314
+
1315
+
1316
+ /*
1317
+ * uv_work_t is a subclass of uv_req_t
1318
+ */
1319
+ struct uv_work_s {
1320
+ UV_REQ_FIELDS
1321
+ uv_loop_t* loop;
1322
+ uv_work_cb work_cb;
1323
+ uv_after_work_cb after_work_cb;
1324
+ UV_WORK_PRIVATE_FIELDS
1325
+ };
1326
+
1327
+ /* Queues a work request to execute asynchronously on the thread pool. */
1328
+ UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
1329
+ uv_work_cb work_cb, uv_after_work_cb after_work_cb);
1330
+
1331
+
1332
+ struct uv_cpu_info_s {
1333
+ char* model;
1334
+ int speed;
1335
+ struct uv_cpu_times_s {
1336
+ uint64_t user;
1337
+ uint64_t nice;
1338
+ uint64_t sys;
1339
+ uint64_t idle;
1340
+ uint64_t irq;
1341
+ } cpu_times;
1342
+ };
1343
+
1344
+ struct uv_interface_address_s {
1345
+ char* name;
1346
+ int is_internal;
1347
+ union {
1348
+ struct sockaddr_in address4;
1349
+ struct sockaddr_in6 address6;
1350
+ } address;
1351
+ };
1352
+
1353
+ UV_EXTERN char** uv_setup_args(int argc, char** argv);
1354
+ UV_EXTERN uv_err_t uv_get_process_title(char* buffer, size_t size);
1355
+ UV_EXTERN uv_err_t uv_set_process_title(const char* title);
1356
+ UV_EXTERN uv_err_t uv_resident_set_memory(size_t* rss);
1357
+ UV_EXTERN uv_err_t uv_uptime(double* uptime);
1358
+
1359
+ /*
1360
+ * This allocates cpu_infos array, and sets count. The array
1361
+ * is freed using uv_free_cpu_info().
1362
+ */
1363
+ UV_EXTERN uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
1364
+ UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
1365
+
1366
+ /*
1367
+ * This allocates addresses array, and sets count. The array
1368
+ * is freed using uv_free_interface_addresses().
1369
+ */
1370
+ UV_EXTERN uv_err_t uv_interface_addresses(uv_interface_address_t** addresses,
1371
+ int* count);
1372
+ UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses,
1373
+ int count);
1374
+
1375
+ /*
1376
+ * File System Methods.
1377
+ *
1378
+ * The uv_fs_* functions execute a blocking system call asynchronously (in a
1379
+ * thread pool) and call the specified callback in the specified loop after
1380
+ * completion. If the user gives NULL as the callback the blocking system
1381
+ * call will be called synchronously. req should be a pointer to an
1382
+ * uninitialized uv_fs_t object.
1383
+ *
1384
+ * uv_fs_req_cleanup() must be called after completion of the uv_fs_
1385
+ * function to free any internal memory allocations associated with the
1386
+ * request.
1387
+ */
1388
+
1389
+ typedef enum {
1390
+ UV_FS_UNKNOWN = -1,
1391
+ UV_FS_CUSTOM,
1392
+ UV_FS_OPEN,
1393
+ UV_FS_CLOSE,
1394
+ UV_FS_READ,
1395
+ UV_FS_WRITE,
1396
+ UV_FS_SENDFILE,
1397
+ UV_FS_STAT,
1398
+ UV_FS_LSTAT,
1399
+ UV_FS_FSTAT,
1400
+ UV_FS_FTRUNCATE,
1401
+ UV_FS_UTIME,
1402
+ UV_FS_FUTIME,
1403
+ UV_FS_CHMOD,
1404
+ UV_FS_FCHMOD,
1405
+ UV_FS_FSYNC,
1406
+ UV_FS_FDATASYNC,
1407
+ UV_FS_UNLINK,
1408
+ UV_FS_RMDIR,
1409
+ UV_FS_MKDIR,
1410
+ UV_FS_RENAME,
1411
+ UV_FS_READDIR,
1412
+ UV_FS_LINK,
1413
+ UV_FS_SYMLINK,
1414
+ UV_FS_READLINK,
1415
+ UV_FS_CHOWN,
1416
+ UV_FS_FCHOWN
1417
+ } uv_fs_type;
1418
+
1419
+ /* uv_fs_t is a subclass of uv_req_t */
1420
+ struct uv_fs_s {
1421
+ UV_REQ_FIELDS
1422
+ uv_fs_type fs_type;
1423
+ uv_loop_t* loop;
1424
+ uv_fs_cb cb;
1425
+ ssize_t result;
1426
+ void* ptr;
1427
+ const char* path;
1428
+ uv_err_code errorno;
1429
+ UV_FS_PRIVATE_FIELDS
1430
+ };
1431
+
1432
+ UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);
1433
+
1434
+ UV_EXTERN int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1435
+ uv_fs_cb cb);
1436
+
1437
+ UV_EXTERN int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path,
1438
+ int flags, int mode, uv_fs_cb cb);
1439
+
1440
+ UV_EXTERN int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1441
+ void* buf, size_t length, int64_t offset, uv_fs_cb cb);
1442
+
1443
+ UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
1444
+ uv_fs_cb cb);
1445
+
1446
+ UV_EXTERN int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1447
+ void* buf, size_t length, int64_t offset, uv_fs_cb cb);
1448
+
1449
+ UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
1450
+ int mode, uv_fs_cb cb);
1451
+
1452
+ UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
1453
+ uv_fs_cb cb);
1454
+
1455
+ UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req,
1456
+ const char* path, int flags, uv_fs_cb cb);
1457
+
1458
+ UV_EXTERN int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path,
1459
+ uv_fs_cb cb);
1460
+
1461
+ UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1462
+ uv_fs_cb cb);
1463
+
1464
+ UV_EXTERN int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
1465
+ const char* new_path, uv_fs_cb cb);
1466
+
1467
+ UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1468
+ uv_fs_cb cb);
1469
+
1470
+ UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1471
+ uv_fs_cb cb);
1472
+
1473
+ UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1474
+ int64_t offset, uv_fs_cb cb);
1475
+
1476
+ UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
1477
+ uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb);
1478
+
1479
+ UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path,
1480
+ int mode, uv_fs_cb cb);
1481
+
1482
+ UV_EXTERN int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path,
1483
+ double atime, double mtime, uv_fs_cb cb);
1484
+
1485
+ UV_EXTERN int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1486
+ double atime, double mtime, uv_fs_cb cb);
1487
+
1488
+ UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path,
1489
+ uv_fs_cb cb);
1490
+
1491
+ UV_EXTERN int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
1492
+ const char* new_path, uv_fs_cb cb);
1493
+
1494
+ /*
1495
+ * This flag can be used with uv_fs_symlink on Windows
1496
+ * to specify whether path argument points to a directory.
1497
+ */
1498
+ #define UV_FS_SYMLINK_DIR 0x0001
1499
+
1500
+ /*
1501
+ * This flag can be used with uv_fs_symlink on Windows
1502
+ * to specify whether the symlink is to be created using junction points.
1503
+ */
1504
+ #define UV_FS_SYMLINK_JUNCTION 0x0002
1505
+
1506
+ UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
1507
+ const char* new_path, int flags, uv_fs_cb cb);
1508
+
1509
+ UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
1510
+ uv_fs_cb cb);
1511
+
1512
+ UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1513
+ int mode, uv_fs_cb cb);
1514
+
1515
+ UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,
1516
+ int uid, int gid, uv_fs_cb cb);
1517
+
1518
+ UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1519
+ int uid, int gid, uv_fs_cb cb);
1520
+
1521
+
1522
+ enum uv_fs_event {
1523
+ UV_RENAME = 1,
1524
+ UV_CHANGE = 2
1525
+ };
1526
+
1527
+
1528
+ struct uv_fs_event_s {
1529
+ UV_HANDLE_FIELDS
1530
+ char* filename;
1531
+ UV_FS_EVENT_PRIVATE_FIELDS
1532
+ };
1533
+
1534
+
1535
+ /*
1536
+ * uv_fs_stat() based polling file watcher.
1537
+ */
1538
+ struct uv_fs_poll_s {
1539
+ UV_HANDLE_FIELDS
1540
+ /* Private, don't touch. */
1541
+ int busy_polling; /* TODO(bnoordhuis) Fold into flags field. */
1542
+ unsigned int interval;
1543
+ uint64_t start_time;
1544
+ char* path;
1545
+ uv_fs_poll_cb poll_cb;
1546
+ uv_timer_t timer_handle;
1547
+ uv_fs_t* fs_req;
1548
+ uv_statbuf_t statbuf;
1549
+ };
1550
+
1551
+ UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
1552
+
1553
+ /*
1554
+ * Check the file at `path` for changes every `interval` milliseconds.
1555
+ *
1556
+ * Your callback i invoked with `status == -1` if `path` does not exist
1557
+ * or is inaccessible. The watcher is *not* stopped but your callback is
1558
+ * not called again until something changes (e.g. when the file is created
1559
+ * or the error reason changes).
1560
+ *
1561
+ * When `status == 0`, your callback receives pointers to the old and new
1562
+ * `uv_statbuf_t` structs. They are valid for the duration of the callback
1563
+ * only!
1564
+ *
1565
+ * For maximum portability, use multi-second intervals. Sub-second intervals
1566
+ * will not detect all changes on many file systems.
1567
+ */
1568
+ UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
1569
+ uv_fs_poll_cb poll_cb,
1570
+ const char* path,
1571
+ unsigned int interval);
1572
+
1573
+ UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
1574
+
1575
+
1576
+ /*
1577
+ * UNIX signal handling on a per-event loop basis. The implementation is not
1578
+ * ultra efficient so don't go creating a million event loops with a million
1579
+ * signal watchers.
1580
+ *
1581
+ * TODO(bnoordhuis) As of 2012-08-10 only the default event loop supports
1582
+ * signals. That will be fixed.
1583
+ */
1584
+ struct uv_signal_s {
1585
+ UV_HANDLE_FIELDS
1586
+ uv_signal_cb signal_cb;
1587
+ UV_SIGNAL_PRIVATE_FIELDS
1588
+ };
1589
+
1590
+ /* These functions are no-ops on Windows. */
1591
+ int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle);
1592
+ int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum);
1593
+ int uv_signal_stop(uv_signal_t* handle);
1594
+
1595
+
1596
+ /*
1597
+ * Gets load avg
1598
+ * See: http://en.wikipedia.org/wiki/Load_(computing)
1599
+ * (Returns [0,0,0] for windows and cygwin)
1600
+ */
1601
+ UV_EXTERN void uv_loadavg(double avg[3]);
1602
+
1603
+
1604
+ /*
1605
+ * Flags to be passed to uv_fs_event_init.
1606
+ */
1607
+ enum uv_fs_event_flags {
1608
+ /*
1609
+ * By default, if the fs event watcher is given a directory name, we will
1610
+ * watch for all events in that directory. This flags overrides this behavior
1611
+ * and makes fs_event report only changes to the directory entry itself. This
1612
+ * flag does not affect individual files watched.
1613
+ * This flag is currently not implemented yet on any backend.
1614
+ */
1615
+ UV_FS_EVENT_WATCH_ENTRY = 1,
1616
+
1617
+ /*
1618
+ * By default uv_fs_event will try to use a kernel interface such as inotify
1619
+ * or kqueue to detect events. This may not work on remote filesystems such
1620
+ * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
1621
+ * regular interval.
1622
+ * This flag is currently not implemented yet on any backend.
1623
+ */
1624
+ UV_FS_EVENT_STAT = 2
1625
+ };
1626
+
1627
+
1628
+ UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
1629
+ const char* filename, uv_fs_event_cb cb, int flags);
1630
+
1631
+ /* Utility */
1632
+
1633
+ /* Convert string ip addresses to binary structures */
1634
+ UV_EXTERN struct sockaddr_in uv_ip4_addr(const char* ip, int port);
1635
+ UV_EXTERN struct sockaddr_in6 uv_ip6_addr(const char* ip, int port);
1636
+
1637
+ /* Convert binary addresses to strings */
1638
+ UV_EXTERN int uv_ip4_name(struct sockaddr_in* src, char* dst, size_t size);
1639
+ UV_EXTERN int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size);
1640
+
1641
+ /* Cross-platform IPv6-capable implementation of the 'standard' inet_ntop */
1642
+ /* and inet_pton functions. On success they return UV_OK. If an error */
1643
+ /* the target of the `dst` pointer is unmodified. */
1644
+ uv_err_t uv_inet_ntop(int af, const void* src, char* dst, size_t size);
1645
+ uv_err_t uv_inet_pton(int af, const char* src, void* dst);
1646
+
1647
+ /* Gets the executable path */
1648
+ UV_EXTERN int uv_exepath(char* buffer, size_t* size);
1649
+
1650
+ /* Gets the current working directory */
1651
+ UV_EXTERN uv_err_t uv_cwd(char* buffer, size_t size);
1652
+
1653
+ /* Changes the current working directory */
1654
+ UV_EXTERN uv_err_t uv_chdir(const char* dir);
1655
+
1656
+ /* Gets memory info in bytes */
1657
+ UV_EXTERN uint64_t uv_get_free_memory(void);
1658
+ UV_EXTERN uint64_t uv_get_total_memory(void);
1659
+
1660
+ /*
1661
+ * Returns the current high-resolution real time. This is expressed in
1662
+ * nanoseconds. It is relative to an arbitrary time in the past. It is not
1663
+ * related to the time of day and therefore not subject to clock drift. The
1664
+ * primary use is for measuring performance between intervals.
1665
+ *
1666
+ * Note not every platform can support nanosecond resolution; however, this
1667
+ * value will always be in nanoseconds.
1668
+ */
1669
+ UV_EXTERN extern uint64_t uv_hrtime(void);
1670
+
1671
+
1672
+ /*
1673
+ * Disables inheritance for file descriptors / handles that this process
1674
+ * inherited from its parent. The effect is that child processes spawned by
1675
+ * this proces don't accidently inherit these handles.
1676
+ *
1677
+ * It is recommended to call this function as early in your program as possible,
1678
+ * before the inherited file descriptors can be closed or duplicated.
1679
+ *
1680
+ * Note that this function works on a best-effort basis: there is no guarantee
1681
+ * that libuv can discover all file descriptors that were inherited. In general
1682
+ * it does a better job on Windows than it does on unix.
1683
+ *
1684
+ * TODO(bb): insert snarky remark to annoy bnoordhuis and the folks at joyent.
1685
+ */
1686
+ UV_EXTERN void uv_disable_stdio_inheritance(void);
1687
+
1688
+ /*
1689
+ * Opens a shared library. The filename is in utf-8. Returns 0 on success and
1690
+ * -1 on error. Call `uv_dlerror(uv_lib_t*)` to get the error message.
1691
+ */
1692
+ UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib);
1693
+
1694
+ /*
1695
+ * Close the shared libary.
1696
+ */
1697
+ UV_EXTERN void uv_dlclose(uv_lib_t* lib);
1698
+
1699
+ /*
1700
+ * Retrieves a data pointer from a dynamic library. It is legal for a symbol to
1701
+ * map to NULL. Returns 0 on success and -1 if the symbol was not found.
1702
+ */
1703
+ UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
1704
+
1705
+ /*
1706
+ * Returns the last uv_dlopen() or uv_dlsym() error message.
1707
+ */
1708
+ UV_EXTERN const char* uv_dlerror(uv_lib_t* lib);
1709
+
1710
+ /*
1711
+ * The mutex functions return 0 on success, -1 on error
1712
+ * (unless the return type is void, of course).
1713
+ */
1714
+ UV_EXTERN int uv_mutex_init(uv_mutex_t* handle);
1715
+ UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
1716
+ UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
1717
+ UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle);
1718
+ UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
1719
+
1720
+ /*
1721
+ * Same goes for the read/write lock functions.
1722
+ */
1723
+ UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock);
1724
+ UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock);
1725
+ UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock);
1726
+ UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock);
1727
+ UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock);
1728
+ UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
1729
+ UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
1730
+ UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
1731
+
1732
+ /*
1733
+ * Same goes for the semaphore functions.
1734
+ */
1735
+ UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
1736
+ UV_EXTERN void uv_sem_destroy(uv_sem_t* sem);
1737
+ UV_EXTERN void uv_sem_post(uv_sem_t* sem);
1738
+ UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
1739
+ UV_EXTERN int uv_sem_trywait(uv_sem_t* sem);
1740
+
1741
+ /* Runs a function once and only once. Concurrent calls to uv_once() with the
1742
+ * same guard will block all callers except one (it's unspecified which one).
1743
+ * The guard should be initialized statically with the UV_ONCE_INIT macro.
1744
+ */
1745
+ UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
1746
+
1747
+ UV_EXTERN int uv_thread_create(uv_thread_t *tid,
1748
+ void (*entry)(void *arg), void *arg);
1749
+ UV_EXTERN int uv_thread_join(uv_thread_t *tid);
1750
+
1751
+ /* the presence of these unions force similar struct layout */
1752
+ union uv_any_handle {
1753
+ uv_handle_t handle;
1754
+ uv_stream_t stream;
1755
+ uv_tcp_t tcp;
1756
+ uv_pipe_t pipe;
1757
+ uv_prepare_t prepare;
1758
+ uv_check_t check;
1759
+ uv_idle_t idle;
1760
+ uv_async_t async;
1761
+ uv_timer_t timer;
1762
+ uv_fs_event_t fs_event;
1763
+ uv_fs_poll_t fs_poll;
1764
+ uv_poll_t poll;
1765
+ uv_process_t process;
1766
+ uv_tty_t tty;
1767
+ uv_udp_t udp;
1768
+ };
1769
+
1770
+ union uv_any_req {
1771
+ uv_req_t req;
1772
+ uv_write_t write;
1773
+ uv_connect_t connect;
1774
+ uv_shutdown_t shutdown;
1775
+ uv_fs_t fs_req;
1776
+ uv_work_t work_req;
1777
+ uv_udp_send_t udp_send_req;
1778
+ uv_getaddrinfo_t getaddrinfo_req;
1779
+ };
1780
+
1781
+
1782
+ struct uv_counters_s {
1783
+ uint64_t async_init;
1784
+ uint64_t check_init;
1785
+ uint64_t eio_init;
1786
+ uint64_t fs_event_init;
1787
+ uint64_t fs_poll_init;
1788
+ uint64_t handle_init;
1789
+ uint64_t idle_init;
1790
+ uint64_t pipe_init;
1791
+ uint64_t poll_init;
1792
+ uint64_t prepare_init;
1793
+ uint64_t process_init;
1794
+ uint64_t req_init;
1795
+ uint64_t stream_init;
1796
+ uint64_t tcp_init;
1797
+ uint64_t timer_init;
1798
+ uint64_t tty_init;
1799
+ uint64_t udp_init;
1800
+ };
1801
+
1802
+
1803
+ struct uv_loop_s {
1804
+ UV_LOOP_PRIVATE_FIELDS
1805
+ /* The last error */
1806
+ uv_err_t last_err;
1807
+ /* Loop reference counting */
1808
+ unsigned int active_handles;
1809
+ ngx_queue_t handle_queue;
1810
+ ngx_queue_t active_reqs;
1811
+ /* User data - use this for whatever. */
1812
+ void* data;
1813
+ };
1814
+
1815
+
1816
+ /* Don't export the private CPP symbols. */
1817
+ #undef UV_HANDLE_TYPE_PRIVATE
1818
+ #undef UV_REQ_TYPE_PRIVATE
1819
+ #undef UV_REQ_PRIVATE_FIELDS
1820
+ #undef UV_STREAM_PRIVATE_FIELDS
1821
+ #undef UV_TCP_PRIVATE_FIELDS
1822
+ #undef UV_PREPARE_PRIVATE_FIELDS
1823
+ #undef UV_CHECK_PRIVATE_FIELDS
1824
+ #undef UV_IDLE_PRIVATE_FIELDS
1825
+ #undef UV_ASYNC_PRIVATE_FIELDS
1826
+ #undef UV_TIMER_PRIVATE_FIELDS
1827
+ #undef UV_GETADDRINFO_PRIVATE_FIELDS
1828
+ #undef UV_FS_REQ_PRIVATE_FIELDS
1829
+ #undef UV_WORK_PRIVATE_FIELDS
1830
+ #undef UV_FS_EVENT_PRIVATE_FIELDS
1831
+ #undef UV_SIGNAL_PRIVATE_FIELDS
1832
+ #undef UV_LOOP_PRIVATE_FIELDS
1833
+ #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
1834
+
1835
+ #ifdef __cplusplus
1836
+ }
1837
+ #endif
1838
+ #endif /* UV_H */