xs_include/dn_expand.inc

filter: Statementstmt 90.0% 9 / 10 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 75.0% 12 / 16 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« Template/t/Template.t ↑ Summary ToolKit.xs »
1 #
2 # Copyright (c) 1997-2009 Michael Fuhr. All rights reserved. This
3 # program is free software; you can redistribute it and/or modify it
4 # under the same terms as Perl itself.
5 #
6 # Net::DNS is currently maintained by a group, led by:
7 # Chris Reinhardt
8 # ctriv@net-dns.org
9 #
10 # Net::DNS was created by:
11 # Michael Fuhr
12 # mike@fuhr.org
13 #
14 # Modified ever so slightly and those changes are
15 # Copyright 2003-2009 Michael Robinton. All rights reserved. This
16 # program is free software; you can redistribute it and/or modify it
17 # under the same terms as Perl itself.
18 #
19 #
20 # int dn_expand(unsigned char *msg, unsigned char *eomorig,
21 # unsigned char *comp_dn, unsigned char *exp_dn, int length);
22 #
23 # dn_expand
24 # dn_expand() expands the compressed domain name given by the
25 # pointer comp _dn into a full domain name. Expanded names are
26 # converted to upper case. The compressed name is contained in
27 # a query or reply message; msg is a pointer to the beginning
28 # of that message. Expanded names are stored in the buffer
29 # referenced by the exp_dn buffer of size length, which should
30 # be large enough to hold the expanded result.
31 #
32 # dn_expand() returns the size of the compressed name, or -1
33 # if there was an error.
34 #
35  
36 void
37 dn_expand(buffer, offset)
38 SV * buffer
39 int offset
40 PROTOTYPE: $$
41 PPCODE:
42 STRLEN len;
43 u_char * buf;
44 char name[MAXDNAME];
45 int size;
46  
47 40 ▶ if (SvROK(buffer))
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(buffer)) 40 0 40
48 40 buffer = SvRV(buffer);
49  
50 40 buf = (u_char *)SvPV(buffer, len);
51 40 size = dn_expand(buf, buf+len, buf+offset, &name[0], MAXDNAME);
52  
53 40 ▶ if (size < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (size < 0) { 0 40 40
54 0 XSRETURN_EMPTY;
55 } else {
56 40 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 40 40
57 40 PUSHs(sv_2mortal(newSViv(size + offset)));
58 40 PUSHs(sv_2mortal(newSVpv(name, 0)));
59 }
60 40 XSRETURN(2);
61  
« Template/t/Template.t ↑ Summary ToolKit.xs »