← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:14 2021

Filename/usr/local/lib/perl5/site_perl/Mail/DKIM/MessageParser.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMail::DKIM::MessageParser::::BEGIN@14Mail::DKIM::MessageParser::BEGIN@14
0000s0sMail::DKIM::MessageParser::::BEGIN@2Mail::DKIM::MessageParser::BEGIN@2
0000s0sMail::DKIM::MessageParser::::BEGIN@3Mail::DKIM::MessageParser::BEGIN@3
0000s0sMail::DKIM::MessageParser::::CLOSEMail::DKIM::MessageParser::CLOSE
0000s0sMail::DKIM::MessageParser::::PRINTMail::DKIM::MessageParser::PRINT
0000s0sMail::DKIM::MessageParser::::TIEHANDLEMail::DKIM::MessageParser::TIEHANDLE
0000s0sMail::DKIM::MessageParser::::add_bodyMail::DKIM::MessageParser::add_body
0000s0sMail::DKIM::MessageParser::::add_headerMail::DKIM::MessageParser::add_header
0000s0sMail::DKIM::MessageParser::::finish_bodyMail::DKIM::MessageParser::finish_body
0000s0sMail::DKIM::MessageParser::::finish_headerMail::DKIM::MessageParser::finish_header
0000s0sMail::DKIM::MessageParser::::initMail::DKIM::MessageParser::init
0000s0sMail::DKIM::MessageParser::::new_handleMail::DKIM::MessageParser::new_handle
0000s0sMail::DKIM::MessageParser::::new_objectMail::DKIM::MessageParser::new_object
0000s0sMail::DKIM::MessageParser::::resetMail::DKIM::MessageParser::reset
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mail::DKIM::MessageParser;
2use strict;
3use warnings;
4our $VERSION = '1.20200907'; # VERSION
5# ABSTRACT: Signs/verifies Internet mail with DKIM/DomainKey signatures
6
7# Copyright 2005 Messiah College. All rights reserved.
8# Jason Long <jlong@messiah.edu>
9
10# Copyright (c) 2004 Anthony D. Urso. All rights reserved.
11# This program is free software; you can redistribute it and/or
12# modify it under the same terms as Perl itself.
13
14use Carp;
15
16sub new_object {
17 my $class = shift;
18 return $class->TIEHANDLE(@_);
19}
20
21sub new_handle {
22 my $class = shift;
23 local *TMP;
24 tie *TMP, $class, @_;
25 return *TMP;
26}
27
28sub TIEHANDLE {
29 my $class = shift;
30 my %args = @_;
31 my $self = bless \%args, $class;
32 $self->init;
33 return $self;
34}
35
36sub init {
37 my $self = shift;
38
39 my $buf = '';
40 $self->{buf_ref} = \$buf;
41 $self->{in_header} = 1;
42}
43
44sub PRINT {
45 my $self = shift;
46 my $buf_ref = $self->{buf_ref};
47 $$buf_ref .= @_ == 1 ? $_[0] : join( '', @_ ) if @_;
48
49 if ( $self->{in_header} ) {
50 local $1; # avoid polluting a global $1
51 while ( $$buf_ref ne '' ) {
52 if ( substr( $$buf_ref, 0, 2 ) eq "\015\012" ) {
53 substr( $$buf_ref, 0, 2 ) = '';
54 $self->finish_header();
55 $self->{in_header} = 0;
56 last;
57 }
58 if ( $$buf_ref !~ /^(.+?\015\012)[^\ \t]/s ) {
59 last;
60 }
61 my $header = $1;
62 $self->add_header($header);
63 substr( $$buf_ref, 0, length($header) ) = '';
64 }
65 }
66
67 if ( !$self->{in_header} ) {
68 my $j = rindex( $$buf_ref, "\015\012" );
69 if ( $j >= 0 ) {
70
71 # avoid copying a large buffer: the unterminated
72 # last line is typically short compared to the rest
73
74 my $carry = substr( $$buf_ref, $j + 2 );
75 substr( $$buf_ref, $j + 2 ) = ''; # shrink to last CRLF
76 $self->add_body($$buf_ref); # must end on CRLF
77 $$buf_ref = $carry; # restore unterminated last line
78 }
79 }
80 return 1;
81}
82
83sub CLOSE {
84 my $self = shift;
85 my $buf_ref = $self->{buf_ref};
86
87 if ( $self->{in_header} ) {
88 if ( $$buf_ref ne '' ) {
89
90 # A line of header text ending CRLF would not have been
91 # processed yet since before we couldn't tell if it was
92 # the complete header. Now that we're in CLOSE, we can
93 # finish the header...
94 $$buf_ref =~ s/\015\012\z//s;
95 $self->add_header("$$buf_ref\015\012");
96 }
97 $self->finish_header;
98 $self->{in_header} = 0;
99 }
100 else {
101 if ( $$buf_ref ne '' ) {
102 $self->add_body($$buf_ref);
103 }
104 }
105 $$buf_ref = '';
106 $self->finish_body;
107 return 1;
108}
109
110sub add_header {
111 die 'add_header not implemented';
112}
113
114sub finish_header {
115 die 'finish_header not implemented';
116}
117
118sub add_body {
119 die 'add_body not implemented';
120}
121
122sub finish_body {
123
124 # do nothing by default
125}
126
127sub reset {
128 carp 'reset not implemented';
129}
130
1311;
132
133__END__