]> diplodocus.org Git - nmh/blob - man/mhstore.man
pending-release-notes: add mhshow's "-prefer", and mh-format's %(kibi/kilo)
[nmh] / man / mhstore.man
1 .TH MHSTORE %manext1% "March 2, 2014" "%nmhversion%"
2 .\"
3 .\" %nmhwarning%
4 .\"
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 [ \-outfile
16 .IR outfile ]
17 .RB [ \-part
18 .IR number ]
19 \&...
20 .RB [ \-type
21 .IR content ]
22 \&...
23 .RB [ \-prefer
24 .IR content ]
25 \&...
26 .RB [ \-auto " | " \-noauto ]
27 .RB [ \-clobber
28 .IR always " | " auto " | " suffix " | " ask " | " never ]
29 .RB [ \-rcache
30 .IR policy ]
31 .RB [ \-wcache
32 .IR policy ]
33 .RB [ \-check " | " \-nocheck ]
34 .RB [ \-verbose " | " \-noverbose ]
35 .RB [ \-version ]
36 .RB [ \-help ]
37 .ad
38 .SH DESCRIPTION
39 The
40 .B mhstore
41 command allows you to store the contents of a
42 collection of MIME (multi-media) messages into files or other
43 messages.
44 .PP
45 .B mhstore
46 manipulates multi-media messages as specified in
47 RFC 2045 to RFC 2049.
48 .PP
49 By default,
50 .B mhstore
51 will store all the parts of each message.
52 Each part will be store in a separate file. The header fields of
53 the message are not stored. By using the
54 .B \-part
55 and
56 .B \-type
57 switches, you may limit the scope of
58 .B mhstore
59 to particular
60 subparts (of a multipart content) and/or particular content types.
61 .PP
62 The
63 .B \-file
64 .I file
65 switch directs
66 .B mhstore
67 to use the specified
68 file as the source message, rather than a message from a folder.
69 If you specify this file as \*(lq-\*(rq, then
70 .B mhstore
71 will
72 accept the source message on the standard input. Note that the
73 file, or input from standard input should be a validly formatted
74 message, just like any other
75 .B nmh
76 message. It should
77 .B NOT
78 be in mail drop format (to convert a file in mail drop format to
79 a folder of
80 .B nmh
81 messages, see
82 .IR inc (1)).
83 .PP
84 A part specification consists of a series of numbers separated by
85 dots. For example, in a multipart content containing three parts,
86 these would be named as 1, 2, and 3, respectively. If part 2 was
87 also a multipart content containing two parts, these would be named
88 as 2.1 and 2.2, respectively. Note that the
89 .B \-part
90 switch is
91 effective for only messages containing a multipart content. If a
92 message has some other kind of content, or if the part is itself
93 another multipart content, the
94 .B \-part
95 switch will not prevent
96 the content from being acted upon.
97 .PP
98 A content specification consists of a content type and a subtype.
99 The initial list of \*(lqstandard\*(rq content types and subtypes
100 can be found in RFC 2046.
101 .PP
102 A list of commonly used contents is briefly reproduced here:
103 .PP
104 .RS 5
105 .nf
106 .ta \w'application 'u
107 Type Subtypes
108 ---- --------
109 text plain, enriched
110 multipart mixed, alternative, digest, parallel
111 message rfc822, partial, external-body
112 application octet-stream, postscript
113 image jpeg, gif, png
114 audio basic
115 video mpeg
116 .fi
117 .RE
118 .PP
119 A legal MIME message must contain a subtype specification.
120 .PP
121 To specify a content, regardless of its subtype, just use the name
122 of the content, e.g., \*(lqaudio\*(rq. To specify a specific
123 subtype, separate the two with a slash, e.g., \*(lqaudio/basic\*(rq.
124 Note that regardless of the values given to the
125 .B \-type
126 switch,
127 a multipart content (of any subtype listed above) is always acted
128 upon. Further note that if the
129 .B \-type
130 switch is used, and it is
131 desirable to act on a message/external-body content, then the
132 .B \-type
133 switch must be used twice: once for message/external-body
134 and once for the content externally referenced.
135 .PP
136 The
137 .B \-prefer
138 switch will alter the part ordering of multipart/alternative MIME sections
139 in order to override the sender-imposed default ordering.
140 The
141 .B \-prefer
142 switch is functionally most important for
143 .BR mhshow ,
144 but is also implemented in
145 .B mhlist
146 and
147 .B mhstore
148 to make common part number ordering possible across all three programs.
149 See
150 .IR mhlist (1)
151 and
152 .IR mhshow (1)
153 for more information on
154 .BR \-prefer.
155 .SS "Checking the Contents"
156 The
157 .B \-check
158 switch tells
159 .B mhstore
160 to check each content for
161 an integrity checksum. If a content has such a checksum (specified
162 as a Content-MD5 header field), then
163 .B mhstore
164 will attempt to
165 verify the integrity of the content.
166 .SS "Storing the Contents"
167 .B mhstore
168 will store the contents of the named messages in
169 \*(lqnative\*(rq (decoded) format. Two things must be determined:
170 the directory to store the content, and the filenames. Files are
171 written in the directory given by the \*(lqnmh-storage\*(rq profile
172 entry, e.g.,
173 .PP
174 .RS 5
175 nmh-storage: /tmp
176 .RE
177 .PP
178 If this entry isn't present,
179 the current working directory is used.
180 .PP
181 If the
182 .B \-outfile
183 switch is given, its argument is used for the filename to store all
184 of the content, with \*(lq-\*(rq indicating standard output. If the
185 .B \-auto
186 switch is given, then
187 .B mhstore
188 will check if the message contains information indicating the filename
189 that should be used to store the content. This information should be
190 specified as the \*(lqfilename\*(rq attribute in the
191 \*(lqContent-Disposition\*(rq header or as the \*(lqname\*(rq
192 attribute in the \*(lqContent-Type\*(rq header for the content you are
193 storing. For security reasons, this filename will be ignored if it
194 begins with the character '/', '.', '|', or '!', or if it contains the
195 character '%'. We also recommend using a \*(lqnmh-storage\*(rq profile
196 entry or a
197 .B \-clobber
198 switch setting other than the default of \*(lqalways\*(rq to avoid
199 overwriting existing files.
200 .PP
201 If the
202 .B \-auto
203 switch is not given (or is being ignored for security
204 reasons) then
205 .B mhstore
206 will look in the user's profile for a
207 \*(lqformatting string\*(rq to determine how the different contents
208 should be stored. First,
209 .B mhstore
210 will look for an entry of
211 the form:
212 .PP
213 .RS 5
214 mhstore-store-<type>/<subtype>
215 .RE
216 .PP
217 to determine the formatting string. If this isn't found,
218 .B mhstore
219 will look for an entry of the form:
220 .PP
221 .RS 5
222 mhstore-store-<type>
223 .RE
224 .PP
225 to determine the formatting string.
226 .PP
227 If the formatting string starts with a \*(lq+\*(rq character, then
228 content is stored in the named folder. A formatting string consisting
229 solely of a \*(lq+\*(rq character is interpreted to be the current
230 folder.
231 .PP
232 If the formatting string consists solely of a \*(lq-\*(rq character,
233 then the content is sent to the standard output.
234 .PP
235 If the formatting string starts with a '|', then it represents
236 a command for
237 .B mhstore
238 to execute which should
239 ultimately store the content. The content will be passed to the
240 standard input of the command. Before the command is executed,
241 .B mhstore
242 will change to the appropriate directory, and any
243 escapes (given below) in the formatting string will be expanded.
244 The use of the \*(lq%a\*(rq sequence is not recommended because
245 the user has no control over the Content-Type parameter data.
246 .PP
247 Otherwise the formatting string will represent a pathname in which
248 to store the content. If the formatting string starts with a '/',
249 then the content will be stored in the full path given, else the
250 file name will be relative to the value of \*(lqnmh-storage\*(rq or
251 the current working directory. Any escapes (given below) will be
252 expanded, except for the a-escape. Note that if \*(lqnmh-storage\*(rq
253 is not an absolute path, it will be relative to the folder that
254 contains the message(s).
255 .PP
256 A command or pathname formatting string may contain the following
257 escapes. If the content isn't part of a multipart (of any subtype
258 listed above) content, the p-escapes are ignored.
259 .PP
260 .RS 5
261 .nf
262 .ta \w'%P 'u
263 %a Parameters from Content-Type (only valid with command)
264 %m Insert message number
265 %P Insert part number with leading dot
266 %p Insert part number without leading dot
267 %t Insert content type
268 %s Insert content subtype
269 %% Insert character %
270 .fi
271 .RE
272 .PP
273 If no formatting string is found,
274 .B mhstore
275 will check to see
276 if the content is application/octet-stream with parameter
277 \*(lqtype=tar\*(rq. If so,
278 .B mhstore
279 will choose an appropriate
280 filename. If the content is not application/octet-stream, then
281 .B mhstore
282 will check to see if the content is a message. If
283 so,
284 .B mhstore
285 will use the value \*(lq+\*(rq. As a last resort,
286 .B mhstore
287 will use the value \*(lq%m%P.%s\*(rq.
288 .PP
289 Example profile entries might be:
290 .PP
291 .RS 5
292 .nf
293 mhstore-store-text: %m%P.txt
294 mhstore-store-text: +inbox
295 mhstore-store-message/partial: +
296 mhstore-store-audio/basic: | raw2audio -e ulaw -s 8000 -c 1 > %m%P.au
297 mhstore-store-image/jpeg: %m%P.jpg
298 mhstore-store-application/PostScript: %m%P.ps
299 .fi
300 .RE
301 .PP
302 The
303 .B \-verbose
304 switch directs
305 .B mhstore
306 to print out the names of files that it stores. For backward
307 compatibility, it is the default. The
308 .B \-noverbose
309 switch suppresses these printouts.
310 .PP
311 .SS "Overwriting Existing Files"
312 The
313 .B \-clobber
314 switch controls whether
315 .B mhstore
316 should overwrite existing files. The allowed values for this switch
317 and corresponding behavior when
318 .B mhstore
319 encounters an existing file are:
320 .PP
321 .RS 5
322 .nf
323 .ta \w'suffix 'u
324 always Overwrite existing file (default)
325 auto Create new file of form name-n.extension
326 suffix Create new file of form name.extension.n
327 ask Prompt the user to specify whether or not to overwrite
328 the existing file
329 never Do not overwrite existing file
330 .fi
331 .RE
332 .PP
333 With
334 .I auto
335 and
336 .IR suffix ,
337 .I n
338 is the lowest unused number, starting from one, in the same form. If
339 a filename does not have an extension (following a '.'), then
340 .I auto
341 and
342 .I suffix
343 create a new file of the form
344 .I name-n
345 and
346 .IR name.n ,
347 respectively. With
348 .I never
349 and
350 .IR ask ,
351 the exit status of
352 .B mhstore
353 will be the number of files that were requested but not stored.
354 .PP
355 With
356 .IR ask ,
357 if standard input is connected to a terminal,
358 the user is prompted to respond
359 .IR yes ,
360 .IR no ,
361 or
362 .I rename
363 to whether the file should be overwritten. The responses
364 can be abbreviated. If the user responds with
365 .IR rename ,
366 then
367 .B mhstore
368 prompts the user for the name of the new file to be created. If it is
369 a relative path name (does not begin with '/'), then it is relative to
370 the current directory. If it is an absolute or relative path to a
371 directory that does not exist, the user will be prompted whether to
372 create the directory. If standard input is not connected to a
373 terminal,
374 .I ask
375 behaves the same as
376 .IR always .
377 .SS "Reassembling Messages of Type message/partial"
378 .B mhstore
379 is also able to reassemble messages that have been
380 split into multiple messages of type \*(lqmessage/partial\*(rq.
381 .PP
382 When asked to store a content containing a partial message,
383 .B mhstore
384 will try to locate all of the portions and combine
385 them accordingly. The default is to store the combined parts as
386 a new message in the current folder, although this can be changed
387 using formatting strings as discussed above. Thus, if someone has
388 sent you a message in several parts (such as the output from
389 .BR sendfiles ),
390 you can easily reassemble them all into a single
391 message in the following fashion:
392 .PP
393 .RS 5
394 .nf
395 % mhlist 5-8
396 msg part type/subtype size description
397 5 message/partial 47K part 1 of 4
398 6 message/partial 47K part 2 of 4
399 7 message/partial 47K part 3 of 4
400 8 message/partial 18K part 4 of 4
401 % mhstore 5-8
402 reassembling partials 5,6,7,8 to folder inbox as message 9
403 % mhlist -verbose 9
404 msg part type/subtype size description
405 9 application/octet-stream 118K
406 (extract with uncompress | tar xvpf -)
407 type=tar
408 conversions=compress
409 .fi
410 .RE
411 .PP
412 This will store exactly one message, containing the sum of the
413 parts. It doesn't matter whether the partials are specified in
414 order, since
415 .B mhstore
416 will sort the partials, so that they
417 are combined in the correct order. But if
418 .B mhstore
419 can not
420 locate every partial necessary to reassemble the message, it will
421 not store anything.
422 .SS "External Access"
423 For contents of type message/external-body,
424 \fImhstore\fR supports these access-types:
425 .PP
426 .IP \(bu 4
427 afs
428 .IP \(bu 4
429 anon-ftp
430 .IP \(bu 4
431 ftp
432 .IP \(bu 4
433 local-file
434 .IP \(bu 4
435 mail-server
436 .IP \(bu 4
437 url
438 .PP
439 For the \*(lqanon-ftp\*(rq and \*(lqftp\*(rq access types,
440 .B mhstore
441 will look for the \*(lqnmh-access-ftp\*(rq
442 profile entry, e.g.,
443 .PP
444 .RS 5
445 nmh-access-ftp: myftp.sh
446 .RE
447 .PP
448 to determine the pathname of a program to perform the FTP retrieval.
449 This program is invoked with these arguments:
450 .PP
451 .RS 5
452 .nf
453 domain name of FTP-site
454 username
455 password
456 remote directory
457 remote filename
458 local filename
459 \*(lqascii\*(rq or \*(lqbinary\*(rq
460 .fi
461 .RE
462 .PP
463 The program should terminate with an exit status of zero if the
464 retrieval is successful, and a non-zero exit status otherwise.
465 .PP
466 For the \*(lqurl\*(rq access types,
467 .B mhstore
468 will look for the \*(lqnmh-access-url\*(rq profile entry, e.g.,
469 .PP
470 .RS 5
471 nmh-access-url: curl -L
472 .RE
473 .PP
474 to determine the program to use to perform the HTTP retrieval. This program
475 is invoked with one argument: the URL of the content to retrieve. The program
476 should write the content to standard out, and should terminate with a status of zero if the retrieval is successful and a non\-zero exit status otherwise.
477 .PP
478 .SS "The Content Cache"
479 When
480 .B mhstore
481 encounters an external content containing a
482 \*(lqContent-ID:\*(rq field, and if the content allows caching, then
483 depending on the caching behavior of
484 .BR mhstore ,
485 the content might be read from or written to a cache.
486 .PP
487 The caching behavior of
488 .B mhstore
489 is controlled with the
490 .B \-rcache
491 and
492 .B \-wcache
493 switches, which define the policy for reading from,
494 and writing to, the cache, respectively. One of four policies may be
495 specified: \*(lqpublic\*(rq, indicating that
496 .B mhstore
497 should make use
498 of a publically-accessible content cache; \*(lqprivate\*(rq, indicating
499 that
500 .B mhstore
501 should make use of the user's private content cache;
502 \*(lqnever\*(rq, indicating that
503 .B mhstore
504 should never make use of
505 caching; and, \*(lqask\*(rq, indicating that
506 .B mhstore
507 should ask the user.
508 .PP
509 There are two directories where contents may be cached: the profile entry
510 \*(lqnmh-cache\*(rq names a directory containing world-readable contents, and,
511 the profile entry \*(lqnmh-private-cache\*(rq names a directory containing
512 private contents. The former should be an absolute (rooted) directory
513 name.
514 .PP
515 For example,
516 .PP
517 .RS 5
518 nmh-cache: /tmp
519 .RE
520 .PP
521 might be used if you didn't care that the cache got wiped after each
522 reboot of the system. The latter is interpreted relative to the user's
523 nmh directory, if not rooted, e.g.,
524 .PP
525 .RS 5
526 nmh-private-cache: .cache
527 .RE
528 .PP
529 (which is the default value).
530 .SS "User Environment"
531 Because the environment in which
532 .B mhstore
533 operates may vary for
534 different machines,
535 .B mhstore
536 will look for the environment variable
537 .BR $MHSTORE .
538 If present, this specifies the name of an additional
539 user profile which should be read. Hence, when a user logs in on a
540 particular machine, this environment variable should be set to
541 refer to a file containing definitions useful for that machine.
542 Finally,
543 .B mhstore
544 will attempt to consult
545 .PP
546 .RS 5
547 %nmhetcdir%/mhn.defaults
548 .RE
549 .PP
550 which is created automatically during
551 .B nmh
552 installation.
553 .PP
554 See "Profile Lookup" in
555 .IR mh-profile (5)
556 for the profile search order, and for how duplicate entries are treated.
557 .SH FILES
558 .B mhstore
559 looks for additional profile files in multiple locations: absolute
560 pathnames are accessed directly, tilde expansion is done on usernames,
561 and files are searched for in the user's
562 .I Mail
563 directory as specified in their profile. If not found there, the directory
564 .RI \*(lq %nmhetcdir% \*(rq
565 is checked.
566 .PP
567 .fc ^ ~
568 .nf
569 .ta \w'%nmhetcdir%/ExtraBigFileName 'u
570 ^$HOME/\&.mh\(ruprofile~^The user profile
571 ^$MHSTORE~^Additional profile entries
572 ^%nmhetcdir%/mhn.defaults~^System default MIME profile entries
573 .fi
574 .SH "PROFILE COMPONENTS"
575 .fc ^ ~
576 .nf
577 .ta 2.4i
578 .ta \w'ExtraBigProfileName 'u
579 ^Path:~^To determine the user's nmh directory
580 ^Current\-Folder:~^To find the default current folder
581 ^nmh-access-ftp:~^Program to retrieve contents via FTP
582 ^nmh-access-url:~^Program to retrieve contents via HTTP
583 ^nmh-cache~^Public directory to store cached external contents
584 ^nmh-private-cache~^Personal directory to store cached external contents
585 ^nmh-storage~^Directory to store contents
586 ^mhstore-store-<type>*~^Template for storing contents
587 .fi
588 .SH "SEE ALSO"
589 .IR mhbuild (1),
590 .IR mhlist (1),
591 .IR mhshow (1),
592 .IR sendfiles (1)
593 .SH DEFAULTS
594 .nf
595 .RB ` +folder "' defaults to the current folder"
596 .RB ` msgs "' defaults to cur"
597 .RB ` \-noauto '
598 .RB ` \-clobber\ always '
599 .RB ` \-nocheck '
600 .RB ` \-rcache\ ask '
601 .RB ` \-wcache\ ask '
602 .RB ` \-verbose '
603 .SH CONTEXT
604 If a folder is given, it will become the current folder. The last
605 message selected will become the current message.
606 .SH BUGS
607 Partial messages contained within a multipart content are not reassembled.