]> diplodocus.org Git - nmh/blob - man/mhstore.man
Reorder configure options to be before variables
[nmh] / man / mhstore.man
1 .TH MHSTORE %manext1% 2015-02-06 "%nmhversion%"
2 .
3 .\" %nmhwarning%
4 .
5 .SH NAME
6 mhstore \- store contents of nmh MIME messages into files
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B mhstore
11 .RB [ \-help ]
12 .RB [ \-version ]
13 .RI [ +folder ]
14 .RI [ msgs ]
15 .RB [ \-file
16 .IR file ]
17 .RB [ \-outfile
18 .IR outfile ]
19 .RB [ \-part
20 .IR number ]
21 \&...
22 .RB [ \-type
23 .IR content ]
24 \&...
25 .RB [ \-prefer
26 .IR content ]
27 \&...
28 .RB [ \-noprefer ]
29 .RB [ \-auto " | " \-noauto ]
30 .RB [ \-clobber
31 .IR always " | " auto " | " suffix " | " ask " | " never ]
32 .RB [ \-verbose " | " \-noverbose ]
33 .ad
34 .SH DESCRIPTION
35 The
36 .B mhstore
37 command allows you to store the contents of a collection of MIME
38 (multi-media) messages into files or other messages.
39 .PP
40 .B mhstore
41 manipulates multi-media messages as specified in RFC 2045 to RFC 2049.
42 .PP
43 By default,
44 .B mhstore
45 will store all the parts of each message.
46 Each part will be stored in a separate file. The header fields of
47 the message are not stored. By using the
48 .BR \-part ,
49 .BR \-type ,
50 and
51 .B \-prefer
52 switches, you may limit and reorder the set of parts to be stored,
53 based on part number and/or content type.
54 .PP
55 The
56 .B \-file
57 .I file
58 switch directs
59 .B mhstore
60 to use the specified file as the source message, rather than a message
61 from a folder. If you specify this file as \*(lq-\*(rq, then
62 .B mhstore
63 will 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 .I not
69 be in mail drop format (to convert a file in
70 mail drop format to a folder of
71 .B nmh
72 messages, see
73 .IR 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 also
78 a multipart content containing two parts, these would be named as 2.1
79 and 2.2, respectively. Note that the
80 .B \-part
81 switch is effective only for messages containing a multipart content.
82 If a message has some other kind of content, or if the part is itself
83 another multipart content, the
84 .B \-part
85 switch will not prevent the content from being acted upon.
86 .PP
87 The
88 .B \-type
89 switch can also be used to restrict (or, when used in conjunction with
90 .BR \-part ,
91 to further restrict) the selection of parts according to content type.
92 One or more
93 .B \-type
94 switches part will only select the first match from a
95 multipart/alternative, even if there is more than one
96 subpart that matches (one of) the given content type(s).
97 .PP
98 Using either
99 .B \-part
100 or
101 .B -type
102 switches alone will cause either to select the part(s) they match.
103 Using them together will select only the part(s) matched by both
104 (sets of) switches. In other words, the result is the intersection,
105 and not the union, of their separate match results.
106 .PP
107 A content specification consists of a content type and a subtype.
108 The initial list of \*(lqstandard\*(rq content types and subtypes can
109 be found in RFC 2046.
110 .PP
111 A list of commonly used contents is briefly reproduced here:
112 .PP
113 .RS 5
114 .nf
115 .ta \w'application 'u
116 Type Subtypes
117 ---- --------
118 text plain, enriched
119 multipart mixed, alternative, digest, parallel
120 message rfc822, external-body
121 application octet-stream, postscript
122 image jpeg, gif, png
123 audio basic
124 video mpeg
125 .fi
126 .RE
127 .PP
128 A legal MIME message must contain a subtype specification.
129 .PP
130 To specify a content, regardless of its subtype, just use the name
131 of the content, e.g., \*(lqaudio\*(rq. To specify a specific
132 subtype, separate the two with a slash, e.g., \*(lqaudio/basic\*(rq.
133 Note that regardless of the values given to the
134 .B \-type
135 switch, a multipart content (of any subtype listed above) is always acted
136 upon. Further note that if the
137 .B \-type
138 switch is used, and it is desirable to act on a message/external-body
139 content, then the
140 .B \-type
141 switch must be used twice: once for message/external-body and once for
142 the content externally referenced.
143 .PP
144 The
145 .B \-prefer
146 switch will alter the part-ordering of multipart/alternative MIME sections
147 in order to override the sender-imposed default ordering.
148 The
149 .B \-prefer
150 switch is functionally most important for
151 .BR mhshow ,
152 but is also implemented in
153 .B mhlist
154 and
155 .B mhstore
156 to make common part-numbering possible across all three programs.
157 The last of multiple
158 .B \-prefer
159 switches will have the highest priority. This allows the command line
160 switches to override profile entries.
161 See
162 .IR mhlist (1)
163 and
164 .IR mhshow (1)
165 for more information on
166 .BR \-prefer .
167 .PP
168 The
169 .B \-noprefer
170 switch will cancel any previous
171 .B \-prefer
172 switches.
173 .SS "Storing the Contents"
174 .B mhstore
175 will store the contents of the named messages in
176 \*(lqnative\*(rq (decoded) format. Two things must be determined:
177 the directory in which to store the content, and the filenames.
178 Files are written in the directory given by the
179 \*(lqnmh-storage\*(rq profile entry, e.g.,
180 .PP
181 .RS 5
182 nmh-storage: /tmp
183 .RE
184 .PP
185 If this entry isn't present, the current working directory is used.
186 .PP
187 If the
188 .B \-outfile
189 switch is given, its argument is used for the filename to store all
190 of the content, with \*(lq-\*(rq indicating standard output. If the
191 .B \-auto
192 switch is given, then
193 .B mhstore
194 will check if the message contains information indicating the filename
195 that should be used to store the content. This information should be
196 specified as the \*(lqfilename\*(rq attribute in the
197 \*(lqContent-Disposition\*(rq header or as the \*(lqname\*(rq
198 attribute in the \*(lqContent-Type\*(rq header for the content you are
199 storing. For security reasons, this filename will be ignored if it
200 begins with the character '/', '.', '|', or '!', or if it contains the
201 character '%'. We also recommend using a \*(lqnmh-storage\*(rq profile
202 entry or a
203 .B \-clobber
204 switch setting other than the default of \*(lqalways\*(rq to avoid
205 overwriting existing files.
206 .PP
207 If the
208 .B \-auto
209 switch is not given (or is being ignored for security reasons) then
210 .B mhstore
211 will look in the user's profile for a \*(lqformatting string\*(rq to
212 determine how the different contents should be stored. First,
213 .B mhstore
214 will look for an entry of the form:
215 .PP
216 .RS 5
217 mhstore-store-<type>/<subtype>
218 .RE
219 .PP
220 to determine the formatting string. If this isn't found,
221 .B mhstore
222 will look for an entry of the form:
223 .PP
224 .RS 5
225 mhstore-store-<type>
226 .RE
227 .PP
228 to determine the formatting string.
229 .PP
230 If the formatting string starts with a \*(lq+\*(rq character, then
231 content is stored in the named folder. A formatting string consisting
232 solely of a \*(lq+\*(rq character is interpreted to be the current
233 folder.
234 .PP
235 If the formatting string consists solely of a \*(lq-\*(rq character,
236 then the content is sent to the standard output.
237 .PP
238 If the formatting string starts with a '|', then it represents
239 a command for
240 .B mhstore
241 to execute which should ultimately store the content.
242 The content will be passed to the standard input of the command.
243 Before the command is executed,
244 .B mhstore
245 will change to the appropriate directory, and any escapes (given below)
246 in the formatting string will be expanded.
247 The use of the \*(lq%a\*(rq sequence is not recommended because
248 the user has no control over the Content-Type parameter data.
249 .PP
250 Otherwise, the formatting string will represent a pathname in which
251 to store the content. If the formatting string starts with a '/',
252 then the content will be stored in the full path given, else the
253 file name will be relative to the value of \*(lqnmh-storage\*(rq or
254 the current working directory. Any escapes (given below) will be
255 expanded, except for the a-escape. Note that if \*(lqnmh-storage\*(rq
256 is not an absolute path, it will be relative to the folder that
257 contains the message(s).
258 .PP
259 A command or pathname formatting string may contain the following
260 escapes. If the content isn't part of a multipart (of any subtype
261 listed above) content, the p-escapes are ignored.
262 .PP
263 .RS 5
264 .nf
265 .ta \w'%P 'u
266 %a Parameters from Content-Type (only valid with command)
267 %m Insert message number
268 %P Insert part number with leading dot
269 %p Insert part number without leading dot
270 %t Insert content type
271 %s Insert content subtype
272 %% Insert character %
273 .fi
274 .RE
275 .PP
276 If no formatting string is found,
277 .B mhstore
278 will check to see if the content is application/octet-stream with parameter
279 \*(lqtype=tar\*(rq. If so,
280 .B mhstore
281 will choose an appropriate filename. If the content is not
282 application/octet-stream, then
283 .B mhstore
284 will check to see if the content is a message. If so,
285 .B mhstore
286 will use the value \*(lq+\*(rq. As a last resort,
287 .B mhstore
288 will use the value \*(lq%m%P.%s\*(rq.
289 .PP
290 Example profile entries might be:
291 .PP
292 .RS 5
293 .nf
294 mhstore-store-text: %m%P.txt
295 mhstore-store-text: +inbox
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 .SS "Overwriting Existing Files"
311 The
312 .B \-clobber
313 switch controls whether
314 .B mhstore
315 should overwrite existing files. The allowed values for this switch
316 and corresponding behavior when
317 .B mhstore
318 encounters an existing file are:
319 .PP
320 .RS 5
321 .nf
322 .ta \w'suffix 'u
323 always Overwrite existing file (default)
324 auto Create new file of form name-n.extension
325 suffix Create new file of form name.extension.n
326 ask Prompt the user to specify whether or not to overwrite
327 the existing file
328 never Do not overwrite existing file
329 .fi
330 .RE
331 .PP
332 With
333 .I auto
334 and
335 .IR suffix ,
336 .I n
337 is the lowest unused number, starting from one, in the same form. If
338 a filename does not have an extension (following a '.'), then
339 .I auto
340 and
341 .I suffix
342 create a new file of the form
343 .I name-n
344 and
345 .IR name.n ,
346 respectively. With
347 .I never
348 and
349 .IR ask ,
350 the exit status of
351 .B mhstore
352 will be the number of files that were requested but not stored.
353 .PP
354 With
355 .IR ask ,
356 if standard input is connected to a terminal, the user is prompted to
357 respond
358 .IR yes ,
359 .IR no ,
360 or
361 .IR rename ,
362 to whether the file should be overwritten. The responses
363 can be abbreviated. If the user responds with
364 .IR rename ,
365 then
366 .B mhstore
367 prompts the user for the name of the new file to be created. If it is
368 a relative path name (does not begin with '/'), then it is relative to
369 the current directory. If it is an absolute or relative path to a
370 directory that does not exist, the user will be prompted whether to
371 create the directory. If standard input is not connected to a
372 terminal,
373 .I ask
374 behaves the same as
375 .IR always .
376 .SS "External Access"
377 For contents of type message/external-body,
378 \fImhstore\fR supports these access-types:
379 .IP \(bu 4
380 afs
381 .IP \(bu 4
382 anon-ftp
383 .IP \(bu 4
384 ftp
385 .IP \(bu 4
386 local-file
387 .IP \(bu 4
388 mail-server
389 .IP \(bu 4
390 url
391 .PP
392 For the \*(lqanon-ftp\*(rq and \*(lqftp\*(rq access types,
393 .B mhstore
394 will look for the \*(lqnmh-access-ftp\*(rq
395 profile entry, e.g.,
396 .PP
397 .RS 5
398 nmh-access-ftp: myftp.sh
399 .RE
400 .PP
401 to determine the pathname of a program to perform the FTP retrieval.
402 This program is invoked with these arguments:
403 .PP
404 .RS 5
405 .nf
406 domain name of FTP-site
407 username
408 password
409 remote directory
410 remote filename
411 local filename
412 \*(lqascii\*(rq or \*(lqbinary\*(rq
413 .fi
414 .RE
415 .PP
416 The program should terminate with an exit status of zero if the
417 retrieval is successful, and a non-zero exit status otherwise.
418 .PP
419 For the \*(lqurl\*(rq access types,
420 .B mhstore
421 will look for the \*(lqnmh-access-url\*(rq profile entry, e.g.,
422 .PP
423 .RS 5
424 nmh-access-url: curl -L
425 .RE
426 .PP
427 to determine the program to use to perform the HTTP retrieval. This program
428 is invoked with one argument: the URL of the content to retrieve. The program
429 should write the content to standard out, and should terminate with a status
430 of zero if the retrieval is successful and a non-zero exit status otherwise.
431 .SS "User Environment"
432 Because the environment in which
433 .B mhstore
434 operates may vary for different machines,
435 .B mhstore
436 will look for the environment variable MHSTORE .
437 If present, this specifies the name of an additional user profile
438 which should be read. Hence, when a user logs in on a particular
439 machine, this environment variable should be set to refer to a
440 file containing definitions useful for that machine. Finally,
441 .B mhstore
442 will attempt to consult
443 .PP
444 .RS 5
445 %nmhetcdir%/mhn.defaults
446 .RE
447 .PP
448 which is created automatically during
449 .B nmh
450 installation.
451 .PP
452 See "Profile Lookup" in
453 .IR mh-profile (5)
454 for the profile search order, and for how duplicate entries are treated.
455 .SH EXAMPLES
456 .SS Decoding RFC 2047-encoded file names
457 The improper RFC 2047 encoding of file name parameters can be replaced
458 with correct RFC 2231 encoding using
459 .BR mhfixmsg ,
460 either permanently or ephemerally, e.g.,
461 .PP
462 .RS
463 .nf
464 mhfixmsg -outfile - | mhstore -auto -clobber ask -file -
465 .fi
466 .RE
467 .PP
468 The
469 .BI \-clobber ask
470 is not necessary, though recommended to avoid silently overwriting an existing
471 file.
472 .SH FILES
473 .B mhstore
474 looks for additional profile files in multiple locations: absolute
475 pathnames are accessed directly, tilde expansion is done on usernames,
476 and files are searched for in the user's
477 .I Mail
478 directory as specified in their profile. If not found there, the directory
479 .RI \*(lq %nmhetcdir% \*(rq
480 is checked.
481 .PP
482 .fc ^ ~
483 .nf
484 .ta \w'%nmhetcdir%/ExtraBigFileName 'u
485 ^$HOME/.mh_profile~^The user profile
486 ^$MHSTORE~^Additional profile entries
487 ^%nmhetcdir%/mhn.defaults~^System default MIME profile entries
488 .fi
489 .SH "PROFILE COMPONENTS"
490 .fc ^ ~
491 .nf
492 .ta 2.4i
493 .ta \w'ExtraBigProfileName 'u
494 ^Path:~^To determine the user's nmh directory
495 ^Current\-Folder:~^To find the default current folder
496 ^nmh-access-ftp:~^Program to retrieve contents via FTP
497 ^nmh-access-url:~^Program to retrieve contents via HTTP
498 ^nmh-storage~^Directory to store contents
499 ^mhstore-store-<type>*~^Template for storing contents
500 .fi
501 .SH "SEE ALSO"
502 .IR mhbuild (1),
503 .IR mhfixmsg (1),
504 .IR mhlist (1),
505 .IR mhshow (1),
506 .IR sendfiles (1)
507 .SH DEFAULTS
508 .nf
509 .RB ` +folder "' defaults to the current folder"
510 .RB ` msgs "' defaults to cur"
511 .RB ` \-noauto '
512 .RB ` \-clobber\ always '
513 .RB ` \-nocheck '
514 .RB ` \-verbose '
515 .SH CONTEXT
516 If a folder is given, it will become the current folder. The last
517 message selected will become the current message.
518 .SH BUGS
519 Partial messages contained within a multipart content are not reassembled.