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

Comparing EV/EV.xs (file contents):
Revision 1.4 by root, Fri Oct 26 18:21:32 2007 UTC vs.
Revision 1.9 by root, Mon Oct 29 07:24:37 2007 UTC

116 116
117 if (ev->abstime) 117 if (ev->abstime)
118 { 118 {
119 double now = e_now (); 119 double now = e_now ();
120 120
121 if (now > to && ev->interval) 121 if (ev->interval)
122 ev->timeout = (to += ceil ((now - to) / ev->interval) * ev->interval); 122 ev->timeout = (to += ceil ((now - to) / ev->interval) * ev->interval);
123 123
124 to -= now; 124 to -= now;
125 } 125 }
126 else if (to < 0.) 126 else if (to < 0.)
169 dSP; 169 dSP;
170 170
171 ENTER; 171 ENTER;
172 SAVETMPS; 172 SAVETMPS;
173 173
174 if (!(ev->ev.ev_events & EV_PERSIST)) 174 if (!(ev->ev.ev_events & EV_PERSIST) || (events & EV_TIMEOUT))
175 ev->active = 0; 175 ev->active = 0;
176 176
177 PUSHMARK (SP); 177 PUSHMARK (SP);
178 EXTEND (SP, 2); 178 EXTEND (SP, 2);
179 PUSHs (sv_2mortal (e_self (ev))); 179 PUSHs (sv_2mortal (e_self (ev)));
180 PUSHs (sv_2mortal (newSViv (events))); 180 PUSHs (sv_2mortal (newSViv (events)));
181 PUTBACK; 181 PUTBACK;
182 call_sv (ev->cb, G_DISCARD | G_VOID | G_EVAL); 182 call_sv (ev->cb, G_DISCARD | G_VOID | G_EVAL);
183 /*TODO: if err, call some logging function */
184 183
185 if (ev->interval && !ev->active) 184 if (ev->interval && !ev->active)
186 e_start (ev); 185 e_start (ev);
187 186
188 FREETMPS; 187 FREETMPS;
188
189 if (SvTRUE (ERRSV))
190 {
191 PUSHMARK (SP);
192 PUTBACK;
193 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
194 }
195
189 LEAVE; 196 LEAVE;
190} 197}
191 198
192///////////////////////////////////////////////////////////////////////////// 199/////////////////////////////////////////////////////////////////////////////
193// DNS 200// DNS
228 235
229 PUTBACK; 236 PUTBACK;
230 call_sv (sv_2mortal (cb), G_DISCARD | G_VOID | G_EVAL); 237 call_sv (sv_2mortal (cb), G_DISCARD | G_VOID | G_EVAL);
231 238
232 FREETMPS; 239 FREETMPS;
240
241 if (SvTRUE (ERRSV))
242 {
243 PUSHMARK (SP);
244 PUTBACK;
245 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
246 }
247
233 LEAVE; 248 LEAVE;
234} 249}
235 250
236///////////////////////////////////////////////////////////////////////////// 251/////////////////////////////////////////////////////////////////////////////
237// XS interface functions 252// XS interface functions
312 RETVAL = e_new (fh, events, cb); 327 RETVAL = e_new (fh, events, cb);
313 if (!ix) e_start (RETVAL); 328 if (!ix) e_start (RETVAL);
314 OUTPUT: 329 OUTPUT:
315 RETVAL 330 RETVAL
316 331
332Event timed_io (SV *fh, short events, double timeout, SV *cb)
333 ALIAS:
334 timed_io_ns = 1
335 CODE:
336{
337 events = timeout ? events & ~EV_PERSIST : events | EV_PERSIST;
338
339 RETVAL = e_new (fh, events, cb);
340
341 if (timeout)
342 {
343 RETVAL->timeout = timeout;
344 RETVAL->interval = 1;
345 }
346
347 if (!ix) e_start (RETVAL);
348}
349 OUTPUT:
350 RETVAL
351
317Event timer (double after, int repeat, SV *cb) 352Event timer (double after, int repeat, SV *cb)
318 ALIAS: 353 ALIAS:
319 timer_ns = 1 354 timer_ns = 1
320 CODE: 355 CODE:
321 RETVAL = e_new (NEWSV (0, 0), 0, cb); 356 RETVAL = e_new (NEWSV (0, 0), 0, cb);
421 OUTPUT: 456 OUTPUT:
422 RETVAL 457 RETVAL
423 458
424SV *fh (Event ev, SV *new_fh = 0) 459SV *fh (Event ev, SV *new_fh = 0)
425 ALIAS: 460 ALIAS:
426 signal = 0 461 signal = 1
427 CODE: 462 CODE:
428 RETVAL = newSVsv (ev->fh); 463 RETVAL = newSVsv (ev->fh);
429 if (items > 1) 464 if (items > 1)
430 { 465 {
431 if (ev->active) event_del (&ev->ev); 466 if (ev->active) event_del (&ev->ev);
432 sv_setsv (ev->fh, new_fh); 467 sv_setsv (ev->fh, new_fh);
433 ev->ev.ev_fd = sv_fileno (ev->fh); 468 ev->ev.ev_fd = sv_fileno (ev->fh);
469 ev->ev.ev_events = signal ? ev->ev.ev_events | EV_SIGNAL : ev->ev.ev_events & ~EV_SIGNAL;
434 if (ev->active) event_add (&ev->ev, e_tv (ev)); 470 if (ev->active) event_add (&ev->ev, e_tv (ev));
435 } 471 }
436 OUTPUT: 472 OUTPUT:
437 RETVAL 473 RETVAL
438 474
480 static const struct { 516 static const struct {
481 const char *name; 517 const char *name;
482 IV iv; 518 IV iv;
483 } *civ, const_iv[] = { 519 } *civ, const_iv[] = {
484# define const_iv(pfx, name) { # name, (IV) pfx ## name }, 520# define const_iv(pfx, name) { # name, (IV) pfx ## name },
485
486 const_iv (DNS_, ERR_NONE) 521 const_iv (DNS_, ERR_NONE)
487 const_iv (DNS_, ERR_FORMAT) 522 const_iv (DNS_, ERR_FORMAT)
488 const_iv (DNS_, ERR_SERVERFAILED) 523 const_iv (DNS_, ERR_SERVERFAILED)
489 const_iv (DNS_, ERR_NOTEXIST) 524 const_iv (DNS_, ERR_NOTEXIST)
490 const_iv (DNS_, ERR_NOTIMPL) 525 const_iv (DNS_, ERR_NOTIMPL)
536 CODE: 571 CODE:
537{ 572{
538 STRLEN len; 573 STRLEN len;
539 char *data = SvPVbyte (addr, len); 574 char *data = SvPVbyte (addr, len);
540 if (len != (ix ? 16 : 4)) 575 if (len != (ix ? 16 : 4))
541 croak ("ipv4/ipv6 address to resolve must be given as 4/16 byte octet string"); 576 croak ("ipv4/ipv6 address to be resolved must be given as 4/16 byte octet string");
542 577
543 RETVAL = ix 578 RETVAL = ix
544 ? evdns_resolve_reverse_ipv6 ((struct in6_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)) 579 ? evdns_resolve_reverse_ipv6 ((struct in6_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb))
545 : evdns_resolve_reverse ((struct in_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)); 580 : evdns_resolve_reverse ((struct in_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb));
546} 581}
561 596
562void evdns_search_add (char *domain) 597void evdns_search_add (char *domain)
563 598
564void evdns_search_ndots_set (int ndots) 599void evdns_search_ndots_set (int ndots)
565 600
601
602MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_
603
604BOOT:
605{
606 HV *stash = gv_stashpv ("EV::HTTP", 1);
607
608 static const struct {
609 const char *name;
610 IV iv;
611 } *civ, const_iv[] = {
612# define const_iv(pfx, name) { # name, (IV) pfx ## name },
613 const_iv (HTTP_, OK)
614 const_iv (HTTP_, NOCONTENT)
615 const_iv (HTTP_, MOVEPERM)
616 const_iv (HTTP_, MOVETEMP)
617 const_iv (HTTP_, NOTMODIFIED)
618 const_iv (HTTP_, BADREQUEST)
619 const_iv (HTTP_, NOTFOUND)
620 const_iv (HTTP_, SERVUNAVAIL)
621 const_iv (EVHTTP_, REQ_OWN_CONNECTION)
622 const_iv (EVHTTP_, PROXY_REQUEST)
623 const_iv (EVHTTP_, REQ_GET)
624 const_iv (EVHTTP_, REQ_POST)
625 const_iv (EVHTTP_, REQ_HEAD)
626 const_iv (EVHTTP_, REQUEST)
627 const_iv (EVHTTP_, RESPONSE)
628 };
629
630 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
631 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
632}
633
634MODULE = EV PACKAGE = EV::HTTP::Request PREFIX = evhttp_request_
635
636#HttpRequest new (SV *klass, SV *cb)
637
638#void DESTROY (struct evhttp_request *req);
639
640
641
642
643
644
645
646

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines