… | |
… | |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | /*#include <netinet/in.h>*/ |
5 | /*#include <netinet/in.h>*/ |
6 | |
6 | |
7 | #define EV_PROTOTYPES 1 |
7 | #define EV_PROTOTYPES 1 |
|
|
8 | #define EV_H <ev.h> |
8 | #include "EV/EVAPI.h" |
9 | #include "EV/EVAPI.h" |
9 | |
10 | |
10 | /* fix perl api breakage */ |
11 | /* fix perl api breakage */ |
11 | #undef signal |
12 | #undef signal |
12 | #undef sigaction |
13 | #undef sigaction |
… | |
… | |
17 | # define NFDBITS PERL_NFDBITS |
18 | # define NFDBITS PERL_NFDBITS |
18 | # define fd_mask Perl_fd_mask |
19 | # define fd_mask Perl_fd_mask |
19 | #endif |
20 | #endif |
20 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
21 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
21 | #include "libev/ev.c" |
22 | #include "libev/ev.c" |
22 | #include "event.c" |
|
|
23 | |
|
|
24 | #ifndef _WIN32 |
|
|
25 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
|
|
26 | #if !defined (WIN32) && !defined(__CYGWIN__) |
|
|
27 | # define HAVE_STRUCT_IN6_ADDR 1 |
|
|
28 | #endif |
|
|
29 | #undef HAVE_STRTOK_R |
|
|
30 | #undef strtok_r |
|
|
31 | #define strtok_r fake_strtok_r |
|
|
32 | #include "evdns.h" |
|
|
33 | #include "evdns.c" |
|
|
34 | #endif |
|
|
35 | |
23 | |
36 | #ifndef _WIN32 |
24 | #ifndef _WIN32 |
37 | # include <pthread.h> |
25 | # include <pthread.h> |
38 | #endif |
26 | #endif |
39 | |
27 | |
40 | #define WFLAG_KEEPALIVE 1 |
28 | #define WFLAG_KEEPALIVE 1 |
41 | |
29 | |
42 | #define UNREF(w) \ |
30 | #define UNREF(w) \ |
43 | if (!((w)->flags & WFLAG_KEEPALIVE) \ |
31 | if (!((w)->flags & WFLAG_KEEPALIVE) \ |
44 | && !ev_is_active (w)) \ |
32 | && !ev_is_active (w)) \ |
45 | ev_unref (); |
33 | ev_unref (w->loop); |
46 | |
34 | |
47 | #define REF(w) \ |
35 | #define REF(w) \ |
48 | if (!((w)->flags & WFLAG_KEEPALIVE) \ |
36 | if (!((w)->flags & WFLAG_KEEPALIVE) \ |
49 | && ev_is_active (w)) \ |
37 | && ev_is_active (w)) \ |
50 | ev_ref (); |
38 | ev_ref (w->loop); |
51 | |
39 | |
52 | #define START(type,w) \ |
40 | #define START(type,w) \ |
53 | do { \ |
41 | do { \ |
54 | UNREF (w); \ |
42 | UNREF (w); \ |
55 | ev_ ## type ## _start (w); \ |
43 | ev_ ## type ## _start (w->loop, w); \ |
56 | } while (0) |
44 | } while (0) |
57 | |
45 | |
58 | #define STOP(type,w) \ |
46 | #define STOP(type,w) \ |
59 | do { \ |
47 | do { \ |
60 | REF (w); \ |
48 | REF (w); \ |
61 | ev_ ## type ## _stop (w); \ |
49 | ev_ ## type ## _stop (w->loop, w); \ |
62 | } while (0) |
50 | } while (0) |
|
|
51 | |
|
|
52 | #define RESET(type,w,seta) \ |
|
|
53 | do { \ |
|
|
54 | int active = ev_is_active (w); \ |
|
|
55 | if (active) STOP (type, w); \ |
|
|
56 | ev_ ## type ## _set seta; \ |
|
|
57 | if (active) START (type, w); \ |
|
|
58 | } while (0) |
63 | |
59 | |
64 | typedef int Signal; |
60 | typedef int Signal; |
65 | |
61 | |
66 | static struct EVAPI evapi; |
62 | static struct EVAPI evapi; |
67 | |
63 | |
… | |
… | |
69 | *stash_watcher, |
65 | *stash_watcher, |
70 | *stash_io, |
66 | *stash_io, |
71 | *stash_timer, |
67 | *stash_timer, |
72 | *stash_periodic, |
68 | *stash_periodic, |
73 | *stash_signal, |
69 | *stash_signal, |
|
|
70 | *stash_child, |
|
|
71 | *stash_stat, |
74 | *stash_idle, |
72 | *stash_idle, |
75 | *stash_prepare, |
73 | *stash_prepare, |
76 | *stash_check, |
74 | *stash_check, |
77 | *stash_child; |
75 | *stash_embed, |
|
|
76 | *stash_fork; |
78 | |
77 | |
79 | #ifndef SIG_SIZE |
78 | #ifndef SIG_SIZE |
80 | /* kudos to Slaven Rezic for the idea */ |
79 | /* kudos to Slaven Rezic for the idea */ |
81 | static char sig_size [] = { SIG_NUM }; |
80 | static char sig_size [] = { SIG_NUM }; |
82 | # define SIG_SIZE (sizeof (sig_size) + 1) |
81 | # define SIG_SIZE (sizeof (sig_size) + 1) |
83 | #endif |
82 | #endif |
84 | |
83 | |
85 | static int |
84 | static Signal |
86 | sv_signum (SV *sig) |
85 | sv_signum (SV *sig) |
87 | { |
86 | { |
88 | int signum; |
87 | Signal signum; |
89 | |
88 | |
90 | SvGETMAGIC (sig); |
89 | SvGETMAGIC (sig); |
91 | |
90 | |
92 | for (signum = 1; signum < SIG_SIZE; ++signum) |
91 | for (signum = 1; signum < SIG_SIZE; ++signum) |
93 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
92 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
94 | return signum; |
93 | return signum; |
95 | |
94 | |
96 | if (SvIV (sig) > 0) |
95 | signum = SvIV (sig); |
|
|
96 | |
|
|
97 | if (signum > 0 && signum < SIG_SIZE) |
97 | return SvIV (sig); |
98 | return signum; |
98 | |
99 | |
99 | return -1; |
100 | return -1; |
100 | } |
101 | } |
101 | |
102 | |
102 | ///////////////////////////////////////////////////////////////////////////// |
103 | ///////////////////////////////////////////////////////////////////////////// |
103 | // Event |
104 | // Event |
104 | |
105 | |
105 | static void e_cb (ev_watcher *w, int revents); |
106 | static void e_cb (EV_P_ ev_watcher *w, int revents); |
106 | |
107 | |
107 | static int |
108 | static int |
108 | sv_fileno (SV *fh) |
109 | sv_fileno (SV *fh) |
109 | { |
110 | { |
110 | SvGETMAGIC (fh); |
111 | SvGETMAGIC (fh); |
… | |
… | |
131 | |
132 | |
132 | w = (ev_watcher *)SvPVX (self); |
133 | w = (ev_watcher *)SvPVX (self); |
133 | |
134 | |
134 | ev_init (w, e_cb); |
135 | ev_init (w, e_cb); |
135 | |
136 | |
|
|
137 | w->loop = EV_DEFAULT; |
136 | w->flags = WFLAG_KEEPALIVE; |
138 | w->flags = WFLAG_KEEPALIVE; |
137 | w->data = 0; |
139 | w->data = 0; |
138 | w->fh = 0; |
140 | w->fh = 0; |
139 | w->cb_sv = newSVsv (cb_sv); |
141 | w->cb_sv = newSVsv (cb_sv); |
140 | w->self = self; |
142 | w->self = self; |
… | |
… | |
170 | } |
172 | } |
171 | |
173 | |
172 | static SV *sv_events_cache; |
174 | static SV *sv_events_cache; |
173 | |
175 | |
174 | static void |
176 | static void |
175 | e_cb (ev_watcher *w, int revents) |
177 | e_cb (EV_P_ ev_watcher *w, int revents) |
176 | { |
178 | { |
177 | dSP; |
179 | dSP; |
178 | I32 mark = SP - PL_stack_base; |
180 | I32 mark = SP - PL_stack_base; |
179 | SV *sv_self, *sv_events; |
181 | SV *sv_self, *sv_events; |
180 | |
182 | |
… | |
… | |
203 | else |
205 | else |
204 | sv_events_cache = sv_events; |
206 | sv_events_cache = sv_events; |
205 | |
207 | |
206 | if (SvTRUE (ERRSV)) |
208 | if (SvTRUE (ERRSV)) |
207 | { |
209 | { |
|
|
210 | SPAGAIN; |
208 | PUSHMARK (SP); |
211 | PUSHMARK (SP); |
209 | PUTBACK; |
212 | PUTBACK; |
210 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
213 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
211 | } |
214 | } |
212 | |
215 | |
… | |
… | |
242 | else |
245 | else |
243 | sv_events_cache = sv_events; |
246 | sv_events_cache = sv_events; |
244 | |
247 | |
245 | if (SvTRUE (ERRSV)) |
248 | if (SvTRUE (ERRSV)) |
246 | { |
249 | { |
|
|
250 | SPAGAIN; |
247 | PUSHMARK (SP); |
251 | PUSHMARK (SP); |
248 | PUTBACK; |
252 | PUTBACK; |
249 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
253 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
250 | } |
254 | } |
251 | |
255 | |
… | |
… | |
294 | LEAVE; |
298 | LEAVE; |
295 | |
299 | |
296 | return retval; |
300 | return retval; |
297 | } |
301 | } |
298 | |
302 | |
299 | ///////////////////////////////////////////////////////////////////////////// |
|
|
300 | // DNS |
|
|
301 | |
|
|
302 | #ifndef _WIN32 |
|
|
303 | static void |
|
|
304 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
|
|
305 | { |
|
|
306 | dSP; |
|
|
307 | SV *cb = (SV *)arg; |
|
|
308 | |
|
|
309 | ENTER; |
|
|
310 | SAVETMPS; |
|
|
311 | PUSHMARK (SP); |
|
|
312 | EXTEND (SP, count + 3); |
|
|
313 | PUSHs (sv_2mortal (newSViv (result))); |
|
|
314 | |
|
|
315 | if (result == DNS_ERR_NONE && ttl >= 0) |
|
|
316 | { |
|
|
317 | int i; |
|
|
318 | |
|
|
319 | PUSHs (sv_2mortal (newSViv (type))); |
|
|
320 | PUSHs (sv_2mortal (newSViv (ttl))); |
|
|
321 | |
|
|
322 | for (i = 0; i < count; ++i) |
|
|
323 | switch (type) |
|
|
324 | { |
|
|
325 | case DNS_IPv6_AAAA: |
|
|
326 | PUSHs (sv_2mortal (newSVpvn (i * 16 + (char *)addresses, 16))); |
|
|
327 | break; |
|
|
328 | case DNS_IPv4_A: |
|
|
329 | PUSHs (sv_2mortal (newSVpvn (i * 4 + (char *)addresses, 4))); |
|
|
330 | break; |
|
|
331 | case DNS_PTR: |
|
|
332 | PUSHs (sv_2mortal (newSVpv (*(char **)addresses, 0))); |
|
|
333 | break; |
|
|
334 | } |
|
|
335 | } |
|
|
336 | |
|
|
337 | PUTBACK; |
|
|
338 | call_sv (sv_2mortal (cb), G_DISCARD | G_VOID | G_EVAL); |
|
|
339 | |
|
|
340 | FREETMPS; |
|
|
341 | |
|
|
342 | if (SvTRUE (ERRSV)) |
|
|
343 | { |
|
|
344 | PUSHMARK (SP); |
|
|
345 | PUTBACK; |
|
|
346 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
347 | } |
|
|
348 | |
|
|
349 | LEAVE; |
|
|
350 | } |
|
|
351 | #endif |
|
|
352 | |
|
|
353 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
303 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
354 | croak (# repeat " value must be >= 0"); |
304 | croak (# repeat " value must be >= 0"); |
355 | |
305 | |
356 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
306 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
357 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
307 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
|
|
308 | |
|
|
309 | #define CHECK_SIG(sv,num) if ((num) < 0) \ |
|
|
310 | croak ("illegal signal number or name: %s", SvPV_nolen (sv)); |
358 | |
311 | |
359 | ///////////////////////////////////////////////////////////////////////////// |
312 | ///////////////////////////////////////////////////////////////////////////// |
360 | // XS interface functions |
313 | // XS interface functions |
361 | |
314 | |
362 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
315 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
… | |
… | |
396 | const_iv (EV, BACKEND_KQUEUE) |
349 | const_iv (EV, BACKEND_KQUEUE) |
397 | const_iv (EV, BACKEND_DEVPOLL) |
350 | const_iv (EV, BACKEND_DEVPOLL) |
398 | const_iv (EV, BACKEND_PORT) |
351 | const_iv (EV, BACKEND_PORT) |
399 | const_iv (EV, FLAG_AUTO) |
352 | const_iv (EV, FLAG_AUTO) |
400 | const_iv (EV, FLAG_NOENV) |
353 | const_iv (EV, FLAG_NOENV) |
|
|
354 | const_iv (EV, FLAG_FORKCHECK) |
401 | }; |
355 | }; |
402 | |
356 | |
403 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
357 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
404 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
358 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
405 | |
359 | |
… | |
… | |
410 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
364 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
411 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
365 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
412 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
366 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
413 | stash_check = gv_stashpv ("EV::Check" , 1); |
367 | stash_check = gv_stashpv ("EV::Check" , 1); |
414 | stash_child = gv_stashpv ("EV::Child" , 1); |
368 | stash_child = gv_stashpv ("EV::Child" , 1); |
|
|
369 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
|
|
370 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
|
|
371 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
415 | |
372 | |
416 | { |
373 | { |
417 | SV *sv = perl_get_sv ("EV::API", TRUE); |
374 | SV *sv = perl_get_sv ("EV::API", TRUE); |
418 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
375 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
419 | |
376 | |
420 | /* the poor man's shared library emulator */ |
377 | /* the poor man's shared library emulator */ |
421 | evapi.ver = EV_API_VERSION; |
378 | evapi.ver = EV_API_VERSION; |
422 | evapi.rev = EV_API_REVISION; |
379 | evapi.rev = EV_API_REVISION; |
423 | evapi.sv_fileno = sv_fileno; |
380 | evapi.sv_fileno = sv_fileno; |
424 | evapi.sv_signum = sv_signum; |
381 | evapi.sv_signum = sv_signum; |
|
|
382 | evapi.supported_backends = ev_supported_backends (); |
|
|
383 | evapi.recommended_backends = ev_recommended_backends (); |
|
|
384 | evapi.embeddable_backends = ev_embeddable_backends (); |
|
|
385 | evapi.time = ev_time; |
|
|
386 | evapi.loop_new = ev_loop_new; |
|
|
387 | evapi.loop_destroy = ev_loop_destroy; |
|
|
388 | evapi.loop_fork = ev_loop_fork; |
|
|
389 | evapi.loop_count = ev_loop_count; |
425 | evapi.now = ev_now; |
390 | evapi.now = ev_now; |
426 | evapi.backend = ev_backend; |
391 | evapi.backend = ev_backend; |
427 | evapi.unloop = ev_unloop; |
392 | evapi.unloop = ev_unloop; |
428 | evapi.time = ev_time; |
393 | evapi.ref = ev_ref; |
|
|
394 | evapi.unref = ev_unref; |
429 | evapi.loop = ev_loop; |
395 | evapi.loop = ev_loop; |
430 | evapi.once = ev_once; |
396 | evapi.once = ev_once; |
431 | evapi.io_start = ev_io_start; |
397 | evapi.io_start = ev_io_start; |
432 | evapi.io_stop = ev_io_stop; |
398 | evapi.io_stop = ev_io_stop; |
433 | evapi.timer_start = ev_timer_start; |
399 | evapi.timer_start = ev_timer_start; |
434 | evapi.timer_stop = ev_timer_stop; |
400 | evapi.timer_stop = ev_timer_stop; |
435 | evapi.timer_again = ev_timer_again; |
401 | evapi.timer_again = ev_timer_again; |
436 | evapi.periodic_start = ev_periodic_start; |
402 | evapi.periodic_start = ev_periodic_start; |
437 | evapi.periodic_stop = ev_periodic_stop; |
403 | evapi.periodic_stop = ev_periodic_stop; |
438 | evapi.signal_start = ev_signal_start; |
404 | evapi.signal_start = ev_signal_start; |
439 | evapi.signal_stop = ev_signal_stop; |
405 | evapi.signal_stop = ev_signal_stop; |
440 | evapi.idle_start = ev_idle_start; |
406 | evapi.idle_start = ev_idle_start; |
441 | evapi.idle_stop = ev_idle_stop; |
407 | evapi.idle_stop = ev_idle_stop; |
442 | evapi.prepare_start = ev_prepare_start; |
408 | evapi.prepare_start = ev_prepare_start; |
443 | evapi.prepare_stop = ev_prepare_stop; |
409 | evapi.prepare_stop = ev_prepare_stop; |
444 | evapi.check_start = ev_check_start; |
410 | evapi.check_start = ev_check_start; |
445 | evapi.check_stop = ev_check_stop; |
411 | evapi.check_stop = ev_check_stop; |
446 | evapi.child_start = ev_child_start; |
412 | evapi.child_start = ev_child_start; |
447 | evapi.child_stop = ev_child_stop; |
413 | evapi.child_stop = ev_child_stop; |
|
|
414 | evapi.stat_start = ev_stat_start; |
|
|
415 | evapi.stat_stop = ev_stat_stop; |
|
|
416 | evapi.stat_stat = ev_stat_stat; |
|
|
417 | evapi.embed_start = ev_embed_start; |
|
|
418 | evapi.embed_stop = ev_embed_stop; |
|
|
419 | evapi.embed_sweep = ev_embed_sweep; |
|
|
420 | evapi.fork_start = ev_fork_start; |
|
|
421 | evapi.fork_stop = ev_fork_stop; |
|
|
422 | evapi.clear_pending = ev_clear_pending; |
448 | evapi.ref = ev_ref; |
423 | evapi.invoke = ev_invoke; |
449 | evapi.unref = ev_unref; |
|
|
450 | |
424 | |
451 | sv_setiv (sv, (IV)&evapi); |
425 | sv_setiv (sv, (IV)&evapi); |
452 | SvREADONLY_on (sv); |
426 | SvREADONLY_on (sv); |
453 | } |
427 | } |
454 | #ifndef _WIN32 |
428 | #ifndef _WIN32 |
455 | pthread_atfork (0, 0, ev_default_fork); |
429 | pthread_atfork (0, 0, ev_default_fork); |
456 | #endif |
430 | #endif |
457 | } |
431 | } |
458 | |
432 | |
|
|
433 | SV *ev_default_loop (unsigned int flags = ev_supported_backends ()) |
|
|
434 | CODE: |
|
|
435 | { |
|
|
436 | evapi.default_loop = ev_default_loop (flags); |
|
|
437 | if (!evapi.default_loop) |
|
|
438 | XSRETURN_UNDEF; |
|
|
439 | |
|
|
440 | RETVAL = sv_bless (newRV_noinc (newSViv (PTR2IV (ev_default_loop (flags)))), |
|
|
441 | gv_stashpv ("EV::Loop::Default", 1)); |
|
|
442 | } |
|
|
443 | OUTPUT: |
|
|
444 | RETVAL |
|
|
445 | |
|
|
446 | NV ev_time () |
|
|
447 | |
459 | NV ev_now () |
448 | NV ev_now () |
|
|
449 | C_ARGS: evapi.default_loop |
460 | |
450 | |
461 | unsigned int ev_backend () |
451 | unsigned int ev_backend () |
|
|
452 | C_ARGS: evapi.default_loop |
462 | |
453 | |
463 | NV ev_time () |
454 | unsigned int ev_loop_count () |
464 | |
455 | C_ARGS: evapi.default_loop |
465 | unsigned int ev_default_loop (unsigned int flags = ev_supported_backends ()) |
|
|
466 | |
456 | |
467 | void ev_loop (int flags = 0) |
457 | void ev_loop (int flags = 0) |
|
|
458 | C_ARGS: evapi.default_loop, flags |
468 | |
459 | |
469 | void ev_unloop (int how = 1) |
460 | void ev_unloop (int how = 1) |
|
|
461 | C_ARGS: evapi.default_loop, how |
|
|
462 | |
|
|
463 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
|
|
464 | C_ARGS: evapi.default_loop, fd, revents |
|
|
465 | |
|
|
466 | void ev_feed_signal_event (SV *signal) |
|
|
467 | CODE: |
|
|
468 | { |
|
|
469 | Signal signum = sv_signum (signal); |
|
|
470 | CHECK_SIG (signal, signum); |
|
|
471 | |
|
|
472 | ev_feed_signal_event (evapi.default_loop, signum); |
|
|
473 | } |
470 | |
474 | |
471 | ev_io *io (SV *fh, int events, SV *cb) |
475 | ev_io *io (SV *fh, int events, SV *cb) |
472 | ALIAS: |
476 | ALIAS: |
473 | io_ns = 1 |
477 | io_ns = 1 |
474 | CODE: |
478 | CODE: |
… | |
… | |
511 | if (!ix) START (periodic, w); |
515 | if (!ix) START (periodic, w); |
512 | } |
516 | } |
513 | OUTPUT: |
517 | OUTPUT: |
514 | RETVAL |
518 | RETVAL |
515 | |
519 | |
516 | ev_signal *signal (Signal signum, SV *cb) |
520 | ev_signal *signal (SV *signal, SV *cb) |
517 | ALIAS: |
521 | ALIAS: |
518 | signal_ns = 1 |
522 | signal_ns = 1 |
519 | CODE: |
523 | CODE: |
|
|
524 | { |
|
|
525 | Signal signum = sv_signum (signal); |
|
|
526 | CHECK_SIG (signal, signum); |
|
|
527 | |
520 | RETVAL = e_new (sizeof (ev_signal), cb); |
528 | RETVAL = e_new (sizeof (ev_signal), cb); |
521 | ev_signal_set (RETVAL, signum); |
529 | ev_signal_set (RETVAL, signum); |
522 | if (!ix) START (signal, RETVAL); |
530 | if (!ix) START (signal, RETVAL); |
|
|
531 | } |
523 | OUTPUT: |
532 | OUTPUT: |
524 | RETVAL |
533 | RETVAL |
525 | |
534 | |
526 | ev_idle *idle (SV *cb) |
535 | ev_idle *idle (SV *cb) |
527 | ALIAS: |
536 | ALIAS: |
… | |
… | |
551 | ev_check_set (RETVAL); |
560 | ev_check_set (RETVAL); |
552 | if (!ix) START (check, RETVAL); |
561 | if (!ix) START (check, RETVAL); |
553 | OUTPUT: |
562 | OUTPUT: |
554 | RETVAL |
563 | RETVAL |
555 | |
564 | |
|
|
565 | ev_fork *fork (SV *cb) |
|
|
566 | ALIAS: |
|
|
567 | fork_ns = 1 |
|
|
568 | CODE: |
|
|
569 | RETVAL = e_new (sizeof (ev_fork), cb); |
|
|
570 | ev_fork_set (RETVAL); |
|
|
571 | if (!ix) START (fork, RETVAL); |
|
|
572 | OUTPUT: |
|
|
573 | RETVAL |
|
|
574 | |
556 | ev_child *child (int pid, SV *cb) |
575 | ev_child *child (int pid, SV *cb) |
557 | ALIAS: |
576 | ALIAS: |
558 | child_ns = 1 |
577 | child_ns = 1 |
559 | CODE: |
578 | CODE: |
560 | RETVAL = e_new (sizeof (ev_child), cb); |
579 | RETVAL = e_new (sizeof (ev_child), cb); |
561 | ev_child_set (RETVAL, pid); |
580 | ev_child_set (RETVAL, pid); |
562 | if (!ix) START (child, RETVAL); |
581 | if (!ix) START (child, RETVAL); |
563 | OUTPUT: |
582 | OUTPUT: |
564 | RETVAL |
583 | RETVAL |
565 | |
584 | |
|
|
585 | ev_stat *stat (SV *path, NV interval, SV *cb) |
|
|
586 | ALIAS: |
|
|
587 | stat_ns = 1 |
|
|
588 | CODE: |
|
|
589 | RETVAL = e_new (sizeof (ev_stat), cb); |
|
|
590 | RETVAL->fh = newSVsv (path); |
|
|
591 | ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); |
|
|
592 | if (!ix) START (stat, RETVAL); |
|
|
593 | OUTPUT: |
|
|
594 | RETVAL |
|
|
595 | |
566 | void once (SV *fh, int events, SV *timeout, SV *cb) |
596 | void once (SV *fh, int events, SV *timeout, SV *cb) |
567 | CODE: |
597 | CODE: |
568 | ev_once ( |
598 | ev_once ( |
|
|
599 | evapi.default_loop, |
569 | sv_fileno (fh), events, |
600 | sv_fileno (fh), events, |
570 | SvOK (timeout) ? SvNV (timeout) : -1., |
601 | SvOK (timeout) ? SvNV (timeout) : -1., |
571 | e_once_cb, |
602 | e_once_cb, |
572 | newSVsv (cb) |
603 | newSVsv (cb) |
573 | ); |
604 | ); |
… | |
… | |
577 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
608 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
578 | |
609 | |
579 | int ev_is_active (ev_watcher *w) |
610 | int ev_is_active (ev_watcher *w) |
580 | |
611 | |
581 | int ev_is_pending (ev_watcher *w) |
612 | int ev_is_pending (ev_watcher *w) |
|
|
613 | |
|
|
614 | void ev_invoke (ev_watcher *w, int revents = EV_NONE) |
|
|
615 | C_ARGS: w->loop, w, revents |
|
|
616 | |
|
|
617 | int ev_clear_pending (ev_watcher *w) |
|
|
618 | C_ARGS: w->loop, w |
|
|
619 | |
|
|
620 | void ev_feed_event (ev_watcher *w, int revents = EV_NONE) |
|
|
621 | C_ARGS: w->loop, w, revents |
582 | |
622 | |
583 | int keepalive (ev_watcher *w, int new_value = 0) |
623 | int keepalive (ev_watcher *w, int new_value = 0) |
584 | CODE: |
624 | CODE: |
585 | { |
625 | { |
586 | RETVAL = w->flags & WFLAG_KEEPALIVE; |
626 | RETVAL = w->flags & WFLAG_KEEPALIVE; |
… | |
… | |
609 | |
649 | |
610 | SV *data (ev_watcher *w, SV *new_data = 0) |
650 | SV *data (ev_watcher *w, SV *new_data = 0) |
611 | CODE: |
651 | CODE: |
612 | { |
652 | { |
613 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
653 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
614 | } |
|
|
615 | OUTPUT: |
|
|
616 | RETVAL |
|
|
617 | |
654 | |
618 | void trigger (ev_watcher *w, int revents = EV_NONE) |
655 | if (items > 1) |
619 | CODE: |
656 | { |
620 | w->cb (w, revents); |
657 | SvREFCNT_dec (w->data); |
|
|
658 | w->data = newSVsv (new_data); |
|
|
659 | } |
|
|
660 | } |
|
|
661 | OUTPUT: |
|
|
662 | RETVAL |
621 | |
663 | |
622 | int priority (ev_watcher *w, int new_priority = 0) |
664 | int priority (ev_watcher *w, int new_priority = 0) |
623 | CODE: |
665 | CODE: |
624 | { |
666 | { |
625 | RETVAL = w->priority; |
667 | RETVAL = w->priority; |
626 | |
668 | |
627 | if (items > 1) |
669 | if (items > 1) |
628 | { |
670 | { |
629 | int active = ev_is_active (w); |
671 | int active = ev_is_active (w); |
630 | |
|
|
631 | if (new_priority < EV_MINPRI || new_priority > EV_MAXPRI) |
|
|
632 | croak ("watcher priority out of range, value must be between %d and %d, inclusive", EV_MINPRI, EV_MAXPRI); |
|
|
633 | |
672 | |
634 | if (active) |
673 | if (active) |
635 | { |
674 | { |
636 | /* grrr. */ |
675 | /* grrr. */ |
637 | PUSHMARK (SP); |
676 | PUSHMARK (SP); |
638 | XPUSHs (ST (0)); |
677 | XPUSHs (ST (0)); |
|
|
678 | PUTBACK; |
639 | call_method ("stop", G_DISCARD | G_VOID); |
679 | call_method ("stop", G_DISCARD | G_VOID); |
640 | } |
680 | } |
641 | |
681 | |
642 | ev_set_priority (w, new_priority); |
682 | ev_set_priority (w, new_priority); |
643 | |
683 | |
644 | if (active) |
684 | if (active) |
645 | { |
685 | { |
646 | PUSHMARK (SP); |
686 | PUSHMARK (SP); |
647 | XPUSHs (ST (0)); |
687 | XPUSHs (ST (0)); |
|
|
688 | PUTBACK; |
648 | call_method ("start", G_DISCARD | G_VOID); |
689 | call_method ("start", G_DISCARD | G_VOID); |
649 | } |
690 | } |
650 | } |
691 | } |
651 | } |
692 | } |
652 | OUTPUT: |
693 | OUTPUT: |
… | |
… | |
668 | e_destroy (w); |
709 | e_destroy (w); |
669 | |
710 | |
670 | void set (ev_io *w, SV *fh, int events) |
711 | void set (ev_io *w, SV *fh, int events) |
671 | CODE: |
712 | CODE: |
672 | { |
713 | { |
673 | int active = ev_is_active (w); |
|
|
674 | int fd = sv_fileno (fh); |
714 | int fd = sv_fileno (fh); |
675 | CHECK_FD (fh, fd); |
715 | CHECK_FD (fh, fd); |
676 | |
716 | |
677 | if (active) STOP (io, w); |
|
|
678 | |
|
|
679 | sv_setsv (w->fh, fh); |
717 | sv_setsv (w->fh, fh); |
680 | ev_io_set (w, fd, events); |
718 | RESET (io, w, (w, fd, events)); |
681 | |
|
|
682 | if (active) START (io, w); |
|
|
683 | } |
719 | } |
684 | |
720 | |
685 | SV *fh (ev_io *w, SV *new_fh = 0) |
721 | SV *fh (ev_io *w, SV *new_fh = 0) |
686 | CODE: |
722 | CODE: |
687 | { |
723 | { |
688 | RETVAL = newSVsv (w->fh); |
|
|
689 | |
|
|
690 | if (items > 1) |
724 | if (items > 1) |
691 | { |
725 | { |
692 | int active = ev_is_active (w); |
726 | int fd = sv_fileno (new_fh); |
693 | if (active) STOP (io, w); |
727 | CHECK_FD (new_fh, fd); |
694 | |
728 | |
695 | sv_setsv (w->fh, new_fh); |
729 | RETVAL = w->fh; |
696 | ev_io_set (w, sv_fileno (w->fh), w->events); |
730 | w->fh = newSVsv (new_fh); |
697 | |
731 | |
698 | if (active) START (io, w); |
732 | RESET (io, w, (w, fd, w->events)); |
699 | } |
733 | } |
|
|
734 | else |
|
|
735 | RETVAL = newSVsv (w->fh); |
700 | } |
736 | } |
701 | OUTPUT: |
737 | OUTPUT: |
702 | RETVAL |
738 | RETVAL |
703 | |
739 | |
704 | int events (ev_io *w, int new_events = EV_UNDEF) |
740 | int events (ev_io *w, int new_events = EV_UNDEF) |
705 | CODE: |
741 | CODE: |
706 | { |
742 | { |
707 | RETVAL = w->events; |
743 | RETVAL = w->events; |
|
|
744 | |
|
|
745 | if (items > 1) |
|
|
746 | RESET (io, w, (w, w->fd, new_events)); |
|
|
747 | } |
|
|
748 | OUTPUT: |
|
|
749 | RETVAL |
|
|
750 | |
|
|
751 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
|
|
752 | |
|
|
753 | void ev_signal_start (ev_signal *w) |
|
|
754 | CODE: |
|
|
755 | START (signal, w); |
|
|
756 | |
|
|
757 | void ev_signal_stop (ev_signal *w) |
|
|
758 | CODE: |
|
|
759 | STOP (signal, w); |
|
|
760 | |
|
|
761 | void DESTROY (ev_signal *w) |
|
|
762 | CODE: |
|
|
763 | STOP (signal, w); |
|
|
764 | e_destroy (w); |
|
|
765 | |
|
|
766 | void set (ev_signal *w, SV *signal) |
|
|
767 | CODE: |
|
|
768 | { |
|
|
769 | Signal signum = sv_signum (signal); |
|
|
770 | CHECK_SIG (signal, signum); |
|
|
771 | |
|
|
772 | RESET (signal, w, (w, signum)); |
|
|
773 | } |
|
|
774 | |
|
|
775 | int signal (ev_signal *w, SV *new_signal = 0) |
|
|
776 | CODE: |
|
|
777 | { |
|
|
778 | RETVAL = w->signum; |
708 | |
779 | |
709 | if (items > 1) |
780 | if (items > 1) |
710 | { |
781 | { |
711 | int active = ev_is_active (w); |
|
|
712 | if (active) STOP (io, w); |
|
|
713 | |
|
|
714 | ev_io_set (w, w->fd, new_events); |
|
|
715 | |
|
|
716 | if (active) START (io, w); |
|
|
717 | } |
|
|
718 | } |
|
|
719 | OUTPUT: |
|
|
720 | RETVAL |
|
|
721 | |
|
|
722 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
|
|
723 | |
|
|
724 | void ev_signal_start (ev_signal *w) |
|
|
725 | CODE: |
|
|
726 | START (signal, w); |
|
|
727 | |
|
|
728 | void ev_signal_stop (ev_signal *w) |
|
|
729 | CODE: |
|
|
730 | STOP (signal, w); |
|
|
731 | |
|
|
732 | void DESTROY (ev_signal *w) |
|
|
733 | CODE: |
|
|
734 | STOP (signal, w); |
|
|
735 | e_destroy (w); |
|
|
736 | |
|
|
737 | void set (ev_signal *w, SV *signal) |
|
|
738 | CODE: |
|
|
739 | { |
|
|
740 | Signal signum = sv_signum (signal); /* may croak here */ |
|
|
741 | int active = ev_is_active (w); |
|
|
742 | |
|
|
743 | if (active) STOP (signal, w); |
|
|
744 | |
|
|
745 | ev_signal_set (w, signum); |
|
|
746 | |
|
|
747 | if (active) START (signal, w); |
|
|
748 | } |
|
|
749 | |
|
|
750 | int signal (ev_signal *w, SV *new_signal = 0) |
|
|
751 | CODE: |
|
|
752 | { |
|
|
753 | RETVAL = w->signum; |
|
|
754 | |
|
|
755 | if (items > 1) |
|
|
756 | { |
|
|
757 | Signal signum = sv_signum (new_signal); /* may croak here */ |
782 | Signal signum = sv_signum (new_signal); |
758 | int active = ev_is_active (w); |
783 | CHECK_SIG (new_signal, signum); |
759 | if (active) STOP (signal, w); |
|
|
760 | |
784 | |
761 | ev_signal_set (w, signum); |
785 | RESET (signal, w, (w, signum)); |
762 | |
|
|
763 | if (active) START (signal, w); |
|
|
764 | } |
786 | } |
765 | } |
787 | } |
766 | OUTPUT: |
788 | OUTPUT: |
767 | RETVAL |
789 | RETVAL |
768 | |
790 | |
… | |
… | |
781 | void ev_timer_again (ev_timer *w) |
803 | void ev_timer_again (ev_timer *w) |
782 | INIT: |
804 | INIT: |
783 | CHECK_REPEAT (w->repeat); |
805 | CHECK_REPEAT (w->repeat); |
784 | CODE: |
806 | CODE: |
785 | REF (w); |
807 | REF (w); |
786 | ev_timer_again (w); |
808 | ev_timer_again (w->loop, w); |
787 | UNREF (w); |
809 | UNREF (w); |
788 | |
810 | |
789 | void DESTROY (ev_timer *w) |
811 | void DESTROY (ev_timer *w) |
790 | CODE: |
812 | CODE: |
791 | STOP (timer, w); |
813 | STOP (timer, w); |
… | |
… | |
793 | |
815 | |
794 | void set (ev_timer *w, NV after, NV repeat = 0.) |
816 | void set (ev_timer *w, NV after, NV repeat = 0.) |
795 | INIT: |
817 | INIT: |
796 | CHECK_REPEAT (repeat); |
818 | CHECK_REPEAT (repeat); |
797 | CODE: |
819 | CODE: |
798 | { |
|
|
799 | int active = ev_is_active (w); |
|
|
800 | if (active) STOP (timer, w); |
|
|
801 | ev_timer_set (w, after, repeat); |
820 | RESET (timer, w, (w, after, repeat)); |
802 | if (active) START (timer, w); |
821 | |
803 | } |
822 | NV at (ev_timer *w) |
|
|
823 | CODE: |
|
|
824 | RETVAL = w->at; |
|
|
825 | OUTPUT: |
|
|
826 | RETVAL |
804 | |
827 | |
805 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
828 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
806 | |
829 | |
807 | void ev_periodic_start (ev_periodic *w) |
830 | void ev_periodic_start (ev_periodic *w) |
808 | INIT: |
831 | INIT: |
… | |
… | |
815 | STOP (periodic, w); |
838 | STOP (periodic, w); |
816 | |
839 | |
817 | void ev_periodic_again (ev_periodic *w) |
840 | void ev_periodic_again (ev_periodic *w) |
818 | CODE: |
841 | CODE: |
819 | REF (w); |
842 | REF (w); |
820 | ev_periodic_again (w); |
843 | ev_periodic_again (w->loop, w); |
821 | UNREF (w); |
844 | UNREF (w); |
822 | |
845 | |
823 | void DESTROY (ev_periodic *w) |
846 | void DESTROY (ev_periodic *w) |
824 | CODE: |
847 | CODE: |
825 | STOP (periodic, w); |
848 | STOP (periodic, w); |
… | |
… | |
828 | void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) |
851 | void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) |
829 | INIT: |
852 | INIT: |
830 | CHECK_REPEAT (interval); |
853 | CHECK_REPEAT (interval); |
831 | CODE: |
854 | CODE: |
832 | { |
855 | { |
833 | int active = ev_is_active (w); |
|
|
834 | if (active) STOP (periodic, w); |
|
|
835 | |
|
|
836 | SvREFCNT_dec (w->fh); |
856 | SvREFCNT_dec (w->fh); |
837 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
857 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
858 | |
838 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
859 | RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); |
839 | |
|
|
840 | if (active) START (periodic, w); |
|
|
841 | } |
860 | } |
|
|
861 | |
|
|
862 | NV at (ev_periodic *w) |
|
|
863 | CODE: |
|
|
864 | RETVAL = w->at; |
|
|
865 | OUTPUT: |
|
|
866 | RETVAL |
842 | |
867 | |
843 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
868 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
844 | |
869 | |
845 | void ev_idle_start (ev_idle *w) |
870 | void ev_idle_start (ev_idle *w) |
846 | CODE: |
871 | CODE: |
… | |
… | |
883 | void DESTROY (ev_check *w) |
908 | void DESTROY (ev_check *w) |
884 | CODE: |
909 | CODE: |
885 | STOP (check, w); |
910 | STOP (check, w); |
886 | e_destroy (w); |
911 | e_destroy (w); |
887 | |
912 | |
|
|
913 | MODULE = EV PACKAGE = EV::Fork PREFIX = ev_fork_ |
|
|
914 | |
|
|
915 | void ev_fork_start (ev_fork *w) |
|
|
916 | CODE: |
|
|
917 | START (fork, w); |
|
|
918 | |
|
|
919 | void ev_fork_stop (ev_fork *w) |
|
|
920 | CODE: |
|
|
921 | STOP (fork, w); |
|
|
922 | |
|
|
923 | void DESTROY (ev_fork *w) |
|
|
924 | CODE: |
|
|
925 | STOP (fork, w); |
|
|
926 | e_destroy (w); |
|
|
927 | |
888 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
928 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
889 | |
929 | |
890 | void ev_child_start (ev_child *w) |
930 | void ev_child_start (ev_child *w) |
891 | CODE: |
931 | CODE: |
892 | START (child, w); |
932 | START (child, w); |
… | |
… | |
900 | STOP (child, w); |
940 | STOP (child, w); |
901 | e_destroy (w); |
941 | e_destroy (w); |
902 | |
942 | |
903 | void set (ev_child *w, int pid) |
943 | void set (ev_child *w, int pid) |
904 | CODE: |
944 | CODE: |
905 | { |
945 | RESET (child, w, (w, pid)); |
906 | int active = ev_is_active (w); |
|
|
907 | if (active) STOP (child, w); |
|
|
908 | |
|
|
909 | ev_child_set (w, pid); |
|
|
910 | |
|
|
911 | if (active) START (child, w); |
|
|
912 | } |
|
|
913 | |
946 | |
914 | int pid (ev_child *w, int new_pid = 0) |
947 | int pid (ev_child *w, int new_pid = 0) |
915 | CODE: |
948 | CODE: |
916 | { |
949 | { |
917 | RETVAL = w->pid; |
950 | RETVAL = w->pid; |
918 | |
951 | |
919 | if (items > 1) |
952 | if (items > 1) |
920 | { |
953 | RESET (child, w, (w, new_pid)); |
921 | int active = ev_is_active (w); |
|
|
922 | if (active) STOP (child, w); |
|
|
923 | |
|
|
924 | ev_child_set (w, new_pid); |
|
|
925 | |
|
|
926 | if (active) START (child, w); |
|
|
927 | } |
|
|
928 | } |
954 | } |
929 | OUTPUT: |
955 | OUTPUT: |
930 | RETVAL |
956 | RETVAL |
931 | |
957 | |
932 | |
958 | |
… | |
… | |
936 | CODE: |
962 | CODE: |
937 | RETVAL = ix ? w->rpid : w->rstatus; |
963 | RETVAL = ix ? w->rpid : w->rstatus; |
938 | OUTPUT: |
964 | OUTPUT: |
939 | RETVAL |
965 | RETVAL |
940 | |
966 | |
941 | #ifndef _WIN32 |
|
|
942 | |
|
|
943 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
967 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
944 | |
968 | |
945 | BOOT: |
969 | void ev_stat_start (ev_stat *w) |
946 | { |
970 | CODE: |
947 | HV *stash = gv_stashpv ("EV::DNS", 1); |
971 | START (stat, w); |
948 | |
972 | |
949 | static const struct { |
973 | void ev_stat_stop (ev_stat *w) |
950 | const char *name; |
974 | CODE: |
951 | IV iv; |
975 | STOP (stat, w); |
952 | } *civ, const_iv[] = { |
|
|
953 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
954 | const_iv (DNS_, ERR_NONE) |
|
|
955 | const_iv (DNS_, ERR_FORMAT) |
|
|
956 | const_iv (DNS_, ERR_SERVERFAILED) |
|
|
957 | const_iv (DNS_, ERR_NOTEXIST) |
|
|
958 | const_iv (DNS_, ERR_NOTIMPL) |
|
|
959 | const_iv (DNS_, ERR_REFUSED) |
|
|
960 | const_iv (DNS_, ERR_TRUNCATED) |
|
|
961 | const_iv (DNS_, ERR_UNKNOWN) |
|
|
962 | const_iv (DNS_, ERR_TIMEOUT) |
|
|
963 | const_iv (DNS_, ERR_SHUTDOWN) |
|
|
964 | const_iv (DNS_, IPv4_A) |
|
|
965 | const_iv (DNS_, PTR) |
|
|
966 | const_iv (DNS_, IPv6_AAAA) |
|
|
967 | const_iv (DNS_, QUERY_NO_SEARCH) |
|
|
968 | const_iv (DNS_, OPTION_SEARCH) |
|
|
969 | const_iv (DNS_, OPTION_NAMESERVERS) |
|
|
970 | const_iv (DNS_, OPTION_MISC) |
|
|
971 | const_iv (DNS_, OPTIONS_ALL) |
|
|
972 | const_iv (DNS_, NO_SEARCH) |
|
|
973 | }; |
|
|
974 | |
976 | |
975 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
977 | void DESTROY (ev_stat *w) |
976 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
978 | CODE: |
977 | } |
979 | STOP (stat, w); |
|
|
980 | e_destroy (w); |
978 | |
981 | |
979 | int evdns_init () |
982 | void set (ev_stat *w, SV *path, NV interval) |
|
|
983 | CODE: |
|
|
984 | { |
|
|
985 | sv_setsv (w->fh, path); |
|
|
986 | RESET (stat, w, (w, SvPVbyte_nolen (w->fh), interval)); |
|
|
987 | } |
980 | |
988 | |
981 | void evdns_shutdown (int fail_requests = 1) |
989 | SV *path (ev_stat *w, SV *new_path = 0) |
|
|
990 | CODE: |
|
|
991 | { |
|
|
992 | RETVAL = SvREFCNT_inc (w->fh); |
982 | |
993 | |
983 | const char *evdns_err_to_string (int err) |
994 | if (items > 1) |
|
|
995 | { |
|
|
996 | SvREFCNT_dec (w->fh); |
|
|
997 | w->fh = newSVsv (new_path); |
|
|
998 | RESET (stat, w, (w, SvPVbyte_nolen (w->fh), w->interval)); |
|
|
999 | } |
|
|
1000 | } |
|
|
1001 | OUTPUT: |
|
|
1002 | RETVAL |
984 | |
1003 | |
985 | int evdns_nameserver_add (U32 address) |
1004 | NV interval (ev_stat *w, NV new_interval = 0.) |
|
|
1005 | CODE: |
|
|
1006 | { |
|
|
1007 | RETVAL = w->interval; |
986 | |
1008 | |
987 | int evdns_count_nameservers () |
1009 | if (items > 1) |
|
|
1010 | RESET (stat, w, (w, SvPVbyte_nolen (w->fh), new_interval)); |
|
|
1011 | } |
|
|
1012 | OUTPUT: |
|
|
1013 | RETVAL |
988 | |
1014 | |
989 | int evdns_clear_nameservers_and_suspend () |
1015 | void prev (ev_stat *w) |
990 | |
|
|
991 | int evdns_resume () |
|
|
992 | |
|
|
993 | int evdns_nameserver_ip_add (char *ip_as_string) |
|
|
994 | |
|
|
995 | int evdns_resolve_ipv4 (const char *name, int flags, SV *cb) |
|
|
996 | C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb) |
|
|
997 | |
|
|
998 | int evdns_resolve_ipv6 (const char *name, int flags, SV *cb) |
|
|
999 | C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb) |
|
|
1000 | |
|
|
1001 | int evdns_resolve_reverse (SV *addr, int flags, SV *cb) |
|
|
1002 | ALIAS: |
1016 | ALIAS: |
1003 | evdns_resolve_reverse_ipv6 = 1 |
1017 | stat = 1 |
1004 | CODE: |
1018 | attr = 2 |
|
|
1019 | PPCODE: |
1005 | { |
1020 | { |
1006 | STRLEN len; |
1021 | ev_statdata *s = ix ? &w->attr : &w->prev; |
1007 | char *data = SvPVbyte (addr, len); |
|
|
1008 | if (len != (ix ? 16 : 4)) |
|
|
1009 | croak ("ipv4/ipv6 address to be resolved must be given as 4/16 byte octet string"); |
|
|
1010 | |
1022 | |
1011 | RETVAL = ix |
1023 | if (ix == 1) |
1012 | ? evdns_resolve_reverse_ipv6 ((struct in6_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)) |
1024 | ev_stat_stat (w->loop, w); |
1013 | : evdns_resolve_reverse ((struct in_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)); |
1025 | else if (!s->st_nlink) |
1014 | } |
1026 | errno = ENOENT; |
1015 | OUTPUT: |
|
|
1016 | RETVAL |
|
|
1017 | |
1027 | |
1018 | int evdns_set_option (char *option, char *val, int flags) |
1028 | PL_statcache.st_dev = s->st_nlink; |
|
|
1029 | PL_statcache.st_ino = s->st_ino; |
|
|
1030 | PL_statcache.st_mode = s->st_mode; |
|
|
1031 | PL_statcache.st_nlink = s->st_nlink; |
|
|
1032 | PL_statcache.st_uid = s->st_uid; |
|
|
1033 | PL_statcache.st_gid = s->st_gid; |
|
|
1034 | PL_statcache.st_rdev = s->st_rdev; |
|
|
1035 | PL_statcache.st_size = s->st_size; |
|
|
1036 | PL_statcache.st_atime = s->st_atime; |
|
|
1037 | PL_statcache.st_mtime = s->st_mtime; |
|
|
1038 | PL_statcache.st_ctime = s->st_ctime; |
1019 | |
1039 | |
1020 | int evdns_resolv_conf_parse (int flags, const char *filename) |
1040 | if (GIMME_V == G_SCALAR) |
1021 | |
1041 | XPUSHs (boolSV (s->st_nlink)); |
1022 | #ifdef _WIN32 |
1042 | else if (GIMME_V == G_ARRAY && s->st_nlink) |
1023 | |
1043 | { |
1024 | int evdns_config_windows_nameservers () |
1044 | EXTEND (SP, 13); |
1025 | |
1045 | PUSHs (sv_2mortal (newSViv (s->st_dev))); |
1026 | #endif |
1046 | PUSHs (sv_2mortal (newSViv (s->st_ino))); |
1027 | |
1047 | PUSHs (sv_2mortal (newSVuv (s->st_mode))); |
1028 | void evdns_search_clear () |
1048 | PUSHs (sv_2mortal (newSVuv (s->st_nlink))); |
1029 | |
1049 | PUSHs (sv_2mortal (newSViv (s->st_uid))); |
1030 | void evdns_search_add (char *domain) |
1050 | PUSHs (sv_2mortal (newSViv (s->st_gid))); |
1031 | |
1051 | PUSHs (sv_2mortal (newSViv (s->st_rdev))); |
1032 | void evdns_search_ndots_set (int ndots) |
1052 | PUSHs (sv_2mortal (newSVnv ((NV)s->st_size))); |
|
|
1053 | PUSHs (sv_2mortal (newSVnv (s->st_atime))); |
|
|
1054 | PUSHs (sv_2mortal (newSVnv (s->st_mtime))); |
|
|
1055 | PUSHs (sv_2mortal (newSVnv (s->st_ctime))); |
|
|
1056 | PUSHs (sv_2mortal (newSVuv (4096))); |
|
|
1057 | PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096)))); |
|
|
1058 | } |
|
|
1059 | } |
1033 | |
1060 | |
1034 | #if 0 |
1061 | #if 0 |
1035 | |
1062 | |
1036 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
1063 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
1037 | |
1064 | |
… | |
… | |
1071 | |
1098 | |
1072 | #void DESTROY (struct evhttp_request *req); |
1099 | #void DESTROY (struct evhttp_request *req); |
1073 | |
1100 | |
1074 | #endif |
1101 | #endif |
1075 | |
1102 | |
1076 | #endif |
|
|
1077 | |
1103 | |
1078 | |
1104 | |
1079 | |
1105 | |
1080 | |
1106 | |
1081 | |
1107 | |