diff options
| author | fukachan <fukachan> | 2002-12-10 12:04:52 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2002-12-10 12:04:52 +0000 |
| commit | 4d22e01c81b228d4103d0407513e02cb2d155663 (patch) | |
| tree | 7d02bb73a4a04ae781a7b717fb36606695592a32 /img/lib/IM | |
| parent | 451f5fc29a94e13ec13c99d90ab9c748171fb829 (diff) | |
| download | fml8-im-142.tar.gz fml8-im-142.tar.bz2 fml8-im-142.zip | |
im-142im-142
Diffstat (limited to 'img/lib/IM')
| -rw-r--r-- | img/lib/IM/Address.pm | 110 | ||||
| -rw-r--r-- | img/lib/IM/Alias.pm | 106 | ||||
| -rw-r--r-- | img/lib/IM/Config.pm.in | 290 | ||||
| -rw-r--r-- | img/lib/IM/EncDec.pm | 134 | ||||
| -rw-r--r-- | img/lib/IM/File.pm | 98 | ||||
| -rw-r--r-- | img/lib/IM/Folder.pm | 170 | ||||
| -rw-r--r-- | img/lib/IM/GetPass.pm | 90 | ||||
| -rw-r--r-- | img/lib/IM/Grep.pm | 79 | ||||
| -rw-r--r-- | img/lib/IM/History.pm | 92 | ||||
| -rw-r--r-- | img/lib/IM/Http.pm | 83 | ||||
| -rw-r--r-- | img/lib/IM/Imap.pm | 241 | ||||
| -rw-r--r-- | img/lib/IM/Iso2022jp.pm | 94 | ||||
| -rw-r--r-- | img/lib/IM/Japanese.pm | 90 | ||||
| -rw-r--r-- | img/lib/IM/LocalMbox.pm | 142 | ||||
| -rw-r--r-- | img/lib/IM/Log.pm | 49 | ||||
| -rw-r--r-- | img/lib/IM/MD5.pm | 189 | ||||
| -rw-r--r-- | img/lib/IM/Message.pm | 179 | ||||
| -rw-r--r-- | img/lib/IM/MsgStore.pm | 73 | ||||
| -rw-r--r-- | img/lib/IM/Nntp.pm | 178 | ||||
| -rw-r--r-- | img/lib/IM/Pop.pm | 100 | ||||
| -rw-r--r-- | img/lib/IM/Recipient.pm | 108 | ||||
| -rw-r--r-- | img/lib/IM/Scan.pm | 271 | ||||
| -rw-r--r-- | img/lib/IM/Smtp.pm | 84 | ||||
| -rw-r--r-- | img/lib/IM/Ssh.pm | 121 | ||||
| -rw-r--r-- | img/lib/IM/Stdio.pm | 37 | ||||
| -rw-r--r-- | img/lib/IM/TcpTransaction.pm | 136 | ||||
| -rw-r--r-- | img/lib/IM/Util.pm | 98 |
27 files changed, 2046 insertions, 1396 deletions
diff --git a/img/lib/IM/Address.pm b/img/lib/IM/Address.pm index ba5129cd..089a8b31 100644 --- a/img/lib/IM/Address.pm +++ b/img/lib/IM/Address.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Address.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Address.pm version 20021207(IM142)"; package IM::Address; require 5.003; @@ -22,36 +22,6 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(extract_addr replace_addr fetch_addr); -=head1 NAME - -Address - RFC822 style address parser - -=head1 SYNOPSIS - - use IM::Address; - - $pure_address_portion = &extract_addr($address_with_comment); - - $replaced_address = &replace_addr($original_address_with_comment, - $pure_notation_of_old_address, $pure_notation_of_new_address); - - ($first, $rest) = &fetch_addr($address_list, $pure_address_flag); - -=head1 DESCRIPTION - - $a = "Motonori Nakamura <motonori\@econ.kyoto-u.ac.jp>"; - &extract_addr($a) returns "motonori@econ.kyoto-u.ac.jp". - - $a = "Motonori Nakamura <motonori\@econ.kyoto-u.ac.jp>"; - $b = "motonori\@econ.kyoto-u.ac.jp"; - $c = "motonori\@wide.ad.jp"; - &replace_addr($a, $b, $c) returns "Motonori Nakamura <motonori@wide.ad.jp>". - - $a = "kazu, nom, motonori"; - &fetch_addr($a, 0) returns ("kazu", " nom, motonori"). - -=cut - use vars qw($FOR_SMTP); # sub fetch_addr ##### EXTRACT AN ADDRESS FROM AN ADDRESS EXPRESSION ##### @@ -60,7 +30,7 @@ use vars qw($FOR_SMTP); # sub fetch_addr # address: an address in any style # return values: pure address portion (NULL if error) # -sub extract_addr ($) { +sub extract_addr($) { my $addrin = shift; $addrin =~ s/\n\s+//g; @@ -75,8 +45,8 @@ sub extract_addr ($) { # new: # return value: replaced expression # -sub replace_addr ($$$) { - my ($expr, $old, $new) = @_; +sub replace_addr($$$) { + my($expr, $old, $new) = @_; my $qold = quotemeta($old); if ($expr =~ /$qold.*$qold/) { @@ -99,18 +69,18 @@ sub replace_addr ($$$) { # rest: rest of address in the list # friendly: user friendly portion of the first address # -sub fetch_addr ($$) { - my ($addrin, $extract) = @_; - my ($addrout, $pureout, $groupsyntax) = ('', '', ''); - my ($friendly1, $friendly2, $c) = ('', '', ''); - my ($inquote, $incomment, $addrquote) = (0, 0, 0); - my ($gotpure, $groupcolon, $route) = (0, 0, 0); +sub fetch_addr($$) { + my($addrin, $extract) = @_; + my($addrout, $pureout, $groupsyntax) = ('', '', ''); + my($friendly1, $friendly2, $c) = ('', '', ''); + my($inquote, $incomment, $addrquote) = (0, 0, 0); + my($gotpure, $groupcolon, $route) = (0, 0, 0); im_debug("fetch_addr(in): $addrin\n") if (&debug('addr')); $FOR_SMTP = (&progname =~ /imput/i) unless (defined($FOR_SMTP)); $addrin = '' unless (defined($addrin)); $route = 1 if ($addrin =~ /^\@/); while ($addrin ne '') { - if ($addrin =~ /^([^\e"\\()<>:;,]+)(.*)/s) { + if ($addrin =~ /^([^\e"\\()<>:;,]+)(.*)/s) { #" $c = $1; $addrin = $2; } elsif ($addrin =~ /^\e/) { @@ -131,7 +101,7 @@ sub fetch_addr ($$) { last if ($c eq ',' && !$inquote && !$incomment && !$groupcolon && !$route); - $friendly2 .= $c unless($addrquote); + $friendly2 .= $c unless ($addrquote); if ($inquote) { $addrout .= $c; $pureout .= $c unless ($gotpure); @@ -141,7 +111,7 @@ sub fetch_addr ($$) { ($c, $addrin) = unpack('a a*', $addrin); $addrout .= $c; $pureout .= $c unless ($gotpure); - $friendly2 .= $c unless($addrquote); + $friendly2 .= $c unless ($addrquote); } next; } elsif ($incomment) { @@ -154,7 +124,7 @@ sub fetch_addr ($$) { } elsif ($c eq '\\') { ($c, $addrin) = unpack('a a*', $addrin); $friendly1 .= $c; - $friendly2 .= $c unless($addrquote); + $friendly2 .= $c unless ($addrquote); $addrout .= $c unless ($extract); } chop($friendly1) unless ($incomment); @@ -183,17 +153,17 @@ sub fetch_addr ($$) { $addrout .= $c; $pureout .= $c unless ($gotpure); ($c, $addrin) = unpack('a a*', $addrin); - $friendly2 .= $c unless($addrquote); + $friendly2 .= $c unless ($addrquote); } elsif ($c eq ':') { $addrout .= $c; $pureout .= $c unless ($gotpure); - if ($addrin =~ /^([^"\()<>:;,]+)(.*)/s) { + if ($addrin =~ /^([^"\()<>:;,]+)(.*)/s) { #" $c = $1; $addrin = $2; } else { ($c, $addrin) = unpack('a a*', $addrin); } - $friendly2 .= $c unless($addrquote); + $friendly2 .= $c unless ($addrquote); $groupcolon = 1 if ($c ne ':'); } elsif ($c eq ';') { if ($groupcolon) { @@ -234,6 +204,50 @@ sub fetch_addr ($$) { 1; +__END__ + +=head1 NAME + +IM::Address - RFC822 style address parser + +=head1 SYNOPSIS + + use IM::Address; + + $pure_address_portion = &extract_addr($address_with_comment); + + $replaced_address = &replace_addr($original_address_with_comment, + $pure_notation_of_old_address, $pure_notation_of_new_address); + + ($first, $rest) = &fetch_addr($address_list, $pure_address_flag); + +=head1 DESCRIPTION + +The I<IM::Address> module is a parser for RFC822 style address. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + $a = "Motonori Nakamura <motonori\@econ.kyoto-u.ac.jp>"; + &extract_addr($a) returns "motonori@econ.kyoto-u.ac.jp". + + $a = "Motonori Nakamura <motonori\@econ.kyoto-u.ac.jp>"; + $b = "motonori\@econ.kyoto-u.ac.jp"; + $c = "motonori\@wide.ad.jp"; + &replace_addr($a, $b, $c) returns "Motonori Nakamura <motonori@wide.ad.jp>". + + $a = "kazu, nom, motonori"; + &fetch_addr($a, 0) returns ("kazu", " nom, motonori"). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Alias.pm b/img/lib/IM/Alias.pm index 6a67c068..ccd30b77 100644 --- a/img/lib/IM/Alias.pm +++ b/img/lib/IM/Alias.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Alias.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Alias.pm version 20021207(IM142)"; package IM::Alias; require 5.003; @@ -24,38 +24,6 @@ use vars qw(@ISA @EXPORT); @EXPORT = qw(alias_read alias_lookup alias_print hosts_read hosts_completion hosts_lookup hosts_print); -=head1 NAME - -Alias - mail and host alias looking up package - -=head1 SYNOPSIS - - use IM::Alias; - - alias_read(mail_alias_files, addrbook_files); - $result = alias_lookup(user_name); - alias_print(alias); - - hosts_read(hosts_alias_files); - $result = hosts_completion(mail_address); - hosts_print(alias); - -=head1 DESCRIPTION - - alias_read("$HOME/.im/Aliases", "$HOME/.im/Addrbook"); - hosts_read("$HOME/.hostaliases"); - - $result = alias_lookup('u'); - print "$result\n" if ($result); - - $result = hosts_completion('u@h'); - print "$result\n" if ($result); - - alias_print("a") displays mail addresses whose alias is "a". - hosts_print("") displays all host aliases. - -=cut - use vars qw(%MAIL_ALIAS_HASH %MAIL_ALIASES %HOST_ALIASES); ##### READ MAIL ALIAS FILES ##### @@ -64,7 +32,7 @@ use vars qw(%MAIL_ALIAS_HASH %MAIL_ALIASES %HOST_ALIASES); # # return value: none # -sub alias_read (;$$) { +sub alias_read(;$$) { my @olds = split(',', shift || aliases_file()); my @news = split(',', shift || addrbook_file()); my $usenew = 0; @@ -127,7 +95,7 @@ sub alias_read (;$$) { $cont =~ s/^\s*/ /; $line .= $cont; } - my ($name, $val) = split('\s*[:=]\s*', $line, 2); + my($name, $val) = split('\s*[:=]\s*', $line, 2); $MAIL_ALIASES{$name} = $val if $val; } else { #personal info. Skip continuous lines. @@ -149,7 +117,7 @@ sub alias_read (;$$) { # alias: an alias to be looked up # return value: aliased address OR null # -sub alias_lookup ($) { +sub alias_lookup($) { my $alias = shift; return '' if ($alias =~ /[\@%!:]/o); @@ -168,7 +136,7 @@ sub alias_lookup ($) { # alias: an alias to be looked up # return value: none # -sub alias_print (;$) { +sub alias_print(;$) { my $alias = shift; if ($alias) { @@ -190,7 +158,7 @@ sub alias_print (;$) { # # return value: none # -sub hosts_read (;$) { +sub hosts_read(;$) { my @aliases = split(',', shift || '~/.hostaliases'); my $ali; @@ -222,11 +190,11 @@ sub hosts_read (;$) { # cmpl: flag whether complete with get_host_byname() or not; # return value: completed address OR null # -sub hosts_completion ($;$) { - my ($addr, $cmpl) = @_; +sub hosts_completion($;$) { + my($addr, $cmpl) = @_; - if ($addr =~ /^([\w-.]+)@([\w-.]+)$/) { - my ($local, $domain) = ($1, $2); + if ($addr =~ /^([\w.-]+)@([\w.-]+)$/) { + my($local, $domain) = ($1, $2); im_debug("searching $domain by host alias file.\n") if &debug('alias'); my $new = $HOST_ALIASES{$domain}; if ($new) { @@ -236,7 +204,7 @@ sub hosts_completion ($;$) { if ($cmpl) { im_debug("searching $domain with gethostbyname().\n") if (&debug('alias')); - my ($he_name) = gethostbyname($domain); + my($he_name) = gethostbyname($domain); if (length($he_name) > length($domain)) { im_debug("found(gethostbyname): $domain -> $he_name\n") if (&debug('alias')); @@ -253,7 +221,7 @@ sub hosts_completion ($;$) { # alias: an alias to be looked up # return value: aliased hosts OR null # -sub hosts_lookup ($) { +sub hosts_lookup($) { my $alias = shift; my $host = $HOST_ALIASES{$alias}; if ($host) { @@ -269,7 +237,7 @@ sub hosts_lookup ($) { # alias: an alias to be looked up # return value: none # -sub hosts_print (;$) { +sub hosts_print(;$) { my $alias = shift; if ($alias) { @@ -287,6 +255,52 @@ sub hosts_print (;$) { 1; +__END__ + +=head1 NAME + +IM::Alias - mail and host alias looking up package + +=head1 SYNOPSIS + + use IM::Alias; + + alias_read(mail_alias_files, addrbook_files); + $result = alias_lookup(user_name); + alias_print(alias); + + hosts_read(hosts_alias_files); + $result = hosts_completion(mail_address); + hosts_print(alias); + +=head1 DESCRIPTION + +The I<IM::Alias> module handles mail and host aliases. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + alias_read("$HOME/.im/Aliases", "$HOME/.im/Addrbook"); + hosts_read("$HOME/.hostaliases"); + + $result = alias_lookup('u'); + print "$result\n" if ($result); + + $result = hosts_completion('u@h'); + print "$result\n" if ($result); + + alias_print("a") displays mail addresses whose alias is "a". + hosts_print("") displays all host aliases. + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Config.pm.in b/img/lib/IM/Config.pm.in index 56ebbdb3..1fc3b263 100644 --- a/img/lib/IM/Config.pm.in +++ b/img/lib/IM/Config.pm.in @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Config.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Config.pm version 20021207(IM142)"; package IM::Config; require 5.003; @@ -40,8 +40,8 @@ use vars qw(@ISA @EXPORT); mbox_style nntpservers nntphistoryfile nntpauthuser set_nntpauthuser popaccount pophistoryfile imapaccount httpproxy noproxy - usepwagent pwagentport usepwfiles pwfiles - expand_path usetouchfile touchfile namazuv2 + usepwagent pwagentport pwagent_tmp_dir pwagent_tmp_path usepwfiles pwfiles + expand_path usetouchfile touchfile namazuv2 namazu_lock_dir namazu_lock_path pop_timeout imap_timeout nntp_timeout dns_timeout connect_timeout command_timeout rcv_buf_siz db_type file_attr $SSH_PATH); @@ -70,7 +70,7 @@ $IM_DB_TYPE = '@im_db_type@'; $FSYNC_NO = @im_fsync_no@; $SSH_PATH = "@im_path_ssh@"; -sub file_attr () { +sub file_attr() { return @im_file_attr@; } @@ -86,7 +86,7 @@ $HOME_DIR =~ s:\\:/:g; # "\home\user" -> "/home/user" $HOME_DIR =~ s/\/$//; # "/home/" -> "/home" $IM_SYS_DIR = $ENV{'IM_SYS_DIR'} || "$IM_LIBDIR"; -$IM_USER_DIR = expand_home($ENV{'IM_USER_DIR'} || '.im'); +$IM_USER_DIR = &expand_home($ENV{'IM_USER_DIR'} || '.im'); $IM_SYS_PROFILE = "$IM_SYS_DIR/SiteConfig"; $IM_USER_PROFILE = "$IM_USER_DIR/Config"; @@ -107,6 +107,7 @@ BEGIN { 'msgmode;i;;MsgMode' => 'Message file mode when created', 'usecl;b;;UseCL' => 'Use value of Content-Length header for delimitation', 'nosync;b;;NoSync' => 'Do not need fsync(2) on writing file', + 'fsyncnumber;i;;FsyncNumber' => 'System call number of fsync', 'allowcrlf;b;;AllowCRLF' => 'CRLF may be in saved message', 'preservedot;b;;PreserveDot' => 'Not substitute "." with "/"', 'addrbookfile;s;;AddrBookFile' => 'Address book file', @@ -132,6 +133,7 @@ BEGIN { 'noproxy;s;;Noproxy' => 'URL regex not to use Proxy server', 'usepwagent;b;;UsePwAgent' => 'Use password agent', 'pwagentport;i;;PwAgentPort' => 'Port to connect agent with TCP/IP', + 'pwagenttmpdir;s;;PwAgentTmpDir' => 'Temporary directory for impwagent', 'usepwfiles;b;;UsePwFiles' => 'Use password files', 'pwfiles;s;;PwFiles' => 'Password files', 'poptimeout;i;20;PopTimeout' => 'Timeout for POP connection', @@ -144,15 +146,16 @@ BEGIN { 'usetouchfile;b;;UseTouchFile' => 'Use touch file', 'touchfile;s;;TouchFile' => 'Touch file name', 'namazuv2;b;;NamazuV2' => 'Use Namazu Version 2', + 'namazulockdir;s;;NamazuLockDir' => 'Lock directory for immknmz', ); # these vars should be in current package? - my (@vars) = (); - my ($i, $name, $desc, $dflt, $vnam); + my(@vars) = (); + my($i, $name, $desc, $dflt, $vnam); for ($i = 0; $i < $#CfgConfig; $i+=2) { ($name, $desc, $dflt, $vnam) = split(';', $CfgConfig[$i]); if ($vnam) { - push(@vars, '$' . $vnam); + push(@vars, '$' . $vnam); #' } } # print "use vars qw(@vars);\n"; @@ -163,7 +166,7 @@ BEGIN { ## ## -sub read_cfg_selector ($) { +sub read_cfg_selector($) { my $argvref = shift; my $i = 0; my $selector = ''; @@ -180,11 +183,10 @@ sub read_cfg_selector ($) { return $selector; } -sub init_opt ($;$) -{ - my ($optref, $cptref) = @_; - my ($name, $desc, $dflt, $vnam, $optn, $help); - my ($i, $N); +sub init_opt($;$) { + my($optref, $cptref) = @_; + my($name, $desc, $dflt, $vnam, $optn, $help); + my($i, $N); @O_IORD = (); ## option list in order %O_DESC = (); # --help -> s|s@|i|i@|f|f@|F|F@|b|B @@ -228,7 +230,7 @@ sub init_opt ($;$) $i++; $help = $$optref[$i]; $i++; - if ($desc =~ /^(s|s@|i|i@|f|f@|F|F@|b|B|d)$/){ + if ($desc =~ /^(s|s@|i|i@|f|f@|F|F@|b|B|d)$/) { my $abbr; if ($name =~ ',') { ($name, $abbr) = split(',', $name); @@ -265,7 +267,7 @@ sub init_opt ($;$) $i++; $help = $cptref->[$i]; $i++; - if ($desc =~ /^(s|s@|i|i@|f|f@|F|F@|b|B)$/){ + if ($desc =~ /^(s|s@|i|i@|f|f@|F|F@|b|B)$/) { $optn = "-$name"; ## no lc() push(@O_IORD, $optn); if ($vnam) { @@ -288,10 +290,10 @@ sub init_opt ($;$) return 1; } -sub read_env ($) { +sub read_env($) { my $envref = shift; - my ($i, $N) = (0, scalar(@$envref)); - my ($name, $desc, $dflt, $var); + my($i, $N) = (0, scalar(@$envref)); + my($name, $desc, $dflt, $var); while ($i < $N) { ($name, $desc, $dflt, $var) = split(';', $envref->[$i]); @@ -304,8 +306,8 @@ sub read_env ($) { } } -sub read_cfg () { - my ($profile, @profiles); +sub read_cfg() { + my($profile, @profiles); my $prev_line = ''; my $case; my $use; @@ -400,10 +402,10 @@ sub read_cfg () { } } -sub read_opt ($) { +sub read_opt($) { my $argref = shift; - my ($ref, $i, $N) = (0, 0, scalar(@$argref)); - my ($name, $val, $desc, $vnam); + my($ref, $i, $N) = (0, 0, scalar(@$argref)); + my($name, $val, $desc, $vnam); # delete options from @ARGV so that main{} can treat # @ARGV as argments. @@ -468,8 +470,8 @@ sub read_opt ($) { } } -sub set_selector ($;$) { - my ($selector, $base) = @_; +sub set_selector($;$) { + my($selector, $base) = @_; my $s; foreach $s (split(',', $selector)) { ### xxx lc @@ -480,11 +482,11 @@ sub set_selector ($;$) { } else { if (!defined($base) or $base eq 'default') { push(@SELECTORS, $s) if !defined($base); - foreach (keys(%{$s})){ + foreach (keys(%{$s})) { ${$_} = $s->{$_}; } } else { - foreach (keys(%{$s})){ + foreach (keys(%{$s})) { $base->{$_} = $s->{$_}; } } @@ -493,11 +495,11 @@ sub set_selector ($;$) { return 0; } -sub used_selectors () { +sub used_selectors() { return join(',', @SELECTORS); } -sub sanity_check () { +sub sanity_check() { unless ($MailDir) { im_die("config files\n" . "Please setup user profile \"$IM_USER_PROFILE\".\n" . @@ -505,14 +507,13 @@ sub sanity_check () { } } -sub help ($) -{ +sub help($) { my $explanation = shift; - my ($name, $spec, $desc, $abbr, $dflt); + my($name, $spec, $desc, $abbr, $dflt); print "${explanation}\nOptions are: \n"; - foreach $name (@O_IORD){ + foreach $name (@O_IORD) { next unless (defined($O_HELP{$name})); $desc = $O_DESC{$name}; @@ -548,7 +549,11 @@ sub help ($) print "\t$name$spec $abbr($dflt)\n"; print "\t\t", $O_HELP{$name}, "\n"; } - print "\n* Note that +xxx is equivalent to $O_FOPT=+xxx\n\n" if $O_FOPT; + + if ($O_FOPT) { + print "\nNote that +xxx is equivalent to $O_FOPT=+xxx.\n"; + } + print "\nReport bugs to <img\@mew.org>.\n"; return 1; } @@ -556,10 +561,9 @@ sub help ($) ## ## -sub set_value_cfg ($$$) -{ - my ($name, $val, $case) = @_; - my ($mnam, $desc, $vnam); +sub set_value_cfg($$$) { + my($name, $val, $case) = @_; + my($mnam, $desc, $vnam); $val =~ s/\${(\w+)}/$ENV{$1}/ge; if ($val =~ /^\$(.*)/) { @@ -595,9 +599,8 @@ sub set_value_cfg ($$$) # set_value is not in safe manner. # see if $desc exists before calling this. -sub set_value ($$$$) -{ - my ($desc, $vnam, $val, $who) = @_; # b, $main::opt_help, yes +sub set_value($$$$) { + my($desc, $vnam, $val, $who) = @_; # b, $main::opt_help, yes # require numeric but not numeric, return undef return undef if ($desc =~ /i/ && $val !~ /\d+/); @@ -607,7 +610,7 @@ sub set_value ($$$$) # -> @xxx = (foo, bar, gaz) my @val = split(',', $val); if ($desc =~ /F/) { # xxx how about f - my ($i, $N) = (0, scalar(@val)); + my($i, $N) = (0, scalar(@val)); while ($i < $N) { $val[$i] = "+$val[$i]" unless $val =~ /(^[+\-=%~\/])|(^[a-zA-Z]:)/; @@ -653,9 +656,8 @@ sub set_value ($$$$) return 1; } -sub set_value_case ($$$$) -{ - my ($desc, $vnam, $val, $case) = @_; # b, $main::opt_help, yes +sub set_value_case($$$$) { + my($desc, $vnam, $val, $case) = @_; # b, $main::opt_help, yes # require numeric but not numeric, return undef return undef if ($desc =~ /i/ && $val !~ /\d+/); @@ -685,62 +687,62 @@ sub set_value_case ($$$$) ### Config vs Default ### -sub current_dir () { +sub current_dir() { return $CURRENT_DIR; } -sub home_dir () { +sub home_dir() { return $HOME_DIR; } -sub conf_dir () { +sub conf_dir() { return $IM_USER_DIR; } -sub mail_dir () { +sub mail_dir() { return $MailDir; } -sub mail_path () { +sub mail_path() { return expand_home(mail_dir()); } -sub news_dir () { +sub news_dir() { return $NewsDir; } -sub news_path () { +sub news_path() { return expand_home(news_dir()); } -sub queue_dir () { +sub queue_dir() { return $QueueDir; } -sub queue_path () { +sub queue_path() { expand_path(queue_dir()); } -sub inbox_folder (;$) { - my ($case) = split(',', shift); ## use the first one only +sub inbox_folder(;$) { + my($case) = split(',', shift); ## use the first one only if (defined($case) && $case ne 'default' && defined($case->{InboxFolder}) && - $case->{InboxFolder} ne ''){ + $case->{InboxFolder} ne '') { return $case->{InboxFolder}; } else { return $InboxFolder; } } -sub draft_folder () { +sub draft_folder() { return $DraftFolder; } -sub trash_folder () { +sub trash_folder() { return $TrashFolder; } -sub config_cases () { +sub config_cases() { my @cases = keys(%CASES); if (scalar(@cases) >= 2) { return join(',', @cases); @@ -749,7 +751,7 @@ sub config_cases () { } } -sub config_case_inbox () { +sub config_case_inbox() { my @cases = keys(%CASES); my @caseinbox = (); if (scalar(@cases) >= 2) { @@ -764,11 +766,11 @@ sub config_case_inbox () { } } -sub preserve_dot () { +sub preserve_dot() { return $PreserveDot; } -sub folder_mode ($) { +sub folder_mode($) { my $setumask = shift; $FolderMode = oct($FolderMode) if ($FolderMode =~ /^0\d/); @@ -777,7 +779,7 @@ sub folder_mode ($) { return $FolderMode; } -sub msg_mode ($) { +sub msg_mode($) { my $setumask = shift; $MsgMode = oct($MsgMode) if ($MsgMode =~ /^0\d/); @@ -786,175 +788,191 @@ sub msg_mode ($) { return $MsgMode; } -sub allowcrlf () { +sub allowcrlf() { return $AllowCRLF; } -sub use_cl () { +sub use_cl() { return $UseCL; } -sub no_sync () { +sub no_sync() { return $NoSync; } -sub fsync_no () { - return $FSYNC_NO; +sub fsync_no() { + return $FsyncNumber || $FSYNC_NO; } -sub addrbook_file () { +sub addrbook_file() { return join(',', map {expand_path($_)} split(',', $AddrBookFile)); } -sub aliases_file () { +sub aliases_file() { return join(',', map {expand_path($_)} split(',', $AliasesFile)); } -sub context_file () { +sub context_file() { return &expand_path($ContextFile); } -sub getchksbr_file () { +sub getchksbr_file() { return &expand_path($GetChkSbrFile); } -sub getsbr_file () { +sub getsbr_file() { return &expand_path($GetSbrFile); } -sub scansbr_file () { +sub scansbr_file() { return &expand_path($ScanSbrFile); } -sub scan_header_pick () { +sub scan_header_pick() { return $ScanHeaderPick; } -sub petname_file () { +sub petname_file() { return &expand_path($PetNameFile); } -sub address () { +sub address() { return $Address; } -sub addresses_regex () { +sub addresses_regex() { return $AddrRegex; } -sub msgdbfile () { +sub msgdbfile() { return &expand_path($MsgDBFile); } -sub msgdbtype () { +sub msgdbtype() { return $MsgDBType; } -sub mbox_style () { +sub mbox_style() { return $MBoxStyle; } -sub nntpservers () { +sub nntpservers() { return $NNTPservers; } -sub nntphistoryfile () { +sub nntphistoryfile() { return &expand_path($NNTPhistory); } -sub nntpauthuser () { +sub nntpauthuser() { return $NNTPauthuser; } sub set_nntpauthuser($) { - $NNTPauthuser = shift; + $NNTPauthuser = shift; } -sub popaccount () { +sub popaccount() { return $POPaccount; } -sub pophistoryfile () { +sub pophistoryfile() { return &expand_path($POPhistory); } -sub imapaccount () { +sub imapaccount() { return $IMAPaccount; } -sub httpproxy () { +sub httpproxy() { return $HTTPproxy; } -sub noproxy () { +sub noproxy() { return $Noproxy; } -sub usepwagent () { +sub usepwagent() { return $UsePwAgent; } -sub pwagentport () { +sub pwagentport() { return $PwAgentPort; } -sub usepwfiles () { +sub pwagent_tmp_dir() { + return $PwAgentTmpDir; +} + +sub pwagent_tmp_path() { + return expand_path(pwagent_tmp_dir()); +} + +sub usepwfiles() { return $UsePwFiles; } -sub pwfiles () { +sub pwfiles() { return $PwFiles; } -sub usetouchfile () { +sub usetouchfile() { return $UseTouchFile; } -sub touchfile () { +sub touchfile() { return $TouchFile; } -sub pop_timeout () { +sub pop_timeout() { return $PopTimeout; } -sub imap_timeout () { +sub imap_timeout() { return $ImapTimeout; } -sub nntp_timeout () { +sub nntp_timeout() { return $NntpTimeout; } -sub dns_timeout () { +sub dns_timeout() { return $DnsTimeout; } -sub connect_timeout () { +sub connect_timeout() { return $ConnectTimeout; } -sub command_timeout () { +sub command_timeout() { return $CommandTimeout; } -sub rcv_buf_siz () { +sub rcv_buf_siz() { return $RcvBufSiz; } -sub db_type () { +sub db_type() { return $IM_DB_TYPE; } -sub namazuv2 () { +sub namazuv2() { return $NamazuV2; } +sub namazu_lock_dir() { + return $NamazuLockDir; +} + +sub namazu_lock_path() { + return expand_path(namazu_lock_dir()); +} + ### ### path expansion ### -sub expand_home ($) { +sub expand_home($) { my $folder = shift; return '' if ($folder eq ''); @@ -970,7 +988,7 @@ sub expand_home ($) { return $folder; } -sub expand_path ($) { +sub expand_path($) { my $folder = shift; $folder =~ s/^\s*(.*?)\s*$/$1/; # SPC may be used in folder names @@ -1054,10 +1072,60 @@ QueueDir=queue # relative to ~/.im/ Imget.Src=local # default source of imget (local mailbox) PopHistory=pophist-{POPSERVERID} # to save last state (relative to ~/.im/) NntpHistory=newshist # to save last state (relative to ~/.im/) +# impwagent +PwAgentTmpDir=pwagtmp # temporary directory (relative to ~/.im/) # namazu -NamazuV2=off # use Namazu version2 (1.9.x or late) +NamazuV2=off # use Namazu version 2 (1.9.x or late) +NamazuLockDir=nmzlock # lock directory (relative to ~/.im/) __END__ +=head1 NAME + +IM::Config - confiugration for IM + +=head1 SYNOPSIS + + use IM::Config; + +Subroutines: +read_cfg_selector +init_opt +read_env read_cfg read_opt +set_selector used_selectors +sanity_check +help +home_dir conf_dir +mail_dir mail_path news_dir news_path queue_dir queue_path +inbox_folder draft_folder trash_folder config_cases config_case_inbox +preserve_dot +folder_mode msg_mode allowcrlf use_cl no_sync fsync_no +addrbook_file aliases_file petname_file +context_file getchksbr_file getsbr_file scansbr_file scan_header_pick +address addresses_regex +msgdbfile msgdbtype +mbox_style +nntpservers nntphistoryfile nntpauthuser set_nntpauthuser +popaccount pophistoryfile imapaccount httpproxy noproxy +usepwagent pwagentport pwagent_tmp_dir pwagent_tmp_path usepwfiles pwfiles +expand_path usetouchfile touchfile namazuv2 namazu_lock_dir namazu_lock_path +pop_timeout imap_timeout nntp_timeout dns_timeout +connect_timeout command_timeout rcv_buf_siz +db_type file_attr + +=head1 DESCRIPTION + +The I<IM::Config> module is for configuration of IM. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/EncDec.pm b/img/lib/IM/EncDec.pm index acc1b9a0..11ac71cb 100644 --- a/img/lib/IM/EncDec.pm +++ b/img/lib/IM/EncDec.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::EncDec.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::EncDec.pm version 20021207(IM142)"; package IM::EncDec; require 5.003; @@ -23,40 +23,6 @@ use vars qw(@ISA @EXPORT); b_encode_string b_decode_string q_encode_string q_decode_string); -=head1 NAME - -EncDec - MIME header encoder/decoder - -=head1 SYNOPSIS - - use IM::EncDec; - - $mime_header_encoded_string = - mime_encode_string(string, iso7bit, iso8bit); - $string = - mime_decode_string(mime_header_encoded_string); - - $B_encoded_string = b_encode_string(string); - $string = b_decode_string(B_encoded_string); - - $Q_encoded_string = q_encode_string(string); - $string = q_decode_string(Q_encoded_string); - -=head1 DESCRIPTION - -MIME header encoder/decoder package. - - $_ = "JAPANESE (Kazuhiko Yamamoto)"; - mime_encode_string($_, 'iso-2022-jp', 'iso-8859-1'); - => =?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?= - (Kazuhiko Yamamoto) - - s/\n[\t ]+//g; - print mime_decode_string($_), "\n"; - => "JAPANESE (Kazuhiko Yamamoto)" - -=cut - use vars qw(@D2H $mime_encode_switch $mime_decode_switch @@ -90,7 +56,7 @@ $mime_decode_switch = { ## String Encoder/Decoder ## -sub mime_encode_string ($$$) { +sub mime_encode_string($$$) { my($str, $iso7, $iso8) = (@_); my($point, $len, $nstr, $s) = (0, length($str), '', ''); my($single, $double) = ('', ''); @@ -155,12 +121,12 @@ sub mime_encode_string ($$$) { return $nstr; } -sub mime_decode_string ($) { +sub mime_decode_string($) { my $in = shift; return '' if ($in eq ''); if (!$main::opt_mimedecodequoted) { if ($in =~ /^([^"]*)("[^"]*")([\0-\255]*)$/) { - return mime_decode_string($1) . $2 . mime_decode_string($3); + return &mime_decode_string($1) . $2 . &mime_decode_string($3); } } $in =~ s/\?=\s+=\?/?==?/g; @@ -170,7 +136,7 @@ sub mime_decode_string ($) { } sub mime_decode($$$) { - my ($cs, $bq, $str) = @_; + my($cs, $bq, $str) = @_; my $ret = &{$$mime_decode_switch{uc($3)}}($4); if ($cs =~ /iso-8859-([2-9])/i) { $ret = iso_8859_to_ctext($ret, $1); @@ -194,8 +160,8 @@ sub mime_decode($$$) { return $ret; } -sub iso_8859_to_ctext ($$) { - my ($str, $num) = @_; +sub iso_8859_to_ctext($$) { + my($str, $num) = @_; my @index = ("A", "A", "B", "C", "D", "L", "G", "F", "H", "M"); $str =~ s/([\x80-\xff]+)/\e-$index[$num]$1\e-A/g; return $str; @@ -217,9 +183,9 @@ sub iso_8859_to_ctext ($$) { "\xce", "\xb0", "\xb1", "\xc6", "\xb4", "\xb5", "\xc4", "\xb3", "\xc5", "\xb8", "\xb9", "\xba", "\xbb", "\xbc", "\xbd", "\xbe", "\xbf", "\xcf", "\xc0", "\xc1", "\xc2", "\xc3", "\xb6", "\xb2", - "\xcc", "\xcb", "\xb7", "\xc8", "\xcd", "\xc9", "\xc7", "\xca" ); + "\xcc", "\xcb", "\xb7", "\xc8", "\xcd", "\xc9", "\xc7", "\xca"); -sub koi2iso ($) { +sub koi2iso($) { my $str = shift; $str =~ s/(.)/$koi_iso[ord($1)-128]/ge; return $str; @@ -232,12 +198,12 @@ sub koi8r_to_ctext($) { } sub tis_620_to_ctext($) { - my ($str) = shift; + my($str) = shift; $str =~ s/([\x80-\xff]+)/\e-T$1\e-A/g; return $str; } -sub cn_gb_to_ctext ($) { +sub cn_gb_to_ctext($) { my $str = shift; $str =~ s/([\x80-\xff]+)/"\e\$(A" . remove_msb($1) . "\e(B"/ge; return $str; @@ -251,7 +217,7 @@ sub hz_to_ctext($) { return $str; } -sub euc_jp_to_ctext ($) { +sub euc_jp_to_ctext($) { my $str = shift; $str =~ s/((\x8f[\xa0-\xff][\xa0-\xff])+)/"\e\$(D" . remove_msb(remove_ss($1, "\x8f")) . "\e-A"/ge; @@ -261,25 +227,25 @@ sub euc_jp_to_ctext ($) { return $str; } -sub euc_kr_to_ctext ($) { +sub euc_kr_to_ctext($) { my $str = shift; $str =~ s/([\x80-\xff]+)/"\e\$(C" . remove_msb($1) . "\e(B"/ge; return $str; } -sub remove_msb ($) { +sub remove_msb($) { my $str = shift; $str =~ tr/\x80-\xff/\x00-\x7f/; return $str; } -sub remove_ss ($$) { - my ($str, $si) = @_; +sub remove_ss($$) { + my($str, $si) = @_; $str =~ s/$si//g; return $str; } -sub shift_jis_to_ctext ($) { +sub shift_jis_to_ctext($) { my $str = shift; my $kanji = "[\x81-\x9f\xe0-\xef]."; my $kana = "[\xa0-\xdf]"; @@ -292,7 +258,7 @@ sub shift_jis_to_ctext ($) { sub s2j($) { my $str = shift; - my ($c1, $c2); + my($c1, $c2); my $ret = ""; while ($str) { @@ -311,9 +277,9 @@ sub s2j($) { return $ret; } -sub b157to94 ($) { +sub b157to94($) { my $str = shift; - my ($c1, $c2, $tmp); + my($c1, $c2, $tmp); my $ret = ""; while ($str) { @@ -350,14 +316,14 @@ sub big5_to_ctext($) { ## B Encoder/Decoder ## -sub b_encode_string ($) { +sub b_encode_string($) { my $mod3 = length($_[0]) % 3; local($_); $_ = pack('u', $_[0]); chop; s/(^|\n).//mg; - tr[`!-_][A-Za-z0-9+/]; + tr[`!-_][A-Za-z0-9+/]; #` if ($mod3 == 1) { s/..$/==/; } elsif ($mod3 == 2) { s/.$/=/; } @@ -365,7 +331,7 @@ sub b_encode_string ($) { $_; } -sub b_decode_string ($) { +sub b_decode_string($) { my $s64 = shift; my $len; my $res = ''; @@ -378,7 +344,7 @@ sub b_decode_string ($) { if (/(=+)$/) { $len -= length($1); } - tr[A-Za-z0-9+/=][`!-_A]; + tr[A-Za-z0-9+/=][`!-_A]; #` $res .= sprintf("%c%s\n", $len + 32, $_); } @@ -390,7 +356,7 @@ sub b_decode_string ($) { ## Q Encoder/Decoder ## -sub q_encode_string ($;$) { +sub q_encode_string($;$) { my($line, $struct) = @_; local($_); @@ -404,7 +370,7 @@ sub q_encode_string ($;$) { $_; } -sub q_decode_string ($) { +sub q_decode_string($) { my($qstr) = @_; local($_); @@ -416,6 +382,52 @@ sub q_decode_string ($) { 1; +__END__ + +=head1 NAME + +IM::EncDec - MIME header encoder/decoder + +=head1 SYNOPSIS + + use IM::EncDec; + + $mime_header_encoded_string = + mime_encode_string(string, iso7bit, iso8bit); + $string = + mime_decode_string(mime_header_encoded_string); + + $B_encoded_string = b_encode_string(string); + $string = b_decode_string(B_encoded_string); + + $Q_encoded_string = q_encode_string(string); + $string = q_decode_string(Q_encoded_string); + +=head1 DESCRIPTION + +The I<IM::EncDec> module is encoder/decoder for MIME header. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + $_ = "JAPANESE (Kazuhiko Yamamoto)"; + mime_encode_string($_, 'iso-2022-jp', 'iso-8859-1'); + => =?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?= + (Kazuhiko Yamamoto) + + s/\n[\t ]+//g; + print mime_decode_string($_), "\n"; + => "JAPANESE (Kazuhiko Yamamoto)" + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/File.pm b/img/lib/IM/File.pm index 0b6c1583..303ab310 100644 --- a/img/lib/IM/File.pm +++ b/img/lib/IM/File.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Jul 7, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::File.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::File.pm version 20021207(IM142)"; package IM::File; require 5.003; @@ -24,24 +24,18 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(im_rename im_link im_unlink); -## im_rename(path1, path2); -## im_link (path1, path2); -## im_unlink(path1); -## -## paths may be full-path or [+=]folder../../message. - use vars qw($CHECKED $USE_DB); -sub im_rename ($$) { - my ($p1, $p2) = @_; - my ($m1, $m2); - my ($ret); +sub im_rename($$) { + my($p1, $p2) = @_; + my($m1, $m2); + my($ret); ($p1, $m1) = expand_path_and_msg($p1); ($p2, $m2) = expand_path_and_msg($p2); - #my ($id) = get_msg_info($p1) if (!defined $id && !$main::opt_noharm); + #my($id) = get_msg_info($p1) if (!defined $id && !$main::opt_noharm); #XXX??? - my ($id); + my($id); if (defined($main::id) || $main::opt_noharm) { $id = $main::id; } else { @@ -52,7 +46,7 @@ sub im_rename ($$) { print "mv $p1 $p2\n"; $ret = 1; } else { - if (!($ret = rename($p1, $p2))){ + if (!($ret = rename($p1, $p2))) { $ret = copy($p1, $p2) && unlink($p1); } history_rename($id, $m1, $m2) @@ -61,15 +55,15 @@ sub im_rename ($$) { return $ret; } -sub im_link ($$) { - my ($p1, $p2) = @_; - my ($m1, $m2); - my ($ret); +sub im_link($$) { + my($p1, $p2) = @_; + my($m1, $m2); + my($ret); ($p1, $m1) = expand_path_and_msg($p1); ($p2, $m2) = expand_path_and_msg($p2); - #my ($id) = get_msg_info($p1) if (!defined $id && !$main::opt_noharm); - my ($id); + #my($id) = get_msg_info($p1) if (!defined $id && !$main::opt_noharm); + my($id); if (defined($main::id) || $main::opt_noharm) { $id = $main::id; } else { @@ -80,7 +74,7 @@ sub im_link ($$) { print "ln $p1 $p2\n"; $ret = 1; } else { - if (win95p() || os2p() || wntp() || !($ret = link($p1, $p2))){ + if (win95p() || os2p() || wntp() || !($ret = link($p1, $p2))) { $ret = copy($p1, $p2); } history_link($id, $m1, $m2) @@ -89,15 +83,14 @@ sub im_link ($$) { return $ret; } -sub im_unlink ($) -{ - my ($p1) = @_; - my ($m1, $ret); +sub im_unlink($) { + my($p1) = @_; + my($m1, $ret); ($p1, $m1) = expand_path_and_msg($p1); - # my ($id) = get_msg_info($p1) if (!defined $id && !$main::opt_noharm); - my ($id); + # my($id) = get_msg_info($p1) if (!defined $id && !$main::opt_noharm); + my($id); if (defined($main::id) || $main::opt_noharm) { $id = $main::id; } else { @@ -120,14 +113,13 @@ sub im_unlink ($) ## ## Private. ## -sub get_msg_info ($) -{ - my ($p, $m) = expand_path_and_msg(shift); - my ($id, $date, $hdr); +sub get_msg_info($) { + my($p, $m) = expand_path_and_msg(shift); + my($id, $date, $hdr); local $/ = ''; - if (im_open(\*MSG, "<$p")){ - $hdr = <MSG>; close(MSG); + if (im_open(\*MSG, "<$p")) { + $hdr = <MSG>; close(MSG); } else { im_warn("no message id in $m.\n"); return undef; @@ -142,9 +134,9 @@ sub get_msg_info ($) return ($id); } -sub unexpand_path ($) { +sub unexpand_path($) { my $path = shift; - my ($mail_path, $news_path) = (mail_path(), news_path()); + my($mail_path, $news_path) = (mail_path(), news_path()); $path =~ s!^$mail_path/*!\+!; $path =~ s!^$news_path/*!\=!; @@ -152,12 +144,12 @@ sub unexpand_path ($) { return $path; } -sub expand_path_and_msg ($) { +sub expand_path_and_msg($) { my $path_or_msg = shift; return (expand_path($path_or_msg), unexpand_path($path_or_msg)); } -sub USE_DB () { +sub USE_DB() { if (!$CHECKED) { $CHECKED = 1; if ($USE_DB = msgdbfile()) { @@ -172,6 +164,36 @@ sub USE_DB () { 1; +__END__ + +=head1 NAME + +IM::File - mail/news file handler + +=head1 SYNOPSIS + + use IM::File; + + im_rename(path1, path2); + im_link(path1, path2); + im_unlink(path1); + +Paths may be full-path or [+=]folder../../message. + +=head1 DESCRIPTION + +The I<IM::File> module handles mail/news message files. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Folder.pm b/img/lib/IM/Folder.pm index 572e8b8d..6170a4ee 100644 --- a/img/lib/IM/Folder.pm +++ b/img/lib/IM/Folder.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Folder.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Folder.pm version 20021207(IM142)"; package IM::Folder; require 5.003; @@ -26,58 +26,11 @@ use vars qw(@ISA @EXPORT); get_message_paths create_folder touch_folder chk_folder_existance chk_msg_existance get_impath); -=head1 NAME - -Folder - IM folder handler - -=head1 DESCRIPTION - - -=head1 SYNOPSIS - -use IM::Folder; - -$current_folder_name = &cur_folder(); - -&set_cur_folder($new_current_folder_name); - -($number_of_files, - $number_of_message_files, - $minimum_message_number, - $maximum_message_number) = &folder_info($folder_name); - -$message_number = &message_number($message_number_or_name); - -@message_number_array = &message_range($message_range_string); - -$message_file_path = &message_name($folder_name, $message_number); - -=head1 DESCRIPTION - -&cur_folder(); - results "+inbox" - -&set_cur_folder("+inbox"); - -($a, $b, $c, $d) = &folder_info("+inbox"); - results (10, 3, 1, 3) - -&message_number("+inbox", "cur"); - results 3 - -&message_range("+inbox", "1-3"); - results (1, 2, 3) - -&message_name("+inbox", "3"); - results "/usr/home/itojun/Mail/inbox/3" - -=cut - # # Mail folder related routines. # -sub cur_folder () { +sub cur_folder() { my $folder; local(*IN); @@ -95,7 +48,7 @@ sub cur_folder () { return $folder; } -sub set_cur_folder ($) { +sub set_cur_folder($) { my($folder) = @_; local(*IN, *OUT); my($buf); @@ -118,7 +71,7 @@ sub set_cur_folder ($) { close(OUT); } -sub folder_info ($) { +sub folder_info($) { my($folder) = @_; local(*DIR); my(@allfiles, $filecnt, $numfilecnt, $min, $max); @@ -135,8 +88,8 @@ sub folder_info ($) { return ($filecnt, $numfilecnt, $min, $max); } -sub message_list ($) { - my ($folder_dir) = @_; +sub message_list($) { + my($folder_dir) = @_; my @filesinfolder; opendir(DIR, $folder_dir) || im_die("can't open $folder_dir.\n"); @@ -146,9 +99,9 @@ sub message_list ($) { return @filesinfolder; } -sub message_number ($$;@) { - my ($folder, $number, @filesinfolder) = @_; - my ($folder_dir, $offset, $max, $min); +sub message_number($$;@) { + my($folder, $number, @filesinfolder) = @_; + my($folder_dir, $offset, $max, $min); # simple case: digits if ($number !~ /\D/) { @@ -158,7 +111,7 @@ sub message_number ($$;@) { # get folder $folder = cur_folder if ($folder eq ''); $folder_dir = expand_path($folder); - return '' if (!-d $folder_dir); + return '' if (! -d $folder_dir); @filesinfolder = message_list($folder_dir) if (scalar(@_) == 2); @@ -203,8 +156,8 @@ sub message_number ($$;@) { return ''; } -sub message_range ($$@) { - my ($folder, $range, @filesinfolder) = @_; +sub message_range($$@) { + my($folder, $range, @filesinfolder) = @_; my $range_regexp = '\d+|first|last|next|prev'; $folder = cur_folder if ($folder eq ''); @@ -215,7 +168,7 @@ sub message_range ($$@) { } if ($range =~ /^($range_regexp|new)-($range_regexp|new)$/) { - my ($start, $end) = ($1, $2); + my($start, $end) = ($1, $2); $start = message_number($folder, $start, @filesinfolder); $end = message_number($folder, $end, @filesinfolder); @@ -226,7 +179,7 @@ sub message_range ($$@) { return grep($start <= $_ && $_ <= $end, @filesinfolder); } } elsif ($range =~ /^($range_regexp):([+-]?)(\d+)$/) { - my ($start, $dir, $n) = ($1, $2, $3); + my($start, $dir, $n) = ($1, $2, $3); if ($dir eq '') { $dir = ($start eq 'last') ? '-' : '+'; } @@ -247,7 +200,7 @@ sub message_range ($$@) { } } -sub message_name ($$) { +sub message_name($$) { my($folder, $number) = @_; $number = &message_number($folder, $number); @@ -258,9 +211,9 @@ sub message_name ($$) { } } -sub get_message_paths ($@) { - my ($folder, @messages0) = @_; # local @messages0? - my ($i, @messages, @x); # local(@messages, @x);? +sub get_message_paths($@) { + my($folder, @messages0) = @_; # local @messages0? + my($i, @messages, @x); # local(@messages, @x);? my $folder_dir = &expand_path($folder); @@ -272,7 +225,7 @@ sub get_message_paths ($@) { # messages specified. # print the path to the message. - if (!-d $folder_dir) { + if (! -d $folder_dir) { $@ = "no such folder $folder"; return (); } @@ -305,7 +258,7 @@ sub get_message_paths ($@) { grep($_ = "$folder_dir/$_", @messages); } -sub create_folder ($) { +sub create_folder($) { my $folder = shift; my $path = &expand_path($folder); return 0 if (-d $path); @@ -331,9 +284,9 @@ sub create_folder ($) { return 0; } -sub touch_folder ($) { +sub touch_folder($) { if (&usetouchfile()) { - my ($dir) = shift; + my($dir) = shift; $dir =~ s/\/\d+$//; $dir = &expand_path($dir); my($file) = ($dir . "/" . &touchfile()); @@ -341,7 +294,7 @@ sub touch_folder ($) { print OF "touched by IM."; close(OF); } elsif (&os2p) { - my ($dir) = shift; + my($dir) = shift; $dir =~ s/\/\d+$//; $dir = &expand_path($dir); my $now = time; # XXX @@ -352,19 +305,19 @@ sub touch_folder ($) { ## ## Check folder existance. ## -sub chk_folder_existance (@) { +sub chk_folder_existance(@) { my @folders = @_; my $path; im_debug("chk_folder_existance: folder: @folders\n") if (&debug('all')); - foreach (@folders){ + foreach (@folders) { next if /^[%-]/; # skip IMAP and News folders $path = get_impath($_); if (-e $path) { im_die "folder $_ is not writable. (Nothing was refiled.)\n" - if (!-w $path); + if (! -w $path); } else { if (create_folder($path) == 0) { im_warn "created folder $_.\n"; @@ -376,20 +329,21 @@ sub chk_folder_existance (@) { im_debug("chk_folder_existance: OK.\n") if (&debug('all')); } -sub chk_msg_existance ($@) { +sub chk_msg_existance($@) { my $folder = shift; my @paths = get_impath($folder, @_); im_debug("chk_msg_existance: folder: $folder msg: @_\n") if (&debug('all')); - foreach (@paths){ - im_die "message specification error in $folder. (Nothing was refiled.)\n" - if (!-f $_); + foreach (@paths) { + if (! -f $_) { + im_die "message specification error in $folder. (Nothing was refiled.)\n"; + } } im_debug("chk_msg_existance: OK.\n") if (&debug('all'));; } -sub get_impath ($@) { +sub get_impath($@) { my $folder = shift; my @msgs = @_; my @paths; @@ -403,6 +357,64 @@ sub get_impath ($@) { 1; +__END__ + +=head1 NAME + +IM::Folder - mail/news folder handler + +=head1 SYNOPSIS + + use IM::Folder; + + $current_folder_name = &cur_folder(); + + &set_cur_folder($new_current_folder_name); + + ($number_of_files, + $number_of_message_files, + $minimum_message_number, + $maximum_message_number) = &folder_info($folder_name); + + $message_number = &message_number($message_number_or_name); + + @message_number_array = &message_range($message_range_string); + + $message_file_path = &message_name($folder_name, $message_number); + +=head1 DESCRIPTION + +The I<IM::Folder> module handles mail/news message folders. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + &cur_folder(); + results "+inbox" + + &set_cur_folder("+inbox"); + + ($a, $b, $c, $d) = &folder_info("+inbox"); + results (10, 3, 1, 3) + + &message_number("+inbox", "cur"); + results 3 + + &message_range("+inbox", "1-3"); + results (1, 2, 3) + + &message_name("+inbox", "3"); + results "/usr/home/itojun/Mail/inbox/3" + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/GetPass.pm b/img/lib/IM/GetPass.pm index ec252fbf..6c4caf5f 100644 --- a/img/lib/IM/GetPass.pm +++ b/img/lib/IM/GetPass.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 30, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::GetPass.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::GetPass.pm version 20021207(IM142)"; package IM::GetPass; require 5.003; @@ -24,19 +24,7 @@ use vars qw(@ISA @EXPORT); @EXPORT = qw(getpass getpass_interact loadpass savepass connect_agent talk_agent findpass); -=head1 NAME - -GetPass - Get password from tty or ... - -=head1 SYNOPSIS - -($pass, $agtfound, $interact) = getpass('imap', $auth, $host, $user); - -=head1 DESCRIPTION - -=cut - -sub getpass ($$$$) { +sub getpass($$$$) { my($proto, $auth, $host, $user) = @_; my $pass = ''; my $agtfound = 0; @@ -57,14 +45,14 @@ sub getpass ($$$$) { return ($pass, $agtfound, $interact); } -sub getpass_interact ($) { - my ($prompt) = @_; - my ($secret, $termios, $c_lflag); +sub getpass_interact($) { + my($prompt) = @_; + my($secret, $termios, $c_lflag); if (! -t STDIN) { # stty is not effective for Mule since it's not terminal base. # Anyway, Mew never echos back even if getpass echos back. - } elsif (eval 'require POSIX' & ! win95p() ) { + } elsif (eval 'require POSIX' & !win95p()) { import POSIX qw(termios_h); $termios = new POSIX::Termios; $termios->getattr(fileno(STDIN)); @@ -73,7 +61,7 @@ sub getpass_interact ($) { $termios->setattr(fileno(STDIN), &POSIX::TCSANOW); } elsif (unixp()) { # non-POSIX-ish UNIX. # stty might be available. - my ($OldPath) = $ENV{'PATH'}; # for SUID version + my($OldPath) = $ENV{'PATH'}; # for SUID version $ENV{'PATH'} = '/bin:/usr/bin'; system('/bin/stty -echo'); # Ignore errors. $ENV{'PATH'} = $OldPath; @@ -92,7 +80,7 @@ sub getpass_interact ($) { $termios->setlflag($c_lflag); $termios->setattr(fileno(STDIN), &POSIX::TCSANOW); } elsif (unixp()) { # non-POSIX-ish UNIX. - my ($OldPath) = $ENV{'PATH'}; # for SUID version + my($OldPath) = $ENV{'PATH'}; # for SUID version $ENV{'PATH'} = '/bin:/usr/bin'; system('/bin/stty echo'); # Ignore errors. $ENV{'PATH'} = $OldPath; @@ -101,9 +89,9 @@ sub getpass_interact ($) { return $secret; } -sub loadpass ($$$$) { - my ($proto, $auth, $path, $user) = @_; - local ($_); +sub loadpass($$$$) { + my($proto, $auth, $path, $user) = @_; + local($_); my $key = &connect_agent(0); return '' if ($key eq ''); my @keys = unpack('C*', $key); @@ -124,9 +112,9 @@ sub loadpass ($$$$) { } } -sub savepass ($$$$$) { - my ($proto, $auth, $path, $user, $pass) = @_; - local ($_); +sub savepass($$$$$) { + my($proto, $auth, $path, $user, $pass) = @_; + local($_); my $key = &connect_agent(0); return '' if ($key eq ''); my @keys = unpack('C*', $key); @@ -141,8 +129,8 @@ sub savepass ($$$$$) { &talk_agent("SAVE\t$proto\t$auth\t$path\t$user\nPASS\t$pass\n", 0); } -sub connect_agent ($) { - my ($surpresserror) = shift; +sub connect_agent($) { + my($surpresserror) = shift; require Socket && import Socket; my $realuser = im_getlogin(); @@ -150,7 +138,7 @@ sub connect_agent ($) { im_warn("pwagent: can not get login name\n") unless ($surpresserror); return ''; } - my $dir = "/tmp/im-$realuser"; + my $dir = &pwagent_tmp_path() . "-$realuser"; my $port = &pwagentport(); if ($port > 0) { @@ -172,7 +160,7 @@ sub connect_agent ($) { return ''; } - my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev) = stat($dir); + my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev) = stat($dir); if ($mode & 0077) { im_warn("pwagent: invalid mode: $dir\n") unless ($surpresserror); return ''; @@ -199,8 +187,8 @@ sub connect_agent ($) { return $res; } -sub talk_agent ($) { - my ($msg) = shift; +sub talk_agent($) { + my($msg) = shift; print SOCK $msg; my $res = <SOCK>; shutdown (SOCK, 2); @@ -210,9 +198,9 @@ sub talk_agent ($) { } sub findpass($$$$) { - my ($proto, $auth, $host, $user) = @_; - local ($_); - my ($passfile); + my($proto, $auth, $host, $user) = @_; + local($_); + my($passfile); foreach $passfile (split(',', &pwfiles())) { $passfile = &expand_path($passfile); @@ -222,8 +210,8 @@ sub findpass($$$$) { next if (/^(#.*)?$/); # s/\s+(\#.*)?$//; # remove comments if (/^(\S+)\s+(\S+)\s+(\S+)\s+(\S.+)$/) { - my ($tmp_host, $tmp_user, $tmp_pass) = ($2, $3, $4); - my ($tmp_proto, $tmp_auth) = split('/', $1); + my($tmp_host, $tmp_user, $tmp_pass) = ($2, $3, $4); + my($tmp_proto, $tmp_auth) = split('/', $1); if (($tmp_proto eq $proto) && ($tmp_auth eq $auth) && ($tmp_host eq $host) @@ -241,6 +229,32 @@ sub findpass($$$$) { 1; +__END__ + +=head1 NAME + +IM::GetPass - get password from tty or ... + +=head1 SYNOPSIS + + use IM::GetPass; + + ($pass, $agtfound, $interact) = getpass('imap', $auth, $host, $user); + +=head1 DESCRIPTION + +The I<IM::GetPass> module handles password for mail/news servers. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Grep.pm b/img/lib/IM/Grep.pm index 32bf0c0f..20cfb878 100644 --- a/img/lib/IM/Grep.pm +++ b/img/lib/IM/Grep.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Nov 03, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Grep.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Grep.pm version 20021207(IM142)"; package IM::Grep; require 5.003; @@ -26,23 +26,6 @@ use vars qw(@ISA @EXPORT %MESSAGE_ID_HASH); @ISA = qw(Exporter); @EXPORT = qw(parse_expression grep_folder sortuniq); -=head1 NAME - -Grep - IM grep folder - -=head1 DESCRIPTION - - -=head1 SYNOPSIS - -use IM::Grep; - -$eval_string = &parse_expression($expression, $casefold); - -@message_number_array = &grep_folder($folder_dir, $eval_string, @ranges); - -=cut - ## ## Environments ## @@ -56,13 +39,13 @@ my $draft_delimiter = "\n----\n"; %MESSAGE_ID_HASH = (); -sub grep_folder ($$$@) { - my ($folder, $eval_string, $dup_check, @ranges) = @_; +sub grep_folder($$$@) { + my($folder, $eval_string, $dup_check, @ranges) = @_; my $folder_dir; my @src_msgs = (); my @messages = (); - if ( $folder =~ /^\-/ ) { + if ($folder =~ /^\-/) { im_warn("Newsspool $folder search not supported (ignored)\n"); } @@ -77,12 +60,12 @@ sub grep_folder ($$$@) { # collect message numbers my @filesinfolder = message_list($folder_dir); - foreach ( @ranges ) { + foreach (@ranges) { my @tmp = (); im_die("illegal range specification: $_\n") unless /^$range_regexp$/; im_debug("extract range $_\n") if &debug('all'); - if (( @tmp = message_range($folder, $_, @filesinfolder )) eq '') { + if ((@tmp = message_range($folder, $_, @filesinfolder)) eq '') { im_warn("message $_ out of range\n"); } push(@src_msgs, @tmp); @@ -181,8 +164,8 @@ sub EOL { 0; } sub LITERAL { 1; } sub SYMBOL { 2; } -sub parse_expression ($$) { - my ($expr, $casefold) = @_; +sub parse_expression($$) { + my($expr, $casefold) = @_; my $case_flag = ''; my $expr_string = ''; @@ -196,8 +179,8 @@ sub parse_expression ($$) { my $SYMBOLS = '[!()=]|\&\&?|\|\|?'; my @tokens = (); - my ($escape, $pos, $len) = (0) x 3; - my ($token, $quote) = ('') x 2; + my($escape, $pos, $len) = (0) x 3; + my($token, $quote) = ('') x 2; my $str; LEX: @@ -272,8 +255,8 @@ sub parse_expression ($$) { # 3: before pattern: LITERAL->1, fallback to 1 # - my ($status, $paren) = (0) x 2; - my ($field, $pattern, $string) = ('') x 3; + my($status, $paren) = (0) x 2; + my($field, $pattern, $string) = ('') x 3; # my $token; PARSE: @@ -372,7 +355,7 @@ sub parse_expression ($$) { } # simple check by perl interpreter - my ($head, $body, $all) = ('') x 3; + my($head, $body, $all) = ('') x 3; eval "$eval_string"; if ($@) { if ($main::opt_quiet) { @@ -389,7 +372,7 @@ sub parse_expression ($$) { } sub parse_die($$$) { - my ($die, $expr, $pos) = @_; + my($die, $expr, $pos) = @_; if (!$main::opt_quiet and !$main::opt_verbose) { im_die("$die in the expression\n"); } @@ -405,12 +388,12 @@ sub parse_die($$$) { ## sort and uniqify a list ## -sub sortuniq (@) { +sub sortuniq(@) { my(@target) = @_; my(%tmp); @tmp{@target} = (undef) x @target; - return ( sort {$a <=> $b} keys %tmp ); + return(sort {$a <=> $b} keys %tmp); } ################################################## @@ -465,6 +448,34 @@ sub make_japanese_pattern { 1; +__END__ + +=head1 NAME + +IM::Grep - grep mail/news folder + +=head1 SYNOPSIS + + use IM::Grep; + + $eval_string = &parse_expression($expression, $casefold); + + @message_number_array = &grep_folder($folder_dir, $eval_string, @ranges); + +=head1 DESCRIPTION + +The I<IM::Grep> module enumerates mail/news messages matched given patterns. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/History.pm b/img/lib/IM/History.pm index dad0eb21..0fd358c2 100644 --- a/img/lib/IM/History.pm +++ b/img/lib/IM/History.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Jul 6, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::History.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::History.pm version 20021207(IM142)"; package IM::History; require 5.003; @@ -42,8 +42,8 @@ sub LookUpMsg { 0 } #sub LookUpDate { 1 } -sub history_open ($) { - my ($with_lock) = @_; +sub history_open($) { + my($with_lock) = @_; $DBtype = msgdbtype(); # package global unless ($DBtype) { $DBtype = db_type(); @@ -74,13 +74,13 @@ sub history_open ($) { im_debug("history database: $dbfile\n") if (&debug('history')); - my ($db, $fd); + my($db, $fd); if ($DBtype eq 'DB') { $db = tie %History, 'DB_File', $dbfile, O_CREAT()|O_RDWR(), &msg_mode(0); } elsif ($DBtype eq 'NDBM') { $db = tie %History, 'NDBM_File', $dbfile, O_CREAT()|O_RDWR(), &msg_mode(0); } elsif ($DBtype eq 'SDBM') { - if (&win95p || &os2p){ + if (&win95p || &os2p) { $db = tie %History, 'SDBM_File', $dbfile, O_CREAT()|O_RDWR()|O_BINARY(), &msg_mode(0); } else { $db = tie %History, 'SDBM_File', $dbfile, O_CREAT()|O_RDWR(), &msg_mode(0); @@ -112,7 +112,7 @@ sub history_open ($) { return -1; } } - if (! &win95p ){ + if (! &win95p) { unless (flock (HIST_FH, LOCK_EX | LOCK_NB)) { im_warn "history: waiting for write lock ($!)\n"; unless (flock (HIST_FH, LOCK_EX)) { @@ -126,12 +126,12 @@ sub history_open ($) { } -sub history_close () { +sub history_close() { if ($nodbfile) { im_err("no database specified.\n"); return; } - if (! &win95p ){ + if (! &win95p) { if ($locked) { flock(HIST_FH, LOCK_UN); } @@ -144,12 +144,12 @@ sub history_close () { } -sub history_lookup ($$) { +sub history_lookup($$) { if ($nodbfile) { im_err("no database specified.\n"); return (); } - my ($msgid, $field) = @_; + my($msgid, $field) = @_; $msgid =~ s/^<(.*)>$/$1/; if (defined($History{$msgid})) { if ($field == LookUpAll) { @@ -167,16 +167,16 @@ sub history_lookup ($$) { } } -sub history_store ($$) { +sub history_store($$) { if ($nodbfile) { im_err("no database specified.\n"); return -1; } - my ($msgid, $folder) = @_; + my($msgid, $folder) = @_; $msgid =~ s/^<(.*)>$/$1/; im_notice("add to history: $msgid\t$folder\n"); if (defined($History{$msgid})) { - my ($ofolder) = split("\t", $History{$msgid}); + my($ofolder) = split("\t", $History{$msgid}); if (scalar(grep($folder eq $_, split(',', $ofolder)))) { return; } @@ -185,17 +185,17 @@ sub history_store ($$) { $History{$msgid} = $folder; } -sub history_delete ($$) { +sub history_delete($$) { if ($nodbfile) { im_err("no database specified.\n"); return -1; } - my ($msgid, $folder) = @_; + my($msgid, $folder) = @_; $msgid =~ s/^<(.*)>$/$1/; if (defined($History{$msgid})) { if ($folder ne '') { - my ($f) = split("\t", $History{$msgid}); - my (@list, $found); + my($f) = split("\t", $History{$msgid}); + my(@list, $found); foreach (split(',', $f)) { if ($_ eq $folder) { $found = 1; @@ -221,25 +221,25 @@ sub history_delete ($$) { } -sub history_dump () { +sub history_dump() { if ($nodbfile) { im_err("no database specified.\n"); return; } - my ($key, $val); + my($key, $val); while (($key, $val) = each(%History)) { print "$key\t$val\n"; } } -sub history_rename ($$$) { +sub history_rename($$$) { if ($nodbfile) {im_err("no database specified.\n"); return;} - my ($id, $m1, $m2) = @_; + my($id, $m1, $m2) = @_; $id =~ s/<(.*)>/$1/; my $h; - if (defined $History{$id}){ + if (defined $History{$id}) { $h = $History{$id}; $h =~ s/^([^\t]+)(.*)//; $h = join(',', grep($_ ne $m1, split(',', $1)), $m2) . $2; @@ -251,14 +251,14 @@ sub history_rename ($$$) { return 0; } -sub history_link ($$$) { +sub history_link($$$) { if ($nodbfile) {im_err("no database specified.\n"); return;} - my ($id, $m1, $m2) = @_; + my($id, $m1, $m2) = @_; $id =~ s/<(.*)>/$1/; my $h; - if (defined $History{$id}){ + if (defined $History{$id}) { $h = $History{$id}; $h =~ s/^([^\t]+)(.*)//; $h = join(',', grep($_ ne $m2, split(',', $1)), $m2) . $2; @@ -270,13 +270,13 @@ sub history_link ($$$) { return 0; } -sub history_unlink ($$) { +sub history_unlink($$) { if ($nodbfile) {im_err("no database specified.\n"); return;} - my ($id, $m1) = @_; + my($id, $m1) = @_; $id =~ s/<(.*)>/$1/; - if (defined $History{$id}){ + if (defined $History{$id}) { my $h = $History{$id}; $h =~ s/^([^\t]+)(.*)//; $h = join(',', grep($_ ne $m1, split(',', $1))) . $2; @@ -293,6 +293,40 @@ sub history_unlink ($$) { 1; +__END__ + +=head1 NAME + +IM::History - mail/news history database handler + +=head1 SYNOPSIS + + use IM::History; + + history_open($with_lock); + history_dump(); + history_store($msgid, $folder); + history_lookup($msgid, LookUpAll); + history_lookup($msgid, LookUpMsg); + history_delete($msgid, $folder); + history_rename($id, $m1, $m2); + history_link($id, $m1, $m2); + history_close(); + +=head1 DESCRIPTION + +The I<IM::History> module handles mail/news database. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Http.pm b/img/lib/IM/Http.pm index 59ff1f8d..34949b61 100644 --- a/img/lib/IM/Http.pm +++ b/img/lib/IM/Http.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Http.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Http.pm version 20021207(IM142)"; package IM::Http; require 5.003; @@ -23,16 +23,6 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(http_process http_spec); -=head1 NAME - -Http - HTTP handling package - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw(*HTTPd); ######################## @@ -48,10 +38,10 @@ use vars qw(*HTTPd); # 0: success # -1: failure # -sub http_open ($$) { - my ($host, $port) = @_; - my ($resp); - my (@host_list); +sub http_open($$) { + my($host, $port) = @_; + my($resp); + my(@host_list); if ($port ne '' && $port != 0 && $port != 80) { @host_list = ("$host/$port"); } else { @@ -67,16 +57,16 @@ sub http_open ($$) { return 0; } -sub http_close () { +sub http_close() { im_notice("closing HTTP session.\n"); close(HTTPd); return 0; } -sub http_get ($$$) { - my ($path, $user, $pass) = @_; - local ($_); - my (@Message); +sub http_get($$$) { + my($path, $user, $pass) = @_; + local($_); + my(@Message); im_notice("getting $path.\n"); &send_data(\*HTTPd, "GET $path HTTP/1.0", ''); if ($pass ne '') { @@ -94,11 +84,11 @@ sub http_get ($$$) { } # http_process(spec) -sub http_process ($;$$) { - my ($spec, $http_proxy, $no_proxy) = @_; - my ($msg, $rcode, $auth); - my ($user, $host, $port, $path); - my ($target_host, $target_port); +sub http_process($;$$) { + my($spec, $http_proxy, $no_proxy) = @_; + my($msg, $rcode, $auth); + my($user, $host, $port, $path); + my($target_host, $target_port); $http_proxy = '' if ($no_proxy && $spec =~ /$no_proxy/); @@ -190,7 +180,7 @@ sub http_process ($;$$) { } # HTTP (--src=http://[user@]server[:port]/path) -sub http_spec ($) { +sub http_spec($) { my $spec = shift; if ($spec eq '') { @@ -224,6 +214,45 @@ sub http_spec ($) { 1; +__END__ + +=head1 NAME + +IM::Http - HTTP handler + +=head1 SYNOPSIS + + use IM::Http; + + (rc, data) = http_process(spec, http_proxy, no_proxy) + rc: + 0: success + -1: failure + +=head1 DESCRIPTION + +The I<IM::Http> module handles HTTP. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + my($rc, $data) = http_process($spec, httpproxy(), noproxy()) + if ($rc < 0) { + exit 1; + } + foreach (@$data) { + print; + } + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Imap.pm b/img/lib/IM/Imap.pm index 32583f9c..cdd056d6 100644 --- a/img/lib/IM/Imap.pm +++ b/img/lib/IM/Imap.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Imap.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Imap.pm version 20021207(IM142)"; package IM::Imap; require 5.003; @@ -32,16 +32,6 @@ use vars qw(@ISA @EXPORT); imap_put_message imap_put_file imap_refile imap_delete_message ); -=head1 NAME - -Imap - IMAP handling package - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw($ImapSeq); ######################## # IMAP access routines # @@ -52,10 +42,10 @@ use vars qw($ImapSeq); # 0: success # -1: failure # -sub imap_open ($$$$) { - my ($auth, $host, $user, $pass) = @_; - my ($data, $seq, $errmsg); - my (@host_list) = ($host); +sub imap_open($$$$) { + my($auth, $host, $user, $pass) = @_; + my($data, $seq, $errmsg); + my(@host_list) = ($host); my $HANDLE; $pass = '*' unless ($pass); @@ -72,7 +62,7 @@ sub imap_open ($$$$) { } my $failed = 0; if ($auth eq 'LOGIN') { - my ($us, $pw) = ($user, $pass); + my($us, $pw) = ($user, $pass); $us =~ s/([\\"])/\\$1/g; # escape specials $us = "\"$us\""; # quote it $pw =~ s/([\\"])/\\$1/g; # escape specials @@ -134,9 +124,9 @@ sub imap_open ($$$$) { return (0, $HANDLE); } -sub imap_close ($) { - my ($HANDLE) = @_; - my ($seq) = $ImapSeq++; +sub imap_close($) { + my($HANDLE) = @_; + my($seq) = $ImapSeq++; my $failed = 0; if (1) { im_notice("closing IMAP session.\n"); @@ -162,10 +152,10 @@ sub imap_close ($) { return 0; } -sub imap_select ($$$) { - my ($HANDLE, $mbox, $select) = @_; - my ($seq) = $ImapSeq++; - my ($resp, @field); +sub imap_select($$$) { + my($HANDLE, $mbox, $select) = @_; + my($seq) = $ImapSeq++; + my($resp, @field); if ($select) { im_notice("select mbox $mbox and getting number of message.\n"); $resp = &send_command($HANDLE, "im$seq SELECT $mbox", ''); @@ -195,10 +185,10 @@ sub imap_select ($$$) { return $msgs; } -sub imap_get ($$) { - my ($HANDLE, $num) = @_; - my ($seq) = $ImapSeq++; - my (@message); +sub imap_get($$) { + my($HANDLE, $num) = @_; + my($seq) = $ImapSeq++; + my(@message); im_notice("getting message $num.\n"); my $resp = &send_command($HANDLE, "im$seq UID FETCH $num RFC822", ''); my $failed = 0; @@ -236,18 +226,18 @@ sub imap_get ($$) { return (0, \@message); } -sub imap_head ($$) { - my ($HANDLE, $num) = @_; - my ($seq) = $ImapSeq++; +sub imap_head($$) { + my($HANDLE, $num) = @_; + my($seq) = $ImapSeq++; im_notice("getting header of message $num.\n"); my $resp = &send_command($HANDLE, "im$seq UID FETCH $num (RFC822.SIZE RFC822.HEADER)", ''); my $failed = 0; - my (%head); + my(%head); undef %head; if ($resp =~ /^\* \d+ FETCH \((UID $num )?RFC822.SIZE (\d+) RFC822.HEADER \{(\d+)\}/i) { - my ($size, $len) = ($2, $3); + my($size, $len) = ($2, $3); my $field = ''; alarm(imap_timeout()) unless win95p(); $! = 0; @@ -295,8 +285,8 @@ sub imap_head ($$) { return (0, \%head); } -sub imap_from ($$) { - my ($HANDLE, $num) = @_; +sub imap_from($$) { + my($HANDLE, $num) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("getting sender information of message $num.\n"); @@ -349,10 +339,10 @@ sub imap_from ($$) { return 0; } -sub imap_flags ($$) { - my ($HANDLE, $num) = @_; +sub imap_flags($$) { + my($HANDLE, $num) = @_; my $seq = $ImapSeq++; - my ($flags); + my($flags); im_notice("getting flags for $num.\n"); my $failed = 0; my $resp = &send_command($HANDLE, "im$seq UID FETCH $num FLAGS", ''); @@ -370,8 +360,8 @@ sub imap_flags ($$) { return $flags; } -sub imap_delete ($$) { - my ($HANDLE, $num) = @_; +sub imap_delete($$) { + my($HANDLE, $num) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("deleting message $num.\n"); @@ -386,13 +376,13 @@ sub imap_delete ($$) { return 0; } -sub imap_list_folder ($) { - my ($HANDLE) = @_; +sub imap_list_folder($) { + my($HANDLE) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("listing folders.\n"); my $resp = &send_command($HANDLE, "im$seq LIST \"\" *", ''); - my (@folders) = (); + my(@folders) = (); while ($resp !~ /^im$seq/) { $failed = 1 if ($resp =~ /^\* NO/i); if ($resp =~ /^\* LIST \(([^)]*)\) (\S+) (\S+)/) { @@ -407,8 +397,8 @@ sub imap_list_folder ($) { return @folders; } -sub imap_create_folder ($$) { - my ($HANDLE, $folder) = @_; +sub imap_create_folder($$) { + my($HANDLE, $folder) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("creating folder $folder.\n"); @@ -422,8 +412,8 @@ sub imap_create_folder ($$) { return 0; } -sub imap_delete_folder ($$) { - my ($HANDLE, $folder) = @_; +sub imap_delete_folder($$) { + my($HANDLE, $folder) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("deleting folder $folder.\n"); @@ -437,8 +427,8 @@ sub imap_delete_folder ($$) { return 0; } -sub imap_rename_folder ($$$) { - my ($HANDLE, $old, $new) = @_; +sub imap_rename_folder($$$) { + my($HANDLE, $old, $new) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("rename folder from $old to $new.\n"); @@ -452,8 +442,8 @@ sub imap_rename_folder ($$$) { return 0; } -sub imap_copy ($$$$) { - my ($HANDLE, $srcmsg, $dstfolder, $moveflag) = @_; +sub imap_copy($$$$) { + my($HANDLE, $srcmsg, $dstfolder, $moveflag) = @_; im_notice("copying message $srcmsg to $dstfolder.\n"); # my $resp = &imap_select($HANDLE, $dstfolder, 0); # if ($resp < 0) { @@ -480,8 +470,8 @@ sub imap_copy ($$$$) { return 0; } -sub imap_put ($$$) { - my ($HANDLE, $folder, $Msg) = @_; +sub imap_put($$$) { + my($HANDLE, $folder, $Msg) = @_; my $seq = $ImapSeq++; my $failed = 0; im_notice("appending a new message to $folder.\n"); @@ -516,9 +506,9 @@ sub imap_put ($$$) { } # imap_process(handle, how, host, src, dst, limit) -sub imap_process ($$$$$$$) { - my ($HANDLE, $how, $host, $src, $dst, $limit, $noscan) = @_; - my ($msgs, $count) = (0, 0); +sub imap_process($$$$$$$) { + my($HANDLE, $how, $host, $src, $dst, $limit, $noscan) = @_; + my($msgs, $count) = (0, 0); if (($msgs = &imap_select($HANDLE, $src, 1)) < 0) { im_warn("selecting folder $src failed.\n"); return -1; @@ -553,7 +543,7 @@ sub imap_process ($$$$$$$) { im_info("$count message(s).\n"); return $count; } - my ($rc, $message) = &imap_get($HANDLE, $i); + my($rc, $message) = &imap_get($HANDLE, $i); return -1 if ($rc < 0); return -1 if (store_message($message, $dst, $noscan) < 0); &exec_getsbrfile($dst); @@ -573,17 +563,17 @@ sub imap_process ($$$$$$$) { return $msgs; } -sub imap_get_msg ($$$$$) { - my ($src, $dst, $how, $limit, $noscan) = @_; +sub imap_get_msg($$$$$) { + my($src, $dst, $how, $limit, $noscan) = @_; $src =~ s/^imap//i; - my ($folder, $auth, $user, $host) = &imap_spec($src); + my($folder, $auth, $user, $host) = &imap_spec($src); return -1 if ($folder eq ''); - my ($pass, $agtfound, $interact) = getpass('imap', $auth, $host, $user); + my($pass, $agtfound, $interact) = getpass('imap', $auth, $host, $user); im_notice("accessing IMAP/$auth:$user\@$host for $how\n"); - my ($rc, $HANDLE) = &imap_open($auth, $host, $user, $pass); + my($rc, $HANDLE) = &imap_open($auth, $host, $user, $pass); if ($rc == 0) { &savepass('imap', $auth, $host, $user, $pass) if ($pass ne '' && $interact && &usepwagent()); @@ -601,7 +591,7 @@ sub imap_get_msg ($$$$$) { } # IMAP folder (--src=imap[%folder][//auth][:user][@server[/port]]) -sub imap_spec ($) { +sub imap_spec($) { my $spec = shift; if ($spec eq '' || $spec !~ /[:\@]|\/\//) { @@ -619,7 +609,7 @@ sub imap_spec ($) { $spec .= $s if ($s ne ''); } - my ($folder, $auth, $host) = ('INBOX', 'auth', 'localhost'); + my($folder, $auth, $host) = ('INBOX', 'auth', 'localhost'); my $user = $ENV{'USER'} || $ENV{'LOGNAME'} || im_getlogin(); if ($spec =~ /^%(.*)\/(\/.*)/) { @@ -658,13 +648,13 @@ sub imap_spec ($) { return ($folder, $auth, $user, $host); } -sub imap_range2set ($@) { - my ($HANDLE, @ranges) = @_; - my (@uids, $fromuid, $dir); +sub imap_range2set($@) { + my($HANDLE, @ranges) = @_; + my(@uids, $fromuid, $dir); my @alluids = &imap_all_uids($HANDLE); return -1 if ($alluids[0] < 0); - my ($min, $max) = ($alluids[0], $alluids[$#alluids]); + my($min, $max) = ($alluids[0], $alluids[$#alluids]); @ranges = ('first-last') if ($#ranges < 0 || grep(/^all$/, @ranges)); local $_; @@ -703,9 +693,9 @@ sub imap_range2set ($@) { return join(',', grep($_, @ranges)); } -sub imap_range2msgs ($@) { - my ($HANDLE, @ranges) = @_; - my ($seq, $set, $resp, @uids); +sub imap_range2msgs($@) { + my($HANDLE, @ranges) = @_; + my($seq, $set, $resp, @uids); $set = &imap_range2set($HANDLE, @ranges); $seq = $ImapSeq++; @@ -721,9 +711,9 @@ sub imap_range2msgs ($@) { return wantarray ? @uids : $uids[0]; } -sub imap_folder_regname ($) { +sub imap_folder_regname($) { my $folder = shift; # %... - my ($auth, $user, $host); + my($auth, $user, $host); ($folder, $auth, $user, $host) = imap_spec($folder); $folder =~ s/^/%/; @@ -731,7 +721,7 @@ sub imap_folder_regname ($) { return "$folder//$auth:$user\@$host"; # may be appended '/port' } -sub imap_folder_name ($) { +sub imap_folder_name($) { my $folder = shift; if ($folder =~ /^%([^:\@]+)/) { @@ -744,9 +734,9 @@ sub imap_folder_name ($) { return ''; } -sub imap_folder_acct ($) { +sub imap_folder_acct($) { my $folder = shift; # %... - my ($auth, $user, $host); + my($auth, $user, $host); ($folder, $auth, $user, $host) = imap_spec($folder); @@ -756,9 +746,9 @@ sub imap_folder_acct ($) { return ''; } -sub imap_all_uids ($) { - my ($HANDLE) = @_; - my ($seq, $resp, @uids); +sub imap_all_uids($) { + my($HANDLE) = @_; + my($seq, $resp, @uids); $seq = $ImapSeq++; $resp = &send_command($HANDLE, "im$seq UID SEARCH 1:*", ''); @@ -773,8 +763,8 @@ sub imap_all_uids ($) { return @uids; } -sub imap_message_number ($$$) { - my ($min, $max, $num) = @_; +sub imap_message_number($$$) { + my($min, $max, $num) = @_; return $num if $num =~ /^\d+$/; return $min if $num =~ /^first$/; @@ -787,9 +777,9 @@ sub imap_message_number ($$$) { ## For imls ## -sub imap_scan_folder ($$@) { - my ($HANDLE, $folder, @ranges) = @_; - my ($uid, $size, $len); +sub imap_scan_folder($$@) { + my($HANDLE, $folder, @ranges) = @_; + my($uid, $size, $len); my $msgset = &imap_range2set($HANDLE, @ranges); return 0 if !$msgset; @@ -857,20 +847,20 @@ sub imap_scan_folder ($$@) { my %ImapHandleCache = (); -sub imap_open_folders ($@) { - my ($create, @folders) = @_; +sub imap_open_folders($@) { + my($create, @folders) = @_; foreach (@folders) { next unless (/^%/); my $acct = imap_folder_acct($_); my $ifld = imap_folder_name($_); - my ($rc, $HANDLE); + my($rc, $HANDLE); unless ($HANDLE = $ImapHandleCache{$acct}) { - my ($dummy, $auth, $user, $host) + my($dummy, $auth, $user, $host) = imap_spec(imap_folder_regname($_)); - my ($pass, $agtfound, $interact) = + my($pass, $agtfound, $interact) = getpass('imap', $auth, $host, $user); ($rc, $HANDLE) = imap_open($auth, $host, $user, $pass); @@ -898,19 +888,19 @@ sub imap_open_folders ($@) { return 0; } -sub imap_close_folders () { +sub imap_close_folders() { foreach (keys(%ImapHandleCache)) { imap_close($ImapHandleCache{$_}); } %ImapHandleCache = (); } -sub imap_get_handle ($) { +sub imap_get_handle($) { return $ImapHandleCache{imap_folder_acct(shift)}; } -sub imap_get_message ($$) { - my ($src, $range) = @_; +sub imap_get_message($$) { + my($src, $range) = @_; my $HANDLE = imap_get_handle($src); my $msg = imap_range2msgs($HANDLE, ($range)); @@ -919,7 +909,7 @@ sub imap_get_message ($$) { return (); } - my ($rc, $msgref) = imap_get($HANDLE, $msg); + my($rc, $msgref) = imap_get($HANDLE, $msg); if ($rc < 0) { im_warn("can't get msg $_ from source folder.\n"); return (); @@ -927,8 +917,8 @@ sub imap_get_message ($$) { return $msgref; } -sub imap_put_message ($$;$) { - my ($Message, $dsts, $src_path) = @_; +sub imap_put_message($$;$) { + my($Message, $dsts, $src_path) = @_; my $dst; foreach $dst (@$dsts) { @@ -941,10 +931,10 @@ sub imap_put_message ($$;$) { return 0; } -sub imap_put_file ($$$) { - my ($src, $dsts, $src_path) = @_; +sub imap_put_file($$$) { + my($src, $dsts, $src_path) = @_; my @Message; - local (*SRC); + local(*SRC); unless (im_open(\*SRC, "<$src_path")) { im_warn("can't open local message $src_path.\n"); @@ -959,9 +949,9 @@ sub imap_put_file ($$$) { return imap_put_message(\@Message, $dsts, $src_path); } -sub imap_refile ($$$) { - my ($src, $dsts, $msgs) = @_; - my ($HANDLE, $srcacct, $srcset); +sub imap_refile($$$) { + my($src, $dsts, $msgs) = @_; + my($HANDLE, $srcacct, $srcset); my $link_1st; $srcacct = imap_folder_acct($src); @@ -993,8 +983,8 @@ sub imap_refile ($$$) { return 0; } -sub imap_delete_message () { - my ($src, @range) = @_; +sub imap_delete_message() { + my($src, @range) = @_; my $HANDLE = imap_get_handle($src); my $srcset = imap_range2set($HANDLE, @range); @@ -1003,6 +993,49 @@ sub imap_delete_message () { 1; +__END__ + +=head1 NAME + +IM::Imap - IMAP handler + +=head1 SYNOPSIS + + use IM::Imap; + + imap_open(auth, host, user, pass) + return value: + 0: success + -1: failure + +Other subroutines: +imap_select imap_head imap_get imap_put imap_delete +imap_get_msg imap_spec imap_range2set imap_folder_regname imap_scan_folder +imap_open_folders imap_close_folders imap_get_handle imap_get_message +imap_put_message imap_put_file imap_refile imap_delete_message + +=head1 DESCRIPTION + +The I<IM::Imap> module handles IMAP. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + my($rc, $HANDLE) = imap_open($auth, $host, $user, $pass); + if ($rc < 0) { + exit 1; + } + imap_close($HANDLE); + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Iso2022jp.pm b/img/lib/IM/Iso2022jp.pm index 98f5959b..bcb37bfb 100644 --- a/img/lib/IM/Iso2022jp.pm +++ b/img/lib/IM/Iso2022jp.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Iso2022jp.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Iso2022jp.pm version 20021207(IM142)"; package IM::Iso2022jp; require 5.003; @@ -28,24 +28,6 @@ use vars qw(@ISA @EXPORT); header_iso2022jp_conv ); -=head1 NAME - -Iso2022jp - MIME header encoder for ISO-2022-JP character set - -=head1 SYNOPSIS - -use IM/Iso2022jp; - -$encoded_string_for_structured_header = struct_iso2022jp_mimefy(string); - -$encoded_string_for_unstructured_header = line_iso2022jp_mimefy(string); - -$rcode = header_iso2022jp_conv(\@Header, code_conv_flag); - -=head1 DESCRIPTION - -=cut - use vars qw($Jp_Bin $Jp_Qin $Jp_out $Jis_kanji $Jis_roman $C_pascii); @@ -64,16 +46,16 @@ BEGIN { # return value: (lines, err) # lines: converted lines (NULL if error) # -sub struct_iso2022jp_mimefy ($) { +sub struct_iso2022jp_mimefy($) { my $line_in = shift; - my ($c, $groupsyntax); - my ($inquote, $incomment, $addrquote) = (0, 0, 0); - my ($groupcolon, $need_space, $need_encode) = (0, 0, 0); - my ($line_out, $line_work) = ('', ''); - my ($n); + my($c, $groupsyntax); + my($inquote, $incomment, $addrquote) = (0, 0, 0); + my($groupcolon, $need_space, $need_encode) = (0, 0, 0); + my($line_out, $line_work) = ('', ''); + my($n); im_debug("encoding structured: $line_in\n") if (&debug('encode')); while ($line_in ne '') { - if ($line_in =~ /^($Jis_kanji[^\e]+$Jis_roman([ \t]*$Jis_kanji[^\e]+$Jis_roman)*)(.*)/os){ + if ($line_in =~ /^($Jis_kanji[^\e]+$Jis_roman([ \t]*$Jis_kanji[^\e]+$Jis_roman)*)(.*)/os) { $c = $1; $line_in = $3; $need_encode = 1; @@ -238,7 +220,7 @@ sub struct_iso2022jp_mimefy ($) { # &error_exit; return ''; } - if ($line_out =~ /$Jis_kanji[^\e]+$Jis_roman/o){ + if ($line_out =~ /$Jis_kanji[^\e]+$Jis_roman/o) { im_err("invalid iso-2022-jp charset location in structured field: " . "$line_out\n"); # &error_exit; @@ -253,9 +235,9 @@ sub struct_iso2022jp_mimefy ($) { # lines: continuous header lines to be converted # return value: converted lines # -sub line_iso2022jp_mimefy ($) { - my ($line_in) = @_; - my ($line_out, $this_word, $this_space, $this_code, $follow, $n); +sub line_iso2022jp_mimefy($) { + my($line_in) = @_; + my($line_out, $this_word, $this_space, $this_code, $follow, $n); $follow = 0; $this_space = ''; $line_out = ''; @@ -292,7 +274,7 @@ sub line_iso2022jp_mimefy ($) { $line_in = $3; $this_word .= $1; $this_code = 'iso-2022-jp'; - } elsif ($line_in =~ /^($Jis_roman)(.*)/os){ # XXX + } elsif ($line_in =~ /^($Jis_roman)(.*)/os) { # XXX last if ($this_code ne 'us-ascii' && $this_code ne 'iso-2022-jp'); $line_in = $2; @@ -343,10 +325,10 @@ sub line_iso2022jp_mimefy ($) { # struct: true if in structured field # return value: encoded words # -sub word_iso2022jp_mimefy ($$$$) { - my ($size, $word_in, $need_pre_space, $struct) = @_; - my ($word_out) = ''; - my ($word_conv, $n, $word_sub, $word_rest); +sub word_iso2022jp_mimefy($$$$) { + my($size, $word_in, $need_pre_space, $struct) = @_; + my($word_out) = ''; + my($word_conv, $n, $word_sub, $word_rest); if ($main::NoFolding) { if ($main::HdrQEncoding) { @@ -447,10 +429,10 @@ sub word_iso2022jp_mimefy ($$$$) { # 0: success # -1: failure # -sub header_iso2022jp_conv ($$) { - my ($header, $code_conv) = @_; - my ($i, $c); - my ($field_name, $field_value); +sub header_iso2022jp_conv($$) { + my($header, $code_conv) = @_; + my($i, $c); + my($field_name, $field_value); for ($i = 0; $i <= $#$header; $i++) { im_debug("Iso2022jp: converting: $$header[$i]\n") if (&debug('encode')); $c = &code_check($$header[$i]); @@ -501,8 +483,8 @@ sub header_iso2022jp_conv ($$) { # space: separatig space # return value: a concatinated header string # -sub hdr_cat ($$$) { - my ($str1, $str2, $space) = @_; +sub hdr_cat($$$) { + my($str1, $str2, $space) = @_; if ($str1 eq '' || $str1 =~ /\n[\t ]+$/) { return "$str1$space$str2"; @@ -521,6 +503,34 @@ sub hdr_cat ($$$) { 1; +__END__ + +=head1 NAME + +IM::Iso2022jp - MIME header encoder for ISO-2022-JP + +=head1 SYNOPSIS + + use IM::Iso2022jp; + + $encoded_string_for_structured_header = struct_iso2022jp_mimefy(string); + $encoded_string_for_unstructured_header = line_iso2022jp_mimefy(string); + $rcode = header_iso2022jp_conv(\@Header, code_conv_flag); + +=head1 DESCRIPTION + +The I<IM::Iso2022jp> module is MIME header encoder for ISO-2022-JP. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Japanese.pm b/img/lib/IM/Japanese.pm index 08948d60..f0e1e1bb 100644 --- a/img/lib/IM/Japanese.pm +++ b/img/lib/IM/Japanese.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Japanese.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Japanese.pm version 20021207(IM142)"; package IM::Japanese; require 5.003; @@ -23,22 +23,6 @@ use vars qw(@ISA @EXPORT); convert_iso2022jp_body conv_iso2022jp conv_euc_from_jis conv_euc_from_sjis); -=head1 NAME - -Japanese - IM Japanese handler - -=head1 SYNOPSIS - - use IM::Japanese; - $code = code_check($line, $use_hankaku_kana); - $code = code_check_body($content); - convert_iso2022jp_body($content, $code); - $converted = conv_iso2022jp($line, $code); - -=head1 DESCRIPTION - -=cut - use vars qw($C_jis $C_jis_roman $C_sjis $C_sjis_kana $C_euc $C_euc_kana $C_SorE $C_ascii $C_pascii $C_tascii $C_sascii $C_8bit @@ -75,9 +59,9 @@ BEGIN { # sjis # sORe # -sub code_check ($;$) { - my ($line, $no_hankaku_kana) = @_; - my ($sjis, $euc); +sub code_check($;$) { + my($line, $no_hankaku_kana) = @_; + my($sjis, $euc); if ($line =~ /^$C_ascii*$/o) { return 'ascii'; @@ -114,9 +98,9 @@ sub code_check ($;$) { # EUC # SJIS # -sub code_check_body ($) { +sub code_check_body($) { my $content = shift; - my (%count) = (); + my(%count) = (); $count{'ascii'} = 0; # for debug print $count{'8bit'} = 0; @@ -171,8 +155,8 @@ sub code_check_body ($) { # code: input kanji code # return value: none # -sub convert_iso2022jp_body ($$) { - my ($content, $code) = @_; +sub convert_iso2022jp_body($$) { + my($content, $code) = @_; my $i; for ($i = 0; $i <= $#$content; $i++) { @@ -187,8 +171,8 @@ sub convert_iso2022jp_body ($$) { # code: input kanji code # return value: converted line # -sub conv_iso2022jp ($;$) { - my ($line, $code) = @_; +sub conv_iso2022jp($;$) { + my($line, $code) = @_; im_debug("conv_iso2022jp: $line\n") if (&debug('japanese')); @@ -221,19 +205,19 @@ sub conv_iso2022jp ($;$) { # line: a line of string to be converted # return value: converted line # -sub conv_from_sjis ($) { +sub conv_from_sjis($) { my $line = shift; $line =~ s/((?:$C_sjis|$C_sjis_kana)+)/sjis2jis($1)/geo; return $line; } -sub sjis2jis ($) { +sub sjis2jis($) { my $line = shift; $line =~ s/((?:$C_sjis)+|(?:$C_sjis_kana)+)/s2j($1)/geo; return "$line$E_asc"; } -sub s2e ($) { +sub s2e($) { my $code = shift; - my ($c1, $c2) = unpack('CC', $code); + my($c1, $c2) = unpack('CC', $code); if (0xa1 <= $c1 && $c1 <= 0xdf) { $c2 = $c1; $c1 = 0x8e; @@ -246,7 +230,7 @@ sub s2e ($) { } return pack('CC', $c1, $c2); } -sub s2j ($) { +sub s2j($) { my $cur = shift; if ($cur =~ /^$C_sjis_kana/o) { $cur =~ tr/\xa1-\xdf/\x21-\x5f/; @@ -264,17 +248,17 @@ sub s2j ($) { # line: a line of string to be converted # return value: converted line # -sub conv_from_euc ($) { +sub conv_from_euc($) { my $line = shift; $line =~ s/((?:$C_euc|$C_euc_kana)+)/euc2jis($1)/geo; return $line; } -sub euc2jis ($) { +sub euc2jis($) { my $line = shift; $line =~ s/((?:$C_euc)+|(?:$C_euc_kana)+)/e2j($1)/geo; return "$line$E_asc"; } -sub e2j ($) { +sub e2j($) { my $cur = shift; $cur =~ tr/\xa1-\xfe/\x21-\x7e/; if ($cur =~ tr/\x8e//d) { @@ -291,7 +275,7 @@ sub e2j ($) { # return value: converted line # -sub conv_euc_from_sjis ($) { +sub conv_euc_from_sjis($) { my $line = shift; $line =~ s/($C_sjis|$C_sjis_kana)/s2e($1)/geo; return $line; @@ -304,14 +288,14 @@ sub conv_euc_from_sjis ($) { # return value: converted line # -sub conv_euc_from_jis ($) { +sub conv_euc_from_jis($) { my $line = shift; $line =~ s/$C_jis/j2e($1,$2)/geo; $line =~ s/\e\$C_jis_roman/$2/geo; return $line; } -sub j2e ($$) { +sub j2e($$) { my $esc = shift; my $line = shift; if ($esc =~ /\e\$[\@B]/) { @@ -322,6 +306,36 @@ sub j2e ($$) { 1; +__END__ + +=head1 NAME + +IM::Japanese - Japanese message handler + +=head1 SYNOPSIS + + use IM::Japanese; + + $code = code_check($line, $use_hankaku_kana); + $code = code_check_body($content); + convert_iso2022jp_body($content, $code); + $converted = conv_iso2022jp($line, $code); + +=head1 DESCRIPTION + +The I<IM::Japanese> module handles Japanese message encoded with +ISO-2022-JP, EUC-JP, Shift_JIS, or US-ASCII. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/LocalMbox.pm b/img/lib/IM/LocalMbox.pm index 8a38fde1..1c27bbee 100644 --- a/img/lib/IM/LocalMbox.pm +++ b/img/lib/IM/LocalMbox.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::LocalMbox.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::LocalMbox.pm version 20021207(IM142)"; package IM::LocalMbox; require 5.003; @@ -25,22 +25,6 @@ use vars qw(@ISA @EXPORT $getchk_hook); @ISA = qw(Exporter); @EXPORT = qw(local_get_msg); -=head1 NAME - -LocalMbox - local mailbox managing package - -=head1 SYNOPSIS - -$num_msgs = &local_get_msg(source_mailbox, destination_folder, access_mode); - -=head1 DESCRIPTION - -$mbox = 'local:/var/mail/motonori'; -$folder = '+inbox' -$num_msgs = &local_get_msg($mbox, $folder, 'get'); - -=cut - use vars qw($locked_by_file $locked_by_flock); ################################# # local mailbox access routines # @@ -51,10 +35,10 @@ use vars qw($locked_by_file $locked_by_flock); # local_get_msg(src, dst, how) # check, from, get # -sub local_get_msg ($$$$$) { - my ($src, $dst, $how, $lock_type, $noscan) = @_; - my ($need_lock, $qmail_ok, $msgs, $l, $file, $p); - my (@MailDrops); +sub local_get_msg($$$$$) { + my($src, $dst, $how, $lock_type, $noscan) = @_; + my($need_lock, $qmail_ok, $msgs, $l, $file, $p); + my(@MailDrops); if ($how eq 'get') { $need_lock = 1; @@ -89,7 +73,7 @@ sub local_get_msg ($$$$$) { push(@MailDrops, $ENV{'MAIL'}) if ($ENV{'MAIL'}); push(@MailDrops, "$home/Maildir"); foreach $p (@MailDrops) { - if (( -d $p && -d "$p/new" && -d "$p/cur") || -f $p ) { + if ((-d $p && -d "$p/new" && -d "$p/cur") || -f $p) { $mbox = $p; last; } @@ -104,7 +88,7 @@ sub local_get_msg ($$$$$) { ); unshift(@MailDrops, "$home/Mailbox") if ($qmail_ok); foreach $p (@MailDrops) { - if ( -f $p ) { + if (-f $p) { $mbox = $p; last; } @@ -221,7 +205,7 @@ sub local_get_msg ($$$$$) { } } - truncate (SAVE, tell(SAVE)); + truncate(SAVE, tell(SAVE)); unlink($tmpmbox); } else { if (($msgs = process_mbox($mbox, $dst, $how, '', $noscan)) < 0) { @@ -246,8 +230,8 @@ sub local_get_msg ($$$$$) { } } -sub local_copymbox ($$) { - my ($src, $dst) = @_; +sub local_copymbox($$) { + my($src, $dst) = @_; im_debug("copy from $src to $dst\n") if (&debug('local')); unless (im_open(\*SRC, "<$src")) { @@ -274,15 +258,15 @@ sub local_copymbox ($$) { return -1; } } - truncate (DST, -s SRC); - close (DST); - close (SRC); + truncate(DST, -s SRC); + close(DST); + close(SRC); return 0; } -sub process_maildir ($$$$) { - my ($maildir, $dst, $how, $noscan) = @_; - my ($msgs, $f, $dir); +sub process_maildir($$$$) { + my($maildir, $dst, $how, $noscan) = @_; + my($msgs, $f, $dir); unless (-d "$maildir/new" && -r "$maildir/new" && -x "$maildir/new" && -d "$maildir/cur" && -r "$maildir/cur" && -x "$maildir/cur") { @@ -317,10 +301,10 @@ sub process_maildir ($$$$) { return $msgs; } -sub process_file ($$$$) { - my ($mbox, $dst, $how, $noscan) = @_; - my ($format, $msgs, $rp, $length, $inheader, @Message); - local (*MBOX); +sub process_file($$$$) { + my($mbox, $dst, $how, $noscan) = @_; + my($format, $msgs, $rp, $length, $inheader, @Message); + local(*MBOX); im_notice("opening MBOX ($mbox)\n"); unless (im_open(\*MBOX, "<$mbox")) { @@ -331,8 +315,9 @@ sub process_file ($$$$) { push (@Message, $_); } if ($getchk_hook ne '') { - my $head = lcl_store_header(\@Message); - unless (eval { &getchk_sub($head); }) { + my %head; + lcl_store_header(\%head, \@Message); + unless (eval { &getchk_sub(\%head); }) { close(MBOX); return 1 } @@ -348,11 +333,11 @@ sub process_file ($$$$) { return 0; } -sub process_mbox ($$$$$) { - my ($mbox, $dst, $how, $save, $noscan) = @_; - my ($format, $msgs, $length, $inheader, @Message); - local (*MBOX); - my ($first_line, $FIRST_LINE); +sub process_mbox($$$$$) { + my($mbox, $dst, $how, $save, $noscan) = @_; + my($format, $msgs, $length, $inheader, @Message); + local(*MBOX); + my($first_line, $FIRST_LINE); im_info("Getting new messages from local mailbox into $dst....\n") if ($how eq 'get'); @@ -416,7 +401,7 @@ sub process_mbox ($$$$$) { && /^From / && $Message[$#Message] eq "\n") { chomp($first_line = $_); last; - } elsif ($format eq 'RMAIL' && /^\x1f/ ) { + } elsif ($format eq 'RMAIL' && /^\x1f/) { chomp($first_line = <MBOX>); last; } elsif ($inheader) { @@ -424,7 +409,7 @@ sub process_mbox ($$$$$) { print "$_" if (/^From:/i); } # XXX continuous line processing needed - push (@Message, $_) + push(@Message, $_) unless (/^Return-Path:/i && $main::opt_rpath eq 'replace'); # for Solaris 2.x or ... # XXX option @@ -433,13 +418,13 @@ sub process_mbox ($$$$$) { } $inheader = 0 if (/^\n$/); } else { - push (@Message, $_); + push(@Message, $_); $length -= length($_) if ($length > 0); } } if ($Message[$#Message] eq "\n") { - pop (@Message); + pop(@Message); } if ($getchk_hook) { @@ -475,8 +460,8 @@ sub process_mbox ($$$$$) { return $msgs; } -sub save_message ($$$$) { - my ($msg, $save, $mode, $fline) = @_; +sub save_message($$$$) { + my($msg, $save, $mode, $fline) = @_; im_debug("saving to $save\n") if (&debug('local')); if ($mode eq 'UNIX') { @@ -527,7 +512,7 @@ sub save_message ($$$$) { return 0; } -sub local_empty ($) { +sub local_empty($) { my $mbox = shift; unless (truncate($mbox, 0)) { unless (im_open(\*MBOX, ">$mbox")) { @@ -544,15 +529,15 @@ sub LOCK_EX { 2 } sub LOCK_NB { 4 } sub LOCK_UN { 8 } -sub local_lockmbox ($$) { - my ($base, $type) = @_; +sub local_lockmbox($$) { + my($base, $type) = @_; my $retry = 0; im_warn("creating lock file with uid=$> gid=$)\n") if (&debug('local')); $locked_by_file = 0; $locked_by_flock = 0; if ($type =~ /file/) { -# while (! sysopen(LOCK, "$base.lock", O_RDWR()|O_CREAT()|O_EXCL())) { +# while (!sysopen(LOCK, "$base.lock", O_RDWR()|O_CREAT()|O_EXCL())) { # if ($retry >= 10) { # im_warn("can't create $base.lock: $!\n"); # return -1; @@ -589,7 +574,7 @@ sub local_lockmbox ($$) { im_err "can't open $base :$!\n"; return -1; } - if (! &win95p ){ + if (! &win95p) { unless (flock (LOCK_FH, LOCK_EX|LOCK_NB)) { im_warn "can't flock $base: $!\n"; return -1; @@ -600,7 +585,7 @@ sub local_lockmbox ($$) { return 0; } -sub local_unlockmbox ($) { +sub local_unlockmbox($) { my $base = shift; my $rcode = 0; im_debug("removing lock file with uid=$> gid=$)\n") if (&debug('local')); @@ -612,7 +597,7 @@ sub local_unlockmbox ($) { $locked_by_file = 0; } if ($locked_by_flock) { - if (! &win95p ){ + if (! &win95p) { flock(LOCK_FH, LOCK_UN); } $locked_by_flock = 0; @@ -620,9 +605,9 @@ sub local_unlockmbox ($) { return $rcode; } -sub lcl_store_header ($$) { - my ($href, $msg) = @_; - my ($line); +sub lcl_store_header($$) { + my($href, $msg) = @_; + my($line); foreach (@$msg) { my $l = $_; @@ -640,8 +625,8 @@ sub lcl_store_header ($$) { lcl_set_line($href, $line); } -sub lcl_set_line ($$) { - my ($href, $line) = @_; +sub lcl_set_line($$) { + my($href, $line) = @_; return unless ($line =~ /^([^:]*):\s*(.*)$/); my $label = lc($1); @@ -660,6 +645,39 @@ sub lcl_set_line ($$) { 1; +__END__ + +=head1 NAME + +IM::LocalMbox - local mailbox managing + +=head1 SYNOPSIS + + use IM::LocalMbox; + + $num_msgs = &local_get_msg(source_mailbox, destination_folder, access_mode); + +=head1 DESCRIPTION + +The I<IM::LocalMbox> module handles local mailbox. +MH folder, MMDF file, mbox, and Maildir are supported. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + $mbox = 'local:/var/mail/motonori'; + $folder = '+inbox' + $num_msgs = &local_get_msg($mbox, $folder, 'get'); + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Log.pm b/img/lib/IM/Log.pm index 0bb84e07..256fe9da 100644 --- a/img/lib/IM/Log.pm +++ b/img/lib/IM/Log.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Log.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Log.pm version 20021207(IM142)"; package IM::Log; require 5.003; @@ -23,16 +23,6 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(log_action); -=head1 NAME - -Log - IM log_action - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw($initialized); ##### WRITE DISPATCHING ACTION HISTORY ##### # @@ -43,9 +33,9 @@ use vars qw($initialized); # to: list of recipients # return value: none # -sub log_action ($$$$;@) { - my ($proto, $server, $to, $stat, @resp) = @_; -# my ($proto, $server, $id, $to, $stat, @resp) = @_; +sub log_action($$$$;@) { + my($proto, $server, $to, $stat, @resp) = @_; +# my($proto, $server, $id, $to, $stat, @resp) = @_; return if ($main::Log_file eq '' && !$main::opt_syslog); @@ -73,7 +63,7 @@ sub log_action ($$$$;@) { } } - my ($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year) + my($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year) = localtime(time); my $msg = ''; $msg = sprintf "%d/%02d/%02d %02d:%02d:%02d ", @@ -119,6 +109,33 @@ sub log_action ($$$$;@) { 1; +__END__ + +=head1 NAME + +IM::Log - IM log handler + +=head1 SYNOPSIS + + use IM::Log; + + $main::Log_file = "putlog"; + log_action($proto, $server, $to, $stat, @resp); + +=head1 DESCRIPTION + +The I<IM::Log> module handles log file of IM. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/MD5.pm b/img/lib/IM/MD5.pm index ba9fe4f7..3c995b28 100644 --- a/img/lib/IM/MD5.pm +++ b/img/lib/IM/MD5.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::MD5.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::MD5.pm version 20021207(IM142)"; package IM::MD5; require 5.003; @@ -21,30 +21,6 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(md5_str); -=head1 NAME - -MD5 - The MD5 Message-Digesting package - -=head1 SYNOPSIS - - use IM::MD5; - - $digest = &md5_str($text); - -=head1 DESCRIPTION - - &md5_str("") returns d41d8cd98f00b204e9800998ecf8427e. - &md5_str("a") returns 0cc175b9c0f1b6a831c399e269772661. - &md5_str("abc") returns 900150983cd24fb0d6963f7d28e17f72. - &md5_str("message digest") returns f96b697d7cb7938d525a2f31aaf161d0. - &md5_str("abcdefghijklmnopqrstuvwxyz") returns c3fcd3d76192e4007dfb496cca67e13b. - &md5_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") returns d174ab98d277d9f5a5611c2c9f419d9f. - &md5_str("12345678901234567890123456789012345678901234567890123456789012345678901234567890") returns 57edf4a22be3c955ac49da2e2107b67a. - - % perl -MIM::MD5 -e 'IM::MD5::MD5_TEST()' - -=cut - use vars qw($MD5_S11 $MD5_S12 $MD5_S13 $MD5_S14 $MD5_S21 $MD5_S22 $MD5_S23 $MD5_S24 $MD5_S31 $MD5_S32 $MD5_S33 $MD5_S34 @@ -54,11 +30,11 @@ use vars qw($MD5_S11 $MD5_S12 $MD5_S13 $MD5_S14 # MD5 routines # ################ -sub md5_str ($) { +sub md5_str($) { my($str) = @_; my($len); - my (@context_count, @context_state, @context_buffer); - my (@digest); + my(@context_count, @context_state, @context_buffer); + my(@digest); $len = length($str); my @string = unpack('C*', $str); @@ -69,41 +45,10 @@ sub md5_str ($) { &MD5Final(\@digest, \@context_count, \@context_state, \@context_buffer); return unpack('H*', pack('C*', @digest)); - } +} ############################################################################### -### -### md5.pl -- MD5 message-digest algorithm converted to Perl4 from C version -### -### Copyright (C) 1996 by NAKAMURA, Motonori <motonori@econ.kyoto-u.ac.jp>. -### All rights reserved. -### [August 16, 1996] - -# MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - -# Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -# rights reserved. - -# License to copy and use this software is granted provided that it -# is identified as the "RSA Data Security, Inc. MD5 Message-Digest -# Algorithm" in all material mentioning or referencing this software -# or this function. - -# License is also granted to make and use derivative works provided -# that such works are identified as "derived from the RSA Data -# Security, Inc. MD5 Message-Digest Algorithm" in all material -# mentioning or referencing the derived work. - -# RSA Data Security, Inc. makes no representations concerning either -# the merchantability of this software or the suitability of this -# software for any particular purpose. It is provided "as is" -# without express or implied warranty of any kind. - -# These notices must be retained in any copies of any part of this -# documentation and/or software. - - # F, G, H and I are basic MD5 functions. sub MD5_F {my($x, $y, $z) = @_; ((($x) & ($y)) | (&MD5_trunc(~$x) & ($z))); } @@ -130,19 +75,19 @@ sub MD5_FF { $a = &MD5_trunc($a + &MD5_F($b, $c, $d) + $x + $ac); $a = &MD5_ROTATE_LEFT($a, $s); $a = &MD5_trunc($a + $b); - } +} sub MD5_GG { my($a, $b, $c, $d, $x, $s, $ac) = @_; $a = &MD5_trunc($a + &MD5_G($b, $c, $d) + $x + $ac); $a = &MD5_ROTATE_LEFT($a, $s); $a = &MD5_trunc($a + $b); - } +} sub MD5_HH { my($a, $b, $c, $d, $x, $s, $ac) = @_; $a = &MD5_trunc($a + &MD5_H($b, $c, $d) + $x + $ac); $a = &MD5_ROTATE_LEFT($a, $s); $a = &MD5_trunc($a + $b); - } +} sub MD5_II { my($a, $b, $c, $d, $x, $s, $ac) = @_; $a = &MD5_trunc($a + &MD5_I($b, $c, $d) + $x + $ac); @@ -168,8 +113,8 @@ sub MD5_trunc { # MD5 initialization. Begins an MD5 operation, writing a new context. -sub MD5Init ($$$) { - my ($context_count, $context_state, $context_buffer) = @_; +sub MD5Init($$$) { + my($context_count, $context_state, $context_buffer) = @_; # Constants for MD5Transform routine. $MD5_S11 = 7; @@ -208,10 +153,10 @@ sub MD5Init ($$$) { # operation, processing another message block, and updating the # context. -sub MD5Update ($$$$$) { - my ($context_count, $context_state, $context_buffer, +sub MD5Update($$$$$) { + my($context_count, $context_state, $context_buffer, $input, $inputLen) = @_; - my (@arg1, @arg2); + my(@arg1, @arg2); my($i, $index, $partLen); # Compute number of bytes mod 64 @@ -255,9 +200,9 @@ sub MD5Update ($$$$$) { # MD5 finalization. Ends an MD5 message-digest operation, writing the # the message digest and zeroizing the context. -sub MD5Final ($$$$) { - my ($digest, $context_count, $context_state, $context_buffer) = @_; - my (@bits); +sub MD5Final($$$$) { + my($digest, $context_count, $context_state, $context_buffer) = @_; + my(@bits); my($index, $padLen); @bits = ((0) x 8); @@ -284,13 +229,13 @@ sub MD5Final ($$$$) { # MD5 basic transformation. Transforms state based on block. -sub MD5Transform ($$) { - my ($state, $block) = @_; +sub MD5Transform($$) { + my($state, $block) = @_; my($a) = $state->[0]; my($b) = $state->[1]; my($c) = $state->[2]; my($d) = $state->[3]; - my (@x); + my(@x); &MD5_Decode(\@x, $block, 64); @@ -378,8 +323,8 @@ sub MD5Transform ($$) { # Encodes input (UINT4) into output (unsigned char). Assumes len is # a multiple of 4. -sub MD5_Encode ($$$) { - my ($output, $input, $len) = @_; +sub MD5_Encode($$$) { + my($output, $input, $len) = @_; my($i, $j); for ($i = 0, $j = 0; $j < $len; $i++, $j += 4) { @@ -393,8 +338,8 @@ sub MD5_Encode ($$$) { # Decodes input (unsigned char) into output (UINT4). Assumes len is # a multiple of 4. -sub MD5_Decode ($$$) { - my ($output, $input, my $len) = @_; +sub MD5_Decode($$$) { + my($output, $input, my $len) = @_; my($i, $j); for ($i = 0, $j = 0; $j < $len; $i++, $j += 4) { @@ -405,8 +350,8 @@ sub MD5_Decode ($$$) { # Note: Replace "for loop" with standard memcpy if possible. -sub MD5_memcpy ($$$) { - my ($output, $input, $len) = @_; +sub MD5_memcpy($$$) { + my($output, $input, $len) = @_; my($i); for ($i = 0; $i < $len; $i++) { @@ -416,8 +361,8 @@ sub MD5_memcpy ($$$) { # Note: Replace "for loop" with standard memset if possible. -sub MD5_memset ($$$) { - my ($output, $value, $len) = @_; +sub MD5_memset($$$) { + my($output, $value, $len) = @_; my($i); for ($i = 0; $i < $len; $i++) { @@ -430,8 +375,8 @@ use SelfLoader; __DATA__ sub MD5_CHECK { - my ($str, $should) = @_; - my ($r) = &md5_str($str); + my($str, $should) = @_; + my($r) = &md5_str($str); printf "MD5 (\"%s\") = %s", $str, $r; if ($r eq $should) { @@ -442,7 +387,7 @@ sub MD5_CHECK { } sub MD5_TEST { - my (%v); + my(%v); $v{""} = "d41d8cd98f00b204e9800998ecf8427e"; $v{"a"} = "0cc175b9c0f1b6a831c399e269772661"; $v{"abc"} = "900150983cd24fb0d6963f7d28e17f72"; @@ -457,6 +402,78 @@ sub MD5_TEST { } } +1; + +__END__ + +=head1 NAME + +IM::MD5 - MD5 message-digesting + +=head1 SYNOPSIS + + use IM::MD5; + + $digest = &md5_str($text); + +=head1 DESCRIPTION + +The I<IM::MD5> module handles MD5 message-digest algorithm. + +This modules is provided by IM (Internet Message). + +=head1 EXAMPLES + + &md5_str("") returns d41d8cd98f00b204e9800998ecf8427e. + &md5_str("a") returns 0cc175b9c0f1b6a831c399e269772661. + &md5_str("abc") returns 900150983cd24fb0d6963f7d28e17f72. + &md5_str("message digest") returns f96b697d7cb7938d525a2f31aaf161d0. + &md5_str("abcdefghijklmnopqrstuvwxyz") returns c3fcd3d76192e4007dfb496cca67e13b. + &md5_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") returns d174ab98d277d9f5a5611c2c9f419d9f. + &md5_str("12345678901234567890123456789012345678901234567890123456789012345678901234567890") returns 57edf4a22be3c955ac49da2e2107b67a. + + % perl -MIM::MD5 -e 'IM::MD5::MD5_TEST()' + +=head1 COPYRIGHT + +This modules is derived from md5.pl copyrighted by NAKAMURA, Motonori +<motonori@econ.kyoto-u.ac.jp>. It is converted to Perl4 from C version +derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm. + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + +### md5.pl -- MD5 message-digest algorithm converted to Perl4 from C version +### +### Copyright (C) 1996 by NAKAMURA, Motonori <motonori@econ.kyoto-u.ac.jp>. +### All rights reserved. +### [August 16, 1996] +### +### MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm +### +### Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +### rights reserved. +### +### License to copy and use this software is granted provided that it +### is identified as the "RSA Data Security, Inc. MD5 Message-Digest +### Algorithm" in all material mentioning or referencing this software +### or this function. +### +### License is also granted to make and use derivative works provided +### that such works are identified as "derived from the RSA Data +### Security, Inc. MD5 Message-Digest Algorithm" in all material +### mentioning or referencing the derived work. +### +### RSA Data Security, Inc. makes no representations concerning either +### the merchantability of this software or the suitability of this +### software for any particular purpose. It is provided "as is" +### without express or implied warranty of any kind. +### +### These notices must be retained in any copies of any part of this +### documentation and/or software. ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. diff --git a/img/lib/IM/Message.pm b/img/lib/IM/Message.pm index c96afaa4..04d8e4e4 100644 --- a/img/lib/IM/Message.pm +++ b/img/lib/IM/Message.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Message.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Message.pm version 20021207(IM142)"; package IM::Message; require 5.003; @@ -48,16 +48,6 @@ use vars qw(@ISA @EXPORT); sort_header ); -=head1 NAME - -Message - IM Message - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw($First_body_line $First_part_mid $bcc_mid $crlf_char @Week_str @Month_str $Cur_time @@ -65,7 +55,7 @@ use vars qw($First_body_line $First_part_mid @Week_str = qw(Sun Mon Tue Wed Thu Fri Sat); @Month_str = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); -sub cur_time ($) { +sub cur_time($) { my $part = shift; return $Cur_time if ($Cur_time && $part == 0); return $Cur_time = time; @@ -80,10 +70,10 @@ sub cur_time ($) { # 0: success # -1: failure # -sub read_header (*$$) { +sub read_header(*$$) { local *CHAN = shift; - my ($Header, $dist_append) = @_; - my ($inheader, $line) = (1, ''); + my($Header, $dist_append) = @_; + my($inheader, $line) = (1, ''); $First_body_line = ''; local $_ = <CHAN>; @@ -134,9 +124,9 @@ sub read_header (*$$) { # -1: failed # 0: success # -sub rewrite_header ($) { +sub rewrite_header($) { my $Header = shift; - my ($i, $val); + my($i, $val); local $_; my $e = $#$Header; # do not evaluate in the loop @@ -173,9 +163,9 @@ sub rewrite_header ($) { # append_default: append default domain name for local names if true # return value: rewritten addresses (NULL if error) # -sub rewrite_addr_list ($$$;$) { - my ($Header, $sender_flag, $addr_list, $def_append) = @_; - my ($line, $ret, $addr, $a, $b, $err); +sub rewrite_addr_list($$$;$) { + my($Header, $sender_flag, $addr_list, $def_append) = @_; + my($line, $ret, $addr, $a, $b, $err); $addr_list =~ s/^\s+//; $addr_list =~ s/\s+$//; @@ -224,7 +214,7 @@ sub rewrite_addr_list ($$$;$) { $b = "$a\@$main::Default_to_domain_name"; $addr = &replace_addr($addr, $a, $b); } - } elsif ($b = hosts_completion($a,$main::Cmpl_with_gethostbyname)){ + } elsif ($b = hosts_completion($a,$main::Cmpl_with_gethostbyname)) { $addr = &replace_addr($addr, $a, $b); } } @@ -241,7 +231,7 @@ sub rewrite_addr_list ($$$;$) { # rewrite_resend_header() # return value: none # -sub rewrite_resend_header ($) { +sub rewrite_resend_header($) { my $Header = shift; my $i; @@ -262,10 +252,10 @@ sub rewrite_resend_header ($) { # 0: success # -1: failure # -sub put_header (*$$$) { +sub put_header(*$$$) { local *CHAN = shift; - my ($Header, $proto, $sel) = @_; - my ($line, $del, $s); + my($Header, $proto, $sel) = @_; + my($line, $del, $s); my $crlf = &crlf; im_debug("entering put_header ($sel)\n") @@ -332,9 +322,9 @@ sub put_header (*$$$) { # term_dot: terminating dot protocol is used if true # return value: none # -sub read_body (*$$$) { +sub read_body(*$$$) { local *CHAN = shift; - my ($Body, $hidden_dot, $term_dot) = @_; + my($Body, $hidden_dot, $term_dot) = @_; local $_; @$Body = (); @@ -364,9 +354,9 @@ sub read_body (*$$$) { # content: pointer to body content line list # return value: none # -sub body_qp_encode ($) { +sub body_qp_encode($) { my $Body = shift; - my ($i, $line, $pos); + my($i, $line, $pos); for ($i = 0; $i <= $#$Body; $i++) { $line = $$Body[$i]; @@ -396,10 +386,10 @@ sub body_qp_encode ($) { # content: pointer to body content line list # return value: none # -sub body_base64_encode ($) { +sub body_base64_encode($) { my $Body = shift; my $line = ''; - my ($i, $tmp, @Body_tmp); + my($i, $tmp, @Body_tmp); require IM::EncDec && import IM::EncDec qw(b_encode_string); @@ -429,10 +419,10 @@ sub body_base64_encode ($) { # 0: success # -1: failure # -sub put_body (*$$$) { +sub put_body(*$$$) { local *CHAN = shift; - my ($Body, $hidden_dot, $part) = @_; - my ($start, $end, $i, $line); + my($Body, $hidden_dot, $part) = @_; + my($start, $end, $i, $line); my $crlf= &crlf; if ($part == 0) { @@ -471,9 +461,9 @@ sub put_body (*$$$) { # 0: success # -1: failure # -sub put_mimed_bcc (*$$$$$$) { +sub put_mimed_bcc(*$$$$$$) { local *CHAN = shift; - my ($Header, $Body, $proto, $hidden_dot, $part, $total) = @_; + my($Header, $Body, $proto, $hidden_dot, $part, $total) = @_; my $subj; my $crlf = &crlf; @@ -538,9 +528,9 @@ sub put_mimed_bcc (*$$$$$$) { # 0: success # -1: failure # -sub put_mimed_partial (*$$$$$$) { +sub put_mimed_partial(*$$$$$$) { local *CHAN = shift; - my ($Header, $Body, $proto, $hidden_dot, $part, $total) = @_; + my($Header, $Body, $proto, $hidden_dot, $part, $total) = @_; my $crlf = &crlf; return -1 if (&put_header(\*CHAN, $Header, $proto, 'partial:ext') < 0); @@ -583,10 +573,10 @@ sub put_mimed_partial (*$$$$$$) { # 0: success # -1: failure # -sub put_mimed_error_notify (*$$$$$$$$;$) { +sub put_mimed_error_notify(*$$$$$$$$;$) { local *CHAN = shift; - my ($Header, $Body, $Recp, $Stat, $proto, $server, - $hidden_dot, $session_log, $part) = @_; # XXX: $part missing? + my($Header, $Body, $Recp, $Stat, $proto, $server, + $hidden_dot, $session_log, $part) = @_; # XXX: $part missing? my $subj; my $crlf = &crlf; my $boundary; @@ -639,7 +629,7 @@ sub put_mimed_error_notify (*$$$$$$$$;$) { # host information my $myhostname = hostname(); unless ($myhostname =~ /\./) { - my ($h) = gethostbyname($myhostname); + my($h) = gethostbyname($myhostname); $myhostname = $h if ($h); } @@ -684,9 +674,9 @@ sub put_mimed_error_notify (*$$$$$$$$;$) { # body: reference to a message body array # return value: size of whole message # -sub message_size ($$$) { - my ($Header, $Body, $part) = @_; - my ($start, $end, $i, $size); +sub message_size($$$) { + my($Header, $Body, $part) = @_; + my($start, $end, $i, $size); if ($part == 0) { $start = 0; @@ -706,11 +696,11 @@ sub message_size ($$$) { return $size; } -sub set_crlf ($) { +sub set_crlf($) { $crlf_char = shift; } -sub crlf () { +sub crlf() { $crlf_char; } @@ -720,14 +710,14 @@ sub crlf () { # part: part number of partial messages (for reuse) # return value: a unique message-id string # -sub gen_message_id ($) { +sub gen_message_id($) { my $part = shift; return $Mid_hist{$part} if ($part > 0 && $Mid_hist{$part}); - my ($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year) + my($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year) = localtime(&cur_time($part)); - my ($mid_time) = sprintf("%d%02d%02d%02d%02d%02d", + my($mid_time) = sprintf("%d%02d%02d%02d%02d%02d", $tm_year+1900, $tm_mon+1, $tm_mday, $tm_hour, $tm_min, $tm_sec); - my ($mid_rnd) = sprintf("%c", 0x41 + rand(26)); + my($mid_rnd) = sprintf("%c", 0x41 + rand(26)); if ($Prev_mid_time eq $mid_time) { while ($mid_rnd =~ /[$Mid_rnd_hist]/) { $mid_rnd = sprintf("%c", 0x41 + rand(26)); @@ -746,7 +736,7 @@ sub gen_message_id ($) { } else { $mid_user = $main::Login; } - my ($mid) + my($mid) = "<$mid_time$mid_rnd.$mid_user\@$main::Message_id_domain_name>"; $Mid_hist{$part} = $mid if ($part > 0); return $mid; @@ -761,10 +751,10 @@ sub gen_message_id ($) { # 2 = "WWW MMM DD HH:MM:SS YYYY" (mainly for UNIX From) # return value: date string generated with current time # -sub gen_date ($) { +sub gen_date($) { my $format = shift; - my ($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year, - $tm_wk, $tm_yday, $tm_isdst, $tm_tz); + my($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year, + $tm_wk, $tm_yday, $tm_isdst, $tm_tz); if ($main::NewsGMTdate && $main::News_flag) { ($tm_sec, $tm_min, $tm_hour, $tm_mday, $tm_mon, $tm_year, $tm_wk, $tm_yday) = gmtime(&cur_time(0)); @@ -787,8 +777,8 @@ sub gen_date ($) { } } } else { - my ($gm_sec, $gm_min, $gm_hour, $gm_mday, $gm_mon, - $gm_year, $gm_wk, $gm_yday) = gmtime(&cur_time(0)); + my($gm_sec, $gm_min, $gm_hour, $gm_mday, $gm_mon, + $gm_year, $gm_wk, $gm_yday) = gmtime(&cur_time(0)); $off = ($tm_hour - $gm_hour) * 60 + $tm_min - $gm_min; if ($tm_year < $gm_year) { $off -= 24 * 60; @@ -832,8 +822,8 @@ sub gen_date ($) { # field: field name of which value needed # return value: value for specified field OR null # -sub header_value ($$) { - my ($Header, $field_name) = @_; +sub header_value($$) { + my($Header, $field_name) = @_; my $val; local $_; @@ -855,8 +845,8 @@ sub header_value ($$) { # field_value: field value to be entered with # return value: none # -sub add_header ($$$$) { - my ($Header, $replace_flag, $field_name, $field_value) = @_; +sub add_header($$$$) { + my($Header, $replace_flag, $field_name, $field_value) = @_; $field_value .= "\n" if ($field_value !~ /\n$/); im_debug("adding header> $field_name: $field_value") @@ -881,8 +871,8 @@ sub add_header ($$$$) { # leave_first: leave the first appeared header line if true # return value: none # -sub kill_header ($$$) { - my ($Header, $field_name, $leave_first) = @_; +sub kill_header($$$) { + my($Header, $field_name, $leave_first) = @_; my $i; for ($i = 0; $i <= $#$Header; $i++) { @@ -903,7 +893,7 @@ sub kill_header ($$$) { # header: reference to a message header array # return value: none # -sub kill_empty_header ($) { +sub kill_empty_header($) { my $Header = shift; my $i; @@ -922,12 +912,12 @@ sub kill_empty_header ($) { # name_list: leave the first appeared header line if true # return value: none # -sub sort_header ($$) { - my ($Header, $name_list) = @_; - my ($i, $label, @tail); +sub sort_header($$) { + my($Header, $name_list) = @_; + my($i, $label, @tail); foreach $label (split(',', $name_list)) { - for ($i = 0; $i <= $#$Header; ) { + for ($i = 0; $i <= $#$Header;) { if ($$Header[$i] =~ /^$label:/i) { push (@tail, $$Header[$i]); splice(@$Header, $i, 1); @@ -946,8 +936,8 @@ sub sort_header ($$) { # str2: a header string to be appended to str1 # return value: a concatinated header string # -sub hdr_cat ($$) { - my ($str1, $str2) = @_; +sub hdr_cat($$) { + my($str1, $str2) = @_; if ($str1 eq '' || $str1 =~ /\n[\t ]+$/) { return "$str1$str2"; @@ -964,6 +954,53 @@ sub hdr_cat ($$) { 1; +__END__ + +=head1 NAME + +IM::Message - mail/news message handler + +=head1 SYNOPSIS + + use IM::Message; + +Subroutines: +read_header +message_size +put_header +read_body +put_body +rewrite_header +rewrite_resend_header +body_qp_encode +body_base64_encode +put_mimed_bcc +put_mimed_partial +put_mimed_error_notify +set_crlf +crlf +gen_message_id +gen_date +header_value +add_header +kill_header +kill_empty_header +sort_header + +=head1 DESCRIPTION + +The I<IM::Message> module handles mail/news messages. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/MsgStore.pm b/img/lib/IM/MsgStore.pm index 61a1c90e..9e100293 100644 --- a/img/lib/IM/MsgStore.pm +++ b/img/lib/IM/MsgStore.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::MsgStore.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::MsgStore.pm version 20021207(IM142)"; package IM::MsgStore; require 5.003; @@ -27,16 +27,6 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(store_message exec_getsbrfile open_fcc excl_create fsync); -=head1 NAME - -MsgStore - store message in MH-style folder - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw($MsgNum $PrevFolder $First $Last $PrevDst $sys_fsync); BEGIN { $MsgNum = 0; @@ -54,7 +44,7 @@ BEGIN { # success: file name to be saved # fail: NULL # -sub new_message (\*$) { +sub new_message(\*$) { (local *MESSAGE, my $folder) = @_; if ($folder ne $PrevFolder) { $MsgNum = 0; @@ -68,7 +58,11 @@ sub new_message (\*$) { } $First = $Last = $MsgNum; } else { - $MsgNum++; + $MsgNum = message_number($folder, 'new', ($MsgNum)); + if ($MsgNum == 0) { + im_warn("can't get new message number in $folder\n"); + return ('', ''); + } } my $try = 3; while ($try--) { @@ -83,15 +77,19 @@ sub new_message (\*$) { $Last = $MsgNum; return ("$folder/$MsgNum", $file); } - $MsgNum++; + $MsgNum = message_number($folder, 'new', ($MsgNum)); + if ($MsgNum == 0) { + im_warn("can't get new message number in $folder\n"); + return ('', ''); + } } im_warn("excl_create failed.\n"); # message creation failed return ('', ''); } -sub store_message ($$;$) { - my ($Msg, $dst, $noscan) = @_; +sub store_message($$;$) { + my($Msg, $dst, $noscan) = @_; local *ART; require IM::Scan && import IM::Scan qw(store_header parse_header parse_body disp_msg); @@ -104,7 +102,7 @@ sub store_message ($$;$) { touch_folder($dst); $PrevDst = $dst; } - my ($msgfile, $filepath) = &new_message(\*ART, $dst); + my($msgfile, $filepath) = &new_message(\*ART, $dst); my $size = 0; if ($filepath ne '') { my $line; @@ -190,7 +188,7 @@ sub store_message ($$;$) { } } -sub exec_getsbrfile ($) { +sub exec_getsbrfile($) { my $dst = shift; my $get_hook = getsbr_file(); if ($get_hook) { @@ -229,9 +227,9 @@ sub exec_getsbrfile ($) { # path: file name to be saved # rm_file_on_error: a path to be deleted on error # -sub open_fcc ($$) { - my ($folder, $dir_style) = @_; - my ($fcc_dir, $rm_file_on_error, $fcc_folder, $FILE, $msgfile); +sub open_fcc($$) { + my($folder, $dir_style) = @_; + my($fcc_dir, $rm_file_on_error, $fcc_folder, $FILE, $msgfile); $fcc_folder = &expand_path($folder); if (-d $fcc_folder) { @@ -286,14 +284,14 @@ sub open_fcc ($$) { # 0: success # -1: fail # -sub excl_create (*$) { +sub excl_create(*$) { (local *MESSAGE, my $file) = @_; msg_mode(1); return -1 unless (im_sysopen(\*MESSAGE, $file, file_attr())); return 0; } -sub fsync ($) { +sub fsync($) { my $fno = shift; if (fsync_no()) { @@ -340,6 +338,33 @@ sub fsync ($) { 1; +__END__ + +=head1 NAME + +IM::MsgStore - store message in MH-style folder + +=head1 SYNOPSIS + + use IM::MsgStore; + +Subroutines: +store_message exec_getsbrfile open_fcc excl_create fsync + +=head1 DESCRIPTION + +The I<IM::MsgStore> module stores mail/news messages in MH-style folder. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Nntp.pm b/img/lib/IM/Nntp.pm index 49b50cd8..9751d9c5 100644 --- a/img/lib/IM/Nntp.pm +++ b/img/lib/IM/Nntp.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Nntp.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Nntp.pm version 20021207(IM142)"; package IM::Nntp; require 5.003; @@ -39,20 +39,6 @@ use vars qw(@ISA @EXPORT); nntp_spec ); -=head1 NAME - -NNTP - NNTP interface package - -=head1 SYNOPSIS - -$return_code = &nntp_transaction(server_list, newsgroups, - part_current, part_total, authuser); -$return_code = &nntp_close; - -=head1 DESCRIPTION - -=cut - use vars qw($Nntp_opened *NNTPd $NntpErrTitle); ##### NNTP SESSION OPENING ##### @@ -64,8 +50,8 @@ use vars qw($Nntp_opened *NNTPd $NntpErrTitle); # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub nntp_open ($$) { - my ($servers, $logging) = @_; +sub nntp_open($$) { + my($servers, $logging) = @_; my $rc; if ($Nntp_opened) { @@ -79,7 +65,7 @@ sub nntp_open ($$) { if ($rc = &tcp_command(\*NNTPd, '', '')) { return $rc; } - my (@resp) = &command_response; + my(@resp) = &command_response; if ($resp[0] =~ /InterNetNews server INN/) { return 1 if (&tcp_command(\*NNTPd, 'MODE reader', '')); } @@ -95,7 +81,7 @@ sub nntp_open ($$) { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub nntp_close () { +sub nntp_close() { return 0 unless ($Nntp_opened); $Nntp_opened = 0; im_notice("closing NNTP session.\n"); @@ -117,8 +103,8 @@ sub nntp_close () { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub nntp_transaction ($$$$$$$) { - my ($servers, $Header, $Body, $group, $part, $total, $authuser) = @_; +sub nntp_transaction($$$$$$$) { + my($servers, $Header, $Body, $group, $part, $total, $authuser) = @_; my $rc; require IM::Log && import IM::Log; @@ -126,7 +112,7 @@ sub nntp_transaction ($$$$$$$) { &set_nntpauthuser($authuser); do { $rc = &nntp_transact_sub($servers, $Header, $Body, $part, $total); - my (@resp) = &command_response; + my(@resp) = &command_response; if ($rc) { &im_warn($NntpErrTitle . join("\n", @resp) . "\n"); $NntpErrTitle = ''; @@ -153,8 +139,8 @@ sub nntp_transaction ($$$$$$$) { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub nntp_transact_sub ($$$$$) { - my ($servers, $Header, $Body, $part, $total) = @_; +sub nntp_transact_sub($$$$$) { + my($servers, $Header, $Body, $part, $total) = @_; my $rc; return $rc if ($rc = &nntp_open($servers, 1)); @@ -177,9 +163,9 @@ sub nntp_transact_sub ($$$$$) { return 0; } -sub nntp_head_as_string ($) { +sub nntp_head_as_string($) { my $i = shift; - my ($rc, $count) = ('', 0); + my($rc, $count) = ('', 0); local $_; im_notice("getting article $i.\n"); @@ -190,7 +176,7 @@ sub nntp_head_as_string ($) { return -1; } $count++; - my ($found, $f) = (0, ''); + my($found, $f) = (0, ''); alarm(nntp_timeout()) unless win95p(); $! = 0; while (<NNTPd>) { @@ -211,8 +197,8 @@ sub nntp_head_as_string ($) { return $f; } -sub nntp_head ($$) { - my ($art_start, $art_end) = @_; +sub nntp_head($$) { + my($art_start, $art_end) = @_; local $_; my $count = 0; @@ -226,7 +212,7 @@ sub nntp_head ($$) { return -1; } $count++; - my ($found, $f) = (0, ''); + my($found, $f) = (0, ''); alarm(nntp_timeout()) unless win95p(); $! = 0; while (<NNTPd>) { @@ -257,8 +243,8 @@ sub nntp_head ($$) { return $count; } -sub nntp_xover ($$) { - my ($art_start, $art_end) = @_; +sub nntp_xover($$) { + my($art_start, $art_end) = @_; my $rc = &tcp_command(\*NNTPd, "XOVER $art_start-$art_end", ''); if ($rc) { @@ -266,7 +252,7 @@ sub nntp_xover ($$) { return -1; } my $count = 0; - my ($resp); + my($resp); while (($resp = &next_response(\*NNTPd)) !~ /^\.$/) { $count++; my @overview = split('\t', $resp); @@ -285,17 +271,17 @@ sub nntp_xover ($$) { return $count; } -sub nntp_article ($) { +sub nntp_article($) { my $num = shift; local $_; -# local (@Article); +# local(@Article); im_debug("getting article $num.\n") if (&debug('nntp')); my $rc = &tcp_command(\*NNTPd, "ARTICLE $num", ''); - return (1, '') if ($rc > 0); + return(1, '') if ($rc > 0); if ($rc < 0) { im_warn("ARTICLE command failed.\n"); - return (-1, ''); + return(-1, ''); } my @Article = (); alarm(nntp_timeout()) unless win95p(); @@ -305,7 +291,7 @@ sub nntp_article ($) { alarm(0); if ($!) { # may be channel truoble im_warn("lost connection for ARTICLE.\n"); - return (-1, ''); + return(-1, ''); } } s/\r\n$/\n/; @@ -315,12 +301,12 @@ sub nntp_article ($) { im_debug($_) if (&debug('nntp')); } alarm(0) unless win95p(); - return (0, \@Article); + return(0, \@Article); } -sub nntp_articles ($$$$) { - my ($art_start, $art_end, $dst, $limit) = @_; - my ($rc, $article); +sub nntp_articles($$$$) { + my($art_start, $art_end, $dst, $limit) = @_; + my($rc, $article); my $count = 0; my $last = 0; @@ -343,10 +329,10 @@ sub nntp_articles ($$$$) { last if ($limit && --$limit == 0); } &exec_getsbrfile($dst); - return ($count, $last); + return($count, $last); } -sub nntp_list ($) { +sub nntp_list($) { my $group = shift; local $_; my $rc; @@ -366,13 +352,13 @@ sub nntp_list ($) { return $count; } -sub nntp_command ($) { +sub nntp_command($) { my $cmd = shift; my $rc = &tcp_command(\*NNTPd, $cmd, ''); return -1 if ($rc < 0); if ($rc > 0) { - my ($res) = &command_response(); + my($res) = &command_response(); if ($res =~ /^480/) { require IM::GetPass && import IM::GetPass; @@ -382,7 +368,7 @@ sub nntp_command ($) { my $user = &nntpauthuser() || $ENV{'USER'} || $ENV{'LOGNAME'} || im_getlogin(); my $host = get_cur_server(); - my ($pass, $agtfound, $interact) + my($pass, $agtfound, $interact) = getpass('nntp', 'PASS', $host, $user); # authenticate for posting @@ -398,29 +384,29 @@ sub nntp_command ($) { return $rc; } -sub nntp_command_response () { +sub nntp_command_response() { return &command_response; } -sub nntp_next_response () { +sub nntp_next_response() { return &next_response(\*NNTPd); } -sub set_last_article_number ($$$) { - my ($server, $group, $number) = @_; - my ($pos, $last, $size) = (0, 0, 0); +sub set_last_article_number($$$) { + my($server, $group, $number) = @_; + my($pos, $last, $size) = (0, 0, 0); $server =~ s!\%\d+$!!; $server =~ s!/\d+$!!; my $nntphist = &nntphistoryfile() . '-' . $server; - if ( -f $nntphist ) { + if (-f $nntphist) { im_open(\*NEWSHIST, "+<$nntphist"); while ($pos = tell(NEWSHIST), $_ = <NEWSHIST>) { /^([^:]+):\s*(\d+)/; if ($group eq $1) { $last = $2; im_debug("$last articles in $group ($nntphist)\n") - if(&debug('nntp')); + if (&debug('nntp')); seek(NEWSHIST, $pos, 0); $size = length($_) - length("$group: 0000000\n"); if ($size < 0) { @@ -445,8 +431,8 @@ sub set_last_article_number ($$$) { return $last; } -sub get_last_article_number ($$) { - my ($server, $group) = @_; +sub get_last_article_number($$) { + my($server, $group) = @_; local $_; my $number = 0; @@ -467,33 +453,33 @@ sub get_last_article_number ($$) { } -sub nntp_get_message ($$) { - my ($src, $msg) = @_; - my ($rc, $art); - my ($group, $srvs) = nntp_spec($src, nntpservers()); +sub nntp_get_message($$) { + my($src, $msg) = @_; + my($rc, $art); + my($group, $srvs) = nntp_spec($src, nntpservers()); my @servers = split(',', $srvs); im_notice("accessing to $group on $srvs.\n"); do { if (($rc = nntp_open(\@servers, 0)) < 0) { - return (-1, "can not connect $srvs.\n"); + return(-1, "can not connect $srvs.\n"); } if (($group ne '') && ($rc = nntp_command("GROUP $group")) < 0) { - return (-1, "can not access $group.\n"); + return(-1, "can not access $group.\n"); } } while (@servers > 0 && $rc > 0); - return (-1, "can not access $group on $srvs.\n") if ($rc); + return(-1, "can not access $group on $srvs.\n") if ($rc); ($rc, $art) = nntp_article($msg); nntp_close(); - return (-1, "no message $msg in -$group.\n") if ($rc); - return (0, $art); + return(-1, "no message $msg in -$group.\n") if ($rc); + return(0, $art); } # returns number of got articles # -1 if error -sub nntp_get_msg ($$$$) { - my ($src, $dst, $how, $limit) = @_; - my ($rc, $group, $error, $art_start, $art_end); - my ($servers, @servers); +sub nntp_get_msg($$$$) { + my($src, $dst, $how, $limit) = @_; + my($rc, $group, $error, $art_start, $art_end); + my($servers, @servers); if ($src =~ /^nntp:(.*)/i || $src =~ /^news:(.*)/i) { ($group, $servers) = &nntp_spec($1, nntpservers()); @@ -514,7 +500,7 @@ sub nntp_get_msg ($$$$) { } while (@servers > 0 && $rc > 0); return -1 if ($rc); - my (@resp) = &command_response; + my(@resp) = &command_response; $error = 0; my $i; for ($i = 0; $i <= $#resp; $i++) { @@ -535,7 +521,7 @@ sub nntp_get_msg ($$$$) { return -1; } - my ($art_last, $msgs); + my($art_last, $msgs); $art_last = &get_last_article_number($servers, $group); if ($art_end > $art_last) { # new articles @@ -587,7 +573,7 @@ sub nntp_get_msg ($$$$) { } if ($how eq 'get') { - my ($last); + my($last); if ($msgs > 0) { im_info("Getting new messages from $group at $servers " . "into $dst....\n"); @@ -609,8 +595,8 @@ sub nntp_get_msg ($$$$) { } # News group (-group[@server]) -sub nntp_spec ($$) { - my ($spec, $server) = @_; +sub nntp_spec($$) { + my($spec, $server) = @_; my $group; if ($spec =~ /^-(.*)/) { @@ -621,11 +607,51 @@ sub nntp_spec ($$) { } else { $group = $spec; } - return ($group, $server); + return($group, $server); } 1; +__END__ + +=head1 NAME + +IM::Nntp - NNTP hanlder + +=head1 SYNOPSIS + + use IM::Nntp; + + $return_code = &nntp_transaction(server_list, newsgroups, + part_current, part_total, authuser); + $return_code = &nntp_close; + +Other subroutines: +nntp_open +nntp_article +nntp_list +nntp_command +nntp_command_response +nntp_next_response +nntp_get_message +nntp_get_msg +nntp_head_as_string +nntp_spec + +=head1 DESCRIPTION + +The I<IM::Nntp> module handles NNTP. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Pop.pm b/img/lib/IM/Pop.pm index feb28f22..8486edaa 100644 --- a/img/lib/IM/Pop.pm +++ b/img/lib/IM/Pop.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Pop.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Pop.pm version 20021207(IM142)"; package IM::Pop; require 5.003; @@ -27,16 +27,6 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(pop_get_msg pop_spec); -=head1 NAME - -Pop - POP handling package - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw(*POPd $SERVER_IDENT %history %newhistory); ####################### # POP access routines # @@ -54,11 +44,11 @@ use vars qw(*POPd $SERVER_IDENT %history %newhistory); # -1: failure # -2: failure (connection) # -sub pop_open ($$$$) { - my ($auth, $host, $user, $pass) = @_; +sub pop_open($$$$) { + my($auth, $host, $user, $pass) = @_; my $prompt = lc("pop/$auth:$user\@$host"); - my ($resp, $pwd, $errmsg); - my (@host_list) = ($host); + my($resp, $pwd, $errmsg); + my(@host_list) = ($host); im_notice("opening POP session ($auth)\n"); if ($auth eq 'RPOP' && !$main::SUIDROOT) { im_warn("RPOP operation requires SUID root.\n"); @@ -126,7 +116,7 @@ sub pop_open ($$$$) { return 0; } -sub pop_close () { +sub pop_close() { im_notice("closing POP session.\n"); my $resp = &send_command(\*POPd, 'QUIT', ''); return -1 if ($resp !~ /^\+/); @@ -134,8 +124,8 @@ sub pop_close () { return 0; } -sub pop_stat () { - my (@field); +sub pop_stat() { + my(@field); im_notice("getting number of message.\n"); my $resp = &send_command(\*POPd, 'STAT', ''); if ($resp !~ /^\+/) { @@ -147,10 +137,10 @@ sub pop_stat () { return $field[1]; } -sub pop_retr ($$$) { - my ($num, $dst, $noscan) = @_; - local ($_); - my (@Message); +sub pop_retr($$$) { + my($num, $dst, $noscan) = @_; + local($_); + my(@Message); im_notice("getting message $num.\n"); my $resp = &send_command(\*POPd, "RETR $num", ''); if ($resp !~ /^\+/) { @@ -181,7 +171,7 @@ sub pop_retr ($$$) { return 0; } -sub pop_head ($) { +sub pop_head($) { my $num = shift; im_notice("getting header of message $num.\n"); my $resp = &send_command(\*POPd, "TOP $num 1", ''); @@ -189,9 +179,9 @@ sub pop_head ($) { im_warn("TOP command failed.\n"); return 0; } - my ($field, $inheader) = ('', 1); - local ($_); - my (%head); + my($field, $inheader) = ('', 1); + local($_); + my(%head); undef %head; alarm(pop_timeout()) unless win95p(); $! = 0; @@ -227,7 +217,7 @@ sub pop_head ($) { return \%head; } -sub pop_dele ($) { +sub pop_dele($) { my $num = shift; im_notice("deleting message $num.\n"); my $resp = &send_command(\*POPd, "DELE $num", ''); @@ -238,7 +228,7 @@ sub pop_dele ($) { return 0; } -sub pop_uidl ($) { +sub pop_uidl($) { my $uidlp = shift; local $_; im_notice("getting UIDL information.\n"); @@ -269,9 +259,9 @@ sub pop_uidl ($) { } # pop_process(socket, how) -sub pop_process ($$$$) { - my ($how, $host, $dst, $noscan) = @_; - my ($histfile, $head, $msgs, $i, $h, $new, $last); +sub pop_process($$$$) { + my($how, $host, $dst, $noscan) = @_; + my($histfile, $head, $msgs, $i, $h, $new, $last); return -1 if (($msgs = &pop_stat) < 0); my $keep_proto = 'UIDL'; # UIDL/LAST/STATUS/MSGID @@ -432,9 +422,9 @@ sub pop_process ($$$$) { return $new; } -sub pop_inc ($$$$$$$$) { - my ($msgs, $host, $dst, $last, $keep_proto, $histp, $uidlp, $noscan) = @_; - my ($accesstime, $i, $h, $head); +sub pop_inc($$$$$$$$) { + my($msgs, $host, $dst, $last, $keep_proto, $histp, $uidlp, $noscan) = @_; + my($accesstime, $i, $h, $head); my $got = 0; my $ttl = 0; @@ -530,14 +520,14 @@ sub pop_inc ($$$$$$$$) { return $got; } -sub pop_get_msg ($$$$) { - my ($src, $dst, $how, $noscan) = @_; +sub pop_get_msg($$$$) { + my($src, $dst, $how, $noscan) = @_; $src =~ s/^pop//i; - my ($auth, $user, $host) = &pop_spec($src); + my($auth, $user, $host) = &pop_spec($src); - my ($pass, $agtfound, $interact) = ('', 0, 0); + my($pass, $agtfound, $interact) = ('', 0, 0); ($pass, $agtfound, $interact) = getpass ('pop', $auth, $host, $user) unless $auth eq 'RPOP'; @@ -563,7 +553,7 @@ sub pop_get_msg ($$$$) { } # POP folder (--src=pop[//auth][:user][@server[/port]]) -sub pop_spec ($) { +sub pop_spec($) { my $spec = shift; if ($spec eq '' || $spec !~ /[:\@]|\/\//) { @@ -577,7 +567,7 @@ sub pop_spec ($) { } $spec .= $s if ($s ne ''); } - my ($auth, $host) = ('apop', 'localhost'); + my($auth, $host) = ('apop', 'localhost'); my $user = $ENV{'USER'} || $ENV{'LOGNAME'} || im_getlogin(); if ($spec =~ /^\/\/?(\w+)(.*)/) { @@ -613,6 +603,34 @@ sub pop_spec ($) { 1; +__END__ + +=head1 NAME + +IM::Pop - POP handler + +=head1 SYNOPSIS + + use IM::Pop; + + $msgs = pop_get_msg($src, $dst, $mode, $noscan); + + ($auth, $user, $host) = pop_spec($src) + +=head1 DESCRIPTION + +The I<IM::Pop> module handles Pop. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Recipient.pm b/img/lib/IM/Recipient.pm index 353df12b..7cec8467 100644 --- a/img/lib/IM/Recipient.pm +++ b/img/lib/IM/Recipient.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 27, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Recipient.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Recipient.pm version 20021207(IM142)"; package IM::Recipient; require 5.003; @@ -27,29 +27,19 @@ use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(add_to_rcpt parse_rcpt rcpt_pickup); -=head1 NAME - -Recipient - IM recipient handler - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=cut - use vars qw($Alias_match_count $Include_count %Include_Files); ##### ADD AN ADDRESS TO RECIPIENT LIST ##### # -# add_to_rctp(bcc_flag, addr) +# add_to_rcpt(bcc_flag, addr) # bcc_flag: register with "bcc" tag # addr: an address to be registered # return value: none # 0: success # -1: failure # -sub add_to_rcpt ($$) { - my ($bcc_flag, $addr) = @_; - my ($rec, $a); +sub add_to_rcpt($$) { + my($bcc_flag, $addr) = @_; + my($rec, $a); $addr = &extract_addr($addr); return -1 if ($addr eq ''); return 0 unless ($addr); @@ -89,7 +79,7 @@ sub add_to_rcpt ($$) { ##### PARSE RECIPIENT LIST ##### # -# sub parse_rcpt(bcc_flag, addr_list, need_code_conversion) +# parse_rcpt(bcc_flag, addr_list, need_code_conversion) # bcc_flag: # 1 = BCC distination # 0 = normal distination @@ -97,9 +87,9 @@ sub add_to_rcpt ($$) { # addr_list: address list string (concatinated with ",") # return value: number of addresses in the list (-1 if error) # -sub parse_rcpt ($$$) { - my ($bcc_flag, $addr_list, $conv) = @_; - my ($cnt, $addr); +sub parse_rcpt($$$) { + my($bcc_flag, $addr_list, $conv) = @_; + my($cnt, $addr); $addr_list =~ s/^\s+//; $addr_list =~ s/\n\s*//g; # XXX return 0 if ($addr_list eq ''); @@ -148,13 +138,13 @@ sub parse_rcpt ($$$) { # 0: success # -1: failure # -sub expn_group ($$) { - my ($bcc_flag, $group_expression) = @_; - my ($rest, @mboxes, $rec); +sub expn_group($$) { + my($bcc_flag, $group_expression) = @_; + my($rest, @mboxes, $rec); # return if ($group_expression !~ /:.*;$/); return if ($group_expression !~ /:[^;]*;/); im_debug("expanding $group_expression\n") if (&debug('rcpt')); -# my ($group_name); +# my($group_name); # $group_name = $group_expression; # $group_name =~ s/:.*/:;/; $rest = $group_expression; @@ -181,10 +171,10 @@ sub expn_group ($$) { # 0: success # -1: failure # -sub expn_rcpt_list ($$) { - my ($bcc_flag, $include_file) = @_; - my ($file) = &expand_path($include_file); - my ($INCLUDE) = &include_open($file); +sub expn_rcpt_list($$) { + my($bcc_flag, $include_file) = @_; + my($file) = &expand_path($include_file); + my($INCLUDE) = &include_open($file); if ($INCLUDE) { while (defined($_ = include_readline($INCLUDE))) { chomp; @@ -205,7 +195,7 @@ sub expn_rcpt_list ($$) { } elsif (/^\s*\//) { im_err("Mail to file not supported: $_\n"); return -1; - } elsif (/^\s*\|/ || /^\s*"\s*\|/) { + } elsif (/^\s*\|/ || /^\s*"\s*\|/) { #" im_err("Mail to program not supported: $_\n"); return -1; } @@ -228,8 +218,8 @@ sub expn_rcpt_list ($$) { # -1: failure # 0: success # -sub rcpt_pickup ($$$) { - my ($Header, $resend_flag, $news_only_flag) = @_; +sub rcpt_pickup($$$) { + my($Header, $resend_flag, $news_only_flag) = @_; my $line; my $resend_prefix; @@ -262,25 +252,71 @@ sub rcpt_pickup ($$$) { # return value: handle # no strict 'refs'; -sub include_open ($) { - my ($file) = shift; +sub include_open($) { + my($file) = shift; return undef if $Include_Files{$file}; im_open($file, $file) || return undef; $Include_Files{$file} = 1; return $file; } -sub include_readline ($) { +sub include_readline($) { my $fh = shift; return scalar(<$fh>); } -sub include_close ($) { - my ($fh) = shift; +sub include_close($) { + my($fh) = shift; close($fh); delete $Include_Files{$fh}; } 1; +__END__ + +=head1 NAME + +IM::Recipient - mail/news recipient handler + +=head1 SYNOPSIS + + use IM::Recipient; + + add_to_rcpt(bcc_flag, addr) + bcc_flag: register with "bcc" tag + addr: an address to be registered + return value: none + 0: success + -1: failure + + parse_rcpt(bcc_flag, addr_list, need_code_conversion) + bcc_flag: + 1 = BCC distination + 0 = normal distination + -1 = parse only + addr_list: address list string (concatinated with ",") + return value: number of addresses in the list (-1 if error) + + rcpt_pickup(header, resend_flag, news_only_flag) + resend_flag: pickup addresses for redistributing mode + news_only_flag: do not pickup destination addresses for news mode + return value: + -1: failure + 0: success + +=head1 DESCRIPTION + +The I<IM::Recipient> module handles recipient of mail/news message. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Scan.pm b/img/lib/IM/Scan.pm index 9c14d9c9..c31c0e69 100644 --- a/img/lib/IM/Scan.pm +++ b/img/lib/IM/Scan.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Scan.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Scan.pm version 20021207(IM142)"; package IM::Scan; require 5.003; @@ -28,97 +28,6 @@ use vars qw(@ISA @EXPORT); @EXPORT = qw(set_scan_form get_header store_header parse_body parse_header disp_msg read_petnames); -=head1 NAME - - Scan - Scan listing from mail - -=head1 SYNOPSIS - - use IM::Scan; - - &set_scan_form($scan_form, $width, $use_jis); - &read_petnames(); - %Head = &get_header($mail_file); - &disp_msg(\%Head); - -=head1 DESCRIPTION - -=head1 FILES - - $HOME/.im/Config the user profile - -=head1 PROFILE COMPONENTS - - Component Explanation Example - - MailDir: your mail directory Mail - Width: one line width 80 - JisSafe: safely substr for ISO-2022-JP on - Form: scan format %+5n %m%d %8f %-30S %b - PetnameFile: nickname file ~/.im/Petname - Address: your mail addresses kazu@mew.org, kazu@wide.ad.jp - AddrRegex: regexp of your addresses ^kazu@.*$ - if necessary - -=head1 SCAN FORMAT - - '%{width}{header-type}' format is available. You can define any - header-type as you want. Default valid header-types are - - %n message number - %d raw Date: field - %f MIME decoded From: field - %t MIME decoded To: filed - %g raw Newsgroups: field - %a friendly From: field - %A If this message is originated by yourself, friendly To: - or raw Newsgroups: is displayed in 'To:xxx' or 'Ng:xxx' - format, respectively. Otherwise, friendly From: field is - displayed. - %P Similar to %A, but diplay raw address of mail sender - instead of friendly From: field, just like mh-e. - %i indent to display thread - %s MIME decoded Subject: field - %S indented MIME decoded Subject (same as %i+%s) - %b a part of body extracted with heuristic - %m Multipart type - 'S'igned, 'E'ncrypt, 'M'ultipart, 'P'artial or none - %p mark '*' if the message is destined to you - %D mark 'D' if the message is duplicated - %M %p+%D - %F folder path -# %B file size - %K file block size (1024 bytes/block) - - %y year - %c month (digit) - %C month (string) - %e mday - %h hour - %E min - %G sec - - {width} is a integer with/without '-' sign. if a '-' sign exists, content - of a header-type will be displaied with left adjustment. If the integer - have leading '0', the field will be padded with leading '0's. - - To improve processing speed, needless process on JIS character should be - avoided. Even if 'JisSafe' is on, only %f, %t, %A, %s, %S and %b are - processed with 'substr' routine for JIS characters by default. If you want - to process other header-types with JIS version of 'substr', specify '!' - just after '%' like: %!-8S. - - ScanForm "%+5n %m%d %-14A %-18S %b" works as same as IM default scaning. - -=head1 PETNAMES FORMAT - - Following format is valid in petnames file. - A line beginning with '#' is ignored. - # This is comments - Kazu@Mew.org "Mr.Kazu" - nom@Mew.org "Nomsun" - -=cut use vars qw($WIDTH $JIS_SAFE $HEADLINELIMIT $BODYLINELIMIT $MSTR2NUM @MSTR @WSTR %symbol_table %multipart_mark @NEEDSAFE %NEEDSAFE_HASH @@ -188,8 +97,8 @@ BEGIN { 'sig' => 'S', ); - @NEEDSAFE = qw (from: to: cc: address: Address: - subject: indent-subject: body: ); + @NEEDSAFE = qw(from: to: cc: address: Address: + subject: indent-subject: body:); %NEEDSAFE_HASH = (); @@ -203,8 +112,8 @@ BEGIN { ## If user specifies a scan format, convert that to 'eval-form'. ## -sub set_scan_form ($$$) { - my ($scan_form, $width, $jis_safe) = @_; +sub set_scan_form($$$) { + my($scan_form, $width, $jis_safe) = @_; $ALLOW_CRLF = allowcrlf(); @@ -233,7 +142,7 @@ sub set_scan_form ($$$) { ## get_header ## -sub get_header ($) { +sub get_header($) { my $path = shift; my %Head = (); my $folder; @@ -301,8 +210,8 @@ foreach (@STRUCTURED) { $STRUCTURED_HASH{$_} = 1; } -sub store_header ($$) { - my ($href, $header) = @_; +sub store_header($$) { + my($href, $header) = @_; local $_; my $lines = 0; @@ -334,10 +243,10 @@ sub store_header ($$) { # mode: 1 if HANDLER is File Handler, otherwise HANDLER is Array # return value: substring from body # -sub parse_body (*$) { +sub parse_body(*$) { local *HANDLE = shift; my $mode = shift; - my ($content, $lines) = ('', 0); + my($content, $lines) = ('', 0); while (1) { if ($mode == 0) { @@ -351,7 +260,7 @@ sub parse_body (*$) { next if /^\s*\n/; next if /^--/; next if /^- --/; - next if /^\s+[\w-*]+=/; # eg. "boundary="; * = RFC2231 + next if /^\s+[\w*-]+=/; # eg. "boundary="; * = RFC2231 next if /^\s*[\w-]+: /; # Headers and header style citation next if /^\s*[\w-]*[>|]/; # other citation next if /:\n$/; @@ -385,7 +294,7 @@ sub parse_body (*$) { return substr_safe($content, $WIDTH); } -sub parse_header ($) { +sub parse_header($) { my $href = shift; ## @@ -409,10 +318,10 @@ sub parse_header ($) { if ($href->{'date'}) { $href->{'date:'} = $href->{'date'}; } else { - my ($sec, $min, $hour, $mday, $mon, $year, - $wday, $yday, $isdst) = localtime((stat($href->{'path'}))[9]); - my ($gsec, $gmin, $ghour, $gmday, $gmon, $gyear, - $gwday, $gyday, $gisdst) = gmtime((stat($href->{'path'}))[9]); + my($sec, $min, $hour, $mday, $mon, $year, + $wday, $yday, $isdst) = localtime((stat($href->{'path'}))[9]); + my($gsec, $gmin, $ghour, $gmday, $gmon, $gyear, + $gwday, $gyday, $gisdst) = gmtime((stat($href->{'path'}))[9]); my $off = ($hour - $ghour) * 60 + $min - $gmin; if ($year < $gyear) { @@ -439,11 +348,11 @@ sub parse_header ($) { } $href->{'date:'} =~ /(\d\d?)\s+([A-Za-z]+)\s+(\d+)\s/; - my ($mday, $monthstr, $year) = ($1, "\u\L$2", $3); + my($mday, $monthstr, $year) = ($1, "\u\L$2", $3); my $mon = $MSTR2NUM->{$monthstr}; $href->{'date:'} =~ /\s(\d\d?):(\d\d?)/; - my ($hour, $min, $sec) = ($1, $2, 0); + my($hour, $min, $sec) = ($1, $2, 0); if ($href->{'date:'} =~ /\s\d\d?:\d\d?:(\d\d?)\s/) { $sec = $1; } @@ -510,7 +419,7 @@ sub parse_header ($) { if ($REF_SYMBOL{'pureaddr:'}) { if (my_addr($href->{'from'})) { if ($href->{'to'}) { - my ($to, $rest) = &fetch_addr($href->{'to'}, 1); + my($to, $rest) = &fetch_addr($href->{'to'}, 1); if ($to) { $href->{'pureaddr:'} = 'To:' . $to; } @@ -552,8 +461,8 @@ sub parse_header ($) { &scan_sub($href) if (defined(&scan_sub)); } -sub disp_msg ($;$) { - my ($href, $vscan) = @_; +sub disp_msg($;$) { + my($href, $vscan) = @_; $href->{'indent:'} = '' unless defined($href->{'indent:'}); $href->{'subject:'} = '' unless defined($href->{'subject:'}); @@ -586,11 +495,11 @@ sub disp_msg ($;$) { ## Convert into Friendly Address ## -sub friendly_addr ($$) { - my ($addr, $need_addr) = @_; +sub friendly_addr($$) { + my($addr, $need_addr) = @_; return '' unless $addr; my $friendly = ''; - my ($a, $f, $p); + my($a, $f, $p); while (($a, $addr, $f) = &fetch_addr($addr, 1), $a ne '') { $a =~ s/\/[^@]*//; if (defined(%petnames) && $petnames{lc($a)}) { @@ -616,14 +525,14 @@ sub friendly_addr ($$) { %ADDRESS_HASH = (); -sub my_addr (@) { +sub my_addr(@) { my @addrs = @_; my $addr; unless (defined($ADDRESS_HASH{'init'})) { $ADDRESS_HASH{'addr'} = addresses_regex(); unless ($ADDRESS_HASH{'addr'}) { - $ADDRESS_HASH{'addr'} = '^' . quotemeta(address()) . '$'; + $ADDRESS_HASH{'addr'} = '^' . quotemeta(address()) . '$'; #' $ADDRESS_HASH{'addr'} =~ s/(\\\s)*\\,(\\\s)*/\$|\^/g; } $ADDRESS_HASH{'init'} = 1; @@ -643,7 +552,7 @@ sub my_addr (@) { ## Convert scan_form() to 'eval-form' ## -sub convert_scan_form ($) { +sub convert_scan_form($) { my $SCANFORM = shift; if (!$main::INSECURE && $SCANFORM && $SCANFORM !~ /%/) { @@ -652,7 +561,7 @@ sub convert_scan_form ($) { } my @symbols = (); - my ($format, $jis_safe, $plus, $hyphen, $size, $type, $arg); + my($format, $jis_safe, $plus, $hyphen, $size, $type, $arg); if (scan_header_pick()) { my $elem; @@ -714,7 +623,7 @@ sub convert_scan_form ($) { $arg = join(',', @symbols); my $EVAL_SCAN_FORM = "sprintf('$format', $arg)"; - eval "sub scan_form { my (\$href) = shift; $EVAL_SCAN_FORM }"; + eval "sub scan_form { my(\$href) = shift; $EVAL_SCAN_FORM }"; if ($@) { im_die("Form seems to be wrong.\nPerl error message is: $@"); } @@ -734,7 +643,7 @@ BEGIN { $SS3 = "\x1b\x4f"; # <ISO 2022 Single_shift three> } -sub substr_safe ($$) { +sub substr_safe($$) { ($_, my $len) = @_; # This hack makes the code a few percent faster but it's kinda ugly. @@ -864,20 +773,19 @@ sub substr_safe ($$) { ## Read petnames entry ## -sub w2n ($) { +sub w2n($) { my $line = shift; $line =~ tr/\x20/\x0/; return $line; } -sub read_petnames () { - +sub read_petnames() { if (addrbook_file() && open(ADDRBOOK, addrbook_file())) { my $key; my $addr; my $petname; my $a; my @addrs; my $code; - while(<ADDRBOOK>) { + while (<ADDRBOOK>) { my $line = ''; do { chomp; @@ -893,7 +801,7 @@ sub read_petnames () { $line .= $_; } while (/[,\\]$/ && defined($_ = <ADDRBOOK>)); $_ = $line; - s/"([^"]+)"/w2n($1)/geo; + s/"([^"]+)"/w2n($1)/geo; #" s/,\s+/,/g; if (s/^(\S+)\s+(\S+)\s+(\S+)//) { $key = $1; @@ -921,11 +829,11 @@ sub read_petnames () { im_warn("can't open petname file $file\n"); return; } - while(<PETNAMES>) { + while (<PETNAMES>) { next if (/^$/); next if (/^#/); chomp; - my ($name, $petname); + my($name, $petname); if (/(\S+)\s+(.*)/) { $name = $1; $petname = $2; @@ -938,6 +846,111 @@ sub read_petnames () { 1; +__END__ + +=head1 NAME + +IM::Scan - scan listing from mail/news message + +=head1 SYNOPSIS + + use IM::Scan; + + &set_scan_form($scan_form, $width, $use_jis); + &read_petnames(); + %Head = &get_header($mail_file); + &disp_msg(\%Head); + +=head1 DESCRIPTION + +The I<IM::Scan> module handles scan format and petnames format +for mail/news message. + +This modules is provided by IM (Internet Message). + +=head1 FILES + + $HOME/.im/Config the user profile + +=head1 PROFILE COMPONENTS + + Component Explanation Example + + MailDir: your mail directory Mail + Width: one line width 80 + JisSafe: safely substr for ISO-2022-JP on + Form: scan format %+5n %m%d %8f %-30S %b + PetnameFile: nickname file ~/.im/Petname + Address: your mail addresses kazu@mew.org, kazu@wide.ad.jp + AddrRegex: regexp of your addresses ^kazu@.*$ + if necessary + +=head1 SCAN FORMAT + +'%{width}{header-type}' format is available. You can define any +header-type as you want. Default valid header-types are + + %n message number + %d raw Date: field + %f MIME decoded From: field + %t MIME decoded To: filed + %g raw Newsgroups: field + %a friendly From: field + %A If this message is originated by yourself, friendly To: + or raw Newsgroups: is displayed in 'To:xxx' or 'Ng:xxx' + format, respectively. Otherwise, friendly From: field is + displayed. + %P Similar to %A, but diplay raw address of mail sender + instead of friendly From: field, just like mh-e. + %i indent to display thread + %s MIME decoded Subject: field + %S indented MIME decoded Subject (same as %i+%s) + %b a part of body extracted with heuristic + %m Multipart type + 'S'igned, 'E'ncrypt, 'M'ultipart, 'P'artial or none + %p mark '*' if the message is destined to you + %D mark 'D' if the message is duplicated + %M %p+%D + %F folder path + %K file block size (1024 bytes/block) + + %y year + %c month (digit) + %C month (string) + %e mday + %h hour + %E min + %G sec + +{width} is a integer with/without '-' sign. if a '-' sign exists, content +of a header-type will be displaied with left adjustment. If the integer +have leading '0', the field will be padded with leading '0's. + +To improve processing speed, needless process on JIS character should be +avoided. Even if 'JisSafe' is on, only %f, %t, %A, %s, %S and %b are +processed with 'substr' routine for JIS characters by default. If you want +to process other header-types with JIS version of 'substr', specify '!' +just after '%' like: %!-8S. + +ScanForm "%+5n %m%d %-14A %-18S %b" works as same as IM default scaning. + +=head1 PETNAMES FORMAT + +Following format is valid in petnames file. +A line beginning with '#' is ignored. + + # This is comments + Kazu@Mew.org "Mr.Kazu" + nom@Mew.org "Nomsun" + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Smtp.pm b/img/lib/IM/Smtp.pm index b913a2e4..af730a06 100644 --- a/img/lib/IM/Smtp.pm +++ b/img/lib/IM/Smtp.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Smtp.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Smtp.pm version 20021207(IM142)"; package IM::Smtp; require 5.003; @@ -28,21 +28,6 @@ use vars qw(@ISA @EXPORT); @EXPORT = qw(smtp_open smtp_close smtp_transaction smtp_transaction_for_error_notify); -=head1 NAME - -Smtp - SMTP interface package - -=head1 SYNOPSIS - -$return_code = &smtp_open(current_server, server_list, log_flag); -$return_code = &smtp_close(socket, savehist_flag); -$return_code = &smtp_transaction(bcc_flag, part_current, part_total); -$return_code = &smtp_transaction_for_error_notify; - -=head1 DESCRIPTION - -=cut - use vars qw(@Status $Smtp_opened *SMTPd $SmtpErrTitle $Esmtp_flag %ESMTP); ##### SMTP SESSION OPENING ##### @@ -56,8 +41,8 @@ use vars qw(@Status $Smtp_opened *SMTPd $SmtpErrTitle # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub smtp_open ($$$) { - my ($server, $server_list, $logging) = @_; +sub smtp_open($$$) { + my($server, $server_list, $logging) = @_; local $_; my $rc; my $svr = &get_cur_server_original_form(); @@ -77,7 +62,7 @@ sub smtp_open ($$$) { $SmtpErrTitle = "(while talking to " . &get_cur_server() . " with smtp)\n"; return $rc if ($rc = &tcp_command(\*SMTPd, '', '')); $Esmtp_flag = 0; - my (@resp) = &command_response; + my(@resp) = &command_response; if (join('/', @resp) =~ /ESMTP/) { $Esmtp_flag = 1; } @@ -85,7 +70,7 @@ sub smtp_open ($$$) { if ($Esmtp_flag) { unless (&tcp_command(\*SMTPd, "EHLO $main::Client_name", '')) { # ESMTP OK - my (@resp) = &command_response; + my(@resp) = &command_response; foreach (@resp) { if (/^250[ \-]([A-Z0-9]+)$/) { $ESMTP{$1} = 1; @@ -114,7 +99,7 @@ sub smtp_open ($$$) { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub smtp_close () { +sub smtp_close() { # @Status =(); return 0 unless ($SMTPd); return 0 unless ($Smtp_opened); @@ -137,8 +122,8 @@ sub smtp_close () { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub smtp_transaction ($$$$$$) { - my ($servers, $Header, $Body, $bcc, $part, $total) = @_; +sub smtp_transaction($$$$$$) { + my($servers, $Header, $Body, $bcc, $part, $total) = @_; my $rc; my $fatal_error = 0; @@ -181,9 +166,9 @@ sub smtp_transaction ($$$$$$) { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub smtp_transact_sub ($$$$$$$) { - my ($server, $server_list, $Header, $Body, $bcc, $part, $total) = @_; - my ($i, $rc, $fail, @fatal, $msg_size, $btype); +sub smtp_transact_sub($$$$$$$) { + my($server, $server_list, $Header, $Body, $bcc, $part, $total) = @_; + my($i, $rc, $fail, @fatal, $msg_size, $btype); return $rc if ($rc = smtp_open($server, $server_list, 1)); if ($ESMTP{'8BITMIME'} && $main::Has_8bit_body && !$main::do_conv_8to7) { $btype = ' BODY=8BIT'; @@ -199,7 +184,7 @@ sub smtp_transact_sub ($$$$$$$) { } return $rc if ($rc); $fail = 0; - my ($rec); + my($rec); for ($i = 0; $i <= $#main::Recipients; $i++) { $rec = $main::Recipients[$i]; if ($bcc) { @@ -210,7 +195,7 @@ sub smtp_transact_sub ($$$$$$$) { } else { $rc = &tcp_command(\*SMTPd, "RCPT TO:<$rec>", ''); } - my (@resp) = &command_response; + my(@resp) = &command_response; if ($rc) { push(@fatal, @resp); } @@ -223,7 +208,7 @@ sub smtp_transact_sub ($$$$$$$) { } else { $rc = &tcp_command(\*SMTPd, "RCPT TO:$rec", ''); } - my (@resp) = &command_response; + my(@resp) = &command_response; if ($rc) { push(@fatal, @resp); } @@ -252,7 +237,7 @@ sub smtp_transact_sub ($$$$$$$) { } select (SMTPd); $| = 1; select (STDOUT); return $rc if ($rc = &tcp_command(\*SMTPd, '.', '')); - my (@resp) = &command_response; + my(@resp) = &command_response; &log_action($Esmtp_flag ? 'esmtp' : 'smtp', &get_cur_server(), join(',', @main::Recipients), 'sent', @resp); $main::Info .= "Delivery successful for the following recipient(s):\n"; @@ -276,9 +261,9 @@ sub smtp_transact_sub ($$$$$$$) { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub smtp_transaction_for_error_notify ($$$$) { - my ($server, $servers, $Header, $Body) = @_; - my ($rc, @prev_rcpt, @prev_stat); +sub smtp_transaction_for_error_notify($$$$) { + my($server, $servers, $Header, $Body) = @_; + my($rc, @prev_rcpt, @prev_stat); @prev_rcpt = @main::Recipients; @prev_stat = @Status; @main::Recipients = ($main::Sender); @@ -292,7 +277,7 @@ sub smtp_transaction_for_error_notify ($$$$) { $Esmtp_flag ? 'esmtp' : 'smtp', &get_cur_server, 1, &get_session_log); select (SMTPd); $| = 1; select (STDOUT); return $rc if ($rc = &tcp_command(\*SMTPd, '.', '')); - my (@resp) = &command_response; + my(@resp) = &command_response; &log_action($Esmtp_flag ? 'esmtp' : 'smtp', &get_cur_server(), join(',', @main::Recipients), 'sent', @resp); return 0; @@ -300,6 +285,35 @@ sub smtp_transaction_for_error_notify ($$$$) { 1; +__END__ + +=head1 NAME + +IM::Smtp - SMTP handler + +=head1 SYNOPSIS + + use IM::Smtp; + + $return_code = &smtp_open(current_server, server_list, log_flag); + $return_code = &smtp_close(socket, savehist_flag); + $return_code = &smtp_transaction(bcc_flag, part_current, part_total); + $return_code = &smtp_transaction_for_error_notify; + +=head1 DESCRIPTION + +The I<IM::Smtp> module handles SMTP. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Ssh.pm b/img/lib/IM/Ssh.pm index bcac3f39..404a8f78 100644 --- a/img/lib/IM/Ssh.pm +++ b/img/lib/IM/Ssh.pm @@ -4,46 +4,47 @@ ### Ssh.pm ### ### Author: Masatoshi Tsuchiya <tsuchiya@pine.kuee.kyoto-u.ac.jp> +### Internet Message Group <img@mew.org> ### Created: Oct 05, 1999 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Ssh.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Ssh.pm version 20021207(IM142)"; package IM::Ssh; require 5.003; require Exporter; -use IM::Config qw( connect_timeout command_timeout $SSH_PATH ); +use IM::Config qw(connect_timeout command_timeout $SSH_PATH); use IM::Util; use strict; -use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $SSH $FH @PID ); -@ISA = qw( Exporter ); -@EXPORT = qw( ssh_proxy ); +use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $SSH $FH @PID); +@ISA = qw(Exporter); +@EXPORT = qw(ssh_proxy); # Global Variables $FH = "SSH00000"; @PID = (); -sub ssh_proxy ($$$$) { - my( $server, $remote, $local, $host ) = @_; +sub ssh_proxy($$$$) { + my($server, $remote, $local, $host) = @_; - unless( $host ){ - im_err( "Missing relay host.\n" ); + unless ($host) { + im_err("Missing relay host.\n"); return 0; } - im_notice( "openning SSH-tunnel to $server/$remote\%$local via $host\n" ) + im_notice("openning SSH-tunnel to $server/$remote\%$local via $host\n") if &verbose; - my( $pid, $read, $write ); + my($pid, $read, $write); FORK: { no strict 'refs'; $read = $FH++; $write = $FH++; - pipe( $read, $write ); - if ( $pid = fork ) { + pipe($read, $write); + if ($pid = fork) { close $write; - my( $buf, $sig, $i ); - for( $i=0; $i<3; $i++ ){ + my($buf, $sig, $i); + for ($i=0; $i<3; $i++) { $sig = $SIG{ALRM}; $SIG{ALRM} = sub { die "SIGALRM is received\n"; }; eval { @@ -52,34 +53,35 @@ sub ssh_proxy ($$$$) { alarm 0; }; $SIG{ALRM} = $sig; - if ( $@ !~ /SIGALRM is received/ ) { - push( @PID, $pid ); - if ( $buf =~ /ssh_proxy_connect/ ) { + if ($@ !~ /SIGALRM is received/) { + push(@PID, $pid); + if ($buf =~ /ssh_proxy_connect/) { return $local; - } elsif ( $buf =~ /Local: bind: Address already in use/ ) { + } elsif ($buf =~ /Local: bind: Address already in use/) { $local++; redo FORK; - } elsif( $buf ){ + } elsif ($buf) { last; } } } $buf =~ s/\s+$//; $buf =~ s/\n/\\n/g; - im_warn( "Accident in Port Forwading: $buf\n" ); - } elsif ( $pid == 0 ) { + im_warn("Accident in Port Forwading: $buf\n"); + } elsif ($pid == 0) { close $read; - open(STDOUT, ">&$write" ); - open(STDERR, ">&$write" ); + open(STDOUT, ">&$write"); + open(STDERR, ">&$write"); exec($SSH_PATH, '-n', '-x', '-o', 'BatchMode yes', - "-L$local:$server:$remote", $host, - sprintf( 'echo ssh_proxy_connect ; sleep %s', &command_timeout() ) ); + "-L$local:$server:$remote", $host, + sprintf('echo ssh_proxy_connect ; sleep %s', + &command_timeout())); exit 0; # Not reach. - } elsif ( $! =~ /No more process/ ) { + } elsif ($! =~ /No more process/) { sleep 5; redo FORK; } else { - im_warn( "Can't fork $SSH_PATH.\n" ); + im_warn("Can't fork $SSH_PATH.\n"); } } 0; @@ -87,12 +89,69 @@ sub ssh_proxy ($$$$) { sub END { - if ( @PID ) { + if (@PID) { kill 15, @PID; sleep 3; kill 9, @PID; } } - 1; + +__END__ + +=head1 NAME + +IM::Ssh - SSH handler + +=head1 SYNOPSIS + + use IM::Ssh; + + if ($remote = ssh_proxy($server, $remote, $local, $host)) { + # connection succeeded + } else { + # connection failed + } + +=head1 DESCRIPTION + +The I<IM::Ssh> module handles SSH. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + +### Copyright (C) 1997, 1998, 1999 IM developing team +### All rights reserved. +### +### Redistribution and use in source and binary forms, with or without +### modification, are permitted provided that the following conditions +### are met: +### +### 1. Redistributions of source code must retain the above copyright +### notice, this list of conditions and the following disclaimer. +### 2. Redistributions in binary form must reproduce the above copyright +### notice, this list of conditions and the following disclaimer in the +### documentation and/or other materials provided with the distribution. +### 3. Neither the name of the team nor the names of its contributors +### may be used to endorse or promote products derived from this software +### without specific prior written permission. +### +### THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND +### ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +### PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE +### LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +### CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +### SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +### BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +### WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +### OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +### IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/img/lib/IM/Stdio.pm b/img/lib/IM/Stdio.pm index c247e6b1..7d4d9808 100644 --- a/img/lib/IM/Stdio.pm +++ b/img/lib/IM/Stdio.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: May 7, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Stdio.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Stdio.pm version 20021207(IM142)"; package IM::Stdio; require 5.003; @@ -22,7 +22,7 @@ use vars qw(@ISA @EXPORT $old); # why not my($old)? @ISA = qw(Exporter); @EXPORT = qw(flush); -sub flush (*) { +sub flush(*) { local($old) = select(shift); $| = 1; print ''; @@ -32,6 +32,37 @@ sub flush (*) { 1; +__END__ + +=head1 NAME + +IM::Stdio - stdio handler + +=head1 SYNOPSIS + + use IM::Stdio; + + flush(OUTPUT_HANDLE); + +=head1 DESCRIPTION + +The I<IM::Stdio> module handles stdio. + +This modules is provided by IM (Internet Message). + +=head1 BUGS + +This module is semi-obsolete. This module conflicts with the +I<IM::Util> module. + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/TcpTransaction.pm b/img/lib/IM/TcpTransaction.pm index 389d47c6..63d6599c 100644 --- a/img/lib/IM/TcpTransaction.pm +++ b/img/lib/IM/TcpTransaction.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::TcpTransaction.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::TcpTransaction.pm version 20021207(IM142)"; package IM::TcpTransaction; require 5.003; @@ -31,21 +31,6 @@ use vars qw(@ISA @EXPORT); get_session_log set_cur_server get_cur_server get_cur_server_original_form pool_priv_sock); -=head1 NAME - -TcpTransaction - TCP Transaction processing interface for SMTP and NNTP - -=head1 SYNOPSIS - -$socket = &connect_server(server_list, protocol, log_flag); -$return_code = &tcp_command(socket, command_string, log_flag); -@response = &command_response; -&set_command_response(response_string_list); - -=head1 DESCRIPTION - -=cut - use vars qw($Cur_server $Cur_server_original_form $Session_log $TcpSockName $SOCK @Response $Logging @SockPool @Sock6Pool); BEGIN { @@ -54,7 +39,7 @@ BEGIN { $TcpSockName = 'tcp00'; } -sub log_transaction () { +sub log_transaction() { use IM::Log; } @@ -66,8 +51,8 @@ sub log_transaction () { # root: privilidge port required # return value: handle if success # -sub connect_server ($$$) { - my ($servers, $serv, $root) = @_; +sub connect_server($$$) { + my($servers, $serv, $root) = @_; if ($#$servers < 0) { im_err("no server specified for $serv\n"); @@ -77,14 +62,14 @@ sub connect_server ($$$) { $SIG{'ALRM'} = \&alarm_func; no strict 'refs'; # XXX - local (*SOCK) = \*{$TcpSockName}; + local(*SOCK) = \*{$TcpSockName}; $SOCK = $serv; @Response = (); - my (@he_infos); - my ($s, $localport, $remoteport); + my(@he_infos); + my($s, $localport, $remoteport); foreach $s (@$servers) { $Cur_server_original_form = $s; - my ($r) = ($#$servers >= 0) ? 'skipped' : 'failed'; + my($r) = ($#$servers >= 0) ? 'skipped' : 'failed'; # manage server[/remoteport]%localport if ($s =~ s/\%(\d+)$//) { $localport = $1; @@ -95,14 +80,14 @@ sub connect_server ($$$) { next unless ($remoteport = getserv($serv, 'tcp')); } if ($main::SSH_server eq 'localhost') { - im_warn( "Don't use port-forwarding to `localhost'.\n" ); + im_warn("Don't use port-forwarding to `localhost'.\n"); $Cur_server = "$s/$remoteport"; } else { - if ( $remoteport = &ssh_proxy($s,$remoteport,$localport,$main::SSH_server) ) { + if ($remoteport = &ssh_proxy($s,$remoteport,$localport,$main::SSH_server)) { $s = 'localhost'; $Cur_server = "$Cur_server%$remoteport"; } else { # Connection failed. - im_warn( "Can't login to $main::SSH_server\n" ); + im_warn("Can't login to $main::SSH_server\n"); if ($serv eq 'smtp') { &log_action($serv, $Cur_server, join(',', @main::Recipients), $r, @Response); @@ -138,7 +123,7 @@ sub connect_server ($$$) { next; } while ($#he_infos >= 0) { - my ($family, $socktype, $proto, $sin, $canonname) + my($family, $socktype, $proto, $sin, $canonname) = splice(@he_infos, 0, 5); if ($root && unixp()) { my $name = priv_sock($family); @@ -207,9 +192,9 @@ sub connect_server ($$$) { # 1: recoverable error (should be retried) # -1: unrecoverable error # -sub tcp_command ($$$) { - my ($CHAN, $command, $fake) = @_; - my ($resp, $stat, $rcode, $logcmd); +sub tcp_command($$$) { + my($CHAN, $command, $fake) = @_; + my($resp, $stat, $rcode, $logcmd); @Response = (); $stat = ''; @@ -266,9 +251,9 @@ sub tcp_command ($$$) { # send_command(channel, command, fake_message) # return value: the first line of responses # -sub send_command ($$$) { - my ($CHAN, $command, $fake) = @_; - my ($resp, $logcmd); +sub send_command($$$) { + my($CHAN, $command, $fake) = @_; + my($resp, $logcmd); if ($command) { print $CHAN "$command\r\n"; if ($fake) { @@ -299,9 +284,9 @@ sub send_command ($$$) { return $resp; } -sub send_data ($$$) { - my ($CHAN, $data, $fake) = @_; - my ($logdata); +sub send_data($$$) { + my($CHAN, $data, $fake) = @_; + my($logdata); $data =~ s/\r?\n?$//; print $CHAN "$data\r\n"; if ($fake) { @@ -313,7 +298,7 @@ sub send_data ($$$) { $Session_log .= "<<< $logdata\n" if ($Logging); } -sub next_response ($) { +sub next_response($) { my $CHAN = shift; my $resp; @@ -334,36 +319,36 @@ sub next_response ($) { return $resp; } -sub command_response () { +sub command_response() { return @Response; } -sub set_command_response (@) { +sub set_command_response(@) { @Response = @_; } -sub tcp_logging ($) { +sub tcp_logging($) { # conversations are saved in $Session_log if true $Logging = shift; } -sub get_session_log () { +sub get_session_log() { return $Session_log; } -sub set_cur_server ($) { +sub set_cur_server($) { $Cur_server = shift; } -sub get_cur_server () { +sub get_cur_server() { return $Cur_server; } -sub get_cur_server_original_form () { +sub get_cur_server_original_form() { return $Cur_server_original_form; } -sub pool_priv_sock ($) { +sub pool_priv_sock($) { my $count = shift; pool_priv_sock_af($count, AF_INET); @@ -373,12 +358,12 @@ sub pool_priv_sock ($) { } } -sub pool_priv_sock_af ($$) { - my ($count, $family) = @_; +sub pool_priv_sock_af($$) { + my($count, $family) = @_; my $privport = 1023; no strict 'refs'; # XXX - my ($pe_name, $pe_aliases, $pe_proto); + my($pe_name, $pe_aliases, $pe_proto); ($pe_name, $pe_aliases, $pe_proto) = getprotobyname ('tcp'); unless ($pe_name) { $pe_proto = 6; @@ -389,7 +374,7 @@ sub pool_priv_sock_af ($$) { return -1; } while ($privport > 0) { - my ($ANYADDR, $psin); + my($ANYADDR, $psin); im_debug("binding port $privport.\n") if (&debug('tcp')); if ($family == AF_INET) { @@ -419,9 +404,9 @@ sub pool_priv_sock_af ($$) { return 0; } -sub priv_sock ($) { - my ($family) = shift; - my ($sock_name); +sub priv_sock($) { + my($family) = shift; + my($sock_name); if ($family == AF_INET) { return '' if ($#SockPool < 0); @@ -438,12 +423,12 @@ sub alarm_func { im_die("connection error\n"); } -sub im_getaddrinfo ($$;$$$$) { +sub im_getaddrinfo($$;$$$$) { return getaddrinfo(@_) if (defined &getaddrinfo); - my ($node, $serv, $family, $socktype, $proto, $flags) = @_; + my($node, $serv, $family, $socktype, $proto, $flags) = @_; - my ($pe_name, $pe_aliases, $pe_proto, $se_port); + my($pe_name, $pe_aliases, $pe_proto, $se_port); if (unixp()) { $proto = 'tcp' unless ($proto); ($pe_name, $pe_aliases, $pe_proto) = getprotobyname($proto); @@ -451,7 +436,7 @@ sub im_getaddrinfo ($$;$$$$) { $pe_proto = 6 unless ($pe_name); return unless ($se_port = getserv($serv, $proto)); - my ($he_name, $he_alias, $he_type, $he_len, @he_addrs); + my($he_name, $he_alias, $he_type, $he_len, @he_addrs); if ($node =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { @he_addrs = (pack('C4', $1, $2, $3, $4)); } else { @@ -462,7 +447,7 @@ sub im_getaddrinfo ($$;$$$$) { return unless ($he_name); } - my ($he_addr, @infos); + my($he_addr, @infos); foreach $he_addr (@he_addrs) { push(@infos, AF_INET, $socktype, $pe_proto, pack_sockaddr_in($se_port, $he_addr), $he_name); @@ -471,13 +456,13 @@ sub im_getaddrinfo ($$;$$$$) { } sub getserv($$) { - my ($serv, $proto) = @_; + my($serv, $proto) = @_; - my ($se_port); + my($se_port); if ($serv =~ /^\d+$/o) { $se_port = $serv; } else { - my ($se_name, $se_aliases); + my($se_name, $se_aliases); ($se_name, $se_aliases, $se_port) = getservbyname($serv, $proto) if (unixp()); unless ($se_name) { @@ -502,6 +487,35 @@ sub getserv($$) { 1; +__END__ + +=head1 NAME + +IM::TcpTransaction - TCP transaction processing interface for SMTP and NNTP + +=head1 SYNOPSIS + + use IM::TcpTransaction; + + $socket = &connect_server(server_list, protocol, log_flag); + $return_code = &tcp_command(socket, command_string, log_flag); + @response = &command_response; + &set_command_response(response_string_list); + +=head1 DESCRIPTION + +The I<IM::TcpTransaction> module handles TCP transaction for SMTP and NNTP. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### diff --git a/img/lib/IM/Util.pm b/img/lib/IM/Util.pm index 8b9235ff..68da1a5e 100644 --- a/img/lib/IM/Util.pm +++ b/img/lib/IM/Util.pm @@ -5,10 +5,10 @@ ### ### Author: Internet Message Group <img@mew.org> ### Created: Apr 23, 1997 -### Revised: Apr 14, 2000 +### Revised: Dec 7, 2002 ### -my $PM_VERSION = "IM::Util.pm version 20000414(IM141)"; +my $PM_VERSION = "IM::Util.pm version 20021207(IM142)"; package IM::Util; require 5.003; @@ -71,7 +71,7 @@ sub unixp { } sub win95p { - if (($OS eq 'WIN95') || ($OS eq 'WNT') ){ + if (($OS eq 'WIN95') || ($OS eq 'WNT')) { return 1; } else { return 0; @@ -94,14 +94,14 @@ sub os2p { } } -sub progname () { +sub progname() { return $main::Prog; } ### ### get login name ### -sub im_getlogin () { +sub im_getlogin() { if (&unixp()) { my $login = getlogin(); if ($login ne '' && $login ne 'root') { @@ -109,9 +109,9 @@ sub im_getlogin () { } else { return (getpwuid($<))[0] || undef; } - } elsif (&os2p()){ + } elsif (&os2p()) { return getlogin() || undef; - } elsif (&win95p()){ + } elsif (&win95p()) { return Win32::LoginName(); } } @@ -128,54 +128,54 @@ sub im_getlogin () { # im_err - display critical error messages -- process will be aborted # im_die - display critical error messages and exit -sub im_msg ($) { +sub im_msg($) { my $msg = shift; print progname(), ': ', $msg; } -sub im_info ($) { +sub im_info($) { my $info = shift; return if $main::opt_quiet; print progname(), ': ', $info; } -sub im_debug ($) { +sub im_debug($) { my $dbg = shift; print STDERR progname(), ':DEBUG: ', $dbg; } -sub im_notice ($) { +sub im_notice($) { return unless &verbose; my $warn = progname() . ': '. shift; $SavedMsg .= $warn; print STDERR $warn; } -sub im_warn ($) { +sub im_warn($) { my $warn = progname() . ': '. shift; $SavedMsg .= $warn; print STDERR $warn; } -sub im_err ($) { +sub im_err($) { my $err = progname() . ': ERROR: ' . shift; $SavedMsg .= $err; print STDERR $err; } -sub im_die ($) { +sub im_die($) { my $die = shift; print STDERR progname(), ': ERROR: ', $die; exit $EXIT_ERROR; } -sub im_die2 ($) { +sub im_die2($) { my $die = shift; print STDERR progname(), ': ', $die; exit $EXIT_ERROR; } -sub im_save_error (;$) { +sub im_save_error(;$) { my $string = shift; if ($string eq '') { $SavedMsg = ''; # reset @@ -184,7 +184,7 @@ sub im_save_error (;$) { } } -sub im_saved_errors () { +sub im_saved_errors() { return $SavedMsg; } @@ -192,22 +192,21 @@ sub im_saved_errors () { ### Debug ### -sub print_hash (\%) -{ +sub print_hash(\%) { my $hashref = shift; - foreach (keys(%{$hashref})){ + foreach (keys(%{$hashref})) { print "$_ -> $hashref->{$_}\n"; } } -sub set_debug ($$) { +sub set_debug($$) { my $category = shift; $Debug{$category} = shift; } -sub debug ($) { +sub debug($) { my $category = shift; if ($Debug{'all'}) { @@ -217,11 +216,11 @@ sub debug ($) { } } -sub set_verbose ($) { +sub set_verbose($) { $main::opt_verbose = shift; } -sub verbose () { +sub verbose() { return $main::opt_verbose; } @@ -229,7 +228,7 @@ sub verbose () { # # debug_option() # -sub debug_option ($) { +sub debug_option($) { my $DebugFlag = shift; if ($DebugFlag && ($DebugFlag !~ /^(off|no|false|0)$/)) { @@ -245,7 +244,7 @@ sub debug_option ($) { # flush buffer # -sub flush (*) { +sub flush(*) { local($old) = select(shift); $| = 1; print ''; @@ -258,8 +257,8 @@ sub flush (*) { # sub im_open($$) { - my ($d, $a) = @_; - my ($r); + my($d, $a) = @_; + my($r); if ($r = open($d, $a)) { binmode($d); } @@ -267,8 +266,8 @@ sub im_open($$) { } sub im_sysopen($$$) { - my ($d, $f, $a) = @_; - my ($r); + my($d, $f, $a) = @_; + my($r); if ($r = sysopen($d, $f, $a)) { binmode($d); } @@ -277,6 +276,45 @@ sub im_sysopen($$$) { 1; +__END__ + +=head1 NAME + +IM::Util - utility functions for IM + +=head1 SYNOPSIS + + use IM::Util; + +Constant variables: +$SUCCESS +$ERROR +$EXIT_SUCCESS +$EXIT_ERROR + +Subroutines: +unixp win95p wntp os2p +progname +im_getlogin +im_msg im_info im_debug im_notice im_warn im_err im_die im_die2 +im_save_error im_saved_errors im_open im_sysopen +debug_option set_debug debug set_verbose verbose +flush + +=head1 DESCRIPTION + +The I<IM::Util> module provides utility functions for IM. + +This modules is provided by IM (Internet Message). + +=head1 COPYRIGHT + +IM (Internet Message) is copyrighted by IM developing team. +You can redistribute it and/or modify it under the modified BSD +license. See the copyright file for more details. + +=cut + ### Copyright (C) 1997, 1998, 1999 IM developing team ### All rights reserved. ### |
