eventmachine 1.2.0.dev.2-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +105 -0
  3. data/GNU +281 -0
  4. data/LICENSE +60 -0
  5. data/README.md +108 -0
  6. data/docs/DocumentationGuidesIndex.md +27 -0
  7. data/docs/GettingStarted.md +521 -0
  8. data/docs/old/ChangeLog +211 -0
  9. data/docs/old/DEFERRABLES +246 -0
  10. data/docs/old/EPOLL +141 -0
  11. data/docs/old/INSTALL +13 -0
  12. data/docs/old/KEYBOARD +42 -0
  13. data/docs/old/LEGAL +25 -0
  14. data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
  15. data/docs/old/PURE_RUBY +75 -0
  16. data/docs/old/RELEASE_NOTES +94 -0
  17. data/docs/old/SMTP +4 -0
  18. data/docs/old/SPAWNED_PROCESSES +148 -0
  19. data/docs/old/TODO +8 -0
  20. data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
  21. data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
  22. data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
  23. data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
  24. data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
  25. data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
  26. data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
  27. data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
  28. data/examples/old/ex_channel.rb +43 -0
  29. data/examples/old/ex_queue.rb +2 -0
  30. data/examples/old/ex_tick_loop_array.rb +15 -0
  31. data/examples/old/ex_tick_loop_counter.rb +32 -0
  32. data/examples/old/helper.rb +2 -0
  33. data/ext/binder.cpp +124 -0
  34. data/ext/binder.h +46 -0
  35. data/ext/cmain.cpp +988 -0
  36. data/ext/ed.cpp +2111 -0
  37. data/ext/ed.h +442 -0
  38. data/ext/em.cpp +2379 -0
  39. data/ext/em.h +308 -0
  40. data/ext/eventmachine.h +143 -0
  41. data/ext/extconf.rb +270 -0
  42. data/ext/fastfilereader/extconf.rb +110 -0
  43. data/ext/fastfilereader/mapper.cpp +216 -0
  44. data/ext/fastfilereader/mapper.h +59 -0
  45. data/ext/fastfilereader/rubymain.cpp +127 -0
  46. data/ext/kb.cpp +79 -0
  47. data/ext/page.cpp +107 -0
  48. data/ext/page.h +51 -0
  49. data/ext/pipe.cpp +354 -0
  50. data/ext/project.h +176 -0
  51. data/ext/rubymain.cpp +1504 -0
  52. data/ext/ssl.cpp +615 -0
  53. data/ext/ssl.h +103 -0
  54. data/java/.classpath +8 -0
  55. data/java/.project +17 -0
  56. data/java/src/com/rubyeventmachine/EmReactor.java +591 -0
  57. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  58. data/java/src/com/rubyeventmachine/EventableChannel.java +72 -0
  59. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +201 -0
  60. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +415 -0
  61. data/lib/2.0/fastfilereaderext.so +0 -0
  62. data/lib/2.0/rubyeventmachine.so +0 -0
  63. data/lib/2.1/fastfilereaderext.so +0 -0
  64. data/lib/2.1/rubyeventmachine.so +0 -0
  65. data/lib/2.2/fastfilereaderext.so +0 -0
  66. data/lib/2.2/rubyeventmachine.so +0 -0
  67. data/lib/2.3/fastfilereaderext.so +0 -0
  68. data/lib/2.3/rubyeventmachine.so +0 -0
  69. data/lib/em/buftok.rb +59 -0
  70. data/lib/em/callback.rb +58 -0
  71. data/lib/em/channel.rb +69 -0
  72. data/lib/em/completion.rb +304 -0
  73. data/lib/em/connection.rb +770 -0
  74. data/lib/em/deferrable.rb +210 -0
  75. data/lib/em/deferrable/pool.rb +2 -0
  76. data/lib/em/file_watch.rb +73 -0
  77. data/lib/em/future.rb +61 -0
  78. data/lib/em/iterator.rb +252 -0
  79. data/lib/em/messages.rb +66 -0
  80. data/lib/em/pool.rb +151 -0
  81. data/lib/em/process_watch.rb +45 -0
  82. data/lib/em/processes.rb +123 -0
  83. data/lib/em/protocols.rb +37 -0
  84. data/lib/em/protocols/header_and_content.rb +138 -0
  85. data/lib/em/protocols/httpclient.rb +299 -0
  86. data/lib/em/protocols/httpclient2.rb +600 -0
  87. data/lib/em/protocols/line_and_text.rb +125 -0
  88. data/lib/em/protocols/line_protocol.rb +29 -0
  89. data/lib/em/protocols/linetext2.rb +166 -0
  90. data/lib/em/protocols/memcache.rb +331 -0
  91. data/lib/em/protocols/object_protocol.rb +46 -0
  92. data/lib/em/protocols/postgres3.rb +246 -0
  93. data/lib/em/protocols/saslauth.rb +175 -0
  94. data/lib/em/protocols/smtpclient.rb +394 -0
  95. data/lib/em/protocols/smtpserver.rb +666 -0
  96. data/lib/em/protocols/socks4.rb +66 -0
  97. data/lib/em/protocols/stomp.rb +205 -0
  98. data/lib/em/protocols/tcptest.rb +54 -0
  99. data/lib/em/pure_ruby.rb +1022 -0
  100. data/lib/em/queue.rb +80 -0
  101. data/lib/em/resolver.rb +232 -0
  102. data/lib/em/spawnable.rb +84 -0
  103. data/lib/em/streamer.rb +118 -0
  104. data/lib/em/threaded_resource.rb +90 -0
  105. data/lib/em/tick_loop.rb +85 -0
  106. data/lib/em/timers.rb +61 -0
  107. data/lib/em/version.rb +3 -0
  108. data/lib/eventmachine.rb +1584 -0
  109. data/lib/fastfilereaderext.rb +2 -0
  110. data/lib/jeventmachine.rb +301 -0
  111. data/lib/rubyeventmachine.rb +2 -0
  112. data/rakelib/package.rake +120 -0
  113. data/rakelib/test.rake +8 -0
  114. data/tests/client.crt +31 -0
  115. data/tests/client.key +51 -0
  116. data/tests/dhparam.pem +13 -0
  117. data/tests/em_test_helper.rb +151 -0
  118. data/tests/test_attach.rb +151 -0
  119. data/tests/test_basic.rb +283 -0
  120. data/tests/test_channel.rb +75 -0
  121. data/tests/test_completion.rb +178 -0
  122. data/tests/test_connection_count.rb +54 -0
  123. data/tests/test_connection_write.rb +35 -0
  124. data/tests/test_defer.rb +35 -0
  125. data/tests/test_deferrable.rb +35 -0
  126. data/tests/test_epoll.rb +142 -0
  127. data/tests/test_error_handler.rb +38 -0
  128. data/tests/test_exc.rb +28 -0
  129. data/tests/test_file_watch.rb +66 -0
  130. data/tests/test_fork.rb +75 -0
  131. data/tests/test_futures.rb +170 -0
  132. data/tests/test_get_sock_opt.rb +37 -0
  133. data/tests/test_handler_check.rb +35 -0
  134. data/tests/test_hc.rb +155 -0
  135. data/tests/test_httpclient.rb +233 -0
  136. data/tests/test_httpclient2.rb +128 -0
  137. data/tests/test_idle_connection.rb +25 -0
  138. data/tests/test_inactivity_timeout.rb +54 -0
  139. data/tests/test_ipv4.rb +125 -0
  140. data/tests/test_ipv6.rb +131 -0
  141. data/tests/test_iterator.rb +115 -0
  142. data/tests/test_kb.rb +28 -0
  143. data/tests/test_line_protocol.rb +33 -0
  144. data/tests/test_ltp.rb +138 -0
  145. data/tests/test_ltp2.rb +308 -0
  146. data/tests/test_many_fds.rb +22 -0
  147. data/tests/test_next_tick.rb +104 -0
  148. data/tests/test_object_protocol.rb +36 -0
  149. data/tests/test_pause.rb +107 -0
  150. data/tests/test_pending_connect_timeout.rb +52 -0
  151. data/tests/test_pool.rb +196 -0
  152. data/tests/test_process_watch.rb +50 -0
  153. data/tests/test_processes.rb +128 -0
  154. data/tests/test_proxy_connection.rb +180 -0
  155. data/tests/test_pure.rb +88 -0
  156. data/tests/test_queue.rb +64 -0
  157. data/tests/test_resolver.rb +104 -0
  158. data/tests/test_running.rb +14 -0
  159. data/tests/test_sasl.rb +47 -0
  160. data/tests/test_send_file.rb +217 -0
  161. data/tests/test_servers.rb +33 -0
  162. data/tests/test_set_sock_opt.rb +39 -0
  163. data/tests/test_shutdown_hooks.rb +23 -0
  164. data/tests/test_smtpclient.rb +75 -0
  165. data/tests/test_smtpserver.rb +57 -0
  166. data/tests/test_spawn.rb +293 -0
  167. data/tests/test_ssl_args.rb +78 -0
  168. data/tests/test_ssl_dhparam.rb +83 -0
  169. data/tests/test_ssl_ecdh_curve.rb +79 -0
  170. data/tests/test_ssl_extensions.rb +49 -0
  171. data/tests/test_ssl_methods.rb +65 -0
  172. data/tests/test_ssl_protocols.rb +246 -0
  173. data/tests/test_ssl_verify.rb +126 -0
  174. data/tests/test_stomp.rb +37 -0
  175. data/tests/test_system.rb +46 -0
  176. data/tests/test_threaded_resource.rb +61 -0
  177. data/tests/test_tick_loop.rb +59 -0
  178. data/tests/test_timers.rb +123 -0
  179. data/tests/test_ud.rb +8 -0
  180. data/tests/test_unbind_reason.rb +52 -0
  181. metadata +381 -0
@@ -0,0 +1,308 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: em.h
6
+ Date: 06Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #ifndef __EventMachine__H_
21
+ #define __EventMachine__H_
22
+
23
+ #ifdef BUILD_FOR_RUBY
24
+ #include <ruby.h>
25
+ #ifdef HAVE_RB_THREAD_FD_SELECT
26
+ #define EmSelect rb_thread_fd_select
27
+ #else
28
+ // ruby 1.9.1 and below
29
+ #define EmSelect rb_thread_select
30
+ #endif
31
+
32
+ #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
33
+ #include <ruby/thread.h>
34
+ #endif
35
+
36
+ #ifdef HAVE_RB_WAIT_FOR_SINGLE_FD
37
+ #include <ruby/io.h>
38
+ #endif
39
+
40
+ #if defined(HAVE_RB_TRAP_IMMEDIATE)
41
+ #include <rubysig.h>
42
+ #elif defined(HAVE_RB_ENABLE_INTERRUPT)
43
+ extern "C" {
44
+ void rb_enable_interrupt(void);
45
+ void rb_disable_interrupt(void);
46
+ }
47
+
48
+ #define TRAP_BEG rb_enable_interrupt()
49
+ #define TRAP_END do { rb_disable_interrupt(); rb_thread_check_ints(); } while(0)
50
+ #else
51
+ #define TRAP_BEG
52
+ #define TRAP_END
53
+ #endif
54
+
55
+ // 1.9.0 compat
56
+ #ifndef RUBY_UBF_IO
57
+ #define RUBY_UBF_IO RB_UBF_DFL
58
+ #endif
59
+ #ifndef RSTRING_PTR
60
+ #define RSTRING_PTR(str) RSTRING(str)->ptr
61
+ #endif
62
+ #ifndef RSTRING_LEN
63
+ #define RSTRING_LEN(str) RSTRING(str)->len
64
+ #endif
65
+ #ifndef RSTRING_LENINT
66
+ #define RSTRING_LENINT(str) RSTRING_LEN(str)
67
+ #endif
68
+ #else
69
+ #define EmSelect select
70
+ #endif
71
+
72
+ #if !defined(HAVE_TYPE_RB_FDSET_T)
73
+ #define fd_check(n) (((n) < FD_SETSIZE) ? 1 : 0*fprintf(stderr, "fd %d too large for select\n", (n)))
74
+ // These definitions are cribbed from include/ruby/intern.h in Ruby 1.9.3,
75
+ // with this change: any macros that read or write the nth element of an
76
+ // fdset first call fd_check to make sure n is in bounds.
77
+ typedef fd_set rb_fdset_t;
78
+ #define rb_fd_zero(f) FD_ZERO(f)
79
+ #define rb_fd_set(n, f) do { if (fd_check(n)) FD_SET((n), (f)); } while(0)
80
+ #define rb_fd_clr(n, f) do { if (fd_check(n)) FD_CLR((n), (f)); } while(0)
81
+ #define rb_fd_isset(n, f) (fd_check(n) ? FD_ISSET((n), (f)) : 0)
82
+ #define rb_fd_copy(d, s, n) (*(d) = *(s))
83
+ #define rb_fd_dup(d, s) (*(d) = *(s))
84
+ #define rb_fd_resize(n, f) ((void)(f))
85
+ #define rb_fd_ptr(f) (f)
86
+ #define rb_fd_init(f) FD_ZERO(f)
87
+ #define rb_fd_init_copy(d, s) (*(d) = *(s))
88
+ #define rb_fd_term(f) ((void)(f))
89
+ #define rb_fd_max(f) FD_SETSIZE
90
+ #define rb_fd_select(n, rfds, wfds, efds, timeout) \
91
+ select(fd_check((n)-1) ? (n) : FD_SETSIZE, (rfds), (wfds), (efds), (timeout))
92
+ #define rb_thread_fd_select(n, rfds, wfds, efds, timeout) \
93
+ rb_thread_select(fd_check((n)-1) ? (n) : FD_SETSIZE, (rfds), (wfds), (efds), (timeout))
94
+ #endif
95
+
96
+
97
+ // This Solaris fix is adapted from eval_intern.h in Ruby 1.9.3:
98
+ // Solaris sys/select.h switches select to select_large_fdset to support larger
99
+ // file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment.
100
+ // But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically.
101
+ // So following definition is required to use select_large_fdset.
102
+ #ifdef HAVE_SELECT_LARGE_FDSET
103
+ #define select(n, r, w, e, t) select_large_fdset((n), (r), (w), (e), (t))
104
+ extern "C" {
105
+ int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval *);
106
+ }
107
+ #endif
108
+
109
+ class EventableDescriptor;
110
+ class InotifyDescriptor;
111
+ struct SelectData_t;
112
+
113
+ /*************
114
+ enum Poller_t
115
+ *************/
116
+ enum Poller_t {
117
+ Poller_Default, // typically Select
118
+ Poller_Epoll,
119
+ Poller_Kqueue
120
+ };
121
+
122
+
123
+ /********************
124
+ class EventMachine_t
125
+ ********************/
126
+
127
+ class EventMachine_t
128
+ {
129
+ public:
130
+ static int GetMaxTimerCount();
131
+ static void SetMaxTimerCount (int);
132
+
133
+ static int GetSimultaneousAcceptCount();
134
+ static void SetSimultaneousAcceptCount (int);
135
+
136
+ public:
137
+ EventMachine_t (EMCallback, Poller_t);
138
+ virtual ~EventMachine_t();
139
+
140
+ bool RunOnce();
141
+ void Run();
142
+ void ScheduleHalt();
143
+ bool Stopping();
144
+ void SignalLoopBreaker();
145
+ const uintptr_t InstallOneshotTimer (int);
146
+ const uintptr_t ConnectToServer (const char *, int, const char *, int);
147
+ const uintptr_t ConnectToUnixServer (const char *);
148
+
149
+ const uintptr_t CreateTcpServer (const char *, int);
150
+ const uintptr_t OpenDatagramSocket (const char *, int);
151
+ const uintptr_t CreateUnixDomainServer (const char*);
152
+ const uintptr_t AttachSD (SOCKET);
153
+ const uintptr_t OpenKeyboard();
154
+ //const char *Popen (const char*, const char*);
155
+ const uintptr_t Socketpair (char* const*);
156
+
157
+ void Add (EventableDescriptor*);
158
+ void Modify (EventableDescriptor*);
159
+ void Deregister (EventableDescriptor*);
160
+
161
+ const uintptr_t AttachFD (SOCKET, bool);
162
+ int DetachFD (EventableDescriptor*);
163
+
164
+ void ArmKqueueWriter (EventableDescriptor*);
165
+ void ArmKqueueReader (EventableDescriptor*);
166
+
167
+ void SetTimerQuantum (int);
168
+ static void SetuidString (const char*);
169
+ static int SetRlimitNofile (int);
170
+
171
+ pid_t SubprocessPid;
172
+ int SubprocessExitStatus;
173
+
174
+ int GetConnectionCount();
175
+ float GetHeartbeatInterval();
176
+ int SetHeartbeatInterval(float);
177
+
178
+ const uintptr_t WatchFile (const char*);
179
+ void UnwatchFile (int);
180
+ void UnwatchFile (const uintptr_t);
181
+
182
+ #ifdef HAVE_KQUEUE
183
+ void _HandleKqueueFileEvent (struct kevent*);
184
+ void _RegisterKqueueFileEvent(int);
185
+ #endif
186
+
187
+ const uintptr_t WatchPid (int);
188
+ void UnwatchPid (int);
189
+ void UnwatchPid (const uintptr_t);
190
+
191
+ #ifdef HAVE_KQUEUE
192
+ void _HandleKqueuePidEvent (struct kevent*);
193
+ #endif
194
+
195
+ uint64_t GetCurrentLoopTime() { return MyCurrentLoopTime; }
196
+
197
+ void QueueHeartbeat(EventableDescriptor*);
198
+ void ClearHeartbeat(uint64_t, EventableDescriptor*);
199
+
200
+ uint64_t GetRealTime();
201
+
202
+ Poller_t GetPoller() { return Poller; }
203
+
204
+ static bool name2address (const char *server, int port, struct sockaddr *addr, size_t *addr_len);
205
+
206
+ private:
207
+ void _RunTimers();
208
+ void _UpdateTime();
209
+ void _AddNewDescriptors();
210
+ void _ModifyDescriptors();
211
+ void _InitializeLoopBreaker();
212
+ void _CleanupSockets();
213
+
214
+ void _RunSelectOnce();
215
+ void _RunEpollOnce();
216
+ void _RunKqueueOnce();
217
+
218
+ void _ModifyEpollEvent (EventableDescriptor*);
219
+ void _DispatchHeartbeats();
220
+ timeval _TimeTilNextEvent();
221
+ void _CleanBadDescriptors();
222
+
223
+ public:
224
+ void _ReadLoopBreaker();
225
+ void _ReadInotifyEvents();
226
+ int NumCloseScheduled;
227
+
228
+ private:
229
+ enum {
230
+ MaxEpollDescriptors = 64*1024,
231
+ MaxEvents = 4096
232
+ };
233
+ int HeartbeatInterval;
234
+ EMCallback EventCallback;
235
+
236
+ class Timer_t: public Bindable_t {
237
+ };
238
+
239
+ multimap<uint64_t, Timer_t> Timers;
240
+ multimap<uint64_t, EventableDescriptor*> Heartbeats;
241
+ map<int, Bindable_t*> Files;
242
+ map<int, Bindable_t*> Pids;
243
+ vector<EventableDescriptor*> Descriptors;
244
+ vector<EventableDescriptor*> NewDescriptors;
245
+ set<EventableDescriptor*> ModifiedDescriptors;
246
+
247
+ SOCKET LoopBreakerReader;
248
+ SOCKET LoopBreakerWriter;
249
+ #ifdef OS_WIN32
250
+ struct sockaddr_in LoopBreakerTarget;
251
+ #endif
252
+
253
+ timeval Quantum;
254
+
255
+ uint64_t MyCurrentLoopTime;
256
+
257
+ #ifdef OS_WIN32
258
+ unsigned TickCountTickover;
259
+ unsigned LastTickCount;
260
+ #endif
261
+
262
+ #ifdef OS_DARWIN
263
+ mach_timebase_info_data_t mach_timebase;
264
+ #endif
265
+
266
+ private:
267
+ bool bTerminateSignalReceived;
268
+ SelectData_t *SelectData;
269
+
270
+ Poller_t Poller;
271
+
272
+ int epfd; // Epoll file-descriptor
273
+ #ifdef HAVE_EPOLL
274
+ struct epoll_event epoll_events [MaxEvents];
275
+ #endif
276
+
277
+ int kqfd; // Kqueue file-descriptor
278
+ #ifdef HAVE_KQUEUE
279
+ struct kevent Karray [MaxEvents];
280
+ #endif
281
+
282
+ #ifdef HAVE_INOTIFY
283
+ InotifyDescriptor *inotify; // pollable descriptor for our inotify instance
284
+ #endif
285
+ };
286
+
287
+
288
+ /*******************
289
+ struct SelectData_t
290
+ *******************/
291
+
292
+ struct SelectData_t
293
+ {
294
+ SelectData_t();
295
+ ~SelectData_t();
296
+
297
+ int _Select();
298
+ void _Clear();
299
+
300
+ SOCKET maxsocket;
301
+ rb_fdset_t fdreads;
302
+ rb_fdset_t fdwrites;
303
+ rb_fdset_t fderrors;
304
+ timeval tv;
305
+ int nSockets;
306
+ };
307
+
308
+ #endif // __EventMachine__H_
@@ -0,0 +1,143 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: eventmachine.h
6
+ Date: 15Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #ifndef __EVMA_EventMachine__H_
21
+ #define __EVMA_EventMachine__H_
22
+
23
+ #if __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ enum { // Event names
28
+ EM_TIMER_FIRED = 100,
29
+ EM_CONNECTION_READ = 101,
30
+ EM_CONNECTION_UNBOUND = 102,
31
+ EM_CONNECTION_ACCEPTED = 103,
32
+ EM_CONNECTION_COMPLETED = 104,
33
+ EM_LOOPBREAK_SIGNAL = 105,
34
+ EM_CONNECTION_NOTIFY_READABLE = 106,
35
+ EM_CONNECTION_NOTIFY_WRITABLE = 107,
36
+ EM_SSL_HANDSHAKE_COMPLETED = 108,
37
+ EM_SSL_VERIFY = 109,
38
+ EM_PROXY_TARGET_UNBOUND = 110,
39
+ EM_PROXY_COMPLETED = 111
40
+ };
41
+
42
+ enum { // SSL/TLS Protocols
43
+ EM_PROTO_SSLv2 = 2,
44
+ EM_PROTO_SSLv3 = 4,
45
+ EM_PROTO_TLSv1 = 8,
46
+ EM_PROTO_TLSv1_1 = 16,
47
+ EM_PROTO_TLSv1_2 = 32
48
+ };
49
+
50
+ void evma_initialize_library (EMCallback);
51
+ bool evma_run_machine_once();
52
+ void evma_run_machine();
53
+ void evma_release_library();
54
+ const uintptr_t evma_install_oneshot_timer (int seconds);
55
+ const uintptr_t evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port);
56
+ const uintptr_t evma_connect_to_unix_server (const char *server);
57
+
58
+ const uintptr_t evma_attach_fd (int file_descriptor, int watch_mode);
59
+ int evma_detach_fd (const uintptr_t binding);
60
+ int evma_get_file_descriptor (const uintptr_t binding);
61
+ int evma_is_notify_readable (const uintptr_t binding);
62
+ void evma_set_notify_readable (const uintptr_t binding, int mode);
63
+ int evma_is_notify_writable (const uintptr_t binding);
64
+ void evma_set_notify_writable (const uintptr_t binding, int mode);
65
+
66
+ int evma_pause(const uintptr_t binding);
67
+ int evma_is_paused(const uintptr_t binding);
68
+ int evma_resume(const uintptr_t binding);
69
+
70
+ int evma_num_close_scheduled();
71
+
72
+ void evma_stop_tcp_server (const uintptr_t binding);
73
+ const uintptr_t evma_create_tcp_server (const char *address, int port);
74
+ const uintptr_t evma_create_unix_domain_server (const char *filename);
75
+ const uintptr_t evma_attach_sd (int sd);
76
+ const uintptr_t evma_open_datagram_socket (const char *server, int port);
77
+ const uintptr_t evma_open_keyboard();
78
+ void evma_set_tls_parms (const uintptr_t binding, const char *privatekey_filename, const char *certchain_filenane, int verify_peer, int fail_if_no_peer_cert, const char *sni_hostname, const char *cipherlist, const char *ecdh_curve, const char *dhparam, int protocols);
79
+ void evma_start_tls (const uintptr_t binding);
80
+
81
+ #ifdef WITH_SSL
82
+ X509 *evma_get_peer_cert (const uintptr_t binding);
83
+ int evma_get_cipher_bits (const uintptr_t binding);
84
+ const char *evma_get_cipher_name (const uintptr_t binding);
85
+ const char *evma_get_cipher_protocol (const uintptr_t binding);
86
+ const char *evma_get_sni_hostname (const uintptr_t binding);
87
+ void evma_accept_ssl_peer (const uintptr_t binding);
88
+ #endif
89
+
90
+ int evma_get_peername (const uintptr_t binding, struct sockaddr*, socklen_t*);
91
+ int evma_get_sockname (const uintptr_t binding, struct sockaddr*, socklen_t*);
92
+ int evma_get_subprocess_pid (const uintptr_t binding, pid_t*);
93
+ int evma_get_subprocess_status (const uintptr_t binding, int*);
94
+ int evma_get_connection_count();
95
+ int evma_send_data_to_connection (const uintptr_t binding, const char *data, int data_length);
96
+ int evma_send_datagram (const uintptr_t binding, const char *data, int data_length, const char *address, int port);
97
+ float evma_get_comm_inactivity_timeout (const uintptr_t binding);
98
+ int evma_set_comm_inactivity_timeout (const uintptr_t binding, float value);
99
+ float evma_get_pending_connect_timeout (const uintptr_t binding);
100
+ int evma_set_pending_connect_timeout (const uintptr_t binding, float value);
101
+ int evma_get_outbound_data_size (const uintptr_t binding);
102
+ uint64_t evma_get_last_activity_time (const uintptr_t binding);
103
+ int evma_send_file_data_to_connection (const uintptr_t binding, const char *filename);
104
+
105
+ void evma_close_connection (const uintptr_t binding, int after_writing);
106
+ int evma_report_connection_error_status (const uintptr_t binding);
107
+ void evma_signal_loopbreak();
108
+ void evma_set_timer_quantum (int);
109
+ int evma_get_max_timer_count();
110
+ void evma_set_max_timer_count (int);
111
+ int evma_get_simultaneous_accept_count();
112
+ void evma_set_simultaneous_accept_count (int);
113
+ void evma_setuid_string (const char *username);
114
+ void evma_stop_machine();
115
+ bool evma_stopping();
116
+ float evma_get_heartbeat_interval();
117
+ int evma_set_heartbeat_interval(float);
118
+
119
+ const uintptr_t evma_popen (char * const*cmd_strings);
120
+
121
+ const uintptr_t evma_watch_filename (const char *fname);
122
+ void evma_unwatch_filename (const uintptr_t binding);
123
+
124
+ const uintptr_t evma_watch_pid (int);
125
+ void evma_unwatch_pid (const uintptr_t binding);
126
+
127
+ void evma_start_proxy(const uintptr_t from, const uintptr_t to, const unsigned long bufsize, const unsigned long length);
128
+ void evma_stop_proxy(const uintptr_t from);
129
+ unsigned long evma_proxied_bytes(const uintptr_t from);
130
+
131
+ int evma_set_rlimit_nofile (int n_files);
132
+
133
+ void evma_set_epoll (int use);
134
+ void evma_set_kqueue (int use);
135
+
136
+ uint64_t evma_get_current_loop_time();
137
+ #if __cplusplus
138
+ }
139
+ #endif
140
+
141
+
142
+ #endif // __EventMachine__H_
143
+