ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.xs
(Generate patch)

Comparing EV/EV.xs (file contents):
Revision 1.84 by root, Sat Dec 1 15:32:53 2007 UTC vs.
Revision 1.92 by root, Thu Dec 20 08:18:54 2007 UTC

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)
63 51
64#define RESET(type,w,seta) \ 52#define RESET(type,w,seta) \
65 do { \ 53 do { \
66 int active = ev_is_active (w); \ 54 int active = ev_is_active (w); \
113} 101}
114 102
115///////////////////////////////////////////////////////////////////////////// 103/////////////////////////////////////////////////////////////////////////////
116// Event 104// Event
117 105
118static void e_cb (ev_watcher *w, int revents); 106static void e_cb (EV_P_ ev_watcher *w, int revents);
119 107
120static int 108static int
121sv_fileno (SV *fh) 109sv_fileno (SV *fh)
122{ 110{
123 SvGETMAGIC (fh); 111 SvGETMAGIC (fh);
144 132
145 w = (ev_watcher *)SvPVX (self); 133 w = (ev_watcher *)SvPVX (self);
146 134
147 ev_init (w, e_cb); 135 ev_init (w, e_cb);
148 136
137 w->loop = EV_DEFAULT;
149 w->flags = WFLAG_KEEPALIVE; 138 w->flags = WFLAG_KEEPALIVE;
150 w->data = 0; 139 w->data = 0;
151 w->fh = 0; 140 w->fh = 0;
152 w->cb_sv = newSVsv (cb_sv); 141 w->cb_sv = newSVsv (cb_sv);
153 w->self = self; 142 w->self = self;
183} 172}
184 173
185static SV *sv_events_cache; 174static SV *sv_events_cache;
186 175
187static void 176static void
188e_cb (ev_watcher *w, int revents) 177e_cb (EV_P_ ev_watcher *w, int revents)
189{ 178{
190 dSP; 179 dSP;
191 I32 mark = SP - PL_stack_base; 180 I32 mark = SP - PL_stack_base;
192 SV *sv_self, *sv_events; 181 SV *sv_self, *sv_events;
193 182
256 else 245 else
257 sv_events_cache = sv_events; 246 sv_events_cache = sv_events;
258 247
259 if (SvTRUE (ERRSV)) 248 if (SvTRUE (ERRSV))
260 { 249 {
250 SPAGAIN;
261 PUSHMARK (SP); 251 PUSHMARK (SP);
262 PUTBACK; 252 PUTBACK;
263 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);
264 } 254 }
265 255
307 FREETMPS; 297 FREETMPS;
308 LEAVE; 298 LEAVE;
309 299
310 return retval; 300 return retval;
311} 301}
312
313/////////////////////////////////////////////////////////////////////////////
314// DNS
315
316#ifndef _WIN32
317static void
318dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg)
319{
320 dSP;
321 SV *cb = (SV *)arg;
322
323 ENTER;
324 SAVETMPS;
325 PUSHMARK (SP);
326 EXTEND (SP, count + 3);
327 PUSHs (sv_2mortal (newSViv (result)));
328
329 if (result == DNS_ERR_NONE && ttl >= 0)
330 {
331 int i;
332
333 PUSHs (sv_2mortal (newSViv (type)));
334 PUSHs (sv_2mortal (newSViv (ttl)));
335
336 for (i = 0; i < count; ++i)
337 switch (type)
338 {
339 case DNS_IPv6_AAAA:
340 PUSHs (sv_2mortal (newSVpvn (i * 16 + (char *)addresses, 16)));
341 break;
342 case DNS_IPv4_A:
343 PUSHs (sv_2mortal (newSVpvn (i * 4 + (char *)addresses, 4)));
344 break;
345 case DNS_PTR:
346 PUSHs (sv_2mortal (newSVpv (*(char **)addresses, 0)));
347 break;
348 }
349 }
350
351 PUTBACK;
352 call_sv (sv_2mortal (cb), G_DISCARD | G_VOID | G_EVAL);
353
354 FREETMPS;
355
356 if (SvTRUE (ERRSV))
357 {
358 PUSHMARK (SP);
359 PUTBACK;
360 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
361 }
362
363 LEAVE;
364}
365#endif
366 302
367#define CHECK_REPEAT(repeat) if (repeat < 0.) \ 303#define CHECK_REPEAT(repeat) if (repeat < 0.) \
368 croak (# repeat " value must be >= 0"); 304 croak (# repeat " value must be >= 0");
369 305
370#define CHECK_FD(fh,fd) if ((fd) < 0) \ 306#define CHECK_FD(fh,fd) if ((fd) < 0) \
430 stash_prepare = gv_stashpv ("EV::Prepare" , 1); 366 stash_prepare = gv_stashpv ("EV::Prepare" , 1);
431 stash_check = gv_stashpv ("EV::Check" , 1); 367 stash_check = gv_stashpv ("EV::Check" , 1);
432 stash_child = gv_stashpv ("EV::Child" , 1); 368 stash_child = gv_stashpv ("EV::Child" , 1);
433 stash_embed = gv_stashpv ("EV::Embed" , 1); 369 stash_embed = gv_stashpv ("EV::Embed" , 1);
434 stash_stat = gv_stashpv ("EV::Stat" , 1); 370 stash_stat = gv_stashpv ("EV::Stat" , 1);
371 stash_fork = gv_stashpv ("EV::Fork" , 1);
435 372
436 { 373 {
437 SV *sv = perl_get_sv ("EV::API", TRUE); 374 SV *sv = perl_get_sv ("EV::API", TRUE);
438 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 375 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
439 376
440 /* the poor man's shared library emulator */ 377 /* the poor man's shared library emulator */
441 evapi.ver = EV_API_VERSION; 378 evapi.ver = EV_API_VERSION;
442 evapi.rev = EV_API_REVISION; 379 evapi.rev = EV_API_REVISION;
443 evapi.sv_fileno = sv_fileno; 380 evapi.sv_fileno = sv_fileno;
444 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;
445 evapi.now = ev_now; 390 evapi.now = ev_now;
446 evapi.backend = ev_backend; 391 evapi.backend = ev_backend;
447 evapi.unloop = ev_unloop; 392 evapi.unloop = ev_unloop;
448 evapi.ref = ev_ref; 393 evapi.ref = ev_ref;
449 evapi.unref = ev_unref; 394 evapi.unref = ev_unref;
450 evapi.time = ev_time;
451 evapi.loop = ev_loop; 395 evapi.loop = ev_loop;
452 evapi.once = ev_once; 396 evapi.once = ev_once;
453 evapi.io_start = ev_io_start; 397 evapi.io_start = ev_io_start;
454 evapi.io_stop = ev_io_stop; 398 evapi.io_stop = ev_io_stop;
455 evapi.timer_start = ev_timer_start; 399 evapi.timer_start = ev_timer_start;
456 evapi.timer_stop = ev_timer_stop; 400 evapi.timer_stop = ev_timer_stop;
457 evapi.timer_again = ev_timer_again; 401 evapi.timer_again = ev_timer_again;
458 evapi.periodic_start = ev_periodic_start; 402 evapi.periodic_start = ev_periodic_start;
459 evapi.periodic_stop = ev_periodic_stop; 403 evapi.periodic_stop = ev_periodic_stop;
460 evapi.signal_start = ev_signal_start; 404 evapi.signal_start = ev_signal_start;
461 evapi.signal_stop = ev_signal_stop; 405 evapi.signal_stop = ev_signal_stop;
462 evapi.idle_start = ev_idle_start; 406 evapi.idle_start = ev_idle_start;
463 evapi.idle_stop = ev_idle_stop; 407 evapi.idle_stop = ev_idle_stop;
464 evapi.prepare_start = ev_prepare_start; 408 evapi.prepare_start = ev_prepare_start;
465 evapi.prepare_stop = ev_prepare_stop; 409 evapi.prepare_stop = ev_prepare_stop;
466 evapi.check_start = ev_check_start; 410 evapi.check_start = ev_check_start;
467 evapi.check_stop = ev_check_stop; 411 evapi.check_stop = ev_check_stop;
468 evapi.child_start = ev_child_start; 412 evapi.child_start = ev_child_start;
469 evapi.child_stop = ev_child_stop; 413 evapi.child_stop = ev_child_stop;
470 evapi.stat_start = ev_stat_start; 414 evapi.stat_start = ev_stat_start;
471 evapi.stat_stop = ev_stat_stop; 415 evapi.stat_stop = ev_stat_stop;
472 evapi.stat_stat = ev_stat_stat; 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;
423 evapi.invoke = ev_invoke;
473 424
474 sv_setiv (sv, (IV)&evapi); 425 sv_setiv (sv, (IV)&evapi);
475 SvREADONLY_on (sv); 426 SvREADONLY_on (sv);
476 } 427 }
477#ifndef _WIN32 428#ifndef _WIN32
478 pthread_atfork (0, 0, ev_default_fork); 429 pthread_atfork (0, 0, ev_default_fork);
479#endif 430#endif
480} 431}
481 432
433SV *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
446NV ev_time ()
447
482NV ev_now () 448NV ev_now ()
449 C_ARGS: evapi.default_loop
483 450
484unsigned int ev_backend () 451unsigned int ev_backend ()
452 C_ARGS: evapi.default_loop
485 453
486NV ev_time () 454unsigned int ev_loop_count ()
487 455 C_ARGS: evapi.default_loop
488unsigned int ev_default_loop (unsigned int flags = ev_supported_backends ())
489 456
490void ev_loop (int flags = 0) 457void ev_loop (int flags = 0)
458 C_ARGS: evapi.default_loop, flags
491 459
492void ev_unloop (int how = 1) 460void ev_unloop (int how = 1)
461 C_ARGS: evapi.default_loop, how
462
463void ev_feed_fd_event (int fd, int revents = EV_NONE)
464 C_ARGS: evapi.default_loop, fd, revents
465
466void 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}
493 474
494ev_io *io (SV *fh, int events, SV *cb) 475ev_io *io (SV *fh, int events, SV *cb)
495 ALIAS: 476 ALIAS:
496 io_ns = 1 477 io_ns = 1
497 CODE: 478 CODE:
579 ev_check_set (RETVAL); 560 ev_check_set (RETVAL);
580 if (!ix) START (check, RETVAL); 561 if (!ix) START (check, RETVAL);
581 OUTPUT: 562 OUTPUT:
582 RETVAL 563 RETVAL
583 564
565ev_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
584ev_child *child (int pid, SV *cb) 575ev_child *child (int pid, SV *cb)
585 ALIAS: 576 ALIAS:
586 child_ns = 1 577 child_ns = 1
587 CODE: 578 CODE:
588 RETVAL = e_new (sizeof (ev_child), cb); 579 RETVAL = e_new (sizeof (ev_child), cb);
603 RETVAL 594 RETVAL
604 595
605void once (SV *fh, int events, SV *timeout, SV *cb) 596void once (SV *fh, int events, SV *timeout, SV *cb)
606 CODE: 597 CODE:
607 ev_once ( 598 ev_once (
599 evapi.default_loop,
608 sv_fileno (fh), events, 600 sv_fileno (fh), events,
609 SvOK (timeout) ? SvNV (timeout) : -1., 601 SvOK (timeout) ? SvNV (timeout) : -1.,
610 e_once_cb, 602 e_once_cb,
611 newSVsv (cb) 603 newSVsv (cb)
612 ); 604 );
616MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ 608MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_
617 609
618int ev_is_active (ev_watcher *w) 610int ev_is_active (ev_watcher *w)
619 611
620int ev_is_pending (ev_watcher *w) 612int ev_is_pending (ev_watcher *w)
613
614void ev_invoke (ev_watcher *w, int revents = EV_NONE)
615 C_ARGS: w->loop, w, revents
616
617int ev_clear_pending (ev_watcher *w)
618 C_ARGS: w->loop, w
619
620void ev_feed_event (ev_watcher *w, int revents = EV_NONE)
621 C_ARGS: w->loop, w, revents
621 622
622int keepalive (ev_watcher *w, int new_value = 0) 623int keepalive (ev_watcher *w, int new_value = 0)
623 CODE: 624 CODE:
624{ 625{
625 RETVAL = w->flags & WFLAG_KEEPALIVE; 626 RETVAL = w->flags & WFLAG_KEEPALIVE;
658 } 659 }
659} 660}
660 OUTPUT: 661 OUTPUT:
661 RETVAL 662 RETVAL
662 663
663void trigger (ev_watcher *w, int revents = EV_NONE)
664 CODE:
665 w->cb (w, revents);
666
667int priority (ev_watcher *w, int new_priority = 0) 664int priority (ev_watcher *w, int new_priority = 0)
668 CODE: 665 CODE:
669{ 666{
670 RETVAL = w->priority; 667 RETVAL = w->priority;
671 668
672 if (items > 1) 669 if (items > 1)
673 { 670 {
674 int active = ev_is_active (w); 671 int active = ev_is_active (w);
675
676 if (new_priority < EV_MINPRI || new_priority > EV_MAXPRI)
677 croak ("watcher priority out of range, value must be between %d and %d, inclusive", EV_MINPRI, EV_MAXPRI);
678 672
679 if (active) 673 if (active)
680 { 674 {
681 /* grrr. */ 675 /* grrr. */
682 PUSHMARK (SP); 676 PUSHMARK (SP);
683 XPUSHs (ST (0)); 677 XPUSHs (ST (0));
678 PUTBACK;
684 call_method ("stop", G_DISCARD | G_VOID); 679 call_method ("stop", G_DISCARD | G_VOID);
685 } 680 }
686 681
687 ev_set_priority (w, new_priority); 682 ev_set_priority (w, new_priority);
688 683
689 if (active) 684 if (active)
690 { 685 {
691 PUSHMARK (SP); 686 PUSHMARK (SP);
692 XPUSHs (ST (0)); 687 XPUSHs (ST (0));
688 PUTBACK;
693 call_method ("start", G_DISCARD | G_VOID); 689 call_method ("start", G_DISCARD | G_VOID);
694 } 690 }
695 } 691 }
696} 692}
697 OUTPUT: 693 OUTPUT:
807void ev_timer_again (ev_timer *w) 803void ev_timer_again (ev_timer *w)
808 INIT: 804 INIT:
809 CHECK_REPEAT (w->repeat); 805 CHECK_REPEAT (w->repeat);
810 CODE: 806 CODE:
811 REF (w); 807 REF (w);
812 ev_timer_again (w); 808 ev_timer_again (w->loop, w);
813 UNREF (w); 809 UNREF (w);
814 810
815void DESTROY (ev_timer *w) 811void DESTROY (ev_timer *w)
816 CODE: 812 CODE:
817 STOP (timer, w); 813 STOP (timer, w);
821 INIT: 817 INIT:
822 CHECK_REPEAT (repeat); 818 CHECK_REPEAT (repeat);
823 CODE: 819 CODE:
824 RESET (timer, w, (w, after, repeat)); 820 RESET (timer, w, (w, after, repeat));
825 821
822NV at (ev_timer *w)
823 CODE:
824 RETVAL = w->at;
825 OUTPUT:
826 RETVAL
827
826MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 828MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
827 829
828void ev_periodic_start (ev_periodic *w) 830void ev_periodic_start (ev_periodic *w)
829 INIT: 831 INIT:
830 CHECK_REPEAT (w->interval); 832 CHECK_REPEAT (w->interval);
836 STOP (periodic, w); 838 STOP (periodic, w);
837 839
838void ev_periodic_again (ev_periodic *w) 840void ev_periodic_again (ev_periodic *w)
839 CODE: 841 CODE:
840 REF (w); 842 REF (w);
841 ev_periodic_again (w); 843 ev_periodic_again (w->loop, w);
842 UNREF (w); 844 UNREF (w);
843 845
844void DESTROY (ev_periodic *w) 846void DESTROY (ev_periodic *w)
845 CODE: 847 CODE:
846 STOP (periodic, w); 848 STOP (periodic, w);
855 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 857 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
856 858
857 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 859 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0));
858} 860}
859 861
862NV at (ev_periodic *w)
863 CODE:
864 RETVAL = w->at;
865 OUTPUT:
866 RETVAL
867
860MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 868MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
861 869
862void ev_idle_start (ev_idle *w) 870void ev_idle_start (ev_idle *w)
863 CODE: 871 CODE:
864 START (idle, w); 872 START (idle, w);
898 STOP (check, w); 906 STOP (check, w);
899 907
900void DESTROY (ev_check *w) 908void DESTROY (ev_check *w)
901 CODE: 909 CODE:
902 STOP (check, w); 910 STOP (check, w);
911 e_destroy (w);
912
913MODULE = EV PACKAGE = EV::Fork PREFIX = ev_fork_
914
915void ev_fork_start (ev_fork *w)
916 CODE:
917 START (fork, w);
918
919void ev_fork_stop (ev_fork *w)
920 CODE:
921 STOP (fork, w);
922
923void DESTROY (ev_fork *w)
924 CODE:
925 STOP (fork, w);
903 e_destroy (w); 926 e_destroy (w);
904 927
905MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 928MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
906 929
907void ev_child_start (ev_child *w) 930void ev_child_start (ev_child *w)
996 PPCODE: 1019 PPCODE:
997{ 1020{
998 ev_statdata *s = ix ? &w->attr : &w->prev; 1021 ev_statdata *s = ix ? &w->attr : &w->prev;
999 1022
1000 if (ix == 1) 1023 if (ix == 1)
1001 ev_stat_stat (w); 1024 ev_stat_stat (w->loop, w);
1002 else if (!s->st_nlink) 1025 else if (!s->st_nlink)
1003 errno = ENOENT; 1026 errno = ENOENT;
1004 1027
1005 PL_statcache.st_dev = s->st_nlink; 1028 PL_statcache.st_dev = s->st_nlink;
1006 PL_statcache.st_ino = s->st_ino; 1029 PL_statcache.st_ino = s->st_ino;
1032 PUSHs (sv_2mortal (newSVnv (s->st_ctime))); 1055 PUSHs (sv_2mortal (newSVnv (s->st_ctime)));
1033 PUSHs (sv_2mortal (newSVuv (4096))); 1056 PUSHs (sv_2mortal (newSVuv (4096)));
1034 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096)))); 1057 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096))));
1035 } 1058 }
1036} 1059}
1037
1038#ifndef _WIN32
1039
1040MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_
1041
1042BOOT:
1043{
1044 HV *stash = gv_stashpv ("EV::DNS", 1);
1045
1046 static const struct {
1047 const char *name;
1048 IV iv;
1049 } *civ, const_iv[] = {
1050# define const_iv(pfx, name) { # name, (IV) pfx ## name },
1051 const_iv (DNS_, ERR_NONE)
1052 const_iv (DNS_, ERR_FORMAT)
1053 const_iv (DNS_, ERR_SERVERFAILED)
1054 const_iv (DNS_, ERR_NOTEXIST)
1055 const_iv (DNS_, ERR_NOTIMPL)
1056 const_iv (DNS_, ERR_REFUSED)
1057 const_iv (DNS_, ERR_TRUNCATED)
1058 const_iv (DNS_, ERR_UNKNOWN)
1059 const_iv (DNS_, ERR_TIMEOUT)
1060 const_iv (DNS_, ERR_SHUTDOWN)
1061 const_iv (DNS_, IPv4_A)
1062 const_iv (DNS_, PTR)
1063 const_iv (DNS_, IPv6_AAAA)
1064 const_iv (DNS_, QUERY_NO_SEARCH)
1065 const_iv (DNS_, OPTION_SEARCH)
1066 const_iv (DNS_, OPTION_NAMESERVERS)
1067 const_iv (DNS_, OPTION_MISC)
1068 const_iv (DNS_, OPTIONS_ALL)
1069 const_iv (DNS_, NO_SEARCH)
1070 };
1071
1072 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1073 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1074}
1075
1076int evdns_init ()
1077
1078void evdns_shutdown (int fail_requests = 1)
1079
1080const char *evdns_err_to_string (int err)
1081
1082int evdns_nameserver_add (U32 address)
1083
1084int evdns_count_nameservers ()
1085
1086int evdns_clear_nameservers_and_suspend ()
1087
1088int evdns_resume ()
1089
1090int evdns_nameserver_ip_add (char *ip_as_string)
1091
1092int evdns_resolve_ipv4 (const char *name, int flags, SV *cb)
1093 C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb)
1094
1095int evdns_resolve_ipv6 (const char *name, int flags, SV *cb)
1096 C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb)
1097
1098int evdns_resolve_reverse (SV *addr, int flags, SV *cb)
1099 ALIAS:
1100 evdns_resolve_reverse_ipv6 = 1
1101 CODE:
1102{
1103 STRLEN len;
1104 char *data = SvPVbyte (addr, len);
1105 if (len != (ix ? 16 : 4))
1106 croak ("ipv4/ipv6 address to be resolved must be given as 4/16 byte octet string");
1107
1108 RETVAL = ix
1109 ? evdns_resolve_reverse_ipv6 ((struct in6_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb))
1110 : evdns_resolve_reverse ((struct in_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb));
1111}
1112 OUTPUT:
1113 RETVAL
1114
1115int evdns_set_option (char *option, char *val, int flags)
1116
1117int evdns_resolv_conf_parse (int flags, const char *filename)
1118
1119#ifdef _WIN32
1120
1121int evdns_config_windows_nameservers ()
1122
1123#endif
1124
1125void evdns_search_clear ()
1126
1127void evdns_search_add (char *domain)
1128
1129void evdns_search_ndots_set (int ndots)
1130 1060
1131#if 0 1061#if 0
1132 1062
1133MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ 1063MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_
1134 1064
1168 1098
1169#void DESTROY (struct evhttp_request *req); 1099#void DESTROY (struct evhttp_request *req);
1170 1100
1171#endif 1101#endif
1172 1102
1173#endif
1174 1103
1175 1104
1176 1105
1177 1106
1178 1107

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines