| 1 | package Net::Server::Mail::ESMTP::HELP; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base qw(Net::Server::Mail::ESMTP::Extension); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Net::Server::Mail::ESMTP::HELP - Simple implementation of HELP for Net::Server::Mail::ESMTP | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Version 0.01 | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | Simple implementation of HELP for Net::Server::Mail::ESMTP. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | use Net::Server::Mail::ESMTP; | ||||||||||||||||||||||||||||
| 26 | my $server = new IO::Socket::INET Listen => 1, LocalPort => 25; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | my $conn; | ||||||||||||||||||||||||||||
| 29 | while($conn = $server->accept) | ||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||
| 31 | my $esmtp = new Net::Server::Mail::ESMTP socket => $conn; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # activate HELP extension | ||||||||||||||||||||||||||||
| 34 | $esmtp->register('Net::Server::Mail::ESMTP::HELP'); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # adding (optional) HELP handler | ||||||||||||||||||||||||||||
| 37 | $esmtp->set_callback(HELP => \&show_help); | ||||||||||||||||||||||||||||
| 38 | $esmtp->process; | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # if you don't set a custom HELP handler, the default one will be used which just lists all known verbs | ||||||||||||||||||||||||||||
| 42 | sub show_help { | ||||||||||||||||||||||||||||
| 43 | my ($session, $command) = @_; | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | $session->reply(214, ($command ? "2.0.0 Heck yeah, '$command' rules!\n":'') . "2.0.0 Available Commands: " . join(', ', keys %{$session->{verb}}) . "\nEnd of HELP info"); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | return 1; | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 EXPORT | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | A list of functions that can be exported. You can delete this section | ||||||||||||||||||||||||||||
| 55 | if you don't export anything, such as for a purely object-oriented module. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head2 verb | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub verb { | ||||||||||||||||||||||||||
|
Subroutine
verb: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 0 | return [ 'HELP' => 'help' ]; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head2 keyword | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub keyword { | ||||||||||||||||||||||||||
|
Subroutine
keyword: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | return 'HELP'; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 reply | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub reply { | ||||||||||||||||||||||||||
|
Subroutine
reply: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 0 | return ( [ 'HELP', ] ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =head2 help | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub help { | ||||||||||||||||||||||||||
|
Subroutine
help: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 91 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | my $ref = $self->{callback}->{HELP}; | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( ref $ref eq 'ARRAY' && ref $ref->[0] eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $ref eq "ARRAY" and ref $ref->[0] eq "CODE"
MC/DC0%0/2
ref $ref eq "ARRAY" and ref $ref->[0] eq "CODE"
ref $ref eq "ARRAY"
ref $ref->[0] eq "CODE"
Truth table0%0/3
A and B
A= ref $ref eq "ARRAY"B= ref $ref->[0] eq "CODE"
| |||||||||||||||||||||||||||||
| 95 | 0 | my $code = $ref->[0]; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my $ok = &$code($self, $args); | |||||||||||||||||||||||||||
| 98 | } else { | ||||||||||||||||||||||||||||
| 99 | 0 | $self->reply(214, "2.0.0 Available Commands: " . join(', ', keys %{$self->{verb}}) . "\nEnd of HELP info"); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | return (); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | *Net::Server::Mail::ESMTP::help = \&help; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Dan Moore, C<< <dan at moore.cx> >> | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head1 BUGS | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Please report any bugs or feature requests to C<bug-net-server-mail-esmtp-help at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 115 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Server-Mail-ESMTP-HELP>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 116 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | perldoc Net::Server::Mail::ESMTP::HELP | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | You can also look for information at: | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =over 4 | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Server-Mail-ESMTP-HELP> | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | L<http://annocpan.org/dist/Net-Server-Mail-ESMTP-HELP> | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | L<http://cpanratings.perl.org/d/Net-Server-Mail-ESMTP-HELP> | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | L<http://search.cpan.org/dist/Net-Server-Mail-ESMTP-HELP/> | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =back | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | Copyright 2011 Dan Moore. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 159 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 160 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =cut | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 2 | 1; # End of Net::Server::Mail::ESMTP::HELP | |||||||||||||||||||||||||||