| 1 | ##---------------------------------------------------------------------------## | ||
| 2 | ## File: | ||
| 3 | ## $Id: mhopt.pl,v 2.68 2012/01/29 19:45:55 ehood Exp $ | ||
| 4 | ## Author: | ||
| 5 | ## Earl Hood mhonarc@mhonarc.org | ||
| 6 | ## Description: | ||
| 7 | ## Routines to set options for MHonArc. | ||
| 8 | ##---------------------------------------------------------------------------## | ||
| 9 | ## MHonArc -- Internet mail-to-HTML converter | ||
| 10 | ## Copyright (C) 1997-2002 Earl Hood, mhonarc@mhonarc.org | ||
| 11 | ## | ||
| 12 | ## This program is free software; you can redistribute it and/or modify | ||
| 13 | ## it under the terms of the GNU General Public License as published by | ||
| 14 | ## the Free Software Foundation; either version 2 of the License, or | ||
| 15 | ## (at your option) any later version. | ||
| 16 | ## | ||
| 17 | ## This program is distributed in the hope that it will be useful, | ||
| 18 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ## GNU General Public License for more details. | ||
| 21 | ## | ||
| 22 | ## You should have received a copy of the GNU General Public License | ||
| 23 | ## along with this program; if not, write to the Free Software | ||
| 24 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
| 25 | ## 02111-1307, USA | ||
| 26 | ##---------------------------------------------------------------------------## | ||
| 27 | |||
| 28 | package mhonarc; | ||
| 29 | |||
| 30 | use Getopt::Long; | ||
| 31 | use Time::Local; | ||
| 32 | |||
| 33 | ##--------------------------------------------------------------------------- | ||
| 34 | ## get_resources() is responsible for grabbing resource settings from | ||
| 35 | ## the command-line and resource file(s). | ||
| 36 | ## | ||
| 37 | sub get_resources { | ||
| 38 | my ($tmp); | ||
| 39 | my (%opt) = (); | ||
| 40 | local ($_); | ||
| 41 | |||
| 42 | die(qq{Try "$PROG -help" for usage information\n}) | ||
| 43 | unless GetOptions( | ||
| 44 | \%opt, | ||
| 45 | 'add', # Add a message to archive | ||
| 46 | 'afs', # Bypass file permission checks | ||
| 47 | 'addressmodifycode=s', | ||
| 48 | # Perl expression for modifying displayed addresses | ||
| 49 | 'annotate', # Add a note to message(s) | ||
| 50 | 'attachmentdir=s', | ||
| 51 | # Pathname to attachment files directory | ||
| 52 | 'attachmenturl=s', | ||
| 53 | # URL to attachment files directory | ||
| 54 | 'authsort', # Sort by author | ||
| 55 | 'archive', # Create an archive (the default) | ||
| 56 | 'conlen', # Honor Content-Length fields | ||
| 57 | 'checknoarchive', | ||
| 58 | # Check for 'no archive' flag in messages | ||
| 59 | 'datefields=s', # Fields that contains the date of a message | ||
| 60 | 'dbfile=s', # Database/state filename for mhonarc archive | ||
| 61 | 'dbfileperms=i', # Octal permission to set DBFILE | ||
| 62 | 'debug', # Turn on debugging | ||
| 63 | 'decodeheads', # Decode all 1522 encoded data in message headers | ||
| 64 | 'definevar|definevars=s@', | ||
| 65 | # Define custom resource variables | ||
| 66 | 'doc', # Print link to doc at end of index page | ||
| 67 | 'docurl=s', # URL to mhonarc documentation | ||
| 68 | 'editidx', # Change index page layout only | ||
| 69 | 'expiredate=s', # Message cut-off date | ||
| 70 | 'expireage=i', # Time in seconds from current if message expires | ||
| 71 | 'fasttempfiles', # Do not use random filenames for temporary files | ||
| 72 | 'followsymlinks', | ||
| 73 | # Follow/allow symlinks when create files | ||
| 74 | 'fileperms=i', # Octal permission to create files | ||
| 75 | 'folrefs', # Print links to explicit follow-ups/references | ||
| 76 | 'footer=s', # File containing user text for bottom of index page | ||
| 77 | # (option no longer applicable) | ||
| 78 | 'force', # Perform archive operation even if unable to lock | ||
| 79 | 'fromfields=s', # Fields that contains the 'from' of a message | ||
| 80 | 'genidx', # Generate an index based upon archive contents | ||
| 81 | 'gmtdatefmt=s', # Date specification for GMT date | ||
| 82 | 'gzipexe=s', # Pathname of Gzip executable | ||
| 83 | 'gzipfiles', # Gzip files | ||
| 84 | 'gziplinks', # Add ".gz" extensions to files | ||
| 85 | 'header=s', # File containing user text for top of index page | ||
| 86 | # (option no longer applicable) | ||
| 87 | 'htmlext=s', # Extension for HTML files | ||
| 88 | 'iconurlprefix=s', | ||
| 89 | # Prefix for icon urls | ||
| 90 | 'idxfname=s', # Filename of index page | ||
| 91 | 'idxprefix=s', # Filename prefix for multi-page main index | ||
| 92 | 'idxsize=i', # Maximum number of messages shown in indexes | ||
| 93 | 'keeponrmm', # Do not delete message files on archive remove | ||
| 94 | 'lang=s', # Set locale/language | ||
| 95 | 'localdatefmt=s', | ||
| 96 | # Date specification for local date | ||
| 97 | 'lock', # Do archive locking (default) | ||
| 98 | 'lockdelay=i', # Time delay in seconds between lock tries | ||
| 99 | 'lockmethod=s', # Set the method of locking | ||
| 100 | 'locktries=i', # Number of tries in locking an archive | ||
| 101 | 'mailtourl=s', # URL to use for e-mail address hyperlinks | ||
| 102 | 'main', # Create a main index | ||
| 103 | 'maxpgs=i', # Maximum number of index pages | ||
| 104 | 'maxsize=i', # Maximum number of messages allowed in archive | ||
| 105 | 'mbox', # Use mailbox format (ignored now) | ||
| 106 | 'mh', # Use MH mail folders format (ignored now) | ||
| 107 | 'mhpattern=s', # Regular expression for message files in a directory | ||
| 108 | 'modifybodyaddresses', | ||
| 109 | # addressmodifycode applies to text entities | ||
| 110 | 'modtime', # Set modification time on files to message date | ||
| 111 | 'months=s', # Month names | ||
| 112 | 'monthsabr=s', # Abbreviated month names | ||
| 113 | 'msgexcfilter=s', | ||
| 114 | # Perl expression(s) for selective message exclusion | ||
| 115 | 'msgpgs', # Create message pages | ||
| 116 | 'msgsep=s', # Message separator for mailbox files | ||
| 117 | 'msgprefix=s', # Filename prefix for message files | ||
| 118 | 'multipg', # Generate multi-page indexes | ||
| 119 | 'news', # Add links to newsgroups | ||
| 120 | 'newsurl=s', # URL to use for news hyperlinks | ||
| 121 | 'noauthsort', # Do not sort by author | ||
| 122 | 'noarchive', # Do not create an archive | ||
| 123 | 'nochecknoarchive', | ||
| 124 | # Do not check for 'no archive' flag in messages | ||
| 125 | 'noconlen', # Ignore Content-Length fields | ||
| 126 | 'nodecodeheads', | ||
| 127 | # Do not decode 1522 encoded data in message headers | ||
| 128 | 'nodoc', # Do not print link to doc at end of index page | ||
| 129 | 'nofasttempfiles', | ||
| 130 | # Use random filenames for temporary files | ||
| 131 | 'nofollowsymlinks', | ||
| 132 | # Do not follow symlinks when creating files | ||
| 133 | 'nofolrefs', # Do not print links to explicit follow-ups/references | ||
| 134 | 'nogzipfiles', # Do not Gzip files | ||
| 135 | 'nogziplinks', # Do not add '.gz' extensions to files | ||
| 136 | 'nokeeponrmm', # Delete message files on archive remove | ||
| 137 | 'nolock', # Do no archive locking | ||
| 138 | 'nomailto', # Do not add in mailto links for e-mail addresses | ||
| 139 | 'nomain', # Do not create a main index | ||
| 140 | 'nomsgpgs', # Do not create message pages | ||
| 141 | 'nomodtime', # Do no set modification time on files to message date | ||
| 142 | 'nomultipg', # Do not generate multi-page indexes | ||
| 143 | 'nonews', # Do not add links to newsgroups | ||
| 144 | 'noposixstrftime', | ||
| 145 | # Use own implementation for time format process | ||
| 146 | 'noprintxcomments', | ||
| 147 | # Do not print X- comments | ||
| 148 | 'noreverse', # List messages in normal order | ||
| 149 | 'nosaveresources', | ||
| 150 | # Do not save resource values in db | ||
| 151 | 'nosort', # Do not sort | ||
| 152 | 'nospammode', # Do not run in (anti)spam mode | ||
| 153 | 'nosubsort', # Do not sort by subject | ||
| 154 | 'nosubjectthreads', | ||
| 155 | # Do not do subject based threading | ||
| 156 | 'nosubjecttxt=s', | ||
| 157 | # Text to use if message has no subject | ||
| 158 | 'notedir', # Location of notes | ||
| 159 | 'notetext=s@', # Text data of note | ||
| 160 | 'nothread', # Do not create threaded index | ||
| 161 | 'notreverse', # List oldest thread first | ||
| 162 | 'notsubsort|tnosubsort', | ||
| 163 | # Do not list threads by subject | ||
| 164 | 'notsort|tnosort', | ||
| 165 | # List threads by ordered processed | ||
| 166 | 'nourl', # Do not make URL hyperlinks | ||
| 167 | 'otherindex|otherindexes=s@', | ||
| 168 | # List of other rcfiles for extra indexes | ||
| 169 | 'outdir=s', # Destination of HTML files | ||
| 170 | 'pagenum=s', # Page to output if -genidx | ||
| 171 | 'perlinc=s@', # List of paths to search for MIME filters | ||
| 172 | 'posixstrftime', | ||
| 173 | # Use POSIX strftime() | ||
| 174 | 'printxcomments', | ||
| 175 | # Print X- comments | ||
| 176 | 'quiet', # No status messages while running | ||
| 177 | 'rcfile=s@', # Resource file for mhonarc | ||
| 178 | 'reconvert!', # Reconvert existing messages | ||
| 179 | 'varregex=s', # Regex matching resource variables | ||
| 180 | 'reverse', # List messages in reverse order | ||
| 181 | 'rmm', # Remove messages from an archive | ||
| 182 | 'savemem', # Write message data while processing | ||
| 183 | 'saveresources', | ||
| 184 | # Save resource values in db | ||
| 185 | 'scan', # List out archive contents to terminal | ||
| 186 | 'single', # Convert a single message to HTML | ||
| 187 | 'sort', # Sort messages in increasing date order | ||
| 188 | 'spammode', # Run in (anti)spam mode | ||
| 189 | 'stderr=s', # Set file for stderr | ||
| 190 | 'stdin=s', # Set file for stdin | ||
| 191 | 'stdout=s', # Set file for stdout | ||
| 192 | 'subjectarticlerxp=s', | ||
| 193 | # Regex for leading articles in subjects | ||
| 194 | 'subjectreplyrxp=s', | ||
| 195 | # Regex for leading reply string in subjects | ||
| 196 | 'subjectstripcode=s', | ||
| 197 | # Perl expression for modifying subjects | ||
| 198 | 'subjectthreads', | ||
| 199 | # Check subjects for threads | ||
| 200 | 'subsort', # Sort message by subject | ||
| 201 | 'tidxfname=s', # File name of threaded index page | ||
| 202 | 'tidxprefix=s', # Filename prefix for multi-page thread index | ||
| 203 | 'time', # Print processing time | ||
| 204 | 'title=s', # Title of index page | ||
| 205 | 'ttitle=s', # Title of threaded index page | ||
| 206 | 'thread', # Create threaded index | ||
| 207 | 'tlevels=i', # Maximum # of nested lists in threaded index | ||
| 208 | 'treverse', # Reverse order of thread listing | ||
| 209 | 'tslice=s', # Set size of thread slice listing | ||
| 210 | 'tslicelevels=i', | ||
| 211 | # Maximum # of nested lists in thread slices | ||
| 212 | 'tsort', # List threads by date | ||
| 213 | 'tsubsort', # List threads by subject | ||
| 214 | 'umask=i', # Set umask of process | ||
| 215 | 'url', # Make URL hyperlinks | ||
| 216 | 'weekdays=s', # Weekday names | ||
| 217 | 'weekdaysabr=s', | ||
| 218 | # Abbreviated weekday names | ||
| 219 | |||
| 220 | ## API (only?) options | ||
| 221 | 'noarg', # Just load code | ||
| 222 | 'readdb', # Just read db | ||
| 223 | |||
| 224 | 'v', # Version information | ||
| 225 | 'help' # A brief usage message | ||
| 226 | ); | ||
| 227 | |||
| 228 | ## Check for help/version options (nothing to do) | ||
| 229 | if ($opt{'help'}) { &usage(); return 0; } | ||
| 230 | if ($opt{'v'}) { &version(); return 0; } | ||
| 231 | if ($opt{'debug'}) { | ||
| 232 | $DEBUG = 1; | ||
| 233 | } | ||
| 234 | |||
| 235 | ## Check std{in,out,err} options | ||
| 236 | DUP: { | ||
| 237 | $MhaStdin = \*STDIN; | ||
| 238 | #$MhaStdout = \*STDOUT; | ||
| 239 | #$MhaStderr = \*STDERR; | ||
| 240 | STDOUTERR: { | ||
| 241 | if (defined($opt{'stdout'}) && !ref($opt{'stdout'})) { | ||
| 242 | open(STDOUT, ">>$opt{'stdout'}") | ||
| 243 | || die qq/ERROR: Unable to create "$opt{'stdout'}": $!\n/; | ||
| 244 | if ($opt{'stderr'} eq $opt{'stdout'}) { | ||
| 245 | open(STDERR, ">&STDOUT") | ||
| 246 | || die qq/ERROR: Unable to dup STDOUT: $!\n/; | ||
| 247 | last STDOUTERR; | ||
| 248 | } | ||
| 249 | } | ||
| 250 | if (defined($opt{'stderr'}) && !ref($opt{'stderr'})) { | ||
| 251 | open(STDERR, ">>$opt{'stderr'}") | ||
| 252 | || die qq/ERROR: Unable to create "$opt{'stderr'}": $!\n/; | ||
| 253 | } | ||
| 254 | } | ||
| 255 | if (defined($opt{'stdin'})) { | ||
| 256 | if (ref($opt{'stdin'})) { | ||
| 257 | $MhaStdin = $opt{'stdin'}; | ||
| 258 | } else { | ||
| 259 | open(STDIN, "<$opt{'stdin'}") | ||
| 260 | || die qq/ERROR: Unable to open "$opt{'stdin'}": $!\n/; | ||
| 261 | $MhaStdin = \*STDIN; | ||
| 262 | } | ||
| 263 | } | ||
| 264 | my $curfh = select(STDOUT); | ||
| 265 | $| = 1; | ||
| 266 | select(STDERR); | ||
| 267 | $| = 1; | ||
| 268 | select($curfh); | ||
| 269 | } | ||
| 270 | |||
| 271 | ## Initialize variables | ||
| 272 | require 'mhinit.pl'; | ||
| 273 | &mhinit_vars(); | ||
| 274 | |||
| 275 | ## These options have NO resource file equivalent. | ||
| 276 | $NoArg = $opt{'noarg'}; | ||
| 277 | $ReadDB = $opt{'readdb'}; | ||
| 278 | |||
| 279 | $ADD = $opt{'add'}; | ||
| 280 | $RMM = $opt{'rmm'}; | ||
| 281 | $SCAN = $opt{'scan'}; | ||
| 282 | $QUIET = $opt{'quiet'}; | ||
| 283 | $EDITIDX = $opt{'editidx'}; | ||
| 284 | $ANNOTATE = $opt{'annotate'}; | ||
| 285 | $AFS = $opt{'afs'}; | ||
| 286 | if ($opt{'genidx'}) { | ||
| 287 | $IDXONLY = 1; | ||
| 288 | $QUIET = 1; | ||
| 289 | $ADD = 0; | ||
| 290 | } else { | ||
| 291 | $IDXONLY = 0; | ||
| 292 | } | ||
| 293 | if ($opt{'single'} && !$RMM && !$ANNOTATE) { | ||
| 294 | $SINGLE = 1; | ||
| 295 | $QUIET = 1; | ||
| 296 | } else { | ||
| 297 | $SINGLE = 0; | ||
| 298 | } | ||
| 299 | $ReadDB = 1 | ||
| 300 | if ($ADD | ||
| 301 | || $EDITIDX | ||
| 302 | || $RMM | ||
| 303 | || $ANNOTATE | ||
| 304 | || $SCAN | ||
| 305 | || $IDXONLY); | ||
| 306 | $DoArchive = 1 if $opt{'archive'}; | ||
| 307 | $DoArchive = 0 if $opt{'noarchive'}; | ||
| 308 | |||
| 309 | $Reconvert = $opt{'reconvert'} if defined($opt{'reconvert'}); | ||
| 310 | |||
| 311 | my $dolock = !$NoArg && !$opt{'nolock'}; | ||
| 312 | |||
| 313 | ## Check argv | ||
| 314 | unless (($#ARGV >= 0) | ||
| 315 | || $ADD | ||
| 316 | || $SINGLE | ||
| 317 | || $EDITIDX | ||
| 318 | || $SCAN | ||
| 319 | || $IDXONLY | ||
| 320 | || $ReadDB | ||
| 321 | || !$DoArchive | ||
| 322 | || $NoArg) { | ||
| 323 | usage(); | ||
| 324 | return -1; | ||
| 325 | } | ||
| 326 | |||
| 327 | ## Require needed libraries | ||
| 328 | require 'ewhutil.pl'; | ||
| 329 | require 'mhtime.pl'; | ||
| 330 | require 'mhfile.pl'; | ||
| 331 | require 'mhutil.pl'; | ||
| 332 | require 'mhrcfile.pl'; | ||
| 333 | require 'mhscan.pl' if $SCAN; | ||
| 334 | require 'mhsingle.pl' if $SINGLE; | ||
| 335 | require 'mhrmm.pl' if $RMM; | ||
| 336 | require 'mhnote.pl' if $ANNOTATE; | ||
| 337 | if (!$SCAN) { | ||
| 338 | # require readmail library | ||
| 339 | require 'readmail.pl'; | ||
| 340 | mhinit_readmail_vars(); | ||
| 341 | } | ||
| 342 | |||
| 343 | print STDOUT "This is MHonArc v$VERSION, Perl $] $^O\n" unless $QUIET; | ||
| 344 | |||
| 345 | ## Check for locale/lang setting | ||
| 346 | $Lang = $opt{'lang'} if defined($opt{'lang'}); | ||
| 347 | |||
| 348 | ## Evaluate site local initialization | ||
| 349 | delete($INC{'mhasiteinit.pl'}); # force re-evaluation | ||
| 350 | eval { require 'mhasiteinit.pl'; }; # ignore status | ||
| 351 | |||
| 352 | ## Read default resource file | ||
| 353 | DEFRCFILE: { | ||
| 354 | if ($DefRcFile) { | ||
| 355 | last DEFRCFILE if read_resource_file($DefRcFile); | ||
| 356 | } | ||
| 357 | my $home_dir = $ENV{'HOME'}; | ||
| 358 | if (defined $home_dir) { | ||
| 359 | # check if in home directory | ||
| 360 | last DEFRCFILE | ||
| 361 | if read_resource_file(join($DIRSEP, $home_dir, $DefRcName), | ||
| 362 | 1); | ||
| 363 | } | ||
| 364 | local $_; | ||
| 365 | foreach (@INC) { | ||
| 366 | next if ($_ eq $home_dir); | ||
| 367 | last DEFRCFILE | ||
| 368 | if read_resource_file(join($DIRSEP, $_, $DefRcName), 1); | ||
| 369 | } | ||
| 370 | } | ||
| 371 | |||
| 372 | ## Grab a few options | ||
| 373 | @FMTFILE = @{$opt{'rcfile'}} if defined($opt{'rcfile'}); | ||
| 374 | $LOCKTRIES = $opt{'locktries'} | ||
| 375 | if defined($opt{'locktries'}) | ||
| 376 | && ($opt{'locktries'} > 0); | ||
| 377 | $LOCKDELAY = $opt{'lockdelay'} | ||
| 378 | if defined($opt{'lockdelay'}) | ||
| 379 | && ($opt{'lockdelay'} > 0); | ||
| 380 | $FORCELOCK = $opt{'force'}; | ||
| 381 | |||
| 382 | $LockMethod = &set_lock_mode($opt{'lockmethod'}) | ||
| 383 | if defined($opt{'lockmethod'}); | ||
| 384 | |||
| 385 | ## These options must be grabbed before reading the database file | ||
| 386 | ## since these options may tells us where the database file is. | ||
| 387 | $OUTDIR = $opt{'outdir'} if $opt{'outdir'}; | ||
| 388 | if (!$NoArg && !($SCAN || $IDXONLY || $SINGLE)) { | ||
| 389 | die qq/ERROR: "$OUTDIR" does not exist\n/ unless -e $OUTDIR; | ||
| 390 | if (!$AFS) { | ||
| 391 | die qq/ERROR: "$OUTDIR" is not readable\n/ unless -r $OUTDIR; | ||
| 392 | die qq/ERROR: "$OUTDIR" is not writable\n/ unless -w $OUTDIR; | ||
| 393 | die qq/ERROR: "$OUTDIR" is not executable\n/ unless -x $OUTDIR; | ||
| 394 | } | ||
| 395 | } | ||
| 396 | $DBFILE = $opt{'dbfile'} if $opt{'dbfile'}; | ||
| 397 | |||
| 398 | ## Create lock | ||
| 399 | $LOCKFILE = join($DIRSEP, $OUTDIR, $LOCKFILE); | ||
| 400 | if ($dolock && $DoArchive && !$SINGLE) { | ||
| 401 | if (!&$LockFunc($LOCKFILE, $LOCKTRIES, $LOCKDELAY, $FORCELOCK)) { | ||
| 402 | $! = 75; # EX_TEMPFAIL (for sendmail) | ||
| 403 | die("ERROR: Unable to lock $OUTDIR after $LOCKTRIES tries\n"); | ||
| 404 | } | ||
| 405 | } | ||
| 406 | |||
| 407 | ## Check if we need to access database file | ||
| 408 | if ($ReadDB) { | ||
| 409 | $DBPathName = | ||
| 410 | OSis_absolute_path($DBFILE) | ||
| 411 | ? $DBFILE | ||
| 412 | : join($DIRSEP, $OUTDIR, $DBFILE); | ||
| 413 | |||
| 414 | ## Invoke preload callback | ||
| 415 | if (defined($CBDbPreLoad) && defined(&$CBDbPreLoad)) { | ||
| 416 | &$CBDbPreLoad($DBPathName); | ||
| 417 | } | ||
| 418 | if (-e $DBPathName) { | ||
| 419 | print STDOUT "Reading database ...\n" unless $QUIET; | ||
| 420 | |||
| 421 | ## Just perform a require. Delete %INC entry to force | ||
| 422 | ## evaluation. | ||
| 423 | delete $INC{$DBPathName}; | ||
| 424 | require($DBPathName) | ||
| 425 | || die("ERROR: Database read error of $DBPathName\n"); | ||
| 426 | |||
| 427 | ## Check db version with program version | ||
| 428 | if ($VERSION ne $DbVERSION) { | ||
| 429 | warn "Warning: Database ($DbVERSION) != ", | ||
| 430 | "program ($VERSION) version.\n"; | ||
| 431 | } | ||
| 432 | |||
| 433 | ## Check for 1.x archive, and update data as needed | ||
| 434 | if ($DbVERSION =~ /^1\./) { | ||
| 435 | print STDOUT "Updating database $DbVERSION data ...\n" | ||
| 436 | unless $QUIET; | ||
| 437 | &update_data_1_to_2(); | ||
| 438 | &update_data_2_1_to_later(); | ||
| 439 | &update_data_2_4_to_later(); | ||
| 440 | |||
| 441 | ## Check for 2.[0-4] archive | ||
| 442 | } elsif ($DbVERSION =~ /^2\.[0-4]\./) { | ||
| 443 | print STDOUT "Updating database $DbVERSION data ...\n" | ||
| 444 | unless $QUIET; | ||
| 445 | if ($DbVERSION =~ /^2\.[01]\./) { | ||
| 446 | &update_data_2_1_to_later(); | ||
| 447 | } | ||
| 448 | &update_data_2_4_to_later(); | ||
| 449 | } | ||
| 450 | |||
| 451 | ## Set %Follow here just incase it does not get recomputed | ||
| 452 | %Follow = %FollowOld; | ||
| 453 | |||
| 454 | ## Check if %Time is defined | ||
| 455 | if (!%Time) { | ||
| 456 | my ($k, $v); | ||
| 457 | while (($k, $v) = each %IndexNum) { | ||
| 458 | $Time{$k} = (split(/$X/o, $k, 2))[0]; | ||
| 459 | } | ||
| 460 | } | ||
| 461 | if ($DoFromAddr && !%FromAddr) { | ||
| 462 | my ($k, $v); | ||
| 463 | while (($k, $v) = each %From) { | ||
| 464 | $FromAddr{$k} = extract_email_address($v); | ||
| 465 | } | ||
| 466 | } | ||
| 467 | if ($DoFromName && !%FromName) { | ||
| 468 | my ($k, $v); | ||
| 469 | while (($k, $v) = each %From) { | ||
| 470 | $FromName{$k} = extract_email_name($v); | ||
| 471 | } | ||
| 472 | } | ||
| 473 | } | ||
| 474 | if (!$IDXONLY) { | ||
| 475 | if ($#ARGV < 0) { $ADDSINGLE = 1; } # See if adding single mesg | ||
| 476 | else { $ADDSINGLE = 0; } | ||
| 477 | $ADD = $MhaStdin; | ||
| 478 | } | ||
| 479 | } | ||
| 480 | my ($OldMULTIIDX) = $MULTIIDX; | ||
| 481 | |||
| 482 | ## Remove lock if db not going to be changed | ||
| 483 | if ($SCAN || $IDXONLY) { | ||
| 484 | &$UnlockFunc(); | ||
| 485 | } | ||
| 486 | |||
| 487 | ## Clear thread flag if genidx, must be explicitly set | ||
| 488 | $THREAD = 0 if $IDXONLY; | ||
| 489 | |||
| 490 | ## Read resource file(s) | ||
| 491 | ## Look for resource in outdir unless existing according to | ||
| 492 | ## current value. | ||
| 493 | foreach (@FMTFILE) { | ||
| 494 | $_ = join($DIRSEP, $OUTDIR, $_) unless -e $_; | ||
| 495 | &read_resource_file($_); | ||
| 496 | } | ||
| 497 | |||
| 498 | ## Set locale | ||
| 499 | eval { | ||
| 500 | require POSIX; | ||
| 501 | if ($Lang) { | ||
| 502 | POSIX::setlocale(&POSIX::LC_ALL, $Lang); | ||
| 503 | } else { | ||
| 504 | POSIX::setlocale(&POSIX::LC_ALL, ''); | ||
| 505 | } | ||
| 506 | }; | ||
| 507 | if ($@ && $Lang) { | ||
| 508 | warn qq/Warning: Setting locale appears to not be supported: $@\n/; | ||
| 509 | } | ||
| 510 | |||
| 511 | ## Re-check readmail settings | ||
| 512 | if (!$SCAN) { | ||
| 513 | # If text encoding has been specified, change $MHeadCnvFunc. | ||
| 514 | if (defined(readmail::load_textencoder())) { | ||
| 515 | $MHeadCnvFunc = \&htmlize_enc_head; | ||
| 516 | } | ||
| 517 | } | ||
| 518 | |||
| 519 | ## Check if extension for HTML files defined on the command-line | ||
| 520 | $HtmlExt = $opt{'htmlext'} if defined($opt{'htmlext'}); | ||
| 521 | |||
| 522 | ## Other indexes resource files | ||
| 523 | if (defined($opt{'otherindex'})) { | ||
| 524 | my @array = (); | ||
| 525 | local ($_); | ||
| 526 | foreach (@{$opt{'otherindex'}}) { | ||
| 527 | push(@array, split(/$PATHSEP/o, $_)); | ||
| 528 | } | ||
| 529 | unshift(@OtherIdxs, @array); | ||
| 530 | } | ||
| 531 | |||
| 532 | ## Perl INC paths | ||
| 533 | if (defined($opt{'perlinc'})) { | ||
| 534 | my @array = (); | ||
| 535 | local ($_); | ||
| 536 | foreach (@{$opt{'perlinc'}}) { | ||
| 537 | push(@array, split(/$PATHSEP/o, $_)); | ||
| 538 | } | ||
| 539 | unshift(@PerlINC, @array); | ||
| 540 | } | ||
| 541 | |||
| 542 | @OtherIdxs = remove_dups(\@OtherIdxs); | ||
| 543 | @PerlINC = remove_dups(\@PerlINC); | ||
| 544 | unshift(@INC, @PerlINC); | ||
| 545 | |||
| 546 | ## Set alternative prefs | ||
| 547 | if (!$SCAN) { | ||
| 548 | readmail::MAILset_alternative_prefs(@MIMEAltPrefs); | ||
| 549 | $IsDefault{'MIMEALTPREFS'} = !scalar(@MIMEAltPrefs); | ||
| 550 | } | ||
| 551 | |||
| 552 | ## Get other command-line options | ||
| 553 | $DBFILE = $opt{'dbfile'} if $opt{'dbfile'}; # Override db | ||
| 554 | $DBPathName = | ||
| 555 | OSis_absolute_path($DBFILE) | ||
| 556 | ? $DBFILE | ||
| 557 | : join($DIRSEP, $OUTDIR, $DBFILE); | ||
| 558 | |||
| 559 | $DOCURL = $opt{'docurl'} if $opt{'docurl'}; | ||
| 560 | $FROM = $opt{'msgsep'} if $opt{'msgsep'}; | ||
| 561 | $IDXPREFIX = $opt{'idxprefix'} if $opt{'idxprefix'}; | ||
| 562 | $IDXSIZE = $opt{'idxsize'} if defined($opt{'idxsize'}); | ||
| 563 | $IDXSIZE *= -1 if $IDXSIZE < 0; | ||
| 564 | $OUTDIR = $opt{'outdir'} if $opt{'outdir'}; # Override db | ||
| 565 | $MAILTOURL = $opt{'mailtourl'} if $opt{'mailtourl'}; | ||
| 566 | $NewsUrl = $opt{'newsurl'} if $opt{'newsurl'}; | ||
| 567 | $MAXPGS = $opt{'maxpgs'} if defined($opt{'maxpgs'}); | ||
| 568 | $MAXPGS = 0 if $MAXPGS < 0; | ||
| 569 | $MAXSIZE = $opt{'maxsize'} if defined($opt{'maxsize'}); | ||
| 570 | $MAXSIZE = 0 if $MAXSIZE < 0; | ||
| 571 | $MHPATTERN = $opt{'mhpattern'} if $opt{'mhpattern'}; | ||
| 572 | $TIDXPREFIX = $opt{'tidxprefix'} if $opt{'tidxprefix'}; | ||
| 573 | $TITLE = $opt{'title'} if $opt{'title'}; | ||
| 574 | $TLEVELS = $opt{'tlevels'} if $opt{'tlevels'}; | ||
| 575 | $TTITLE = $opt{'ttitle'} if $opt{'ttitle'}; | ||
| 576 | $MsgPrefix = $opt{'msgprefix'} if defined($opt{'msgprefix'}); | ||
| 577 | $GzipExe = $opt{'gzipexe'} if $opt{'gzipexe'}; | ||
| 578 | $VarExp = $opt{'varregex'} | ||
| 579 | if $opt{'varregex'} | ||
| 580 | && ($opt{'varregex'} =~ /\S/); | ||
| 581 | $TSLICELEVELS = $opt{'tslicelevels'} if $opt{'tslicelevels'}; | ||
| 582 | $IconURLPrefix = $opt{'iconurlprefix'} if $opt{'iconurlprefix'}; | ||
| 583 | |||
| 584 | $IDXNAME = | ||
| 585 | $opt{'idxfname'} | ||
| 586 | || $IDXNAME | ||
| 587 | || $ENV{'M2H_IDXFNAME'} | ||
| 588 | || "maillist.$HtmlExt"; | ||
| 589 | $TIDXNAME = | ||
| 590 | $opt{'tidxfname'} | ||
| 591 | || $TIDXNAME | ||
| 592 | || $ENV{'M2H_TIDXFNAME'} | ||
| 593 | || "threads.$HtmlExt"; | ||
| 594 | |||
| 595 | $ExpireDate = $opt{'expiredate'} if $opt{'expiredate'}; | ||
| 596 | $ExpireTime = $opt{'expireage'} if $opt{'expireage'}; | ||
| 597 | $ExpireTime *= -1 if $ExpireTime < 0; | ||
| 598 | |||
| 599 | $GMTDateFmt = $opt{'gmtdatefmt'} if $opt{'gmtdatefmt'}; | ||
| 600 | $LocalDateFmt = $opt{'localdatefmt'} if $opt{'localdatefmt'}; | ||
| 601 | |||
| 602 | $AddressModify = $opt{'addressmodifycode'} if $opt{'addressmodifycode'}; | ||
| 603 | $SubArtRxp = $opt{'subjectarticlerxp'} if $opt{'subjectarticlerxp'}; | ||
| 604 | $SubReplyRxp = $opt{'subjectreplyrxp'} if $opt{'subjectreplyrxp'}; | ||
| 605 | $SubStripCode = $opt{'subjectstripcode'} if $opt{'subjectstripcode'}; | ||
| 606 | $MsgExcFilter = $opt{'msgexcfilter'} if defined($opt{'msgexcfilter'}); | ||
| 607 | |||
| 608 | $NoSubjectTxt = $opt{'nosubjecttxt'} if $opt{'nosubjecttxt'}; | ||
| 609 | |||
| 610 | $IdxPageNum = $opt{'pagenum'} if defined($opt{'pagenum'}); | ||
| 611 | |||
| 612 | $AttachmentDir = $opt{'attachmentdir'} if defined($opt{'attachmentdir'}); | ||
| 613 | $AttachmentUrl = $opt{'attachmenturl'} if defined($opt{'attachmenturl'}); | ||
| 614 | |||
| 615 | ## Determine location of message note files | ||
| 616 | $NoteDir = $opt{'notedir'} if $opt{'notedir'}; | ||
| 617 | |||
| 618 | ## See if note text defined on command-line | ||
| 619 | if (defined $opt{'notetext'}) { | ||
| 620 | $NoteText = join(" ", @{$opt{'notetext'}}); | ||
| 621 | } else { | ||
| 622 | $NoteText = undef; | ||
| 623 | } | ||
| 624 | |||
| 625 | ## Parse any rc variable definition from command-line | ||
| 626 | if (defined($opt{'definevar'})) { | ||
| 627 | my @array = (); | ||
| 628 | foreach (@{$opt{'definevar'}}) { | ||
| 629 | push(@array, &parse_vardef_str($_)); | ||
| 630 | } | ||
| 631 | %CustomRcVars = (%CustomRcVars, @array); | ||
| 632 | } | ||
| 633 | |||
| 634 | $CONLEN = 1 if $opt{'conlen'}; | ||
| 635 | $CONLEN = 0 if $opt{'noconlen'}; | ||
| 636 | $MAIN = 1 if $opt{'main'}; | ||
| 637 | $MAIN = 0 if $opt{'nomain'}; | ||
| 638 | $MODTIME = 1 if $opt{'modtime'}; | ||
| 639 | $MODTIME = 0 if $opt{'nomodtime'}; | ||
| 640 | $MULTIIDX = 1 if $opt{'multipg'}; | ||
| 641 | $MULTIIDX = 0 if $opt{'nomultipg'}; | ||
| 642 | $NODOC = 0 if $opt{'doc'}; | ||
| 643 | $NODOC = 1 if $opt{'nodoc'}; | ||
| 644 | $NOMAILTO = 1 if $opt{'nomailto'}; | ||
| 645 | $NONEWS = 0 if $opt{'news'}; | ||
| 646 | $NONEWS = 1 if $opt{'nonews'}; | ||
| 647 | $NOURL = 0 if $opt{'url'}; | ||
| 648 | $NOURL = 1 if $opt{'nourl'}; | ||
| 649 | $SLOW = 1 if $opt{'savemem'}; | ||
| 650 | $THREAD = 1 if $opt{'thread'}; | ||
| 651 | $THREAD = 0 if $opt{'nothread'}; | ||
| 652 | $TREVERSE = 1 if $opt{'treverse'}; | ||
| 653 | $TREVERSE = 0 if $opt{'notreverse'}; | ||
| 654 | $DoFolRefs = 1 if $opt{'folrefs'}; | ||
| 655 | $DoFolRefs = 0 if $opt{'nofolrefs'}; | ||
| 656 | $GzipFiles = 1 if $opt{'gzipfiles'}; | ||
| 657 | $GzipFiles = 0 if $opt{'nogzipfiles'}; | ||
| 658 | $GzipLinks = 1 if $opt{'gziplinks'}; | ||
| 659 | $GzipLinks = 0 if $opt{'nogziplinks'}; | ||
| 660 | $NoMsgPgs = 0 if $opt{'msgpgs'}; | ||
| 661 | $NoMsgPgs = 1 if $opt{'nomsgpgs'}; | ||
| 662 | $SaveRsrcs = 1 if $opt{'saveresources'}; | ||
| 663 | $SaveRsrcs = 0 if $opt{'nosaveresources'}; | ||
| 664 | $SpamMode = 1 if $opt{'spammode'}; | ||
| 665 | $SpamMode = 0 if $opt{'nospammode'}; | ||
| 666 | $KeepOnRmm = 1 if $opt{'keeponrmm'}; | ||
| 667 | $KeepOnRmm = 0 if $opt{'nokeeponrmm'}; | ||
| 668 | |||
| 669 | $PrintXComments = 1 if $opt{'printxcomments'}; | ||
| 670 | $PrintXComments = 0 if $opt{'noprintxcomments'}; | ||
| 671 | |||
| 672 | $CheckNoArchive = 1 if $opt{'checknoarchive'}; | ||
| 673 | $CheckNoArchive = 0 if $opt{'nochecknoarchive'}; | ||
| 674 | $FastTempFiles = 1 if $opt{'fasttempfiles'}; | ||
| 675 | $FastTempFiles = 0 if $opt{'nofasttempfiles'}; | ||
| 676 | $FollowSymlinks = 1 if $opt{'followsymlinks'}; | ||
| 677 | $FollowSymlinks = 0 if $opt{'nofollowsymlinks'}; | ||
| 678 | $POSIXstrftime = 1 if $opt{'posixstrftime'}; | ||
| 679 | $POSIXstrftime = 0 if $opt{'noposixstrftime'}; | ||
| 680 | |||
| 681 | $AddrModifyBodies = 1 if $opt{'modifybodyaddresses'}; | ||
| 682 | $AddrModifyBodies = 0 if $opt{'nomodifybodyaddresses'}; | ||
| 683 | |||
| 684 | $DecodeHeads = 1 if $opt{'decodeheads'}; | ||
| 685 | $DecodeHeads = 0 if $opt{'nodecodeheads'}; | ||
| 686 | $readmail::DecodeHeader = $DecodeHeads; | ||
| 687 | |||
| 688 | ## Clear main flag if genidx and thread specified | ||
| 689 | $MAIN = 0 if $IDXONLY && $THREAD; | ||
| 690 | |||
| 691 | @DateFields = split(/[:;]/, $opt{'datefields'}) if $opt{'datefields'}; | ||
| 692 | @FromFields = split(/[:;]/, $opt{'fromfields'}) if $opt{'fromfields'}; | ||
| 693 | foreach (@FromFields) { s/\s//g; tr/A-Z/a-z/; } | ||
| 694 | |||
| 695 | ($TSliceNBefore, $TSliceNAfter, $TSliceInclusive) = | ||
| 696 | split(/[:;]/, $opt{'tslice'}) | ||
| 697 | if $opt{'tslice'}; | ||
| 698 | |||
| 699 | @Months = split(/:/, $opt{'months'}) if defined($opt{'months'}); | ||
| 700 | @months = split(/:/, $opt{'monthsabr'}) if defined($opt{'monthsabr'}); | ||
| 701 | @Weekdays = split(/:/, $opt{'weekdays'}) if defined($opt{'weekdays'}); | ||
| 702 | @weekdays = split(/:/, $opt{'weekdaysabr'}) | ||
| 703 | if defined($opt{'weekdaysabr'}); | ||
| 704 | |||
| 705 | $MULTIIDX = 0 if !$IDXSIZE; | ||
| 706 | |||
| 707 | ## Set umask | ||
| 708 | if ($UNIX) { | ||
| 709 | $UMASK = $opt{'umask'} if defined($opt{'umask'}); | ||
| 710 | eval { umask oct($UMASK); }; | ||
| 711 | } | ||
| 712 | $FilePerms = $opt{'fileperms'} if defined($opt{'fileperms'}); | ||
| 713 | $FilePermsOct = oct($FilePerms); | ||
| 714 | $DbFilePerms = $opt{'dbfileperms'} if defined($opt{'dbfileperms'}); | ||
| 715 | $DbFilePermsOct = oct($DbFilePerms); | ||
| 716 | |||
| 717 | ## Get sort method | ||
| 718 | $AUTHSORT = 1 if $opt{'authsort'}; | ||
| 719 | $AUTHSORT = 0 if $opt{'noauthsort'}; | ||
| 720 | $SUBSORT = 1 if $opt{'subsort'}; | ||
| 721 | $SUBSORT = 0 if $opt{'nosubsort'}; | ||
| 722 | $NOSORT = 1 if $opt{'nosort'}; | ||
| 723 | $NOSORT = 0 if $opt{'sort'}; | ||
| 724 | $REVSORT = 1 if $opt{'reverse'}; | ||
| 725 | $REVSORT = 0 if $opt{'noreverse'}; | ||
| 726 | if ($NOSORT) { | ||
| 727 | $SUBSORT = 0; | ||
| 728 | $AUTHSORT = 0; | ||
| 729 | } elsif ($SUBSORT) { | ||
| 730 | $AUTHSORT = 0; | ||
| 731 | } | ||
| 732 | |||
| 733 | ## Check for thread listing order | ||
| 734 | $TSUBSORT = 1 if $opt{'tsubsort'}; | ||
| 735 | $TSUBSORT = 0 if $opt{'notsubsort'}; | ||
| 736 | $TNOSORT = 1 if $opt{'notsort'}; | ||
| 737 | $TNOSORT = 0 if $opt{'tsort'}; | ||
| 738 | $TREVERSE = 1 if $opt{'treverse'}; | ||
| 739 | $TREVERSE = 0 if $opt{'notreverse'}; | ||
| 740 | if ($TNOSORT) { | ||
| 741 | $TSUBSORT = 0; | ||
| 742 | } | ||
| 743 | $NoSubjectThreads = 1 if $opt{'nosubjectthreads'}; | ||
| 744 | $NoSubjectThreads = 0 if $opt{'subjectthreads'}; | ||
| 745 | |||
| 746 | ## Check if all messages must be updated (this has been simplified; | ||
| 747 | ## any serious change should be done via editidx). | ||
| 748 | if ($EDITIDX || ($OldMULTIIDX != $MULTIIDX)) { | ||
| 749 | $UPDATE_ALL = 1; | ||
| 750 | } else { | ||
| 751 | $UPDATE_ALL = 0; | ||
| 752 | } | ||
| 753 | |||
| 754 | ## Clean up list-based resources | ||
| 755 | @ExtraHFields = remove_dups(\@ExtraHFields); | ||
| 756 | @FieldOrder = remove_dups(\@FieldOrder); | ||
| 757 | |||
| 758 | ## Set date names | ||
| 759 | &set_date_names(\@weekdays, \@Weekdays, \@months, \@Months); | ||
| 760 | |||
| 761 | ## Set %Zone with user-specified timezones | ||
| 762 | while (($zone, $offset) = each(%ZoneUD)) { | ||
| 763 | $Zone{$zone} = $offset; | ||
| 764 | } | ||
| 765 | |||
| 766 | ## Require some more libaries | ||
| 767 | require 'mhidxrc.pl'; | ||
| 768 | &mhidxrc_set_vars(); | ||
| 769 | require 'mhdysub.pl'; | ||
| 770 | &create_routines(); | ||
| 771 | require 'mhrcvars.pl'; | ||
| 772 | require 'mhindex.pl'; | ||
| 773 | require 'mhthread.pl'; | ||
| 774 | require 'mhdb.pl' unless $SCAN || $IDXONLY || !$DoArchive; | ||
| 775 | |||
| 776 | ## Load text clipping function | ||
| 777 | if (defined($TextClipSrc)) { | ||
| 778 | eval { require $TextClipSrc; }; | ||
| 779 | if ($@) { warn qq/Warning: $@\n/; } | ||
| 780 | } | ||
| 781 | if (!defined($TextClipFunc) || !defined(&$TextClipFunc)) { | ||
| 782 | $TextClipFunc = \&clip_text; | ||
| 783 | $TextClipSrc = undef; | ||
| 784 | $IsDefault{'TEXTCLIPFUNC'} = 1; | ||
| 785 | } else { | ||
| 786 | $IsDefault{'TEXTCLIPFUNC'} = 0; | ||
| 787 | } | ||
| 788 | |||
| 789 | ## Check if rewriting addresses in bodies | ||
| 790 | if ($AddrModifyBodies) { | ||
| 791 | $readmail::TextPreFilter = sub { | ||
| 792 | my $fields = shift; | ||
| 793 | my $data_r = shift; | ||
| 794 | # do not rewrite cid: URLs. | ||
| 795 | #$$data_r =~ s{($AddrExp)}{rewrite_raw_address($1)}geox; | ||
| 796 | $$data_r =~ s{ | ||
| 797 | ((?:cid:)?)($AddrExp) | ||
| 798 | }{ | ||
| 799 | ($1 eq "") ? rewrite_raw_address($2) : $1.$2; | ||
| 800 | }gieox; | ||
| 801 | } | ||
| 802 | } | ||
| 803 | |||
| 804 | ## Predefine %Index2TLoc in case of message deletion | ||
| 805 | if (@TListOrder) { | ||
| 806 | @Index2TLoc{@TListOrder} = (0 .. $#TListOrder); | ||
| 807 | } | ||
| 808 | |||
| 809 | ## Define %Index2MsgId hash | ||
| 810 | foreach (keys %MsgId) { | ||
| 811 | $Index2MsgId{$MsgId{$_}} = $_; | ||
| 812 | } | ||
| 813 | |||
| 814 | ## Set $ExpireDateTime from $ExpireDate | ||
| 815 | if ($ExpireDate) { | ||
| 816 | my @array = (); | ||
| 817 | if (@array = &parse_date($ExpireDate)) { | ||
| 818 | $ExpireDateTime = &get_time_from_date(@array[1 .. $#array]); | ||
| 819 | } else { | ||
| 820 | warn qq|Warning: Unable to parse EXPIREDATE, "$ExpireDate"\n|; | ||
| 821 | } | ||
| 822 | } | ||
| 823 | |||
| 824 | ## Get highest message number | ||
| 825 | if ($ADD) { | ||
| 826 | $LastMsgNum = &get_last_msg_num(); | ||
| 827 | } else { | ||
| 828 | $LastMsgNum = -1; | ||
| 829 | } | ||
| 830 | |||
| 831 | ## Delete bogus empty entries in hashes due to bug in earlier | ||
| 832 | ## versions to avoid any future problems. | ||
| 833 | delete($IndexNum{''}); | ||
| 834 | delete($Subject{''}); | ||
| 835 | delete($From{''}); | ||
| 836 | delete($MsgId{''}); | ||
| 837 | delete($FollowOld{''}); | ||
| 838 | delete($ContentType{''}); | ||
| 839 | delete($Refs{''}); | ||
| 840 | |||
| 841 | # update DOCURL if default old value | ||
| 842 | if ($DOCURL eq 'http://www.oac.uci.edu/indiv/ehood/mhonarc.html') { | ||
| 843 | $DOCURL = 'http://www.mhonarc.org/'; | ||
| 844 | } | ||
| 845 | |||
| 846 | ## Check if printing process time | ||
| 847 | $TIME = $opt{'time'}; | ||
| 848 | |||
| 849 | 1; | ||
| 850 | } | ||
| 851 | |||
| 852 | ##--------------------------------------------------------------------------- | ||
| 853 | ## Version routine | ||
| 854 | ## | ||
| 855 | sub version { | ||
| 856 | select(STDOUT); | ||
| 857 | print $VINFO; | ||
| 858 | } | ||
| 859 | |||
| 860 | ##--------------------------------------------------------------------------- | ||
| 861 | ## Usage routine | ||
| 862 | ## | ||
| 863 | sub usage { | ||
| 864 | require 'mhusage.pl'; | ||
| 865 | &mhusage(); | ||
| 866 | } | ||
| 867 | |||
| 868 | ##--------------------------------------------------------------------------- | ||
| 869 | ## Routine to update 1.x data structures to 2.0. | ||
| 870 | ## | ||
| 871 | sub update_data_1_to_2 { | ||
| 872 | local (%EntName2Char) = ('lt', '<', 'gt', '>', 'amp', '&',); | ||
| 873 | #-------------------------------------- | ||
| 874 | sub entname_to_char { | ||
| 875 | my ($name) = shift; | ||
| 876 | my ($ret) = $EntName2Char{$name}; | ||
| 877 | if (!$ret) { | ||
| 878 | $ret = "&$name;"; | ||
| 879 | } | ||
| 880 | $ret; | ||
| 881 | } | ||
| 882 | #-------------------------------------- | ||
| 883 | my ($index); | ||
| 884 | foreach $index (keys %From) { | ||
| 885 | $From{$index} =~ s/\&([\w\-.]+);/&entname_to_char($1)/ge; | ||
| 886 | } | ||
| 887 | foreach $index (keys %Subject) { | ||
| 888 | $Subject{$index} =~ s/\&([\w\-.]+);/&entname_to_char($1)/ge; | ||
| 889 | } | ||
| 890 | delete $IndexNum{''}; | ||
| 891 | $TLITXT = '<li>' . $TLITXT unless ($TLITXT) && ($TLITXT =~ /<li>/i); | ||
| 892 | $THEAD .= "<ul>\n" unless ($THEAD) && ($THEAD =~ m%<ul>\s*$%i); | ||
| 893 | $TFOOT = "</ul>\n" unless ($TFOOT) && ($TFOOT =~ m%^\s*</ul>%i); | ||
| 894 | } | ||
| 895 | |||
| 896 | ##--------------------------------------------------------------------------- | ||
| 897 | ## Update 2.1, or earlier, data. | ||
| 898 | ## | ||
| 899 | sub update_data_2_1_to_later { | ||
| 900 | no warnings qw(deprecated); | ||
| 901 | # we can preserve filter arguments | ||
| 902 | if (%main::MIMEFiltersArgs) { | ||
| 903 | warn qq/ preserving MIMEARGS...\n/; | ||
| 904 | %readmail::MIMEFiltersArgs = %main::MIMEFiltersArgs; | ||
| 905 | $IsDefault{'MIMEARGS'} = 0; | ||
| 906 | } | ||
| 907 | } | ||
| 908 | |||
| 909 | ##--------------------------------------------------------------------------- | ||
| 910 | ## Update 2.4, or earlier, data. | ||
| 911 | ## | ||
| 912 | sub update_data_2_4_to_later { | ||
| 913 | # convert Perl 4 style data to Perl 5 style | ||
| 914 | my ($index, $value); | ||
| 915 | while (($index, $value) = each(%Refs)) { | ||
| 916 | next if ref($value); | ||
| 917 | $Refs{$index} = [split(/$X/o, $value)]; | ||
| 918 | } | ||
| 919 | while (($index, $value) = each(%FollowOld)) { | ||
| 920 | next if ref($value); | ||
| 921 | $FollowOld{$index} = [split(/$bs/o, $value)]; | ||
| 922 | } | ||
| 923 | while (($index, $value) = each(%Derived)) { | ||
| 924 | next if ref($value); | ||
| 925 | $Derived{$index} = [split(/$X/o, $value)]; | ||
| 926 | } | ||
| 927 | } | ||
| 928 | |||
| 929 | ##--------------------------------------------------------------------------- | ||
| 930 | ## Initialize readmail.pl variables | ||
| 931 | ## | ||
| 932 | sub mhinit_readmail_vars { | ||
| 933 | $readmail::DEBUG = $DEBUG; | ||
| 934 | |||
| 935 | ## Default decoders | ||
| 936 | %readmail::MIMEDecoders = ( | ||
| 937 | '7bit' => 'as-is', | ||
| 938 | '8bit' => 'as-is', | ||
| 939 | 'binary' => 'as-is', | ||
| 940 | 'base64' => 'base64::b64decode', | ||
| 941 | 'quoted-printable' => 'quoted_printable::qprdecode', | ||
| 942 | 'x-uuencode' => 'base64::uudecode', | ||
| 943 | 'x-uue' => 'base64::uudecode', | ||
| 944 | 'uuencode' => 'base64::uudecode', | ||
| 945 | ); | ||
| 946 | %readmail::MIMEDecodersSrc = ( | ||
| 947 | 'base64' => 'base64.pl', | ||
| 948 | 'quoted-printable' => 'qprint.pl', | ||
| 949 | 'x-uuencode' => 'base64.pl', | ||
| 950 | 'x-uue' => 'base64.pl', | ||
| 951 | 'uuencode' => 'base64.pl', | ||
| 952 | ); | ||
| 953 | $IsDefault{'MIMEDECODERS'} = 1; | ||
| 954 | |||
| 955 | ## Default filters | ||
| 956 | %readmail::MIMEFilters = ( | ||
| 957 | # Content-type Filter | ||
| 958 | #----------------------------------------------------------------- | ||
| 959 | "application/ms-tnef", "m2h_null::filter", | ||
| 960 | "application/octet-stream", "m2h_external::filter", | ||
| 961 | "application/x-patch", "m2h_text_plain::filter", | ||
| 962 | "message/delivery-status", "m2h_text_plain::filter", | ||
| 963 | "message/external-body", "m2h_msg_extbody::filter", | ||
| 964 | "message/partial", "m2h_text_plain::filter", | ||
| 965 | "text/enriched", "m2h_text_enriched::filter", | ||
| 966 | "text/html", "m2h_text_html::filter", | ||
| 967 | "text/plain", "m2h_text_plain::filter", | ||
| 968 | "text/richtext", "m2h_text_enriched::filter", | ||
| 969 | "text/tab-separated-values", "m2h_text_tsv::filter", | ||
| 970 | "text/x-html", "m2h_text_html::filter", | ||
| 971 | |||
| 972 | "application/*", "m2h_external::filter", | ||
| 973 | "audio/*", "m2h_external::filter", | ||
| 974 | "chemical/*", "m2h_external::filter", | ||
| 975 | "image/*", "m2h_external::filter", | ||
| 976 | "model/*", "m2h_external::filter", | ||
| 977 | "text/*", "m2h_text_plain::filter", | ||
| 978 | "video/*", "m2h_external::filter", | ||
| 979 | |||
| 980 | "x-sun-attachment", "m2h_text_plain::filter", | ||
| 981 | ); | ||
| 982 | |||
| 983 | %readmail::MIMEFiltersSrc = ( | ||
| 984 | # Content-type Filter | ||
| 985 | #----------------------------------------------------------------- | ||
| 986 | "application/ms-tnef", "mhnull.pl", | ||
| 987 | "application/octet-stream", "mhexternal.pl", | ||
| 988 | "application/x-patch", "mhtxtplain.pl", | ||
| 989 | "message/delivery-status", "mhtxtplain.pl", | ||
| 990 | "message/external-body", "mhmsgextbody.pl", | ||
| 991 | "message/partial", "mhtxtplain.pl", | ||
| 992 | "text/enriched", "mhtxtenrich.pl", | ||
| 993 | "text/html", "mhtxthtml.pl", | ||
| 994 | "text/plain", "mhtxtplain.pl", | ||
| 995 | "text/richtext", "mhtxtenrich.pl", | ||
| 996 | "text/tab-separated-values", "mhtxttsv.pl", | ||
| 997 | "text/x-html", "mhtxthtml.pl", | ||
| 998 | |||
| 999 | "application/*", "mhexternal.pl", | ||
| 1000 | "audio/*", "mhexternal.pl", | ||
| 1001 | "chemical/*", "mhexternal.pl", | ||
| 1002 | "image/*", "mhexternal.pl", | ||
| 1003 | "model/*", "mhexternal.pl", | ||
| 1004 | "text/*", "mhtxtplain.pl", | ||
| 1005 | "video/*", "mhexternal.pl", | ||
| 1006 | |||
| 1007 | "x-sun-attachment", "mhtxtplain.pl", | ||
| 1008 | ); | ||
| 1009 | $IsDefault{'MIMEFILTERS'} = 1; | ||
| 1010 | |||
| 1011 | ## Default filter arguments | ||
| 1012 | %readmail::MIMEFiltersArgs = ( | ||
| 1013 | # Content-type Arguments | ||
| 1014 | #----------------------------------------------------------------- | ||
| 1015 | 'm2h_external::filter', 'inline', | ||
| 1016 | ); | ||
| 1017 | $IsDefault{'MIMEARGS'} = 1; | ||
| 1018 | |||
| 1019 | ## Charset filters | ||
| 1020 | %readmail::MIMECharSetConverters = ( | ||
| 1021 | # Character set Converter Function | ||
| 1022 | #----------------------------------------------------------------- | ||
| 1023 | 'plain', 'mhonarc::htmlize', | ||
| 1024 | 'us-ascii', 'mhonarc::htmlize', | ||
| 1025 | 'iso-8859-1', 'MHonArc::CharEnt::str2sgml', | ||
| 1026 | 'iso-8859-2', 'MHonArc::CharEnt::str2sgml', | ||
| 1027 | 'iso-8859-3', 'MHonArc::CharEnt::str2sgml', | ||
| 1028 | 'iso-8859-4', 'MHonArc::CharEnt::str2sgml', | ||
| 1029 | 'iso-8859-5', 'MHonArc::CharEnt::str2sgml', | ||
| 1030 | 'iso-8859-6', 'MHonArc::CharEnt::str2sgml', | ||
| 1031 | 'iso-8859-7', 'MHonArc::CharEnt::str2sgml', | ||
| 1032 | 'iso-8859-8', 'MHonArc::CharEnt::str2sgml', | ||
| 1033 | 'iso-8859-9', 'MHonArc::CharEnt::str2sgml', | ||
| 1034 | 'iso-8859-10', 'MHonArc::CharEnt::str2sgml', | ||
| 1035 | 'iso-8859-11', 'MHonArc::CharEnt::str2sgml', | ||
| 1036 | 'iso-8859-13', 'MHonArc::CharEnt::str2sgml', | ||
| 1037 | 'iso-8859-14', 'MHonArc::CharEnt::str2sgml', | ||
| 1038 | 'iso-8859-15', 'MHonArc::CharEnt::str2sgml', | ||
| 1039 | 'iso-8859-16', 'MHonArc::CharEnt::str2sgml', | ||
| 1040 | 'iso-2022-jp', 'MHonArc::CharEnt::str2sgml', | ||
| 1041 | 'iso-2022-kr', 'MHonArc::CharEnt::str2sgml', | ||
| 1042 | 'euc-jp', 'MHonArc::CharEnt::str2sgml', | ||
| 1043 | 'utf-8', 'MHonArc::CharEnt::str2sgml', | ||
| 1044 | 'cp866', 'MHonArc::CharEnt::str2sgml', | ||
| 1045 | 'cp932', 'MHonArc::CharEnt::str2sgml', | ||
| 1046 | 'cp936', 'MHonArc::CharEnt::str2sgml', | ||
| 1047 | 'cp949', 'MHonArc::CharEnt::str2sgml', | ||
| 1048 | 'cp950', 'MHonArc::CharEnt::str2sgml', | ||
| 1049 | 'cp1250', 'MHonArc::CharEnt::str2sgml', | ||
| 1050 | 'cp1251', 'MHonArc::CharEnt::str2sgml', | ||
| 1051 | 'cp1252', 'MHonArc::CharEnt::str2sgml', | ||
| 1052 | 'cp1253', 'MHonArc::CharEnt::str2sgml', | ||
| 1053 | 'cp1254', 'MHonArc::CharEnt::str2sgml', | ||
| 1054 | 'cp1255', 'MHonArc::CharEnt::str2sgml', | ||
| 1055 | 'cp1256', 'MHonArc::CharEnt::str2sgml', | ||
| 1056 | 'cp1257', 'MHonArc::CharEnt::str2sgml', | ||
| 1057 | 'cp1258', 'MHonArc::CharEnt::str2sgml', | ||
| 1058 | 'koi-0', 'MHonArc::CharEnt::str2sgml', | ||
| 1059 | 'koi-7', 'MHonArc::CharEnt::str2sgml', | ||
| 1060 | 'koi8-a', 'MHonArc::CharEnt::str2sgml', | ||
| 1061 | 'koi8-b', 'MHonArc::CharEnt::str2sgml', | ||
| 1062 | 'koi8-e', 'MHonArc::CharEnt::str2sgml', | ||
| 1063 | 'koi8-f', 'MHonArc::CharEnt::str2sgml', | ||
| 1064 | 'koi8-r', 'MHonArc::CharEnt::str2sgml', | ||
| 1065 | 'koi8-u', 'MHonArc::CharEnt::str2sgml', | ||
| 1066 | 'gost19768-87', 'MHonArc::CharEnt::str2sgml', | ||
| 1067 | 'viscii', 'MHonArc::CharEnt::str2sgml', | ||
| 1068 | 'big5-eten', 'MHonArc::CharEnt::str2sgml', | ||
| 1069 | 'big5-hkscs', 'MHonArc::CharEnt::str2sgml', | ||
| 1070 | 'gb2312', 'MHonArc::CharEnt::str2sgml', | ||
| 1071 | 'macarabic', 'MHonArc::CharEnt::str2sgml', | ||
| 1072 | 'maccentraleurroman', 'MHonArc::CharEnt::str2sgml', | ||
| 1073 | 'maccroatian', 'MHonArc::CharEnt::str2sgml', | ||
| 1074 | 'maccyrillic', 'MHonArc::CharEnt::str2sgml', | ||
| 1075 | 'macgreek', 'MHonArc::CharEnt::str2sgml', | ||
| 1076 | 'machebrew', 'MHonArc::CharEnt::str2sgml', | ||
| 1077 | 'macicelandic', 'MHonArc::CharEnt::str2sgml', | ||
| 1078 | 'macromanian', 'MHonArc::CharEnt::str2sgml', | ||
| 1079 | 'macroman', 'MHonArc::CharEnt::str2sgml', | ||
| 1080 | 'macthai', 'MHonArc::CharEnt::str2sgml', | ||
| 1081 | 'macturkish', 'MHonArc::CharEnt::str2sgml', | ||
| 1082 | 'hp-roman8', 'MHonArc::CharEnt::str2sgml', | ||
| 1083 | 'default', '-ignore-', | ||
| 1084 | ); | ||
| 1085 | %readmail::MIMECharSetConvertersSrc = ( | ||
| 1086 | # Character set Converter Function | ||
| 1087 | #----------------------------------------------------------------- | ||
| 1088 | 'plain', undef, | ||
| 1089 | 'us-ascii', undef, | ||
| 1090 | 'iso-8859-1', 'MHonArc/CharEnt.pm', | ||
| 1091 | 'iso-8859-2', 'MHonArc/CharEnt.pm', | ||
| 1092 | 'iso-8859-3', 'MHonArc/CharEnt.pm', | ||
| 1093 | 'iso-8859-4', 'MHonArc/CharEnt.pm', | ||
| 1094 | 'iso-8859-5', 'MHonArc/CharEnt.pm', | ||
| 1095 | 'iso-8859-6', 'MHonArc/CharEnt.pm', | ||
| 1096 | 'iso-8859-7', 'MHonArc/CharEnt.pm', | ||
| 1097 | 'iso-8859-8', 'MHonArc/CharEnt.pm', | ||
| 1098 | 'iso-8859-9', 'MHonArc/CharEnt.pm', | ||
| 1099 | 'iso-8859-10', 'MHonArc/CharEnt.pm', | ||
| 1100 | 'iso-8859-11', 'MHonArc/CharEnt.pm', | ||
| 1101 | 'iso-8859-13', 'MHonArc/CharEnt.pm', | ||
| 1102 | 'iso-8859-14', 'MHonArc/CharEnt.pm', | ||
| 1103 | 'iso-8859-15', 'MHonArc/CharEnt.pm', | ||
| 1104 | 'iso-8859-16', 'MHonArc/CharEnt.pm', | ||
| 1105 | 'iso-2022-jp', 'MHonArc/CharEnt.pm', | ||
| 1106 | 'iso-2022-kr', 'MHonArc/CharEnt.pm', | ||
| 1107 | 'euc-jp', 'MHonArc/CharEnt.pm', | ||
| 1108 | 'utf-8', 'MHonArc/CharEnt.pm', | ||
| 1109 | 'cp866', 'MHonArc/CharEnt.pm', | ||
| 1110 | 'cp932', 'MHonArc/CharEnt.pm', | ||
| 1111 | 'cp936', 'MHonArc/CharEnt.pm', | ||
| 1112 | 'cp949', 'MHonArc/CharEnt.pm', | ||
| 1113 | 'cp950', 'MHonArc/CharEnt.pm', | ||
| 1114 | 'cp1250', 'MHonArc/CharEnt.pm', | ||
| 1115 | 'cp1251', 'MHonArc/CharEnt.pm', | ||
| 1116 | 'cp1252', 'MHonArc/CharEnt.pm', | ||
| 1117 | 'cp1253', 'MHonArc/CharEnt.pm', | ||
| 1118 | 'cp1254', 'MHonArc/CharEnt.pm', | ||
| 1119 | 'cp1255', 'MHonArc/CharEnt.pm', | ||
| 1120 | 'cp1256', 'MHonArc/CharEnt.pm', | ||
| 1121 | 'cp1257', 'MHonArc/CharEnt.pm', | ||
| 1122 | 'cp1258', 'MHonArc/CharEnt.pm', | ||
| 1123 | 'koi-0', 'MHonArc/CharEnt.pm', | ||
| 1124 | 'koi-7', 'MHonArc/CharEnt.pm', | ||
| 1125 | 'koi8-a', 'MHonArc/CharEnt.pm', | ||
| 1126 | 'koi8-b', 'MHonArc/CharEnt.pm', | ||
| 1127 | 'koi8-e', 'MHonArc/CharEnt.pm', | ||
| 1128 | 'koi8-f', 'MHonArc/CharEnt.pm', | ||
| 1129 | 'koi8-r', 'MHonArc/CharEnt.pm', | ||
| 1130 | 'koi8-u', 'MHonArc/CharEnt.pm', | ||
| 1131 | 'gost19768-87', 'MHonArc/CharEnt.pm', | ||
| 1132 | 'viscii', 'MHonArc/CharEnt.pm', | ||
| 1133 | 'big5-eten', 'MHonArc/CharEnt.pm', | ||
| 1134 | 'big5-hkscs', 'MHonArc/CharEnt.pm', | ||
| 1135 | 'gb2312', 'MHonArc/CharEnt.pm', | ||
| 1136 | 'macarabic', 'MHonArc/CharEnt.pm', | ||
| 1137 | 'maccentraleurroman', 'MHonArc/CharEnt.pm', | ||
| 1138 | 'maccroatian', 'MHonArc/CharEnt.pm', | ||
| 1139 | 'maccyrillic', 'MHonArc/CharEnt.pm', | ||
| 1140 | 'macgreek', 'MHonArc/CharEnt.pm', | ||
| 1141 | 'machebrew', 'MHonArc/CharEnt.pm', | ||
| 1142 | 'macicelandic', 'MHonArc/CharEnt.pm', | ||
| 1143 | 'macromanian', 'MHonArc/CharEnt.pm', | ||
| 1144 | 'macroman', 'MHonArc/CharEnt.pm', | ||
| 1145 | 'macthai', 'MHonArc/CharEnt.pm', | ||
| 1146 | 'macturkish', 'MHonArc/CharEnt.pm', | ||
| 1147 | 'hp-roman8', 'MHonArc/CharEnt.pm', | ||
| 1148 | 'default', undef, | ||
| 1149 | ); | ||
| 1150 | $IsDefault{'CHARSETCONVERTERS'} = 1; | ||
| 1151 | |||
| 1152 | ## Default charset aliases | ||
| 1153 | readmail::MAILset_charset_aliases( | ||
| 1154 | { 'us-ascii' => [ | ||
| 1155 | 'ascii', 'ansi_x3.4-1968', | ||
| 1156 | 'iso646', 'iso646-us', | ||
| 1157 | 'iso646.irv:1991', 'cp367', | ||
| 1158 | 'ibm367', 'csascii', | ||
| 1159 | 'iso-ir-6', 'us' | ||
| 1160 | ], | ||
| 1161 | 'iso-8859-1' => [ | ||
| 1162 | 'latin1', 'l1', | ||
| 1163 | 'iso_8859_1', 'iso_8859-1:1987', | ||
| 1164 | 'iso8859-1', 'iso8859_1', | ||
| 1165 | '8859-1', '8859_1', | ||
| 1166 | 'cp819', 'ibm819', | ||
| 1167 | 'x-mac-latin1', 'iso-ir-100' | ||
| 1168 | ], | ||
| 1169 | 'iso-8859-2' => [ | ||
| 1170 | 'latin2', 'l2', | ||
| 1171 | 'iso_8859_2', 'iso_8859-2:1987', | ||
| 1172 | 'iso8859-2', 'iso8859_2', | ||
| 1173 | '8859-2', '8859_2', | ||
| 1174 | 'iso-ir-101' | ||
| 1175 | ], | ||
| 1176 | 'iso-8859-3' => [ | ||
| 1177 | 'latin3', 'l3', | ||
| 1178 | 'iso_8859_3', 'iso_8859-3:1988', | ||
| 1179 | 'iso8859-3', 'iso8859_3', | ||
| 1180 | '8859-3', '8859_3', | ||
| 1181 | 'iso-ir-109' | ||
| 1182 | ], | ||
| 1183 | 'iso-8859-4' => [ | ||
| 1184 | 'latin4', 'l4', | ||
| 1185 | 'iso_8859_4', 'iso_8859-4:1988', | ||
| 1186 | 'iso8859-4', 'iso8859_4', | ||
| 1187 | '8859-4', '8859_4', | ||
| 1188 | 'iso-ir-110' | ||
| 1189 | ], | ||
| 1190 | 'iso-8859-5' => ['iso_8859-5:1988', 'cyrillic', 'iso-ir-144'], | ||
| 1191 | 'iso-8859-6' => [ | ||
| 1192 | 'iso_8859-6:1987', 'arabic', | ||
| 1193 | 'asmo-708', 'ecma-114', | ||
| 1194 | 'iso-ir-127' | ||
| 1195 | ], | ||
| 1196 | 'iso-8859-7' => [ | ||
| 1197 | 'iso_8859-7:1987', 'greek', | ||
| 1198 | 'greek8', 'ecma-118', | ||
| 1199 | 'elot_928', 'iso-ir-126' | ||
| 1200 | ], | ||
| 1201 | 'iso-8859-8' => | ||
| 1202 | ['iso-8859-8-i', 'iso_8859-8:1988', 'hebrew', 'iso-ir-138'], | ||
| 1203 | 'iso-8859-9' => [ | ||
| 1204 | 'latin5', 'l5', | ||
| 1205 | 'iso_8859_9', 'iso-8859_9:1989', | ||
| 1206 | 'iso8859-9', 'iso8859_9', | ||
| 1207 | '8859-9', '8859_9', | ||
| 1208 | 'iso-ir-148' | ||
| 1209 | ], | ||
| 1210 | 'iso-8859-10' => [ | ||
| 1211 | 'latin6', 'l6', | ||
| 1212 | 'iso_8859_10', 'iso_8859-10:1993', | ||
| 1213 | 'iso8859-10', 'iso8859_10', | ||
| 1214 | '8859-10', '8859_10', | ||
| 1215 | 'iso-ir-157' | ||
| 1216 | ], | ||
| 1217 | 'iso-8859-13' => ['latin7', 'l7'], | ||
| 1218 | 'iso-8859-14' => ['latin8', 'l8'], | ||
| 1219 | 'iso-8859-15' => [ | ||
| 1220 | 'latin9', 'latin0', 'l9', 'l0', | ||
| 1221 | 'iso_8859_15', 'iso8859-15', 'iso8859_15', '8859-15', | ||
| 1222 | '8859_15' | ||
| 1223 | ], | ||
| 1224 | 'iso-2022-jp' => ['iso-2022-jp-1'], | ||
| 1225 | 'utf-8' => ['utf8'], | ||
| 1226 | 'cp932' => [ | ||
| 1227 | 'shiftjis', 'shift_jis', 'shift-jis', 'x-sjis', | ||
| 1228 | 'ms_kanji', 'csshiftjis' | ||
| 1229 | ], | ||
| 1230 | 'cp936' => ['gbk', 'ms936', 'windows-936'], | ||
| 1231 | 'cp949' => [ | ||
| 1232 | 'euc-kr', 'ks_c_5601-1987', | ||
| 1233 | 'ks_c_5601-1989', 'ksc_5601', | ||
| 1234 | 'iso-ir-149', 'windows-949', | ||
| 1235 | 'ms949', 'korean' | ||
| 1236 | ], | ||
| 1237 | 'cp950' => ['windows-950'], | ||
| 1238 | 'cp1250' => ['windows-1250'], | ||
| 1239 | 'cp1251' => ['windows-1251'], | ||
| 1240 | 'cp1252' => ['windows-1252'], | ||
| 1241 | 'cp1253' => ['windows-1253'], | ||
| 1242 | 'cp1254' => ['windows-1254'], | ||
| 1243 | 'cp1255' => ['windows-1255'], | ||
| 1244 | 'cp1256' => ['windows-1256'], | ||
| 1245 | 'cp1257' => ['windows-1257'], | ||
| 1246 | 'cp1258' => ['windows-1258'], | ||
| 1247 | 'koi-0' => ['gost-13052'], | ||
| 1248 | 'koi8-e' => ['iso-ir-111', 'ecma-113:1986'], | ||
| 1249 | 'koi8-r' => ['cp878'], | ||
| 1250 | 'gost-19768-87' => ['ecma-cyrillic', 'ecma-113', 'ecma-113:1988'], | ||
| 1251 | 'big5-eten' => ['big5', 'csbig5', 'tcs-big5', 'tcsbig5'], | ||
| 1252 | 'big5-hkscs' => ['big5hkscs', 'big5hk', 'hkscs-big5', 'hk-big5'], | ||
| 1253 | 'gb2312' => [ | ||
| 1254 | 'gb_2312-80', 'csgb2312', | ||
| 1255 | 'hz-gb-2312', 'iso-ir-58', | ||
| 1256 | 'euc-cn', 'chinese', | ||
| 1257 | 'csiso58gb231280' | ||
| 1258 | ], | ||
| 1259 | 'macarabic' => ['apple-arabic', 'x-mac-arabic'], | ||
| 1260 | 'maccentraleurroman' => | ||
| 1261 | ['apple-centeuro', 'x-mac-centraleurroman'], | ||
| 1262 | 'maccroatian' => ['apple-croatian', 'x-mac-croatian'], | ||
| 1263 | 'maccyrillic' => ['apple-cyrillic', 'x-mac-cyrillic'], | ||
| 1264 | 'macgreek' => ['apple-greek', 'x-mac-greek'], | ||
| 1265 | 'machebrew' => ['apple-hebrew', 'x-mac-hebrew'], | ||
| 1266 | 'macicelandic' => ['apple-iceland', 'x-mac-icelandic'], | ||
| 1267 | 'macromanian' => ['apple-romanian', 'x-mac-romanian'], | ||
| 1268 | 'macroman' => ['apple-roman', 'mac', 'macintosh', 'x-mac-roman'], | ||
| 1269 | 'macthai' => ['apple-thai', 'x-mac-thai'], | ||
| 1270 | 'macturkish' => ['apple-turkish', 'x-mac-turkish'], | ||
| 1271 | } | ||
| 1272 | ); | ||
| 1273 | $IsDefault{'CHARSETALIASES'} = 1; | ||
| 1274 | |||
| 1275 | ## Content-Types to exclude: | ||
| 1276 | ## Nothing is excluded by default. | ||
| 1277 | %readmail::MIMEExcs = (); | ||
| 1278 | $IsDefault{'MIMEEXCS'} = 1; | ||
| 1279 | |||
| 1280 | ## Content-Types to only include: | ||
| 1281 | ## Blank by default: include everything | ||
| 1282 | %readmail::MIMEIncs = (); | ||
| 1283 | $IsDefault{'MIMEIncs'} = 1; | ||
| 1284 | |||
| 1285 | ## Content-type multipart/alternative preferences | ||
| 1286 | ## Note: The variable is not a readmail package variable, but it | ||
| 1287 | ## is used to set readmail package properties. | ||
| 1288 | @MIMEAltPrefs = (); | ||
| 1289 | $IsDefault{'MIMEALTPREFS'} = 1; | ||
| 1290 | |||
| 1291 | ## Text encoding | ||
| 1292 | $readmail::TextEncode = undef; | ||
| 1293 | $IsDefault{'TEXTENCODE'} = 1; | ||
| 1294 | |||
| 1295 | $readmail::FormatHeaderFunc = \&mhonarc::htmlize_header; | ||
| 1296 | $MHeadCnvFunc = \&readmail::MAILdecode_1522_str; | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | ##--------------------------------------------------------------------------- | ||
| 1300 | 1; |