0a338e7bab4784be45dbfafcfbd9e7a647d4db43
[mmh] / man / mhstore.man1
1 .\"
2 .\" %nmhwarning%
3 .\"
4 .TH MHSTORE %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
5 .SH NAME
6 mhstore \- store contents of MIME messages into files
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B mhstore
11 .RI [ +folder ]
12 .RI [ msgs ]
13 .RB [ \-file
14 .IR file ]
15 .RB [ \-part
16 .IR number ]
17 \&...
18 .RB [ \-type
19 .IR content ]
20 \&...
21 .RB [ \-auto " | " \-noauto ]
22 .RB [ \-rcache
23 .IR policy ]
24 .RB [ \-wcache
25 .IR policy ]
26 .RB [ \-version ]
27 .RB [ \-help ]
28 .ad
29 .SH DESCRIPTION
30 The
31 .B mhstore
32 command allows you to store the contents of a
33 collection of MIME (multi-media) messages into files or other
34 messages.
35 .PP
36 .B mhstore
37 manipulates multi-media messages as specified in
38 RFC\-2045 thru RFC\-2049.
39 .PP
40 By default,
41 .B mhstore
42 will store all the parts of each message.
43 Each part will be store in a separate file.  The header fields of
44 the message are not stored.  By using the
45 .B \-part
46 and
47 .B \-type
48 switches, you may limit the scope of
49 .B mhstore
50 to particular
51 subparts (of a multipart content) and/or particular content types.
52 .PP
53 The option
54 .B \-file
55 .I file
56 directs
57 .B mhstore
58 to use the specified
59 file as the source message, rather than a message from a folder.
60 If you specify this file as \*(lq-\*(rq, then
61 .B mhstore
62 will
63 accept the source message on the standard input.  Note that the
64 file, or input from standard input should be a validly formatted
65 message, just like any other
66 .B nmh
67 message.  It should
68 .B NOT
69 be in mail drop format (to convert a file in mail drop format to
70 a folder of
71 .B nmh
72 messages, see
73 .BR inc (1)).
74 .PP
75 A part specification consists of a series of numbers separated by
76 dots.  For example, in a multipart content containing three parts,
77 these would be named as 1, 2, and 3, respectively.  If part 2 was
78 also a multipart content containing two parts, these would be named
79 as 2.1 and 2.2, respectively.  Note that the
80 .B \-part
81 switch is
82 effective for only messages containing a multipart content.  If a
83 message has some other kind of content, or if the part is itself
84 another multipart content, the
85 .B \-part
86 switch will not prevent
87 the content from being acted upon.
88 .PP
89 A content specification consists of a content type and a subtype.
90 The initial list of \*(lqstandard\*(rq content types and subtypes
91 can be found in RFC\-2046.
92 .PP
93 A list of commonly used contents is briefly reproduced here:
94 .PP
95 .RS 5
96 .nf
97 .ta \w'application  'u
98 Type    Subtypes
99 ----    --------
100 text    plain, enriched
101 multipart       mixed, alternative, digest, parallel
102 message rfc822, partial, external-body
103 application     octet-stream, postscript
104 image   jpeg, gif, png
105 audio   basic
106 video   mpeg
107 .fi
108 .RE
109 .PP
110 A legal MIME message must contain a subtype specification.
111 .PP
112 To specify a content, regardless of its subtype, just use the name
113 of the content, e.g., \*(lqaudio\*(rq.  To specify a specific
114 subtype, separate the two with a slash, e.g., \*(lqaudio/basic\*(rq.
115 Note that regardless of the values given to the
116 .B \-type
117 switch,
118 a multipart content (of any subtype listed above) is always acted
119 upon.  Further note that if the
120 .B \-type
121 switch is used, and it is
122 desirable to act on a message/external-body content, then the
123 .B \-type
124 switch must be used twice: once for message/external-body
125 and once for the content externally referenced.
126 .SS "Storing the Contents"
127 The
128 .B mhstore
129 will store the contents of the named messages in
130 \*(lqnative\*(rq (decoded) format.  Two things must be determined:
131 the directory to store the content, and the filenames.  Files are
132 written in the directory given by the \*(lqnmh-storage\*(rq profile
133 entry, e.g.,
134 .PP
135 .RS 5
136 nmh-storage: /tmp
137 .RE
138 .PP
139 If this entry isn't present,
140 the current working directory is used.
141 .PP
142 If the
143 .B \-auto
144 switch is given, then
145 .B mhstore
146 will check if
147 the message contains information indicating the filename that should
148 be used to store the content.  This information should be specified
149 as the attribute \*(lqname=filename\*(rq in the \*(lqContent-Type\*(rq header
150 for the content you are storing.  For security reasons, this filename
151 will be ignored if it begins with the character '/', '.', '|', or '!',
152 or if it contains the character '%'.  For the sake of security,
153 this switch is not the default, and it is recommended that you do
154 NOT put the
155 .B \-auto
156 switch in your
157 .I \&.mmh/profile
158 file.
159 .PP
160 If the
161 .B \-auto
162 switch is not given (or is being ignored for security
163 reasons) then
164 .B mhstore
165 will look in the user's profile for a
166 \*(lqformatting string\*(rq to determine how the different contents
167 should be stored.  First,
168 .B mhstore
169 will look for an entry of
170 the form:
171 .PP
172 .RS 5
173 mhstore-store-<type>/<subtype>
174 .RE
175 .PP
176 to determine the formatting string.  If this isn't found,
177 .B mhstore
178 will look for an entry of the form:
179 .PP
180 .RS 5
181 mhstore-store-<type>
182 .RE
183 .PP
184 to determine the formatting string.
185 .PP
186 If the formatting string starts with a \*(lq+\*(rq character, then
187 content is stored in the named folder.  A formatting string consisting
188 solely of a \*(lq+\*(rq character is interpreted to be the current
189 folder.
190 .PP
191 If the formatting string consists solely of a \*(lq-\*(rq character,
192 then the content is sent to the standard output.
193 .PP
194 If the formatting string starts with a '|', then the display string
195 will represent a command for
196 .B mhstore
197 to execute which should
198 ultimately store the content.  The content will be passed to the
199 standard input of the command.  Before the command is executed,
200 .B mhstore
201 will change to the appropriate directory, and any
202 escapes (given below) in the display string will be expanded.
203 .PP
204 Otherwise the formatting string will represent a pathname in which
205 to store the content.  If the formatting string starts with a '/',
206 then the content will be stored in the full path given, else the
207 file name will be relative to the value of \*(lqnmh-storage\*(rq or
208 the current working directory.  Any escapes (given below) will be
209 expanded, except for the a-escape.  Note that if \*(lqnmh-storage\*(rq
210 is not an absolute path, it will be relative to the folder that
211 contains the message(s).
212 .PP
213 A command or pathname formatting string may contain the following
214 escapes.  If the content isn't part of a multipart (of any subtype
215 listed above) content, the p-escapes are ignored.
216 .PP
217 .RS 5
218 .nf
219 .ta \w'%P  'u
220 %a      Parameters from Content-type  (only valid with command)
221 %m      Insert message number
222 %P      Insert part number with leading dot
223 %p      Insert part number without leading dot
224 %t      Insert content type
225 %s      Insert content subtype
226 %%      Insert character %
227 .fi
228 .RE
229 .PP
230 If no formatting string is found,
231 .B mhstore
232 will check to see
233 if the content is application/octet-stream with parameter
234 \*(lqtype=tar\*(rq.  If so,
235 .B mhstore
236 will choose an appropriate
237 filename.  If the content is not application/octet-stream, then
238 .B mhstore
239 will check to see if the content is a message.  If
240 so,
241 .B mhstore
242 will use the value \*(lq+\*(rq.  As a last resort,
243 .B mhstore
244 will use the value \*(lq%m%P.%s\*(rq.
245 .PP
246 Example profile entries might be:
247 .PP
248 .RS 5
249 .nf
250 mhstore-store-text: %m%P.txt
251 mhstore-store-text: +inbox
252 mhstore-store-message/partial: +
253 mhstore-store-audio/basic: | raw2audio -e ulaw -s 8000 -c 1 > %m%P.au
254 mhstore-store-image/jpeg: %m%P.jpg
255 mhstore-store-application/PostScript: %m%P.ps
256 .fi
257 .RE
258 .PP
259 .SS "Reassembling Messages of Type message/partial"
260 .B mhstore
261 is also able to reassemble messages that have been
262 split into multiple messages of type \*(lqmessage/partial\*(rq.
263 .PP
264 When asked to store a content containing a partial message,
265 .B mhstore
266 will try to locate all of the portions and combine
267 them accordingly.  The default is to store the combined parts as
268 a new message in the current folder, although this can be changed
269 using formatting strings as discussed above.  Thus, if someone has
270 sent you a message in several parts (such as the output from
271 .BR sendfiles ),
272 you can easily reassemble them all into a single
273 message in the following fashion:
274 .PP
275 .RS 5
276 .nf
277 % mhlist 5-8
278  msg part  type/subtype             size description
279    5       message/partial           47K part 1 of 4
280    6       message/partial           47K part 2 of 4
281    7       message/partial           47K part 3 of 4
282    8       message/partial           18K part 4 of 4
283 % mhstore 5-8
284 reassembling partials 5,6,7,8 to folder inbox as message 9
285 % mhlist 9
286  msg part  type/subtype             size description
287    9       application/octet-stream 118K
288              (extract with uncompress | tar xvpf -)
289              type=tar
290              conversions=compress
291 .fi
292 .RE
293 .PP
294 This will store exactly one message, containing the sum of the
295 parts.  It doesn't matter whether the partials are specified in
296 order, since
297 .B mhstore
298 will sort the partials, so that they
299 are combined in the correct order.  But if
300 .B mhstore
301 can not
302 locate every partial necessary to reassemble the message, it will
303 not store anything.
304 RE
305 .PP
306 By using the
307 .B \-auto
308 switch,
309 .B mhstore
310 will automatically do the extraction for you:
311 .PP
312 .RS 5
313 .nf
314 % mhlist 5-8
315  msg part  type/subtype             size description
316    5       message/partial           47K part 1 of 4
317    6       message/partial           47K part 2 of 4
318    7       message/partial           47K part 3 of 4
319    8       message/partial           18K part 4 of 4
320 % mhstore 5-8
321 reassembling partials 5,6,7,8 to folder inbox as message 9
322 % mhlist 9
323  msg part  type/subtype             size description
324    9       application/octet-stream 118K
325              (extract with uncompress | tar xvpf -)
326              type=tar
327              conversions=compress
328 % mhstore -auto 9
329 -- tar listing appears here as files are extracted
330 .fi
331 .RE
332 .PP
333 As the second
334 .B tar
335 listing is generated, the files are extracted.
336 A prudent user will never put
337 .B \-auto
338 in the profile.
339 The correct procedure is to first use
340 .B mhlist
341 to find out what will be extracted.  Then
342 .B mhstore
343 can be invoked with
344 .B \-auto
345 to perform the extraction.
346 .SS "External Access"
347 For contents of type message/external-body,
348 \fImhstore\fR supports these access-types:
349 .PP
350 .IP \(bu 4
351 afs
352 .IP \(bu 4
353 anon-ftp
354 .IP \(bu 4
355 ftp
356 .IP \(bu 4
357 local-file
358 .IP \(bu 4
359 mail-server
360 .PP
361 For the \*(lqanon-ftp\*(rq and \*(lqftp\*(rq access types,
362 .B mhstore
363 will look for the \*(lqnmh-access-ftp\*(rq
364 profile entry, e.g.,
365 .PP
366 .RS 5
367 nmh-access-ftp: myftp.sh
368 .RE
369 .PP
370 to determine the pathname of a program to perform the FTP retrieval.
371 This program is invoked with these arguments:
372 .PP
373 .RS 5
374 .nf
375 domain name of FTP-site
376 username
377 password
378 remote directory
379 remote filename
380 local filename
381 \*(lqascii\*(rq or \*(lqbinary\*(rq
382 .fi
383 .RE
384 .PP
385 The program should terminate with an exit status of zero if the
386 retrieval is successful, and a non-zero exit status otherwise.
387 .SS "The Content Cache"
388 When
389 .B mhstore
390 encounters an external content containing a
391 \*(lqContent-ID:\*(rq field, and if the content allows caching, then
392 depending on the caching behavior of
393 .BR mhstore ,
394 the content might be read from or written to a cache.
395 .PP
396 The caching behavior of
397 .B mhstore
398 is controlled with the
399 .B \-rcache
400 and
401 .B \-wcache
402 switches, which define the policy for reading from,
403 and writing to, the cache, respectively.  One of four policies may be
404 specified: \*(lqpublic\*(rq, indicating that
405 .B mhstore
406 should make use
407 of a publically-accessible content cache; \*(lqprivate\*(rq, indicating
408 that
409 .B mhstore
410 should make use of the user's private content cache;
411 \*(lqnever\*(rq, indicating that
412 .B mhstore
413 should never make use of
414 caching; and, \*(lqask\*(rq, indicating that
415 .B mhstore
416 should ask the user.
417 .PP
418 There are two directories where contents may be cached: the profile entry
419 \*(lqnmh-cache\*(rq names a directory containing world-readable contents, and,
420 the profile entry \*(lqnmh-private-cache\*(rq names a directory containing
421 private contents.  The former should be an absolute (rooted) directory
422 name.
423 .PP
424 For example,
425 .PP
426 .RS 5
427 nmh-cache: /tmp
428 .RE
429 .PP
430 might be used if you didn't care that the cache got wiped after each
431 reboot of the system.  The private chace is interpreted relative to the user's
432 mail storage, if not rooted, e.g.,
433 .PP
434 .RS 5
435 nmh-private-cache: .cache
436 .RE
437 .PP
438 (which is the default value).
439 .SS "User Environment"
440 Because the display environment in which
441 .B mhstore
442 operates may vary for
443 different machines,
444 .B mhstore
445 will look for the environment variable
446 .BR $MHSTORE .
447 If present, this specifies the name of an additional
448 user profile which should be read.  Hence, when a user logs in on a
449 particular machine, this environment variable should be set to
450 refer to a file containing definitions useful for that machine.
451 Finally,
452 .B mhstore
453 will attempt to consult one other additional
454 user profile, e.g.,
455 .PP
456 .RS 5
457 %etcdir%/mhn.defaults
458 .RE
459 .PP
460 which is created automatically during
461 .B nmh
462 installation.
463
464 .SH FILES
465 .fc ^ ~
466 .nf
467 .ta \w'%etcdir%/ExtraBigFileName  'u
468 ^$HOME/.mmh/profile~^The user profile
469 ^$MHSTORE~^Additional profile entries
470 ^%etcdir%/mhn.defaults~^System default MIME profile entries
471 .fi
472
473 .SH "PROFILE COMPONENTS"
474 .fc ^ ~
475 .nf
476 .ta 2.4i
477 .ta \w'ExtraBigProfileName  'u
478 ^Path:~^To determine the user's mail storage
479 ^Current\-Folder:~^To find the default current folder
480 ^nmh-access-ftp:~^Program to retrieve contents via FTP
481 ^nmh-cache~^Public directory to store cached external contents
482 ^nmh-private-cache~^Personal directory to store cached external contents
483 ^nmh-storage~^Directory to store contents
484 ^mhstore-store-<type>*~^Template for storing contents
485 .fi
486
487 .SH "SEE ALSO"
488 mhbuild(1), mhlist(1), mhshow(1), sendfiles(1)
489
490 .SH DEFAULTS
491 .nf
492 .RB ` +folder "' defaults to the current folder"
493 .RB ` msgs "' defaults to cur"
494 .RB ` \-noauto '
495 .RB ` \-rcache \ ask'
496 .RB ` \-wcache \ ask'
497
498 .SH CONTEXT
499 If a folder is given, it will become the current folder.  The last
500 message selected will become the current message.
501
502 .SH BUGS
503 Partial messages contained within a multipart content are not reassembled.