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.85 by root, Sat Dec 1 22:51:34 2007 UTC

18# define fd_mask Perl_fd_mask 18# define fd_mask Perl_fd_mask
19#endif 19#endif
20/* due to bugs in OS X we have to use libev/ explicitly here */ 20/* due to bugs in OS X we have to use libev/ explicitly here */
21#include "libev/ev.c" 21#include "libev/ev.c"
22#include "event.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
307 FREETMPS; 295 FREETMPS;
308 LEAVE; 296 LEAVE;
309 297
310 return retval; 298 return retval;
311} 299}
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 300
367#define CHECK_REPEAT(repeat) if (repeat < 0.) \ 301#define CHECK_REPEAT(repeat) if (repeat < 0.) \
368 croak (# repeat " value must be >= 0"); 302 croak (# repeat " value must be >= 0");
369 303
370#define CHECK_FD(fh,fd) if ((fd) < 0) \ 304#define CHECK_FD(fh,fd) if ((fd) < 0) \
1033 PUSHs (sv_2mortal (newSVuv (4096))); 967 PUSHs (sv_2mortal (newSVuv (4096)));
1034 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096)))); 968 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096))));
1035 } 969 }
1036} 970}
1037 971
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
1131#if 0 972#if 0
1132 973
1133MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ 974MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_
1134 975
1135BOOT: 976BOOT:
1168 1009
1169#void DESTROY (struct evhttp_request *req); 1010#void DESTROY (struct evhttp_request *req);
1170 1011
1171#endif 1012#endif
1172 1013
1173#endif
1174 1014
1175 1015
1176 1016
1177 1017
1178 1018

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines