| 1 | # FTN::Crypt::Msg - Message parsing for the FTN::Crypt module | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2019 by Petr Antonov | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # This library is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 6 | # under the same terms as Perl 5.10.0. For more details, see the full text | ||||||||||||||||||||||||||||
| 7 | # of the licenses at https://opensource.org/licenses/Artistic-1.0, and | ||||||||||||||||||||||||||||
| 8 | # http://www.gnu.org/licenses/gpl-2.0.html. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # This package is provided "as is" and without any express or implied | ||||||||||||||||||||||||||||
| 11 | # warranties, including, without limitation, the implied warranties of | ||||||||||||||||||||||||||||
| 12 | # merchantability and fitness for a particular purpose. | ||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||
| 14 | package FTN::Crypt::Msg::MsgChunk; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub new { | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | my $self = { | |||||||||||||||||||||||||||
| 24 | data => [], | ||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub get { | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | return $self->{data}; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub set { | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 38 | 0 | my ($line) = @_; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | push @{$self->{data}}, $line; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | package FTN::Crypt::Msg::KludgeChunk; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 1 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | use base qw/FTN::Crypt::Msg::MsgChunk/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub remove { | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 55 | 0 | my ($kludge) = @_; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (defined $kludge && $kludge ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $kludge and $kludge ne ""
MC/DC0%0/2
defined $kludge and $kludge ne ""
defined $kludge
$kludge ne ""
Truth table0%0/3
A and B
A= defined $kludgeB= $kludge ne ""
| |||||||||||||||||||||||||||||
| 58 | 0 | @{$self->{data}} = grep { !/^${kludge}(?::?\s.+)*$/ } | |||||||||||||||||||||||||||
| 59 | 0 | @{$self->{data}}; | |||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||
| 61 | 0 | return; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | return 1; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | package FTN::Crypt::Msg::TextChunk; | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | use base qw/FTN::Crypt::Msg::MsgChunk/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | sub get { | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 79 | 0 | my ($ftn_ready) = @_; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my $sep = $ftn_ready ? "\r" : "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | return join $sep, @{$self->{data}}; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | package FTN::Crypt::Msg; | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 91 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 1 | ▶ | use base qw/FTN::Crypt::Error/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 NAME | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | FTN::Crypt::Msg - Message parsing for the L<FTN::Crypt> module. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | use FTN::Crypt::Msg; | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | my $obj = FTN::Crypt::Msg->new( | ||||||||||||||||||||||||||||
| 107 | Address => $ftn_address, | ||||||||||||||||||||||||||||
| 108 | Message => $msg, | ||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||
| 110 | $obj->add_kludge('ENC: PGP5'); | ||||||||||||||||||||||||||||
| 111 | $obj->remove_kludge('ENC'); | ||||||||||||||||||||||||||||
| 112 | my $text = $obj->get_text; | ||||||||||||||||||||||||||||
| 113 | my $kludges = $obj->get_kludges; | ||||||||||||||||||||||||||||
| 114 | my $msg = $obj->get_message; | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 1 | ▶ | use FTN::Address; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 1 | my $SOH = chr(1); | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 1 | my %PREDEFINED_INDEX = ( | |||||||||||||||||||||||||||
| 127 | 'TOP' => 0, | ||||||||||||||||||||||||||||
| 128 | 'BOTTOM' => -1, | ||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||
| 130 | 1 | my %DEFAULT_INDEX = ( | |||||||||||||||||||||||||||
| 131 | KLUDGE => 'TOP', | ||||||||||||||||||||||||||||
| 132 | TEXT => 'BOTTOM', | ||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head1 METHODS | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head2 new() | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | Constructor. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =over 4 | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =item * C<Address>: Recipient's FTN address. | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =item * C<Message>: FTN message text with kludges. | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =back | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =head3 Returns: | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | Created object or error in C<FTN::Crypt::Msg-E<gt>error>. | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | Sample: | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | my $obj = FTN::Crypt::Msg->new( | ||||||||||||||||||||||||||||
| 164 | Address => $ftn_address, | ||||||||||||||||||||||||||||
| 165 | Message => $msg, | ||||||||||||||||||||||||||||
| 166 | ) or die FTN::Crypt::Msg->error; | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =cut | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | sub new { | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 172 | 0 | my (%opts) = @_; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | ▶ | unless (%opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 0 | $class->set_error('No options specified'); | |||||||||||||||||||||||||||
| 176 | 0 | return; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | unless ($opts{Address}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | $class->set_error('No address specified'); | |||||||||||||||||||||||||||
| 180 | 0 | return; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | 0 | ▶ | unless ($opts{Message}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | $class->set_error('No message specified'); | |||||||||||||||||||||||||||
| 184 | 0 | return; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | my $self = { | |||||||||||||||||||||||||||
| 188 | msg => [], | ||||||||||||||||||||||||||||
| 189 | idx => { | ||||||||||||||||||||||||||||
| 190 | KLUDGE => [], | ||||||||||||||||||||||||||||
| 191 | TEXT => [], | ||||||||||||||||||||||||||||
| 192 | }, | ||||||||||||||||||||||||||||
| 193 | }; | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | $self = bless $self, $class; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | unless ($self->set_address($opts{Address})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | $class->set_error($self->error); | |||||||||||||||||||||||||||
| 199 | 0 | return; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | 0 | ▶ | unless ($self->set_message($opts{Message})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | $class->set_error($self->error); | |||||||||||||||||||||||||||
| 203 | 0 | return; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | return $self; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | sub _check_kludge { | ||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_check_kludge: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 213 | 0 | my ($kludge) = @_; | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | unless (defined $kludge && $kludge ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $kludge and $kludge ne ""
MC/DC0%0/2
defined $kludge and $kludge ne ""
defined $kludge
$kludge ne ""
Truth table0%0/3
A and B
A= defined $kludgeB= $kludge ne ""
| |||||||||||||||||||||||||||||
| 216 | 0 | $self->set_error('Kludge is empty'); | |||||||||||||||||||||||||||
| 217 | 0 | return; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | return $kludge; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | sub _check_text { | ||||||||||||||||||||||||||||
| 226 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_check_text: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 227 | 0 | my ($text) = @_; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | unless (defined $text && $text ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $text and $text ne ""
MC/DC0%0/2
defined $text and $text ne ""
defined $text
$text ne ""
Truth table0%0/3
A and B
A= defined $textB= $text ne ""
| |||||||||||||||||||||||||||||
| 230 | 0 | $self->set_error('Text is empty'); | |||||||||||||||||||||||||||
| 231 | 0 | return; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | return $text; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | sub _check_idx { | ||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_check_idx: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 241 | 0 | my ($type, $idx) = @_; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | ▶ | unless (grep /^$type$/, keys %{$self->{idx}}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | $self->set_error("Invalid message area type (`$type')"); | |||||||||||||||||||||||||||
| 245 | 0 | return; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $idx = $DEFAULT_INDEX{$type} unless defined $idx; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | $idx = $PREDEFINED_INDEX{$idx} if defined $PREDEFINED_INDEX{$idx}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | unless ($idx =~ /^-?\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | $self->set_error("Invalid chunk index (`$idx')"); | |||||||||||||||||||||||||||
| 254 | 0 | return; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | unless (defined $self->{idx}->{$type}->[$idx]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | $self->set_error("Invalid chunk index (`$idx')"); | |||||||||||||||||||||||||||
| 259 | 0 | return; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | return $idx; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =head2 add_kludge() | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | Add kludge to the message. | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =over 4 | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =item * Kludge string. | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =item * B<Optional> C<[TOP|BOTTOM|<index>]> Kludges block, defaults to TOP. | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =back | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | =head3 Returns: | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | True or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | Sample: | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | $obj->add_kludge('ENC: PGP5') or die $obj->error; | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | =cut | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | sub add_kludge { | ||||||||||||||||||||||||||||
| 292 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_kludge: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 293 | 0 | my ($kludge, $idx) = @_; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 0 | $kludge = $self->_check_kludge($kludge); | |||||||||||||||||||||||||||
| 296 | 0 | $idx = $self->_check_idx('KLUDGE', $idx); | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if (defined $kludge && defined $idx) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $kludge and defined $idx
MC/DC0%0/2
defined $kludge and defined $idx
defined $kludge
defined $idx
Truth table0%0/3
A and B
A= defined $kludgeB= defined $idx
| |||||||||||||||||||||||||||||
| 299 | 0 | $self->{msg}->[$self->{idx}->{KLUDGE}->[$idx]]->set($kludge); | |||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||
| 301 | 0 | return; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | return 1; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =head2 remove_kludge() | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | Remove kludge from the message. | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | =over 4 | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | =item * Kludge string, may be only the first part of the composite kludge. | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | =item * B<Optional> C<[TOP|BOTTOM|<index>]> Kludges block, defaults to TOP. | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =back | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | =head3 Returns: | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | True or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | Sample: | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | $obj->remove_kludge('ENC') or die $obj->error; | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | =cut | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | sub remove_kludge { | ||||||||||||||||||||||||||||
| 334 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
remove_kludge: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 335 | 0 | my ($kludge, $idx) = @_; | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | $kludge = $self->_check_kludge($kludge); | |||||||||||||||||||||||||||
| 338 | 0 | $idx = $self->_check_idx('KLUDGE', $idx); | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if (defined $kludge && defined $idx) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $kludge and defined $idx
MC/DC0%0/2
defined $kludge and defined $idx
defined $kludge
defined $idx
Truth table0%0/3
A and B
A= defined $kludgeB= defined $idx
| |||||||||||||||||||||||||||||
| 341 | 0 | $self->{msg}->[$self->{idx}->{KLUDGE}->[$idx]]->remove($kludge); | |||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||
| 343 | 0 | return; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 0 | return 1; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | =head2 get_kludges() | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | Get message kludges. | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | None. | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | =head3 Returns: | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | Arrayref with kludges list or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Sample: | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | $obj->get_kludges() or die $obj->error; | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | =cut | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | sub get_kludges { | ||||||||||||||||||||||||||||
| 370 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_kludges: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | my $kludges = []; | |||||||||||||||||||||||||||
| 373 | 0 | foreach my $c (@{$self->{msg}}) { | |||||||||||||||||||||||||||
| 374 | 0 | ▶ | push @{$kludges}, $c->get if $c->isa('FTN::Crypt::Msg::KludgeChunk'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 0 | return $kludges; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =head2 get_address() | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Get recipient's FTN address. | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | None. | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =head3 Returns: | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | Recipient's FTN address or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | Sample: | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | my $ftn_address = $obj->get_address() or die $obj->error; | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =cut | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | sub get_address { | ||||||||||||||||||||||||||||
| 401 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_address: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | my $addr = $self->{addr}->get; | |||||||||||||||||||||||||||
| 404 | 0 | ▶ | unless ($addr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 0 | $self->set_error($@); | |||||||||||||||||||||||||||
| 406 | 0 | return; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | return $addr; | |||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | =head2 set_address() | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | Set recipient's FTN address. | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | =over 4 | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | =item * Recipient's FTN address. | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | =back | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | =head3 Returns: | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | True or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | Sample: | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | $obj->set_address($ftn_address) | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =cut | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | sub set_address { | ||||||||||||||||||||||||||||
| 437 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_address: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 438 | 0 | my ($addr) = @_; | |||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 0 | $self->{addr} = FTN::Address->new($addr); | |||||||||||||||||||||||||||
| 441 | 0 | ▶ | unless ($self->{addr}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 442 | 0 | $self->set_error($@); | |||||||||||||||||||||||||||
| 443 | 0 | return; | |||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 0 | return 1; | |||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =head2 get_text() | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | Get text part of the message. | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =over 4 | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =item * B<Optional> C<[TOP|BOTTOM|<index>]> Text block, defaults to BOTTOM. | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =back | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | =head3 Returns: | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | Text part of the message or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | Sample: | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | my $text = $obj->get_text() or die $obj->error; | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | =cut | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | sub get_text { | ||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_text: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 475 | 0 | my ($idx) = @_; | |||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 0 | $idx = $self->_check_idx('TEXT', $idx); | |||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | 0 | my $text = ''; | |||||||||||||||||||||||||||
| 480 | 0 | ▶ | if (defined $idx) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | 0 | $text = $self->{msg}->[$self->{idx}->{TEXT}->[$idx]]->get; | |||||||||||||||||||||||||||
| 482 | } else { | ||||||||||||||||||||||||||||
| 483 | 0 | return; | |||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | 0 | return $text; | |||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =head2 get_all_text() | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | Get all text parts of the message. | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | None. | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =head3 Returns: | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | Arrayref with text parts of the message or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | Sample: | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | my $text = $obj->get_all_text() or die $obj->error; | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =cut | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | sub get_all_text { | ||||||||||||||||||||||||||||
| 510 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_all_text: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 0 | my $text = []; | |||||||||||||||||||||||||||
| 513 | 0 | foreach my $c (@{$self->{msg}}) { | |||||||||||||||||||||||||||
| 514 | 0 | ▶ | push @{$text}, $c->get if $c->isa('FTN::Crypt::Msg::TextChunk'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 0 | return $text; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | =head2 set_text() | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | Set text part of the message. | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =over 4 | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | =item * Text part of the message. | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | =item * B<Optional> C<[TOP|BOTTOM|<index>]> Text block, defaults to BOTTOM. | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | =back | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | =head3 Returns: | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | True or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | Sample: | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | $obj->set_text($text) or die $obj->error; | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | =cut | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | sub set_text { | ||||||||||||||||||||||||||||
| 547 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_text: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 548 | 0 | my ($text, $idx) = @_; | |||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 0 | $text = $self->_check_text($text); | |||||||||||||||||||||||||||
| 551 | 0 | $idx = $self->_check_idx('TEXT', $idx); | |||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if (defined $text && defined $idx) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $text and defined $idx
MC/DC0%0/2
defined $text and defined $idx
defined $text
defined $idx
Truth table0%0/3
A and B
A= defined $textB= defined $idx
| |||||||||||||||||||||||||||||
| 554 | 0 | $self->{msg}->[$self->{idx}->{TEXT}->[$idx]] = FTN::Crypt::Msg::TextChunk->new; | |||||||||||||||||||||||||||
| 555 | 0 | $text =~ s/\r\n/\r/g; | |||||||||||||||||||||||||||
| 556 | 0 | $text =~ s/\n/\r/g; | |||||||||||||||||||||||||||
| 557 | 0 | my @text_lines = split /\r/, $text; | |||||||||||||||||||||||||||
| 558 | 0 | foreach my $l (@text_lines) { | |||||||||||||||||||||||||||
| 559 | 0 | $self->{msg}->[$self->{idx}->{TEXT}->[$idx]]->set($l); | |||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | } else { | ||||||||||||||||||||||||||||
| 562 | 0 | return; | |||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||
| 565 | 0 | return 1; | |||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | =head2 get_message() | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | Get FTN message text with kludges. | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | None. | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | =head3 Returns: | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | FTN message text with kludges or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | Sample: | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | my $msg = $obj->get_message() or die $obj->error; | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | =cut | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | sub get_message { | ||||||||||||||||||||||||||||
| 589 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_message: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | 0 | my @msg; | |||||||||||||||||||||||||||
| 592 | 0 | foreach my $c (@{$self->{msg}}) { | |||||||||||||||||||||||||||
| 593 | 0 | ▶ | if ($c->isa('FTN::Crypt::Msg::KludgeChunk')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 594 | 0 | push @msg, join "\r", map { "${SOH}$_" } @{$c->get}; | |||||||||||||||||||||||||||
| 595 | } elsif ($c->isa('FTN::Crypt::Msg::TextChunk')) { | ||||||||||||||||||||||||||||
| 596 | 0 | push @msg, $c->get(1); | |||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 0 | my $msg_out = join "\r", @msg; | |||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 0 | return $msg_out; | |||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | #----------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | =head2 set_message() | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | Set FTN message text with kludges. | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | =head3 Parameters: | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | =over 4 | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | =item * FTN message text with kludges. | ||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | =back | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | =head3 Returns: | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | True or error in C<$obj-E<gt>error>. | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | Sample: | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | $obj->set_message($msg) or die $obj->error; | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | =cut | ||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | sub set_message { | ||||||||||||||||||||||||||||
| 630 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_message: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 631 | 0 | my ($msg) = @_; | |||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | 0 | $self->{msg} = []; | |||||||||||||||||||||||||||
| 634 | 0 | foreach my $a (keys %{$self->{idx}}) { | |||||||||||||||||||||||||||
| 635 | 0 | $self->{idx}->{$a} = []; | |||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | 0 | $msg =~ s/\r\n/\r/g; | |||||||||||||||||||||||||||
| 639 | 0 | $msg =~ s/\n/\r/g; | |||||||||||||||||||||||||||
| 640 | 0 | my @msg_lines = split /\r/, $msg; | |||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | 0 | my $is_kludge; | |||||||||||||||||||||||||||
| 643 | 0 | foreach my $l (@msg_lines) { | |||||||||||||||||||||||||||
| 644 | 0 | ▶ | if ($l =~ s/^${SOH}//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 645 | 0 | ▶ | if (!defined $is_kludge || !$is_kludge) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $is_kludge and $is_kludge
MC/DC0%0/2
defined $is_kludge and $is_kludge
defined $is_kludge
$is_kludge
Truth table0%0/3
A and B
A= defined $is_kludgeB= $is_kludge
| |||||||||||||||||||||||||||||
| 646 | 0 | push @{$self->{msg}}, FTN::Crypt::Msg::KludgeChunk->new; | |||||||||||||||||||||||||||
| 647 | 0 | push @{$self->{idx}->{KLUDGE}}, $#{$self->{msg}}; | |||||||||||||||||||||||||||
| 648 | 0 | $is_kludge = 1; | |||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||
| 650 | } else { | ||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if (!defined $is_kludge || $is_kludge) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $is_kludge or $is_kludge
MC/DC0%0/2
not defined $is_kludge or $is_kludge
not defined $is_kludge
$is_kludge
Truth table0%0/3
not(A) or B
A= not defined $is_kludgeB= $is_kludge
| |||||||||||||||||||||||||||||
| 652 | 0 | push @{$self->{msg}}, FTN::Crypt::Msg::TextChunk->new; | |||||||||||||||||||||||||||
| 653 | 0 | push @{$self->{idx}->{TEXT}}, $#{$self->{msg}}; | |||||||||||||||||||||||||||
| 654 | 0 | $is_kludge = 0; | |||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | 0 | $self->{msg}->[-1]->set($l); | |||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 0 | return 1; | |||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | 1 | 1; | |||||||||||||||||||||||||||
| 664 | __END__ | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | Petr Antonov, E<lt>pietro@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | Copyright (C) 2019 by Petr Antonov | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | This library is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 675 | under the same terms as Perl 5.10.0. For more details, see the full text | ||||||||||||||||||||||||||||
| 676 | of the licenses at L<https://opensource.org/licenses/Artistic-1.0>, and | ||||||||||||||||||||||||||||
| 677 | L<http://www.gnu.org/licenses/gpl-2.0.html>. | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | This package is provided "as is" and without any express or implied | ||||||||||||||||||||||||||||
| 680 | warranties, including, without limitation, the implied warranties of | ||||||||||||||||||||||||||||
| 681 | merchantability and fitness for a particular purpose. | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | =cut | ||||||||||||||||||||||||||||