modules/FTNMAIL: remove default output charset
authorSebastian <basti@notizbuch>
Sun, 15 Jun 2014 11:08:26 +0000 (13:08 +0200)
committerSebastian <basti@notizbuch>
Sun, 15 Jun 2014 11:08:26 +0000 (13:08 +0200)
Packing a mail now requires a (valid) character set.
This removes the dependency on CONFIG.pm and allows
per-mail charsets (per language/echo...).

modules/FTNMAIL.pm

index 551cee91deb190c05e09251c3d00d29dc49b19f3..0f5ea327addfe4cd18e326ed986eb3ea2fe2c25d 100644 (file)
@@ -2,17 +2,15 @@
 use strict;
 use v5.012;
 
-use CONFIG;
-
 # =========================================================================
 # Perl module to handle FTN style mail
 #
-#  $string = pack_mail($mail)
-#    converts a mail to a packed message string (see FTS-0001, C.1)
+#  $string = pack_mail($mail, $charset)   (see FTS-0001, C.1)
+#    converts a mail to correctly encoded packed message
 #    returns undef on error
 #
-#  @mails  = unpack_packet($filename)
-#    reads a packet file (see FTS-0001, F.1) and returns an array of mails
+#  @mails  = unpack_packet($filename)     (see FTS-0001, F.1 / FSC-0048)
+#    reads a packet file and returns an array of mails
 #    returns undef on error, dies on file error
 # =========================================================================
 package FTNMAIL;
@@ -21,21 +19,20 @@ use Encode;
 use Text::Wrap;
 
 # helper functions
-sub chrs2charset($); sub charset2chrs($);      # charset
-sub str2datetime($); sub datetime2str(@);      # datetime string
-sub str2ftn($);      sub ftn2str(@);           # ftn address
+#sub chrs2charset($); sub charset2chrs($);     # charset
+#sub str2datetime($); sub datetime2str(@);     # datetime string
+#sub str2ftn($);      sub ftn2str(@);          # ftn address
 
-sub pack_mail($)
+sub pack_mail($$)
 {
-       my $mail = shift;
+       my ($mail, $charset) = @_;
        my $output;
 
        # encode subject/body correctly
-       my $charset = $CONFIG::config{out_charset};
-       my $chrs    = charset2chrs($charset) or return(undef);
-       my $subj    = encode($charset, $mail->{subj});
-       my $body    = encode($charset, $mail->{body});
-       $body       =~ s/\n/\x0D/g;
+       my $chrs = charset2chrs($charset) or return(undef);
+       my $subj = encode($charset, $mail->{subj});
+       my $body = encode($charset, $mail->{body});
+       $body    =~ s/\n/\x0D/g;
 
        # generate kludge lines
        my @kludges;