| 1 | # This code is part of Perl distribution Mail-Box-Parser-C version 4.01. | ||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2002-2026 by Mark Overmeer. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | package Mail::Box::Parser::C;{ | ||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '4.01'; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use parent qw/Mail::Box::Parser DynaLoader/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | our $VERSION = '4.01'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Log::Report 'mail-box-parser-c'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Mail::Message::Field (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | #-------------------- | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | bootstrap Mail::Box::Parser::C $VERSION; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | ## Defined in the XS library | ||||||||||||||||||||||||||||
| 32 | sub open_filename($$$); | ||||||||||||||||||||||||||||
| 33 | sub open_filehandle($$$); | ||||||||||||||||||||||||||||
| 34 | sub get_filehandle($); | ||||||||||||||||||||||||||||
| 35 | sub close_file($); | ||||||||||||||||||||||||||||
| 36 | sub push_separator($$); | ||||||||||||||||||||||||||||
| 37 | sub pop_separator($); | ||||||||||||||||||||||||||||
| 38 | sub get_position($); | ||||||||||||||||||||||||||||
| 39 | sub set_position($$); | ||||||||||||||||||||||||||||
| 40 | sub read_header($); | ||||||||||||||||||||||||||||
| 41 | sub fold_header_line($$); | ||||||||||||||||||||||||||||
| 42 | sub in_dosmode($); | ||||||||||||||||||||||||||||
| 43 | sub read_separator($); | ||||||||||||||||||||||||||||
| 44 | sub body_as_string($$$); | ||||||||||||||||||||||||||||
| 45 | sub body_as_list($$$); | ||||||||||||||||||||||||||||
| 46 | sub body_as_file($$$$); | ||||||||||||||||||||||||||||
| 47 | sub body_delayed($$$); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # Not used yet. | ||||||||||||||||||||||||||||
| 50 | #fold_header_line(char *original, int wrap) | ||||||||||||||||||||||||||||
| 51 | #in_dosmode(int boxnr) | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | #-------------------- | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub init(@) | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 0 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $self->{MBPC_file} = my $fh = $args->{file}; | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | $self->{MBPC_mode} = $args->{mode} || 'r'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'mode'} || 'r'
MC/DC0%0/1
$args->{'mode'} || 'r'
$args->{'mode'}
Truth table0%0/2
A
A= $args->{'mode'}
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $self->{MBPC_filename} = $args->{filename} || ref $fh | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{'filename'} || ref $fh
MC/DC0%0/2
$args->{'filename'} || ref $fh
$args->{'filename'}
ref $fh
Truth table0%0/3
A || B
A= $args->{'filename'}B= ref $fh
| |||||||||||||||||||||||||||||
| 62 | or error __x"filename or handle required to create a parser."; | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | $self->start; | |||||||||||||||||||||||||||
| 65 | 0 | $self; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | #-------------------- | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub filename() { $_[0]->{MBPC_filename} } | ||||||||||||||||||||||||||
|
Subroutine
filename: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub openMode() { $_[0]->{MBPC_mode} } | ||||||||||||||||||||||||||
|
Subroutine
openMode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub file() { $_[0]->{MBPC_file} } | ||||||||||||||||||||||||||
|
Subroutine
file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub boxnr() { $_[0]->{MBPC_boxnr} } | ||||||||||||||||||||||||||
|
Subroutine
boxnr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | #-------------------- | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub start(@) | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $self->openFile(%args) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | trace "opened folder ".$self->filename." to be parsed"; | |||||||||||||||||||||||||||
| 84 | 0 | $self; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub stop() | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
stop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 0 | trace "close parser for file " . $self->filename; | |||||||||||||||||||||||||||
| 91 | 0 | $self->closeFile; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | sub pushSeparator($) | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | { my ($self, $sep) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pushSeparator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 0 | push_separator $self->boxnr, $sep; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub popSeparator() { pop_separator $_[0]->boxnr } | ||||||||||||||||||||||||||
|
Subroutine
popSeparator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub filePosition(;$) | ||||||||||||||||||||||||||||
| 102 | 0 | ▶ | { my $boxnr = shift->boxnr; | ||||||||||||||||||||||||||
|
Subroutine
filePosition: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | @_ ? set_position($boxnr, shift) : get_position($boxnr); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub readHeader() { read_header $_[0]->boxnr } | ||||||||||||||||||||||||||
|
Subroutine
readHeader: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub readSeparator() { read_separator $_[0]->boxnr } | ||||||||||||||||||||||||||
|
Subroutine
readSeparator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | sub bodyAsString(;$$) | ||||||||||||||||||||||||||||
| 111 | 0 | ▶ | { my ($self, $exp_chars, $exp_lines) = @_; | ||||||||||||||||||||||||||
|
Subroutine
bodyAsString: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | body_as_string $self->boxnr, $exp_chars // -1, $exp_lines // -1; | ||||||||||||||||||||||||||
|
Condition0%0/4
$exp_chars // -1
$exp_lines // -1
MC/DC0%0/1
$exp_chars // -1
$exp_chars
MC/DC0%0/1
$exp_lines // -1
$exp_lines
Truth table0%0/2
A
A= $exp_chars
Truth table0%0/2
A
A= $exp_lines
| |||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub bodyAsList(;$$) | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | { my ($self, $exp_chars, $exp_lines) = @_; | ||||||||||||||||||||||||||
|
Subroutine
bodyAsList: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | body_as_list $self->boxnr, $exp_chars // -1, $exp_lines // -1; | ||||||||||||||||||||||||||
|
Condition0%0/4
$exp_chars // -1
$exp_lines // -1
MC/DC0%0/1
$exp_chars // -1
$exp_chars
MC/DC0%0/1
$exp_lines // -1
$exp_lines
Truth table0%0/2
A
A= $exp_chars
Truth table0%0/2
A
A= $exp_lines
| |||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub bodyAsFile($;$$) | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { my ($self, $file, $exp_chars, $exp_lines) = @_; | ||||||||||||||||||||||||||
|
Subroutine
bodyAsFile: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | body_as_file $self->boxnr, $file, $exp_chars // -1, $exp_lines // -1; | ||||||||||||||||||||||||||
|
Condition0%0/4
$exp_chars // -1
$exp_lines // -1
MC/DC0%0/1
$exp_chars // -1
$exp_chars
MC/DC0%0/1
$exp_lines // -1
$exp_lines
Truth table0%0/2
A
A= $exp_chars
Truth table0%0/2
A
A= $exp_lines
| |||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | sub bodyDelayed(;$$) | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | { my ($self, $exp_chars, $exp_lines) = @_; | ||||||||||||||||||||||||||
|
Subroutine
bodyDelayed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | body_delayed $self->boxnr, $exp_chars // -1, $exp_lines // -1; | ||||||||||||||||||||||||||
|
Condition0%0/4
$exp_chars // -1
$exp_lines // -1
MC/DC0%0/1
$exp_chars // -1
$exp_chars
MC/DC0%0/1
$exp_lines // -1
$exp_lines
Truth table0%0/2
A
A= $exp_chars
Truth table0%0/2
A
A= $exp_lines
| |||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | sub openFile(%) | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
openFile: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $trace = $args{trace} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'trace'} || 0
MC/DC0%0/1
$args{'trace'} || 0
$args{'trace'}
Truth table0%0/2
A
A= $args{'trace'}
| |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my $filename = $args{filename} || $self->filename; | ||||||||||||||||||||||||||
|
Condition0%0/3
$args{'filename'} || $self->filename
MC/DC0%0/2
$args{'filename'} || $self->filename
$args{'filename'}
$self->filename
Truth table0%0/3
A || B
A= $args{'filename'}B= $self->filename
| |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $mode = $args{mode} || $self->openMode; | ||||||||||||||||||||||||||
|
Condition0%0/3
$args{'mode'} || $self->openMode
MC/DC0%0/2
$args{'mode'} || $self->openMode
$args{'mode'}
$self->openMode
Truth table0%0/3
A || B
A= $args{'mode'}B= $self->openMode
| |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my $fh = $args{file} || $self->file; | ||||||||||||||||||||||||||
|
Condition0%0/3
$args{'file'} || $self->file
MC/DC0%0/2
$args{'file'} || $self->file
$args{'file'}
$self->file
Truth table0%0/3
A || B
A= $args{'file'}B= $self->file
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | my $boxnr; | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | if(defined $fh) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | { $boxnr = open_filehandle($fh, $filename // "$fh", $trace); | ||||||||||||||||||||||||||
|
Condition0%0/2
$filename // "$fh"
MC/DC0%0/1
$filename // "$fh"
$filename
Truth table0%0/2
A
A= $filename
| |||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | else | ||||||||||||||||||||||||||||
| 143 | 0 | { $boxnr = open_filename($filename, $mode, $trace); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | $self->{MBPC_boxnr} = $boxnr; | |||||||||||||||||||||||||||
| 147 | 0 | ▶ | defined $boxnr ? $self : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub closeFile() { | ||||||||||||||||||||||||||
|
Subroutine
closeFile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 151 | 0 | my $boxnr = delete $_[0]->{MBPC_boxnr}; | |||||||||||||||||||||||||||
| 152 | 0 | ▶ | defined $boxnr ? close_file $boxnr : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 1 | 1; | |||||||||||||||||||||||||||