DNS_A.xs

filter: Statementstmt 69.7% 23 / 33 Branchbran 34.7% 16 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 49.3% 39 / 79 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/Net/DNS_A.pm »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5  
6 #include <netdb.h>
7  
8 #include "ppport.h"
9  
10 static struct gaicb gcb;
11 static int count = 0;
12  
13 MODULE = Net::DNS_A PACKAGE = Net::DNS_A
14  
15 void
16 lookup(host)
17 char *host
18 INIT:
19 int res;
20 struct sigevent sev;
21 2 struct gaicb *gptr = &gcb;
22 PPCODE:
23 2 ▶ if (count) {
Branch: 1 branch
BranchTrueFalseTotal
if (count) { 1 1 2
24 1 ▶ XPUSHs(sv_2mortal(newSViv(0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); 0 1 1
25 1 ▶ XPUSHs(sv_2mortal(newSVpv("Please call retrieve()", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("Please call retrieve()", 0))); 0 1 1
26 }
27 else {
28 1 gcb.ar_name = host;
29 1 sev.sigev_notify = SIGEV_NONE;
30  
31 1 res = getaddrinfo_a(GAI_NOWAIT, &gptr, 1, &sev);
32 1 ▶ if (res) {
Branch: 1 branch
BranchTrueFalseTotal
if (res) { 0 1 1
33 0 ▶ XPUSHs(sv_2mortal(newSViv(0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); 0 0 0
34 0 ▶ XPUSHs(sv_2mortal(newSVpv(gai_strerror(res), strlen(gai_strerror(res)))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(gai_strerror(res), strlen(gai_strerror(res))))); 0 0 0
35 }
36 else {
37 1 ++count;
38 1 ▶ XPUSHs(sv_2mortal(newSViv(1)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(1))); 0 1 1
39 }
40 }
41  
42 void
43 retrieve()
44 INIT:
45 int res;
46 char host[NI_MAXHOST];
47 PPCODE:
48  
49 3 ▶ if (0 == count) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 == count) { 2 1 3
50 2 ▶ XPUSHs(sv_2mortal(newSViv(0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); 0 2 2
51 2 ▶ XPUSHs(sv_2mortal(newSVpv("Please call lookup()", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("Please call lookup()", 0))); 0 2 2
52 }
53 else {
54 1 res = gai_error(&gcb);
55  
56 1 ▶ if (EAI_INPROGRESS == res) {
Branch: 1 branch
BranchTrueFalseTotal
if (EAI_INPROGRESS == res) { 0 1 1
57 0 ▶ XPUSHs(sv_2mortal(newSViv(0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); 0 0 0
58 0 ▶ XPUSHs(sv_2mortal(newSVpv("EAI_INPROGRESS", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("EAI_INPROGRESS", 0))); 0 0 0
59 }
60 1 ▶ else if (0 == res) {
Branch: 1 branch
BranchTrueFalseTotal
else if (0 == res) { 1 0 1
61 1 --count;
62 1 res = getnameinfo(gcb.ar_result->ai_addr, gcb.ar_result->ai_addrlen,
63 host, sizeof(host),
64 NULL, 0, NI_NUMERICHOST);
65 1 ▶ if (res) {
Branch: 1 branch
BranchTrueFalseTotal
if (res) { 0 1 1
66 0 ▶ XPUSHs(sv_2mortal(newSViv(0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); 0 0 0
67 0 ▶ XPUSHs(sv_2mortal(newSVpv(gai_strerror(res), strlen(gai_strerror(res)))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(gai_strerror(res), strlen(gai_strerror(res))))); 0 0 0
68 }
69 else {
70 1 ▶ XPUSHs(sv_2mortal(newSViv(1)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(1))); 0 1 1
71 1 ▶ XPUSHs(sv_2mortal(newSVpv(gcb.ar_name, strlen(gcb.ar_name))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(gcb.ar_name, strlen(gcb.ar_name)))); 0 1 1
72 1 ▶ XPUSHs(sv_2mortal(newSVpv(host, strlen(host))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(host, strlen(host)))); 0 1 1
73 1 freeaddrinfo(gcb.ar_result);
74 }
75 }
76 0 ▶ else if (EAI_INPROGRESS != res) {
Branch: 1 branch
BranchTrueFalseTotal
else if (EAI_INPROGRESS != res) { 0 0 0
77 0 --count;
78 0 ▶ XPUSHs(sv_2mortal(newSViv(0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(0))); 0 0 0
79 0 ▶ XPUSHs(sv_2mortal(newSVpv(gai_strerror(res), strlen(gai_strerror(res)))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(gai_strerror(res), strlen(gai_strerror(res))))); 0 0 0
80 }
81 }
↑ Summary blib/lib/Net/DNS_A.pm »