Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | ##---------------------------------------------------------------------------## |
2 | ## File: | |
3 | ## $Id: mhinit.pl,v 2.37 2002/09/04 04:09:30 ehood Exp $ | |
4 | ## Author: | |
5 | ## Earl Hood mhonarc@mhonarc.org | |
6 | ## Description: | |
7 | ## Initialization stuff for MHonArc. | |
8 | ##---------------------------------------------------------------------------## | |
9 | ## MHonArc -- Internet mail-to-HTML converter | |
10 | ## Copyright (C) 1995-2001 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 | ##---------------------------------------------------------------------------## | |
31 | ## Callbacks | |
32 | ## We only declare once so custom front-ends do not have to | |
33 | ## re-register each time. This basically serves as a summary | |
34 | ## of the callbacks available. | |
35 | ##---------------------------------------------------------------------------## | |
36 | ||
37 | ## After message body is read and converted: | |
38 | ## &invoke($fields_hash_ref, $html_text_ref, $files_array_ref); | |
39 | $CBMessageBodyRead = undef | |
40 | unless defined($CBMessageBodyRead); | |
41 | ||
42 | ## Right before database file is loaded: | |
43 | ## $do_load = &invoke($pathname); | |
44 | $CBDbPreLoad = undef | |
45 | unless defined($CBDbPreLoad); | |
46 | ||
47 | ## Right before database file is written: | |
48 | ## $do_save = &invoke($pathname, $tmp_pathname); | |
49 | $CBDbPreSave = undef | |
50 | unless defined($CBDbPreSave); | |
51 | ||
52 | ## When data has been written: | |
53 | ## $do_save = &invoke($db_fh); | |
54 | $CBDbSave = undef | |
55 | unless defined($CBDbSave); | |
56 | ||
57 | ## After message header is parsed: | |
58 | ## $do_not_exclude = &invoke($fields_hash_ref, $raw_header_txt); | |
59 | $CBMessageHeadRead = undef | |
60 | unless defined($CBMessageHeadRead); | |
61 | ||
62 | ## After message body is read from input | |
63 | ## &invoke($fields_hash_ref, $raw_data_ref); | |
64 | $CBRawMessageBodyRead = undef | |
65 | unless defined($CBRawMessageBodyRead); | |
66 | ||
67 | ## When a resource variable is being expanded: | |
68 | ## ($result, $recurse, $canclip) = &invoke($index, $varname, $arg); | |
69 | $CBRcVarExpand = undef | |
70 | unless defined($CBRcVarExpand); | |
71 | ||
72 | ##---------------------------------------------------------------------------## | |
73 | ||
74 | sub mhinit_vars { | |
75 | ||
76 | ## The %Zone array should be augmented to contain all timezone | |
77 | ## specifications with the positive/negative hour offset from UTC | |
78 | ## (GMT). The zone value is *added* to the time containing the | |
79 | ## zone to determine GMT time. Hence, the values will be the | |
80 | ## negative inverse used in actual time specifications in messages. | |
81 | ## (There has got to be a better way to handle timezones) | |
82 | ## Array can be augmented/overridden via the resource file. | |
83 | %Zone = ( | |
84 | 'ACDT', '-1030', # Australian Central Daylight | |
85 | 'ACST', '-0930', # Australian Central Standard | |
86 | 'ADT', '0300', # (US) Atlantic Daylight | |
87 | 'AEDT', '-1100', # Australian East Daylight | |
88 | 'AEST', '-1000', # Australian East Standard | |
89 | 'AHDT', '0900', | |
90 | 'AHST', '1000', | |
91 | 'AST', '0400', # (US) Atlantic Standard | |
92 | 'AT', '0200', # Azores | |
93 | 'AWDT', '-0900', # Australian West Daylight | |
94 | 'AWST', '-0800', # Australian West Standard | |
95 | 'BAT', '-0300', # Baghdad | |
96 | 'BDST', '-0200', # British Double Summer | |
97 | 'BET', '1100', # Bering Standard | |
98 | 'BST', '-0100', # British Summer | |
99 | # 'BST', '0300', # Brazil Standard | |
100 | 'BT', '-0300', # Baghdad | |
101 | 'BZT2', '0300', # Brazil Zone 2 | |
102 | 'CADT', '-1030', # Central Australian Daylight | |
103 | 'CAST', '-0930', # Central Australian Standard | |
104 | 'CAT', '1000', # Central Alaska | |
105 | 'CCT', '-0800', # China Coast | |
106 | 'CDT', '0500', # (US) Central Daylight | |
107 | 'CED', '-0200', # Central European Daylight | |
108 | 'CET', '-0100', # Central European | |
109 | 'CST', '0600', # (US) Central Standard | |
110 | 'EAST', '-1000', # Eastern Australian Standard | |
111 | 'EDT', '0400', # (US) Eastern Daylight | |
112 | 'EED', '-0300', # Eastern European Daylight | |
113 | 'EET', '-0200', # Eastern Europe | |
114 | 'EEST', '-0300', # Eastern Europe Summer | |
115 | 'EST', '0500', # (US) Eastern Standard | |
116 | 'FST', '-0200', # French Summer | |
117 | 'FWT', '-0100', # French Winter | |
118 | 'GMT', '0000', # Greenwich Mean | |
119 | 'GST', '-1000', # Guam Standard | |
120 | # 'GST', '0300', # Greenland Standard | |
121 | 'HDT', '0900', # Hawaii Daylight | |
122 | 'HST', '1000', # Hawaii Standard | |
123 | 'IDLE', '-1200', # Internation Date Line East | |
124 | 'IDLW', '1200', # Internation Date Line West | |
125 | 'IST', '-0530', # Indian Standard | |
126 | 'IT', '-0330', # Iran | |
127 | 'JST', '-0900', # Japan Standard | |
128 | 'JT', '-0700', # Java | |
129 | 'KST', '-0900', # Korean Standard | |
130 | 'MDT', '0600', # (US) Mountain Daylight | |
131 | 'MED', '-0200', # Middle European Daylight | |
132 | 'MET', '-0100', # Middle European | |
133 | 'MEST', '-0200', # Middle European Summer | |
134 | 'MEWT', '-0100', # Middle European Winter | |
135 | 'MST', '0700', # (US) Mountain Standard | |
136 | 'MT', '-0800', # Moluccas | |
137 | 'NDT', '0230', # Newfoundland Daylight | |
138 | 'NFT', '0330', # Newfoundland | |
139 | 'NT', '1100', # Nome | |
140 | 'NST', '-0630', # North Sumatra | |
141 | # 'NST', '0330', # Newfoundland Standard | |
142 | 'NZ', '-1100', # New Zealand | |
143 | 'NZST', '-1200', # New Zealand Standard | |
144 | 'NZDT', '-1300', # New Zealand Daylight | |
145 | 'NZT', '-1200', # New Zealand | |
146 | 'PDT', '0700', # (US) Pacific Daylight | |
147 | 'PST', '0800', # (US) Pacific Standard | |
148 | 'ROK', '-0900', # Republic of Korea | |
149 | 'SAD', '-1000', # South Australia Daylight | |
150 | 'SAST', '-0900', # South Australia Standard | |
151 | 'SAT', '-0900', # South Australia | |
152 | 'SDT', '-1000', # South Australia Daylight | |
153 | 'SST', '-0200', # Swedish Summer | |
154 | 'SWT', '-0100', # Swedish Winter | |
155 | 'USZ3', '-0400', # USSR Zone 3 | |
156 | 'USZ4', '-0500', # USSR Zone 4 | |
157 | 'USZ5', '-0600', # USSR Zone 5 | |
158 | 'USZ6', '-0700', # USSR Zone 6 | |
159 | 'UT', '0000', # Universal Coordinated | |
160 | 'UTC', '0000', # Universal Coordinated | |
161 | 'UZ10', '-1100', # USSR Zone 10 | |
162 | 'WAT', '0100', # West Africa | |
163 | 'WET', '0000', # West European | |
164 | 'WST', '-0800', # West Australian Standard | |
165 | 'YDT', '0800', # Yukon Daylight | |
166 | 'YST', '0900', # Yukon Standard | |
167 | 'ZP4', '-0400', # USSR Zone 3 | |
168 | 'ZP5', '-0500', # USSR Zone 4 | |
169 | 'ZP6', '-0600', # USSR Zone 5 | |
170 | ); | |
171 | %ZoneUD = (); | |
172 | ||
173 | ## Assoc array listing mail header fields to exclude in output. | |
174 | ## Each key is treated as a regular expression with '^' prepended | |
175 | ## to it. | |
176 | ||
177 | %HFieldsExc = ( | |
178 | 'content-', 1, # Mime headers | |
179 | 'errors-to', 1, | |
180 | 'forward', 1, # Forward lines (MH may add these) | |
181 | 'lines', 1, | |
182 | 'message-id', 1, | |
183 | 'mime-', 1, # Mime headers | |
184 | 'nntp-', 1, | |
185 | 'originator', 1, | |
186 | 'path', 1, | |
187 | 'precedence', 1, | |
188 | 'received', 1, # MTA added headers | |
189 | 'replied', 1, # Replied lines (MH may add these) | |
190 | 'return-path', 1, # MH/MTA header | |
191 | 'status', 1, | |
192 | 'via', 1, | |
193 | 'x-', 1, # Non-standard headers | |
194 | ); | |
195 | ||
196 | ## Asocc arrays defining HTML formats to apply to header fields | |
197 | ||
198 | %HeadFields = ( | |
199 | "-default-", "", # Nothing | |
200 | ); | |
201 | %HeadHeads = ( | |
202 | "-default-", "em", # Empasize field labels | |
203 | ); | |
204 | @FieldOrder = ( # Order fields are listed | |
205 | 'to', | |
206 | 'subject', | |
207 | 'from', | |
208 | 'date', | |
209 | '-extra-', | |
210 | ); | |
211 | %FieldODefs = ( # Fields not to slurp up in "-extra-" | |
212 | 'to', 1, | |
213 | 'subject', 1, | |
214 | 'from', 1, | |
215 | 'date', 1, | |
216 | ); | |
217 | ||
218 | ## Message information variables | |
219 | ||
220 | $NewMsgCnt = 0; # Total number of new messages | |
221 | $NumOfMsgs = 0; # Total number of messages | |
222 | $LastMsgNum = -1; # Message number of last message | |
223 | %Message = (); # Message indexes to bodies | |
224 | %MsgHead = (); # Message indexes to heads | |
225 | %MsgHtml = (); # Flag if message is html | |
226 | %Subject = (); # Message indexes to subjects | |
227 | %From = (); # Message indexes to froms | |
228 | %Date = (); # Message indexes to dates | |
229 | %MsgId = (); # Message ids to indexes | |
230 | %NewMsgId = (); # New message ids to indexes | |
231 | %IndexNum = (); # Index key to message number | |
232 | %Derived = (); # Index key to derived files for message | |
233 | %Refs = (); # Index key to message references | |
234 | %Follow = (); # Index key to follow-ups | |
235 | %FolCnt = (); # Index key to number of follow-ups | |
236 | %ContentType = (); # Index key to base content-type of message | |
237 | %Icons = (); # Index key to icon URL for content-type | |
238 | %AddIndex = (); # Flags for messages that must be written | |
239 | ||
240 | @MListOrder = (); # List of indexes in order printed on main index | |
241 | %Index2Mloc = (); # Map index to position in main index | |
242 | @TListOrder = (); # List of indexes in order printed on thread index | |
243 | %Index2Tloc = (); # Map index to position in thread index | |
244 | %ThreadLevel = (); # Map index to thread level | |
245 | ||
246 | %UDerivedFile = (); # Key = filename template. Value = content template | |
247 | ||
248 | ## Following variables used in thread computation | |
249 | ||
250 | @ThreadList = (); # List of messages visible in thread index | |
251 | @NotIdxThreadList | |
252 | = (); # List of messages not visible in index | |
253 | %HasRef = (); # Flags if message has references (Keys = indexes) | |
254 | # (Values = reference message indexes) | |
255 | %HasRefDepth = (); # Depth of reference from HasRef value | |
256 | %Replies = (); # Msg-ids of explicit replies (Keys = indexes) | |
257 | %SReplies = (); # Msg-ids of subject-based replies (Keys = indexes) | |
258 | %TVisible = (); # Message visible in thread index (Keys = indexes) | |
259 | $DoMissingMsgs = 0; # Flag is missing messages should be noted in index | |
260 | ||
261 | ## Some miscellaneous variables | |
262 | ||
263 | %IsDefault = (); # Flags if certain resources are the default | |
264 | ||
265 | $bs = "\b"; # Used as a separator | |
266 | $Url = '(http://|https://|ftp://|afs://|wais://|telnet://|' . | |
267 | 'gopher://|news:|nntp:|mid:|cid:|mailto:|prospero:)'; | |
268 | ||
269 | $MLCP = 0; # Main index contains included files flag | |
270 | $SLOW = 0; # Save memory flag | |
271 | $NumOfPages = 0; # Number of index pages | |
272 | $IdxMinPg = -1; # Starting page of index for updating | |
273 | $TIdxMinPg = -1; # Starting page of thread index for updating | |
274 | $IdxPageNum = 0; # Page to output if genidx | |
275 | $DBPathName = ''; # Full pathname of database file | |
276 | ||
277 | ## Initialize readmail variables | |
278 | mhinit_readmail_vars(); | |
279 | ||
280 | ## Variable to hold function for converting message header text. | |
281 | $MHeadCnvFunc = "mhonarc::htmlize"; | |
282 | ||
283 | ## Regexp for variable detection | |
284 | $VarExp = $ENV{'M2H_VARREGEX'}; | |
285 | $VarExp = '\$([^\$]*)\$' if !defined($VarExp) || $VarExp !~ /\S/; | |
286 | ||
287 | ## Regexp for address/msg-id detection (looks like cussing in cartoons) | |
288 | $AddrExp = '[^()<>@,;:\/\s"\'&|]+@[^()<>@,;:\/\s"\'&|]+'; | |
289 | ||
290 | ## Text clipping function and source file: Set in mhopt.pl. | |
291 | $TextClipFunc = undef; | |
292 | $TextClipSrc = undef; | |
293 | ||
294 | ## Grab environment variable settings | |
295 | ## | |
296 | $AFS = $ENV{'M2H_AFS'} || 0; | |
297 | $ANNOTATE = $ENV{'M2H_ANNOTATE'} || 0; | |
298 | $DBFILE = $ENV{'M2H_DBFILE'} || | |
299 | (($MSDOS || $VMS) ? "mhonarc.db": ".mhonarc.db"); | |
300 | $DOCURL = $ENV{'M2H_DOCURL'} || | |
301 | 'http://www.mhonarc.org/'; | |
302 | $IDXNAME = ""; # Set in get_resources() | |
303 | $IDXPREFIX = $ENV{'M2H_IDXPREFIX'} || "mail"; | |
304 | $TIDXPREFIX= $ENV{'M2H_TIDXPREFIX'} || "thrd"; | |
305 | $IDXSIZE = $ENV{'M2H_IDXSIZE'} || 0; | |
306 | $TIDXNAME = ""; # Set in get_resources() | |
307 | $OUTDIR = $ENV{'M2H_OUTDIR'} || $CURDIR; | |
308 | $TTITLE = $ENV{'M2H_TTITLE'} || "Mail Thread Index"; | |
309 | $TITLE = $ENV{'M2H_TITLE'} || "Mail Index"; | |
310 | $MAILTOURL = $ENV{'M2H_MAILTOURL'} || ""; | |
311 | $FROM = $ENV{'M2H_MSGSEP'} || '^From '; | |
312 | $LOCKFILE = $ENV{'M2H_LOCKFILE'} || | |
313 | ($MSDOS ? "mhonarc.lck" : | |
314 | $VMS ? "mhonarc_lck" : ".mhonarc.lck"); | |
315 | $LOCKTRIES = $ENV{'M2H_LOCKTRIES'} || 10; | |
316 | $LOCKDELAY = $ENV{'M2H_LOCKDELAY'} || 3; | |
317 | $MAXSIZE = $ENV{'M2H_MAXSIZE'} || 0; | |
318 | $TLEVELS = $ENV{'M2H_TLEVELS'} || 3; | |
319 | $TSLICELEVELS = | |
320 | $ENV{'M2H_TSLICELEVELS'} || -1; | |
321 | $MHPATTERN = $ENV{'M2H_MHPATTERN'} || '^\d+$'; | |
322 | $DefRcFile = $ENV{'M2H_DEFRCFILE'} || ''; | |
323 | $HtmlExt = $ENV{'M2H_HTMLEXT'} || "html"; | |
324 | $MsgPrefix = $ENV{'M2H_MSGPREFIX'} || "msg"; | |
325 | $DefRcName = $ENV{'M2H_DEFRCNAME'} || | |
326 | (($MSDOS || $VMS) ? "mhonarc.mrc": ".mhonarc.mrc"); | |
327 | $GzipExe = $ENV{'M2H_GZIPEXE'} || 'gzip'; | |
328 | $SpamMode = $ENV{'M2H_SPAMMODE'} || 0; | |
329 | $MainRcDir = undef; # Set in read_resource_file() | |
330 | ||
331 | $GMTDateFmt = $ENV{'M2H_GMTDATEFMT'} || ''; | |
332 | $LocalDateFmt = $ENV{'M2H_LOCALDATEFMT'} || ''; | |
333 | $ExpireDate = $ENV{'M2H_EXPIREDATE'} || ''; | |
334 | $ExpireDateTime = 0; | |
335 | $ExpireTime = $ENV{'M2H_EXPIREAGE'} || 0; | |
336 | ||
337 | $MsgGMTDateFmt = $ENV{'M2H_MSGGMTDATEFMT'} || ''; | |
338 | $MsgLocalDateFmt= $ENV{'M2H_MSGLOCALDATEFMT'} || ''; | |
339 | ||
340 | $NoSubjectTxt = $ENV{'M2H_NOSUBJECTTXT'} || '[no subject]'; | |
341 | ||
342 | $NoteDir = $ENV{'M2H_NOTEDIR'} || 'notes'; | |
343 | ||
344 | $LockMethod = $ENV{'M2H_LOCKMETHOD'} || 'directory'; | |
345 | $LockMethod = set_lock_mode($LockMethod); | |
346 | ||
347 | $CONLEN = defined($ENV{'M2H_CONLEN'}) ? $ENV{'M2H_CONLEN'} : 0; | |
348 | $MAIN = defined($ENV{'M2H_MAIN'}) ? $ENV{'M2H_MAIN'} : 1; | |
349 | $MULTIIDX = defined($ENV{'M2H_MULTIPG'}) ? $ENV{'M2H_MULTIPG'} : 0; | |
350 | $MODTIME = defined($ENV{'M2H_MODTIME'}) ? $ENV{'M2H_MODTIME'} : 0; | |
351 | $NODOC = defined($ENV{'M2H_DOC'}) ? !$ENV{'M2H_DOC'} : 0; | |
352 | $NOMAILTO = defined($ENV{'M2H_MAILTO'}) ? !$ENV{'M2H_MAILTO'} : 0; | |
353 | $NoMsgPgs = defined($ENV{'M2H_MSGPGS'}) ? !$ENV{'M2H_MSGPGS'} : 0; | |
354 | $NONEWS = defined($ENV{'M2H_NEWS'}) ? !$ENV{'M2H_NEWS'} : 0; | |
355 | $NOSORT = defined($ENV{'M2H_SORT'}) ? !$ENV{'M2H_SORT'} : 0; | |
356 | $NOURL = defined($ENV{'M2H_URL'}) ? !$ENV{'M2H_URL'} : 0; | |
357 | $REVSORT = defined($ENV{'M2H_REVSORT'}) ? $ENV{'M2H_REVSORT'} : 0; | |
358 | $SUBSORT = defined($ENV{'M2H_SUBSORT'}) ? $ENV{'M2H_SUBSORT'} : 0; | |
359 | $AUTHSORT = defined($ENV{'M2H_AUTHSORT'}) ? $ENV{'M2H_AUTHSORT'} : 0; | |
360 | $THREAD = defined($ENV{'M2H_THREAD'}) ? $ENV{'M2H_THREAD'} : 1; | |
361 | $TNOSORT = defined($ENV{'M2H_TSORT'}) ? !$ENV{'M2H_TSORT'} : 0; | |
362 | $TREVERSE = defined($ENV{'M2H_TREVERSE'}) ? $ENV{'M2H_TREVERSE'} : 0; | |
363 | $TSUBSORT = defined($ENV{'M2H_TSUBSORT'}) ? $ENV{'M2H_TSUBSORT'} : 0; | |
364 | $GzipFiles = defined($ENV{'M2H_GZIPFILES'}) ? $ENV{'M2H_GZIPFILES'} : 0; | |
365 | $GzipLinks = defined($ENV{'M2H_GZIPLINKS'}) ? $ENV{'M2H_GZIPLINKS'} : 0; | |
366 | $KeepOnRmm = defined($ENV{'M2H_KEEPONRMM'}) ? $ENV{'M2H_KEEPONRMM'} : 0; | |
367 | $UseLocalTime= defined($ENV{'M2H_USELOCALTIME'}) ? | |
368 | $ENV{'M2H_USELOCALTIME'} : 0; | |
369 | $NoSubjectThreads = defined($ENV{'M2H_SUBJECTTHREADS'}) ? | |
370 | !$ENV{'M2H_SUBJECTTHREADS'} : 0; | |
371 | $SaveRsrcs = defined($ENV{'M2H_SAVERESOURCES'}) ? | |
372 | $ENV{'M2H_SAVERESOURCES'} : 1; | |
373 | $POSIXstrftime = defined($ENV{'M2H_POSIXSTRFTIME'}) ? | |
374 | $ENV{'M2H_POSIXSTRFTIME'} : 0; | |
375 | ||
376 | if ($UNIX) { | |
377 | eval { | |
378 | $UMASK = defined($ENV{'M2H_UMASK'}) ? | |
379 | $ENV{'M2H_UMASK'} : sprintf("%o",umask); | |
380 | }; | |
381 | } | |
382 | ||
383 | $CheckNoArchive = defined($ENV{'M2H_CHECKNOARCHIVE'}) ? | |
384 | $ENV{'M2H_CHECKNOARCHIVE'} : 0; | |
385 | $DecodeHeads = defined($ENV{'M2H_DECODEHEADS'}) ? $ENV{'M2H_DECODEHEADS'} : 0; | |
386 | $DoArchive = defined($ENV{'M2H_ARCHIVE'}) ? $ENV{'M2H_ARCHIVE'} : 1; | |
387 | $DoFolRefs = defined($ENV{'M2H_FOLREFS'}) ? $ENV{'M2H_FOLREFS'} : 1; | |
388 | $UsingLASTPG = defined($ENV{'M2H_USINGLASTPG'}) ? $ENV{'M2H_USINGLASTPG'} : 1; | |
389 | ||
390 | @FMTFILE = defined($ENV{'M2H_RCFILE'}) ? | |
391 | ($ENV{'M2H_RCFILE'}) : (); | |
392 | @OtherIdxs = defined($ENV{'M2H_OTHERINDEXES'}) ? | |
393 | split(/:/, $ENV{'M2H_OTHERINDEXES'}) : (); | |
394 | @PerlINC = defined($ENV{'M2H_PERLINC'}) ? | |
395 | split(/:/, $ENV{'M2H_PERLINC'}) : (); | |
396 | @DateFields = defined($ENV{'M2H_DATEFIELDS'}) ? | |
397 | split(/:/, $ENV{'M2H_DATEFIELDS'}) : (); | |
398 | @FromFields = defined($ENV{'M2H_FROMFIELDS'}) ? | |
399 | split(/:/, $ENV{'M2H_FROMFIELDS'}) : (); | |
400 | ||
401 | # Version of @Datefiles in parsed format | |
402 | @_DateFields = ( ); | |
403 | ||
404 | ($TSliceNBefore, $TSliceNAfter, $TSliceInclusive) = | |
405 | defined($ENV{'M2H_TSLICE'}) ? | |
406 | split(/[:;]/, $ENV{'M2H_TSLICE'}) : (0, 4, 0); | |
407 | ||
408 | ## Code for modify addresses in headers | |
409 | $AddressModify = $ENV{'M2H_ADDRESSMODIFYCODE'} || ""; | |
410 | ||
411 | ## Regex representing "article" words for stripping out when doing | |
412 | ## subject sorting. | |
413 | $SubArtRxp = $ENV{'M2H_SUBJECTARTICLERXP'} || | |
414 | q/^(the|a|an)\s+/; | |
415 | ||
416 | ## Regex representing reply/forward prefixes to subject. | |
417 | $SubReplyRxp = $ENV{'M2H_SUBJECTREPLYRXP'} || | |
418 | q/^\s*(re|sv|fwd|fw)[\[\]\d]*[:>-]+\s*/; | |
419 | ||
420 | ## Code for stripping subjects | |
421 | $SubStripCode = $ENV{'M2H_SUBJECTSTRIPCODE'} || ""; | |
422 | ||
423 | $MsgExcFilter = $ENV{'M2H_MSGEXCFILTER'} || ""; | |
424 | ||
425 | ## Arrays for months and weekdays. If empty, the default settings | |
426 | ## in mhtime.pl are used. | |
427 | ||
428 | @Months = $ENV{'M2H_MONTHS'} ? split(/:/, $ENV{'M2H_MONTHS'}) : (); | |
429 | @months = $ENV{'M2H_MONTHSABR'} ? split(/:/, $ENV{'M2H_MONTHSABR'}) : (); | |
430 | @Weekdays = $ENV{'M2H_WEEKDAYS'} ? split(/:/, $ENV{'M2H_WEEKDAYS'}) : (); | |
431 | @weekdays = $ENV{'M2H_WEEKDAYSABR'} ? split(/:/, $ENV{'M2H_WEEKDAYSABR'}) : (); | |
432 | ||
433 | ## Many of the following are set during runtime after the | |
434 | ## database and resources have been read. The variables are | |
435 | ## listed here as a quick reference. | |
436 | ||
437 | $ADDSINGLE = 0; # Flag if adding a single message | |
438 | $IDXONLY = 0; # Flag if generating index to stdout | |
439 | $RMM = 0; # Flag if removing messages | |
440 | $SCAN = 0; # Flag if doing an archive scan | |
441 | ||
442 | $MSGPGSSMARKUP = ''; # Initial markup of message pages | |
443 | $IDXPGSSMARKUP = ''; # Initial markup of index pages | |
444 | $TIDXPGSSMARKUP = ''; # Initial markup of thread index pages | |
445 | $SSMARKUP = ''; # (Default) initial markup of all pages | |
446 | ||
447 | $IDXLABEL = ''; # Label for main index | |
448 | $LIBEG = ''; # List open template for main index | |
449 | $LIEND = ''; # List close template for main index | |
450 | $LITMPL = ''; # List item template | |
451 | $AUTHBEG = ''; # Begin of author group | |
452 | $AUTHEND = ''; # End of author group | |
453 | $DAYBEG = ''; # Begin of a day group | |
454 | $DAYEND = ''; # End of a day group | |
455 | $SUBJECTBEG = ''; # Begin of subject group | |
456 | $SUBJECTEND = ''; # End of subject group | |
457 | ||
458 | $TIDXLABEL = ''; # Label for thread index | |
459 | $THEAD = ''; # Thread index header (and list start) | |
460 | $TFOOT = ''; # Thread index footer (and list end) | |
461 | $TSINGLETXT = ''; # Single/lone thread entry template | |
462 | $TTOPBEG = ''; # Top of a thread begin template | |
463 | $TTOPEND = ''; # Top of a thread end template | |
464 | $TSUBLISTBEG = ''; # Sub-thread list open | |
465 | $TSUBLISTEND = ''; # Sub-thread list close | |
466 | $TLITXT = ''; # Thread list item text | |
467 | $TLIEND = ''; # Thread list item end | |
468 | $TLINONE = ''; # List item for missing message in thread | |
469 | $TLINONEEND = ''; # List item end for missing message in thread | |
470 | $TSUBJECTBEG = ''; # Pre-text for subject-based items | |
471 | $TSUBJECTEND = ''; # Post-text for subject-based items | |
472 | $TINDENTBEG = ''; # Thread indent open | |
473 | $TINDENTEND = ''; # Thread indent close | |
474 | $TCONTBEG = ''; # Thread continue open | |
475 | $TCONTEND = ''; # Thread continue close | |
476 | ||
477 | $TSLICEBEG = ''; # Start of thread slice | |
478 | $TSLICEEND = ''; # End of thread slice | |
479 | $TSLICESINGLETXT = ''; # Single/lone thread entry template | |
480 | $TSLICETOPBEG = ''; # Top of a thread begin template | |
481 | $TSLICETOPEND = ''; # Top of a thread end template | |
482 | $TSLICESUBLISTBEG = ''; # Sub-thread list open | |
483 | $TSLICESUBLISTEND = ''; # Sub-thread list close | |
484 | $TSLICELITXT = ''; # Thread list item text | |
485 | $TSLICELIEND = ''; # Thread list item end | |
486 | $TSLICELINONE = ''; # List item for missing message in thread | |
487 | $TSLICELINONEEND = ''; # List item end for missing message in thread | |
488 | $TSLICESUBJECTBEG = ''; # Pre-text for subject-based items | |
489 | $TSLICESUBJECTEND = ''; # Post-text for subject-based items | |
490 | $TSLICEINDENTBEG = ''; # Thread indent open | |
491 | $TSLICEINDENTEND = ''; # Thread indent close | |
492 | $TSLICECONTBEG = ''; # Thread continue open | |
493 | $TSLICECONTEND = ''; # Thread continue close | |
494 | ||
495 | $TSLICESINGLETXTCUR = ''; # Current Single/lone thread entry template | |
496 | $TSLICETOPBEGCUR = ''; # Current Top of a thread begin template | |
497 | $TSLICETOPENDCUR = ''; # Current Top of a thread end template | |
498 | $TSLICELITXTCUR = ''; # Thread list current item text | |
499 | $TSLICELIENDCUR = ''; # Thread list current item end | |
500 | ||
501 | $MSGFOOT = ''; # Message footer | |
502 | $MSGHEAD = ''; # Message header | |
503 | $TOPLINKS = ''; # Message links at top of message | |
504 | $BOTLINKS = ''; # Message links at bottom of message | |
505 | $SUBJECTHEADER = ''; # Markup for message main subject line | |
506 | $HEADBODYSEP = ''; # Markup between mail header and body | |
507 | $MSGBODYEND = ''; # Markup at end of message data | |
508 | ||
509 | $FIELDSBEG = ''; # Beginning markup for mail header | |
510 | $FIELDSEND = ''; # End markup for mail header | |
511 | $FLDBEG = ''; # Beginning markup for field text | |
512 | $FLDEND = ''; # End markup for field text | |
513 | $LABELBEG = ''; # Beginning markup for field label | |
514 | $LABELEND = ''; # End markup for field label | |
515 | ||
516 | $NEXTBUTTON = ''; # Next button template | |
517 | $NEXTBUTTONIA = ''; # Next inactive button template | |
518 | $PREVBUTTON = ''; # Previous button template | |
519 | $PREVBUTTONIA = ''; # Previous inactive button template | |
520 | $NEXTLINK = ''; # Next link template | |
521 | $NEXTLINKIA = ''; # Next inactive link template | |
522 | $PREVLINK = ''; # Previous link template | |
523 | $PREVLINKIA = ''; # Previous inactive link template | |
524 | ||
525 | $TNEXTBUTTON = ''; # Thread Next button template | |
526 | $TNEXTBUTTONIA = ''; # Thread Next inactive button template | |
527 | $TPREVBUTTON = ''; # Thread Previous button template | |
528 | $TPREVBUTTONIA = ''; # Thread Previous inactive button template | |
529 | ||
530 | $TNEXTTOPBUTTON = ''; # Next Thread button template | |
531 | $TNEXTTOPBUTTONIA = ''; # Next Thread inactive button template | |
532 | $TPREVTOPBUTTON = ''; # Previous Thread button template | |
533 | $TPREVTOPBUTTONIA = ''; # Previous Thread inactive button template | |
534 | ||
535 | $TNEXTINBUTTON = ''; # Within Thread Next button template | |
536 | $TNEXTINBUTTONIA = ''; # Within Thread Next inactive button template | |
537 | $TPREVINBUTTON = ''; # Within Thread Previous button template | |
538 | $TPREVINBUTTONIA = ''; # Within Thread Previous inactive button template | |
539 | ||
540 | $TNEXTLINK = ''; # Thread Next link template | |
541 | $TNEXTLINKIA = ''; # Thread Next inactive link template | |
542 | $TPREVLINK = ''; # Thread Previous link template | |
543 | $TPREVLINKIA = ''; # Thread Previous inactive link template | |
544 | ||
545 | $TNEXTTOPLINK = ''; # Next Thread link template | |
546 | $TNEXTTOPLINKIA = ''; # Next Thread inactive link template | |
547 | $TPREVTOPLINK = ''; # Previous Thread link template | |
548 | $TPREVTOPLINKIA = ''; # Previous Thread inactive link template | |
549 | ||
550 | $TNEXTINLINK = ''; # Within Thread Next link template | |
551 | $TNEXTINLINKIA = ''; # Within Thread Next inactive link template | |
552 | $TPREVINLINK = ''; # Within Thread Previous link template | |
553 | $TPREVINLINKIA = ''; # Within Thread Previous inactive link template | |
554 | ||
555 | $IDXPGBEG = ''; # Beginning of main index page | |
556 | $IDXPGEND = ''; # Ending of main index page | |
557 | $TIDXPGBEG = ''; # Beginning of thread index page | |
558 | $TIDXPGEND = ''; # Ending of thread index page | |
559 | ||
560 | $MSGPGBEG = ''; # Beginning of message page | |
561 | $MSGPGEND = ''; # Ending of message page | |
562 | ||
563 | $FIRSTPGLINK = ''; # First page link template | |
564 | $LASTPGLINK = ''; # Last page link template | |
565 | $NEXTPGLINK = ''; # Next page link template | |
566 | $NEXTPGLINKIA = ''; # Next page inactive link template | |
567 | $PREVPGLINK = ''; # Previous page link template | |
568 | $PREVPGLINKIA = ''; # Previous page inactive link template | |
569 | ||
570 | $TFIRSTPGLINK = ''; # First thread page link template | |
571 | $TLASTPGLINK = ''; # Last thread page link template | |
572 | $TNEXTPGLINK = ''; # Thread next page link template | |
573 | $TNEXTPGLINKIA = ''; # Thread next page inactive link template | |
574 | $TPREVPGLINK = ''; # Thread previous page link template | |
575 | $TPREVPGLINKIA = ''; # Thread previous page inactive link template | |
576 | ||
577 | $FOLUPBEGIN = ''; # Start of follow-ups for message page | |
578 | $FOLUPLITXT = ''; # Markup for follow-up list entry | |
579 | $FOLUPEND = ''; # End of follow-ups for message page | |
580 | $REFSBEGIN = ''; # Start of refs for message page | |
581 | $REFSLITXT = ''; # Markup for ref list entry | |
582 | $REFSEND = ''; # End of refs for message page | |
583 | ||
584 | $MSGIDLINK = ''; # Markup for linking message-ids | |
585 | ||
586 | $NOTE = ''; # Markup template when annotation available | |
587 | $NOTEIA = ''; # Markup template when annotation not available | |
588 | $NOTEICON = ''; # Markup template for note icon if annotation | |
589 | $NOTEICONIA = ''; # Markup template for note icon if no annotation | |
590 | ||
591 | ## The following associative array if for defining custom | |
592 | ## resource variables | |
593 | %CustomRcVars = (); | |
594 | ||
595 | $X = "\034"; # Value separator (should equal $;) | |
596 | # NOTE: Older versions used this variable as | |
597 | # the list value separator. Its use should | |
598 | # now only be for extracting time from | |
599 | # indexes of messages or for processing | |
600 | # old version data. | |
601 | ||
602 | } | |
603 | ||
604 | ##---------------------------------------------------------------------------## | |
605 | ||
606 | sub mhinit_readmail_vars { | |
607 | ||
608 | ##---------------------------------------------------------------------- | |
609 | ## Default filters | |
610 | ## | |
611 | %readmail::MIMEFilters = ( | |
612 | # Content-type Filter | |
613 | #------------------------------------------------------------------- | |
614 | "application/ms-tnef", "m2h_null::filter", | |
615 | "application/octet-stream", "m2h_external::filter", | |
616 | "application/x-patch", "m2h_text_plain::filter", | |
617 | "message/delivery-status", "m2h_text_plain::filter", | |
618 | "message/external-body", "m2h_msg_extbody::filter", | |
619 | "message/partial", "m2h_text_plain::filter", | |
620 | "text/enriched", "m2h_text_enriched::filter", | |
621 | "text/html", "m2h_text_html::filter", | |
622 | "text/plain", "m2h_text_plain::filter", | |
623 | "text/richtext", "m2h_text_enriched::filter", | |
624 | "text/setext", "m2h_text_setext::filter", | |
625 | "text/tab-separated-values", "m2h_text_tsv::filter", | |
626 | "text/x-html", "m2h_text_html::filter", | |
627 | "text/x-setext", "m2h_text_setext::filter", | |
628 | ||
629 | "application/*", "m2h_external::filter", | |
630 | "audio/*", "m2h_external::filter", | |
631 | "chemical/*", "m2h_external::filter", | |
632 | "image/*", "m2h_external::filter", | |
633 | "model/*", "m2h_external::filter", | |
634 | "text/*", "m2h_text_plain::filter", | |
635 | "video/*", "m2h_external::filter", | |
636 | ||
637 | "x-sun-attachment", "m2h_text_plain::filter", | |
638 | ); | |
639 | %readmail::MIMEFiltersSrc = ( | |
640 | # Content-type Filter | |
641 | #------------------------------------------------------------------- | |
642 | "application/ms-tnef", "mhnull.pl", | |
643 | "application/octet-stream", "mhexternal.pl", | |
644 | "application/x-patch", "mhtxtplain.pl", | |
645 | "message/delivery-status", "mhtxtplain.pl", | |
646 | "message/external-body", "mhmsgextbody.pl", | |
647 | "message/partial", "mhtxtplain.pl", | |
648 | "text/enriched", "mhtxtenrich.pl", | |
649 | "text/html", "mhtxthtml.pl", | |
650 | "text/plain", "mhtxtplain.pl", | |
651 | "text/richtext", "mhtxtenrich.pl", | |
652 | "text/setext", "mhtxtsetext.pl", | |
653 | "text/tab-separated-values", "mhtxttsv.pl", | |
654 | "text/x-html", "mhtxthtml.pl", | |
655 | "text/x-setext", "mhtxtsetext.pl", | |
656 | ||
657 | "application/*", "mhexternal.pl", | |
658 | "audio/*", "mhexternal.pl", | |
659 | "chemical/*", "mhexternal.pl", | |
660 | "image/*", "mhexternal.pl", | |
661 | "model/*", "mhexternal.pl", | |
662 | "text/*", "mhtxtplain.pl", | |
663 | "video/*", "mhexternal.pl", | |
664 | ||
665 | "x-sun-attachment", "mhtxtplain.pl", | |
666 | ); | |
667 | $IsDefault{'MIMEFILTERS'} = 1; | |
668 | ||
669 | ## Default filter arguments | |
670 | ## | |
671 | %readmail::MIMEFiltersArgs = ( | |
672 | # Content-type Arguments | |
673 | #------------------------------------------------------------------- | |
674 | 'm2h_external::filter', 'inline', | |
675 | ); | |
676 | $IsDefault{'MIMEARGS'} = 1; | |
677 | ||
678 | ## Charset filters | |
679 | ## | |
680 | %readmail::MIMECharSetConverters = ( | |
681 | # Character set Converter Function | |
682 | #------------------------------------------------------------------- | |
683 | "plain", "mhonarc::htmlize", | |
684 | "us-ascii", "mhonarc::htmlize", | |
685 | "iso-8859-1", "mhonarc::htmlize", | |
686 | "iso-8859-2", "MHonArc::CharEnt::str2sgml", | |
687 | "iso-8859-3", "MHonArc::CharEnt::str2sgml", | |
688 | "iso-8859-4", "MHonArc::CharEnt::str2sgml", | |
689 | "iso-8859-5", "MHonArc::CharEnt::str2sgml", | |
690 | "iso-8859-6", "MHonArc::CharEnt::str2sgml", | |
691 | "iso-8859-7", "MHonArc::CharEnt::str2sgml", | |
692 | "iso-8859-8", "MHonArc::CharEnt::str2sgml", | |
693 | "iso-8859-9", "MHonArc::CharEnt::str2sgml", | |
694 | "iso-8859-10", "MHonArc::CharEnt::str2sgml", | |
695 | "iso-8859-15", "MHonArc::CharEnt::str2sgml", | |
696 | "iso-2022-jp", "iso_2022_jp::str2html", | |
697 | "latin1", "mhonarc::htmlize", | |
698 | "latin2", "MHonArc::CharEnt::str2sgml", | |
699 | "latin3", "MHonArc::CharEnt::str2sgml", | |
700 | "latin4", "MHonArc::CharEnt::str2sgml", | |
701 | "latin5", "MHonArc::CharEnt::str2sgml", | |
702 | "latin6", "MHonArc::CharEnt::str2sgml", | |
703 | "latin9", "MHonArc::CharEnt::str2sgml", | |
704 | "windows-1250", "MHonArc::CharEnt::str2sgml", | |
705 | "windows-1252", "MHonArc::CharEnt::str2sgml", | |
706 | "default", "-ignore-", | |
707 | ); | |
708 | %readmail::MIMECharSetConvertersSrc = ( | |
709 | # Character set Converter Function | |
710 | #------------------------------------------------------------------- | |
711 | "plain", undef, | |
712 | "us-ascii", undef, | |
713 | "iso-8859-1", undef, | |
714 | "iso-8859-2", "MHonArc/CharEnt.pm", | |
715 | "iso-8859-3", "MHonArc/CharEnt.pm", | |
716 | "iso-8859-4", "MHonArc/CharEnt.pm", | |
717 | "iso-8859-5", "MHonArc/CharEnt.pm", | |
718 | "iso-8859-6", "MHonArc/CharEnt.pm", | |
719 | "iso-8859-7", "MHonArc/CharEnt.pm", | |
720 | "iso-8859-8", "MHonArc/CharEnt.pm", | |
721 | "iso-8859-9", "MHonArc/CharEnt.pm", | |
722 | "iso-8859-10", "MHonArc/CharEnt.pm", | |
723 | "iso-8859-15", "MHonArc/CharEnt.pm", | |
724 | "iso-2022-jp", "iso2022jp.pl", | |
725 | "latin1", undef, | |
726 | "latin2", "MHonArc/CharEnt.pm", | |
727 | "latin3", "MHonArc/CharEnt.pm", | |
728 | "latin4", "MHonArc/CharEnt.pm", | |
729 | "latin5", "MHonArc/CharEnt.pm", | |
730 | "latin6", "MHonArc/CharEnt.pm", | |
731 | "latin9", "MHonArc/CharEnt.pm", | |
732 | "windows-1250", "MHonArc/CharEnt.pm", | |
733 | "windows-1252", "MHonArc/CharEnt.pm", | |
734 | "default", undef, | |
735 | ); | |
736 | $IsDefault{'CHARSETCONVERTERS'} = 1; | |
737 | ||
738 | ## Content-Transfer-Encoding decoders: | |
739 | ## readmail.pl has a default set, so we just use it. | |
740 | $IsDefault{'MIMEDECODERS'} = 1; | |
741 | ||
742 | ## Content-Types to exclude: | |
743 | ## Nothing is excluded by default. | |
744 | $IsDefault{'MIMEEXCS'} = 1; | |
745 | ||
746 | ## Content-type multipart/alternative preferences | |
747 | ## Note: The variable is not a readmail package variable, but it | |
748 | ## is used to set readmail package properties. | |
749 | @MIMEAltPrefs = ( ); | |
750 | $IsDefault{'MIMEALTPREFS'} = 1; | |
751 | ||
752 | } | |
753 | ||
754 | ##---------------------------------------------------------------------------## | |
755 | ||
756 | 1; |