| 1 | # | ||||||||||
| 2 | # Mail/Salsa/Archive.pm | ||||||||||
| 3 | # Last Modification: Mon May 31 15:05:16 WEST 2004 | ||||||||||
| 4 | # | ||||||||||
| 5 | # Copyright (c) 2004 Henrique Dias <hdias@aesbuc.pt>. All rights reserved. | ||||||||||
| 6 | # This module is free software; you can redistribute it and/or modify | ||||||||||
| 7 | # it under the same terms as Perl itself. | ||||||||||
| 8 | # | ||||||||||
| 9 | package Mail::Salsa::Archive; | ||||||||||
| 10 | |||||||||||
| 11 | 3 | ▶ | use 5.008000; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 3 | require Exporter; | |||||||||
| 16 | 3 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 3 | ▶ | use Fcntl qw(:DEFAULT :flock); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 3 | ▶ | use POSIX qw(strftime); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 3 | our @ISA = qw(Exporter); | |||||||||
| 21 | |||||||||||
| 22 | # Items to export into callers namespace by default. Note: do not export | ||||||||||
| 23 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||
| 24 | # Do not simply export all your public functions/methods/constants. | ||||||||||
| 25 | |||||||||||
| 26 | # This allows declaration use Mail::Salsa::Archive ':all'; | ||||||||||
| 27 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||
| 28 | # will save memory. | ||||||||||
| 29 | 3 | our %EXPORT_TAGS = ( 'all' => [ qw() ] ); | |||||||||
| 30 | 3 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||
| 31 | 3 | our @EXPORT = qw(&archive_msg); | |||||||||
| 32 | 3 | our $VERSION = '0.01'; | |||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub archive_msg { | ||||||||
|
Subroutine
archive_msg: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||
| 35 | 0 | my $self = shift; | |||||||||
| 36 | |||||||||||
| 37 | 0 | my ($name, $domain) = split(/\@/, $self->{'list'}); | |||||||||
| 38 | 0 | my $dir = join("/", $self->{'archive_dir'}, $domain, $name); | |||||||||
| 39 | 0 | ▶ | unless(-d $dir) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | Mail::Salsa::Utils::make_dir_rec($dir, 0755); | |||||||||
| 41 | 0 | ▶ | (-d $dir) or die("$!"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | } | ||||||||||
| 43 | 0 | my $date = strftime("%a %b %e %H:%M:%S %Y", localtime); | |||||||||
| 44 | 0 | my $mailbox = &mailbox_name(); | |||||||||
| 45 | 0 | ▶ | open(MSG, "<", $self->{'message'}) or die("$!"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | ▶ | open(ARCHIVE, ">>", join("/", $dir, $mailbox)) or die("$!"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | flock(ARCHIVE, LOCK_EX); | |||||||||
| 48 | 0 | print ARCHIVE join(" ", "From", $self->{'from'}, "$date\n"); | |||||||||
| 49 | 0 | ▶ | while(<MSG>) { print ARCHIVE $_; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | flock(ARCHIVE, LOCK_UN); | |||||||||
| 51 | 0 | close(ARCHIVE); | |||||||||
| 52 | 0 | close(MSG); | |||||||||
| 53 | 0 | return(); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub mailbox_name { | ||||||||
|
Subroutine
mailbox_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | 0 | my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); | |||||||||
| 58 | 0 | my ($mon, $year) = (localtime(time))[4,5]; | |||||||||
| 59 | 0 | my $month = $months[$mon]; | |||||||||
| 60 | 0 | $year += 1900; | |||||||||
| 61 | 0 | return("$year-$month"); | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | # Preloaded methods go here. | ||||||||||
| 65 | |||||||||||
| 66 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||
| 67 | |||||||||||
| 68 | 3 | 1; | |||||||||
| 69 | __END__ | ||||||||||