| 1 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Net::OSCAR::XML -- XML functions for Net::OSCAR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | version 1.928 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | We're doing the fancy-schmancy Protocol.xml stuff here, so I'll explain it here. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | Protocol.xml contains a number of "OSCAR protocol elements". One E<lt>defineE<gt> block | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | is one OSCAR protocol elemennt. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | When the module is first loaded, Protocol.xml is parsed and two hashes are created, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | one whose keys are the names the the elements and whose values are the contents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | of the XML::Parser tree which represents the contents of those elements; the other | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | hash has a family/subtype tuple as a key and element names as a value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | To do something with an element, given its name, Net::OSCAR calls C<protoparse("element name")>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | This returns a C<Net::OSCAR::XML::Template> object, which has C<pack> and C<unpack> methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | C<pack> takes a hash and returns a string of binary characters, and C<unpack> goes the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | other way around. The objects are cached, so C<protoparse> only has to do actual work once | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | for every protocol element. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | package Net::OSCAR::XML; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | $Net::OSCAR::XML::VERSION = '1.928'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | $REVISION = '$Revision$'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | ▶ | use vars qw(@ISA @EXPORT); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | ▶ | use Net::OSCAR::TLV; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | ▶ | use Net::OSCAR::XML::Template; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | our(%xmlmap, %xml_revmap, $PROTOPARSE_DEBUG, $NO_XML_CACHE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | protoparse protobit_to_snac snac_to_protobit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | $PROTOPARSE_DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | $NO_XML_CACHE = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub _protopack($$;@); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | sub _xmlnode_to_template($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | ▶ | sub load_xml(;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_xml: called CC=15 SCAR=50.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # Look for parsed-xml file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | if(!$NO_XML_CACHE) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | foreach (@INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 40 | ▶ | next unless -f "$_/Net/OSCAR/XML/Protocol.parsed-xml"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | open(XMLCACHE, "$_/Net/OSCAR/XML/Protocol.parsed-xml") or next; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $xmlcache = join("", <XMLCACHE>); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | close(XMLCACHE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $xmlparse; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | eval $xmlcache or die "Coldn't load xml cache: $@\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return parse_xml($xmlparse); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | require XML::Parser; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } or die "Couldn't load XML::Parser ($@)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $xmlparser = new XML::Parser(Style => "Tree"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $xmlfile = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if($_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $xmlfile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | foreach (@INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | next unless -f "$_/Net/OSCAR/XML/Protocol.xml"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $xmlfile = "$_/Net/OSCAR/XML/Protocol.xml"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | croak "Couldn't find Net/OSCAR/XML/Protocol.xml in search path: " . join(" ", @INC) unless $xmlfile; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | open(XMLFILE, $xmlfile) or croak "Couldn't open $xmlfile: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $xml = join("", <XMLFILE>); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | close XMLFILE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $xmlparse = $xmlparser->parse($xml) or croak "Couldn't parse XML from $xmlfile: $@"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | parse_xml($xmlparse); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub add_xml_data($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_xml_data: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $xmlparse = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my @tags = @{$xmlparse->[1]}; # Get contents of <oscar> | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | shift @tags; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | while(@tags) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my($name, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | (undef, undef, $name, $value) = splice(@tags, 0, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | next unless $name and $name eq "define"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $name eq "define"
MC/DC0%0/2
$name and $name eq "define"
$name
$name eq "define"
Truth table0%0/3
A and B
A= $nameB= $name eq "define"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my %protobit = (xml => $value); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my %attrs = %{$value->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $protobit{$_} = $attrs{$_} foreach keys %attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $xml_revmap{$attrs{family}}->{$attrs{subtype}} = $attrs{name} if exists($attrs{family}) and exists($attrs{subtype}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $attrs{"family"} and exists $attrs{"subtype"}
MC/DC0%0/2
exists $attrs{"family"} and exists $attrs{"subtype"}
exists $attrs{"family"}
exists $attrs{"subtype"}
Truth table0%0/3
A and B
A= exists $attrs{"family"}B= exists $attrs{"subtype"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $xmlmap{$attrs{name}} = \%protobit; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub parse_xml($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_xml: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $xmlparse = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | %xmlmap = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | %xml_revmap = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # We set the autovivification so that keys of xml_revmap are Net::OSCAR::TLV hashrefs. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if(!tied(%xml_revmap)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | tie %xml_revmap, "Net::OSCAR::TLV", 'tie %$value, ref($self)'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | add_xml_data($xmlparse); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub _num_to_packlen($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_num_to_packlen: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my($type, $order) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $order ||= "network"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$order ||= "network"
MC/DC0%0/1
$order ||= "network"
$order
Truth table0%0/2
A
A= $order
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if($type eq "byte") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return ("C", 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } elsif($type eq "word") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if($order eq "vax") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return ("v", 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return ("n", 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } elsif($type eq "dword") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if($order eq "vax") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return ("V", 4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return ("N", 4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | confess "Invalid num type: $type"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # Specification for OSCAR protocol template: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # -Listref whose elements are hashrefs. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # -Hashrefs have following keys: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # type: "ref", "num", "data", or "tlvchain" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # If type = "num": | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # packlet: Pack template letter (C, n, N, v, V) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # len: Length of datum, in bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # enum_byname: If this is an enum, map of names to values. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # enum_byval: If this is an enum, map of values to names. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # If type = "data": | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Arbitrary data | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # If prefix isn't present, all available data will be gobbled. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # len (optional): Size of datum, in bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # null_terminated (optional): Data is terminated by a null (0x00) byte | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # If type = "ref": | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # name: Name of protocol bit to punt to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # If type = "tlvchain": | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # subtyped: If true, this is a 'subtyped' TLV, as per Protocol.dtd. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # prefix: If present, "count" or "length", and "packlet" and "len" will also be present. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # items: Listref containing TLVs, hashrefs in format identical to these, with extra key 'num' (and 'subtype', for subtyped TLVs.) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # value: If present, default value of this datum. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # name: If present, name in parameter list that this datum gets. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # count: If present, number of repetitions of this datum. count==-1 represents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # infinite. If a count is present when unpacking, the data will be encapsulated in a listref. If the user | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # wants to pass in multiple data when packing, they should do so via a listref. Listref-encapsulated data with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # too many elements for the 'count' will trigger an exception when packing. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # prefix: If present, either "count" or "length", and indicates that datum has a prefix indicating its length. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # prefix_packet, prefix_len: As per "num". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub _xmlnode_to_template($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_xmlnode_to_template: not called CC=46 SCAR=76.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my($tag, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | confess "Invalid value in xmlnode_to_template!" unless ref($value); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $attrs = shift @$value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $datum = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $datum->{name} = $attrs->{name} if $attrs->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | $datum->{value} = "" if $attrs->{default_generate} and $attrs->{default_generate} ne "no"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attrs->{"default_generate"} and $attrs->{"default_generate"} ne "no"
MC/DC0%0/2
$attrs->{"default_generate"} and $attrs->{"default_generate"} ne "no"
$attrs->{"default_generate"}
$attrs->{"default_generate"} ne "no"
Truth table0%0/3
A and B
A= $attrs->{"default_generate"}B= $attrs->{"default_generate"} ne "no"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $datum->{value} = $value->[1] if @$value and $value->[1] =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$value and $value->[1] =~ /\S/
MC/DC0%0/2
@$value and $value->[1] =~ /\S/
@$value
$value->[1] =~ /\S/
Truth table0%0/3
A and B
A= @$valueB= $value->[1] =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | $datum->{count} = $attrs->{count} if $attrs->{count}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if($attrs->{count_prefix} || $attrs->{length_prefix}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attrs->{"count_prefix"} or $attrs->{"length_prefix"}
MC/DC0%0/2
$attrs->{"count_prefix"} or $attrs->{"length_prefix"}
$attrs->{"count_prefix"}
$attrs->{"length_prefix"}
Truth table0%0/3
A or B
A= $attrs->{"count_prefix"}B= $attrs->{"length_prefix"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my($packlet, $len) = _num_to_packlen($attrs->{count_prefix} || $attrs->{length_prefix}, $attrs->{prefix_order}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$attrs->{'count_prefix'} || $attrs->{'length_prefix'}
MC/DC0%0/2
$attrs->{'count_prefix'} || $attrs->{'length_prefix'}
$attrs->{'count_prefix'}
$attrs->{'length_prefix'}
Truth table0%0/3
A || B
A= $attrs->{'count_prefix'}B= $attrs->{'length_prefix'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $datum->{prefix_packlet} = $packlet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $datum->{prefix_len} = $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $datum->{prefix} = $attrs->{count_prefix} ? "count" : "length"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if($tag eq "ref") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $datum->{type} = "ref"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ▶ | } elsif($tag eq "byte" or $tag eq "word" or $tag eq "dword" or $tag eq "enum") { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$tag eq "byte" or $tag eq "word" or $tag eq "dword" or $tag eq "enum"
$tag eq "byte" or $tag eq "word" or $tag eq "dword"
$tag eq "byte" or $tag eq "word"
MC/DC0%0/4
$tag eq "byte" or $tag eq "word" or $tag eq "dword" or $tag eq "enum"
$tag eq "byte"
$tag eq "word"
$tag eq "dword"
$tag eq "enum"
Truth table0%0/5
A or B or C or D
A= $tag eq "byte"B= $tag eq "word"C= $tag eq "dword"D= $tag eq "enum"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $datum->{type} = "num"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $enum = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if($tag eq "enum") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $tag = $attrs->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $enum = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my($packlet, $len) = _num_to_packlen($tag, $attrs->{order}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $datum->{packlet} = $packlet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $datum->{len} = $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if($enum) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $datum->{enum_byname} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $datum->{enum_byval} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | while(@$value) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my($subtag, $subval) = splice(@$value, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | next if $subtag eq "0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $attrs = shift @$subval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my($name, $value, $default) = ($attrs->{name}, $attrs->{value}, $attrs->{default}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $datum->{enum_byname}->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $datum->{enum_byval}->{$value} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $datum->{value} = $value if $default; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $datum->{value} = $value->[1] if @$value; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } elsif($tag eq "data") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $datum->{type} = "data"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $datum->{len} = $attrs->{length} if $attrs->{length}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $datum->{pad} = $attrs->{pad} if exists($attrs->{pad}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $datum->{null_terminated} = 1 if $attrs->{null_terminated} and $attrs->{null_terminated} eq "yes"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attrs->{"null_terminated"} and $attrs->{"null_terminated"} eq "yes"
MC/DC0%0/2
$attrs->{"null_terminated"} and $attrs->{"null_terminated"} eq "yes"
$attrs->{"null_terminated"}
$attrs->{"null_terminated"} eq "yes"
Truth table0%0/3
A and B
A= $attrs->{"null_terminated"}B= $attrs->{"null_terminated"} eq "yes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | while(@$value) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my($subtag, $subval) = splice(@$value, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if($subtag eq "0") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $datum->{value} ||= $subval if $subval =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$datum->{"value"} ||= $subval
MC/DC0%0/2
$datum->{"value"} ||= $subval
$datum->{"value"}
$subval
Truth table0%0/3
A ||= B
A= $datum->{"value"}B= $subval
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $item = _xmlnode_to_template($subtag, $subval); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $datum->{items} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$datum->{"items"} ||= []
MC/DC0%0/1
$datum->{"items"} ||= []
$datum->{"items"}
Truth table0%0/2
A
A= $datum->{"items"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | push @{$datum->{items}}, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } elsif($tag eq "tlvchain") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $datum->{type} = "tlvchain"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | $datum->{len} = $attrs->{length} if $attrs->{length}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $datum->{subtyped} = 1 if $attrs->{subtyped} and $attrs->{subtyped} eq "yes"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attrs->{"subtyped"} and $attrs->{"subtyped"} eq "yes"
MC/DC0%0/2
$attrs->{"subtyped"} and $attrs->{"subtyped"} eq "yes"
$attrs->{"subtyped"}
$attrs->{"subtyped"} eq "yes"
Truth table0%0/3
A and B
A= $attrs->{"subtyped"}B= $attrs->{"subtyped"} eq "yes"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my($subtag, $subval); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | while(@$value) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my($tlvtag, $tlvval) = splice(@$value, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | next if $tlvtag ne "tlv"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $tlvattrs = shift @$tlvval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $item->{type} = "data"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $item->{name} = $tlvattrs->{name} if $tlvattrs->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $item->{num} = $tlvattrs->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $item->{subtype} = $tlvattrs->{subtype} if $tlvattrs->{subtype}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $item->{count} = $tlvattrs->{count} if $tlvattrs->{count}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $item->{value} = "" if $tlvattrs->{default_generate} and $tlvattrs->{default_generate} ne "no"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tlvattrs->{"default_generate"} and $tlvattrs->{"default_generate"} ne "no"
MC/DC0%0/2
$tlvattrs->{"default_generate"} and $tlvattrs->{"default_generate"} ne "no"
$tlvattrs->{"default_generate"}
$tlvattrs->{"default_generate"} ne "no"
Truth table0%0/3
A and B
A= $tlvattrs->{"default_generate"}B= $tlvattrs->{"default_generate"} ne "no"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $item->{items} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | while(@$tlvval) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my($subtag, $subval) = splice(@$tlvval, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | next if $subtag eq "0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $tlvitem = _xmlnode_to_template($subtag, $subval); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | push @{$item->{items}}, $tlvitem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | push @{$datum->{items}}, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return $datum; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | our(%PROTOCACHE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub protoparse($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protoparse: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my ($oscar, $wanted) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return $PROTOCACHE{$wanted}->set_oscar($oscar) if exists($PROTOCACHE{$wanted}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | my $xml = $xmlmap{$wanted}->{xml} or croak "Couldn't find requested protocol element '$wanted'."; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | confess "No oscar!" unless $oscar; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $attrs = shift @$xml; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my @template = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | while(@$xml) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $tag = shift @$xml; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $value = shift @$xml; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | next if $tag eq "0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | push @template, _xmlnode_to_template($tag, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | return @template if $PROTOPARSE_DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $obj = Net::OSCAR::XML::Template->new(\@template); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $PROTOCACHE{$wanted} = $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return $obj->set_oscar($oscar); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # Map a "protobit" (XML <define name="foo">) to SNAC (family => foo, subtype => bar) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | sub protobit_to_snac($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protobit_to_snac: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $protobit = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | confess "Unknown protobit $protobit" unless $xmlmap{$protobit}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my %ret = %{$xmlmap{$protobit}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | delete $ret{xml}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # Map a SNAC (family => foo, subtype => bar) to "protobit" (XML <define name="foo">) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub snac_to_protobit(%) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
snac_to_protobit: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my(%snac) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if($xml_revmap{$snac{family}} and $xml_revmap{$snac{family}}->{$snac{subtype}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$Net::OSCAR::XML::xml_revmap{$snac{"family"}} and $Net::OSCAR::XML::xml_revmap{$snac{"family"}}{$snac{"subtype"}}
MC/DC0%0/2
$Net::OSCAR::XML::xml_revmap{$snac{"family"}} and $Net::OSCAR::XML::xml_revmap{$snac{"family"}}{$snac{"subtype"}}
$Net::OSCAR::XML::xml_revmap{$snac{"family"}}
$Net::OSCAR::XML::xml_revmap{$snac{"family"}}{$snac{"subtype"}}
Truth table0%0/3
A and B
A= $Net::OSCAR::XML::xml_revmap{$snac{"family"}}B= $Net::OSCAR::XML::xml_revmap{$snac{"family"}}{$snac{"subtype"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return $xml_revmap{$snac{family}}->{$snac{subtype}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ▶ | } elsif($xml_revmap{'-1'} and $xml_revmap{'-1'}->{$snac{subtype}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Net::OSCAR::XML::xml_revmap{-1} and $Net::OSCAR::XML::xml_revmap{-1}{$snac{"subtype"}}
MC/DC0%0/2
$Net::OSCAR::XML::xml_revmap{-1} and $Net::OSCAR::XML::xml_revmap{-1}{$snac{"subtype"}}
$Net::OSCAR::XML::xml_revmap{-1}
$Net::OSCAR::XML::xml_revmap{-1}{$snac{"subtype"}}
Truth table0%0/3
A and B
A= $Net::OSCAR::XML::xml_revmap{-1}B= $Net::OSCAR::XML::xml_revmap{-1}{$snac{"subtype"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return $xml_revmap{'-1'}->{$snac{subtype}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||