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