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