]> diplodocus.org Git - nmh/blob - man/mhbuild.man
Finished replacing mh_strcasecmp() with strcasecmp(). Removed
[nmh] / man / mhbuild.man
1 .TH MHBUILD %manext1% "March 21, 2013" "%nmhversion%"
2 .\"
3 .\" %nmhwarning%
4 .\"
5 .SH NAME
6 mhbuild \- translate MIME composition draft
7 .SH SYNOPSIS
8 .na
9 .HP 5
10 .B mhbuild
11 .I file
12 .RB [ \-list " | " \-nolist ]
13 .RB [ \-realsize " | " \-norealsize ]
14 .RB [ \-headers " | " \-noheaders ]
15 .RB [ \-directives " | " \-nodirectives ]
16 .RB [ \-rfc934mode " | " \-norfc934mode ]
17 .RB [ \-contentid " | " \-nocontentid ]
18 .RB [ \-verbose " | " \-noverbose ]
19 .RB [ \-check " | " \-nocheck ]
20 .RB [ \-version ]
21 .RB [ \-help ]
22 .ad
23 .SH DESCRIPTION
24 The
25 .B mhbuild
26 command will translate a MIME composition draft into
27 a valid MIME message.
28 .PP
29 .B mhbuild
30 creates multi-media messages as specified in RFC\-2045
31 to RFC\-2049. Currently
32 .B mhbuild
33 only supports encodings in
34 message bodies, and does not support the encoding of message headers as
35 specified in RFC\-2047.
36 .PP
37 If you specify the name of the composition file as \*(lq-\*(rq,
38 then
39 .B mhbuild
40 will accept the composition draft on the standard
41 input. If the translation of this input is successful,
42 .B mhbuild
43 will output the new MIME message to the standard output. This argument
44 must be the last argument on the command line.
45 .PP
46 Otherwise if the file argument to
47 .B mhbuild
48 is the name of a valid
49 composition file, and the translation is successful,
50 .B mhbuild
51 will replace the original file with the new MIME message. It will rename
52 the original file to start with the \*(lq,\*(rq character and end with the
53 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
54 it will be renamed to \*(lq,draft.orig\*(rq. This allows you to easily
55 recover the
56 .B mhbuild
57 input file.
58 .SS "Listing the Contents"
59 The
60 .B \-list
61 switch tells
62 .B mhbuild
63 to list the table of contents associated with the MIME message that is created.
64 .PP
65 The
66 .B \-headers
67 switch indicates
68 that a one-line banner should be displayed above the listing. The
69 .B \-realsize
70 switch tells
71 .B mhbuild
72 to evaluate the \*(lqnative\*(rq
73 (decoded) format of each content prior to listing. This provides an
74 accurate count at the expense of a small delay. If the
75 .B \-verbose
76 switch
77 is present, then the listing will show any \*(lqextra\*(rq information
78 that is present in the message, such as comments in the
79 \*(lqContent-Type\*(rq header.
80 .SS "Translating the Composition File"
81 .B mhbuild
82 is essentially a filter to aid in the composition of MIME
83 messages.
84 .B mhbuild
85 will convert an
86 .B mhbuild
87 \*(lqcomposition file\*(rq
88 into a valid MIME message. A
89 .B mhbuild
90 \*(lqcomposition file\*(rq
91 is just a file containing plain text that is interspersed
92 with various
93 .B mhbuild
94 directives. When this file is processed
95 by
96 .BR mhbuild ,
97 the various directives will be expanded to the
98 appropriate content, and will be encoded according to the MIME standards.
99 The resulting MIME message can then be sent by electronic mail.
100 .PP
101 The formal syntax for a
102 .B mhbuild
103 composition file is defined at the
104 end of this document, but the ideas behind this format are not complex.
105 Basically, the body contains one or more contents. A content consists of
106 either a directive, indicated with a \*(lq#\*(rq as the first character
107 of a line; or, plaintext (one or more lines of text). The continuation
108 character, \*(lq\\\*(lq, may be used to enter a single directive on more
109 than one line, e.g.,
110 .PP
111 .RS 5
112 .nf
113 #image/png \\
114 /home/foobar/junk/picture.png
115 .fi
116 .RE
117 .PP
118 There are five kinds of directives: \*(lqtype\*(rq directives, which
119 name the type and subtype of the content; \*(lqexternal-type\*(rq
120 directives, which also name the type and subtype of the content; the
121 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
122 more messages; the \*(lqbegin\*(rq directive (#begin), which is
123 used to create a multipart content; and the \*(lqon/off/pop\*(rq
124 directives (#on, #off, #pop) which control whether any other
125 directives are honored at all.
126 .PP
127 The
128 .B \-directives
129 switch allows control over whether mhbuild will honor any of the
130 \*(lq#\*(rq-directives. This can also be affected with the #on or
131 #off directives, and #pop, which restores the state of processing to
132 that preceding the most recent #on or #off. (The #on, #off, and #pop
133 directives are always honored, of course.) This allows inclusion of
134 plain text which looks like mhbuild directives, without causing
135 errors:
136 .PP
137 .RS 5
138 .nf
139 #off
140 #include <stdio.h>
141 printf("Hello, World!);
142 #pop
143 .fi
144 .RE
145 .PP
146 Currently the stack depth for the #on/off/pop directives is 32.
147 .PP
148 The \*(lqtype\*(rq directive is used to directly specify the type and
149 subtype of a content. You may only specify discrete types in this manner
150 (can't specify the types multipart or message with this directive).
151 You may optionally specify the name of a file containing the contents
152 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
153 \*(lq|\*(rq character, then it represents a command to execute whose
154 output is captured accordingly.
155 For example,
156 .PP
157 .RS 5
158 .nf
159 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
160 .fi
161 .RE
162 .PP
163 If a filename is not given,
164 .B mhbuild
165 will look for information in the
166 user's profile to determine how the different contents should be composed.
167 This is accomplished by consulting a composition string, and executing
168 it under
169 .BR /bin/sh ,
170 with the standard output set to the content.
171 If the
172 .B \-verbose
173 switch is given,
174 .B mhbuild
175 will echo any commands that are used to create contents in this way.
176 .PP
177 The composition string may contain the following escapes:
178 .PP
179 .RS 5
180 .nf
181 .ta \w'%P 'u
182 %a Insert parameters from directive
183 %f Insert filename containing content
184 %F %f, and stdout is not re-directed
185 %s Insert content subtype
186 %% Insert character %
187 .fi
188 .RE
189 .PP
190 First,
191 .B mhbuild
192 will look for an entry of the form:
193 .PP
194 .RS 5
195 mhbuild-compose-<type>/<subtype>
196 .RE
197 .PP
198 to determine the command to use to compose the content. If this isn't
199 found,
200 .B mhbuild
201 will look for an entry of the form:
202 .PP
203 .RS 5
204 mhbuild-compose-<type>
205 .RE
206 .PP
207 to determine the composition command. If this isn't found,
208 .B mhbuild
209 will complain.
210 .PP
211 An example entry might be:
212 .PP
213 .RS 5
214 mhbuild-compose-audio/basic: record | raw2audio -F
215 .RE
216 .PP
217 Because commands like these will vary, depending on the display
218 environment used for login, composition strings for different
219 contents should probably be put in the file specified by the
220 .B $MHBUILD
221 environment variable, instead of directly in your
222 user profile.
223 .PP
224 The \*(lqexternal-type\*(rq directives are used to provide a MIME
225 reference to a content, rather than enclosing the contents itself
226 (for instance, by specifying an ftp site). Hence, instead of
227 providing a filename as with the type directives, external-parameters
228 are supplied. These look like regular parameters, so they must be
229 separated accordingly. For example,
230 .PP
231 .RS 5
232 .nf
233 #@application/octet-stream; \\
234 type=tar; \\
235 conversions=compress \\
236 [this is the nmh distribution] \\
237 {attachment; filename="nmh.tar.gz"} \\
238 name="nmh.tar.gz"; \\
239 directory="/pub/nmh"; \\
240 site="ftp.math.gatech.edu"; \\
241 access-type=anon-ftp; \\
242 mode="image"
243 .fi
244 .RE
245 .PP
246 You must give a description string to separate the content parameters
247 from the external-parameters (although this string may be empty).
248 This description string is specified by enclosing it within
249 \*(lq[]\*(rq. A disposition string, to appear in a
250 \*(lqContent-Disposition\*(rq header, may appear in the optional
251 \*(lq{}\*(rq.
252 .PP
253 These parameters are of the form:
254 .PP
255 .RS 5
256 .nf
257 .ta \w'access-type= 'u
258 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
259 name= filename
260 permission= read-only or read-write
261 site= hostname
262 directory= directoryname (optional)
263 mode= usually \fIascii\fR or \fIimage\fR (optional)
264 size= number of octets
265 server= mailbox
266 subject= subject to send
267 body= command to send for retrieval
268 url= URL of content
269 .fi
270 .RE
271 .PP
272 A mimimum \*(lqexternal\-type\*(rq directive for the
273 .B url
274 .I access\-type
275 would be as follows:
276 .PP
277 .RS 3
278 .nf
279 #@application/octet-stream [] access-type=url; \\
280 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
281 .fi
282 .RE
283 .PP
284 Any long URLs will be wrapped according to RFC\-2017 rules.
285 .PP
286 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
287 group of messages to include. You may optionally specify the name of
288 the folder and which messages are to be forwarded. If a folder is not
289 given, it defaults to the current folder. Similarly, if a message is not
290 given, it defaults to the current message. Hence, the message directive
291 is similar to the
292 .B forw
293 command, except that the former uses
294 the MIME rules for encapsulation rather than those specified in RFC\-934.
295 For example,
296 .PP
297 .RS 5
298 .nf
299 #forw +inbox 42 43 99
300 .fi
301 .RE
302 .PP
303 If you include a single message, it will be included directly as a content
304 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
305 then
306 .B mhbuild
307 will add a content of type \*(lqmultipart/digest\*(rq
308 and include each message as a subpart of this content.
309 .PP
310 If you are using this directive to include more than one message, you
311 may use the
312 .B \-rfc934mode
313 switch. This switch will indicate that
314 .B mhbuild
315 should attempt to utilize the MIME encapsulation rules
316 in such a way that the \*(lqmultipart/digest\*(rq that is created
317 is (mostly) compatible with the encapsulation specified in RFC\-934.
318 If given, then RFC\-934 compliant user-agents should be able to burst the
319 message on reception\0--\0providing that the messages being encapsulated
320 do not contain encapsulated messages themselves. The drawback of this
321 approach is that the encapsulations are generated by placing an extra
322 newline at the end of the body of each message.
323 .PP
324 The \*(lqbegin\*(rq directive is used to create a multipart content.
325 When using the \*(lqbegin\*(rq directive, you must specify at least one
326 content between the begin and end pairs.
327 .PP
328 .RS 5
329 .nf
330 #begin
331 This will be a multipart with only one part.
332 #end
333 .fi
334 .RE
335 .PP
336 If you use multiple directives in a composition draft,
337 .B mhbuild
338 will
339 automatically encapsulate them inside a multipart content. Therefore the
340 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
341 multiparts, or create a multipart message containing only one part.
342 .PP
343 For all of these directives, the user may include a brief description
344 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
345 character. This description will be copied into the
346 \*(lqContent-Description\*(rq header when the directive is processed.
347 .PP
348 .RS 5
349 .nf
350 #forw [important mail from Bob] +bob 1 2 3 4 5
351 .fi
352 .RE
353 .PP
354 Similarly, a disposition string may optionally be provided between
355 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
356 \*(lqContent-Disposition\*(rq header when the directive is processed.
357 If a disposition string is provided that does not contain a filename
358 parameter, and a filename is provided in the directive, it will be
359 added to the \*(lqContent-Disposition\*(rq header. For example, the
360 following directive:
361 .PP
362 .RS 5
363 .nf
364 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
365 .fi
366 .RE
367 .PP
368 creates these message part headers:
369 .PP
370 .RS 5
371 .nf
372 Content-Type: text/plain; charset="iso-8859-1"
373 Content-Disposition: attachment; filename="summary.txt"
374 .fi
375 .RE
376 .PP
377 By default,
378 .B mhbuild
379 will generate a unique \*(lqContent-ID:\*(rq for each directive,
380 corresponding to each message part; however, the user may override
381 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
382 characters. The
383 .B \-nocontentid
384 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
385 even in the top level of the message.
386 .PP
387 In addition to the various directives, plaintext can be present.
388 Plaintext is gathered, until a directive is found or the draft is
389 exhausted, and this is made to form a text content. If the plaintext
390 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
391 e.g.,
392 .PP
393 .RS 5
394 ##when sent, this line will start with only one #
395 .RE
396 .PP
397 If you want to end the plaintext prior to a directive, e.g., to have two
398 plaintext contents adjacent, simply insert a line containing a single
399 \*(lq#\*(rq character, e.g.,
400 .PP
401 .RS 5
402 .nf
403 this is the first content
404 #
405 and this is the second
406 .fi
407 .RE
408 .PP
409 Finally, if the plaintext starts with a line of the form:
410 .PP
411 .RS 5
412 Content-Description: text
413 .RE
414 .PP
415 then this will be used to describe the plaintext content.
416 You MUST follow this line with a blank line before starting
417 your text.
418 .PP
419 By default, plaintext is captured as a text/plain content. You can
420 override this by starting the plaintext with \*(lq#<\*(rq followed by
421 a content-type specification. For example, e.g.,
422 .PP
423 .RS 5
424 .nf
425 #<text/enriched
426 this content will be tagged as text/enriched
427 #
428 and this content will be tagged as text/plain
429 #
430 #<application/x-patch [this is a patch]
431 and this content will be tagged as application/x-patch
432 .fi
433 .RE
434 .PP
435 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
436 content-description must be on the same line which identifies the content
437 type of the plaintext.
438 .PP
439 When composing a text content, you may indicate the relevant character
440 set by adding the \*(lqcharset\*(rq parameter to the directive.
441 .PP
442 .RS 5
443 #<text/plain; charset=iso-8859-5
444 .RE
445 .PP
446 If a text content contains any 8\-bit characters (characters with the
447 high bit set) and the character set is not specified as above, then
448 .B mhbuild
449 will assume the character set is of the type given by the
450 environment variable MM_CHARSET. If this environment variable is not
451 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
452 .PP
453 If a text content contains only 7\-bit characters and the character set
454 is not specified as above, then the character set will be labeled as
455 \*(lqus-ascii\*(rq.
456 .PP
457 Putting this all together,
458 here is an example of a more complicated message draft. The
459 following draft will expand into a multipart/mixed message
460 containing five parts:
461 .PP
462 .RS 5
463 .nf
464 To: nobody@nowhere.org
465 cc:
466 Subject: Look and listen to me!
467 --------
468 The first part will be text/plain
469 #<text/enriched
470 The second part will be text/enriched
471 #
472 This third part will be text/plain
473 #audio/basic [silly giggle] \\
474 |raw2audio -F < /usr/lib/sounds/giggle.au
475 #image/gif [photo of foobar] \\
476 /home/foobar/lib/picture.gif
477 .fi
478 .RE
479 .SS "Integrity Check"
480 If
481 .B mhbuild
482 is given the
483 .B \-check
484 switch, then it will also associate an integrity check with each
485 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
486 the content, along with the md5 sum of the unencoded contents, per RFC
487 1864. This may be used by the receiver of the message to verify that
488 the contents of the message were not changed in transport.
489 .SS "Transfer Encodings"
490 After
491 .B mhbuild
492 constructs the new MIME message by parsing directives,
493 including files, etc., it scans the contents of the message to determine
494 which transfer encoding to use. It will check for 8bit data, long lines,
495 spaces at the end of lines, and clashes with multipart boundaries. It will
496 then choose a transfer encoding appropriate for each content type.
497 .PP
498 If an integrity check is being associated with each content by using
499 the
500 .B \-check
501 switch, then
502 .B mhbuild
503 will encode each content with
504 a transfer encoding, even it the content contains only 7\-bit data. This
505 is to increase the likelihood that the content is not changed while in
506 transport.
507 .SS "Invoking mhbuild"
508 Typically,
509 .B mhbuild
510 is invoked by the
511 .B whatnow
512 program. This
513 command will expect the body of the draft to be formatted as an
514 .B mhbuild
515 composition file. Once you have composed this input file
516 using a command such as
517 .BR comp ,
518 .BR repl ,
519 or
520 .BR forw ,
521 you invoke
522 .B mhbuild
523 at the \*(lqWhat now\*(rq prompt with
524 .PP
525 .RS 5
526 What now? mime
527 .RE
528 .PP
529 prior to sending the draft. This will cause
530 .B whatnow
531 to execute
532 .B mhbuild
533 to translate the composition file into MIME format.
534 .PP
535 It is also possible to have the
536 .B whatnow
537 program invoke
538 .B mhbuild
539 automatically when a message is sent. To do this, you must add the line
540 .PP
541 .RS 5
542 automimeproc: 1
543 .RE
544 .PP
545 to your
546 .I \&.mh\(ruprofile
547 file.
548 .PP
549 Finally, you should consider adding this line to your profile:
550 .PP
551 .RS 5
552 lproc: show
553 .RE
554 .PP
555 This way, if you decide to
556 .B list
557 after invoking
558 .BR mime ,
559 the command
560 .PP
561 .RS 5
562 What now? list
563 .RE
564 .PP
565 will work as you expect.
566 .SS "User Environment"
567 Because the environment in which
568 .B mhbuild
569 operates may vary for a
570 user,
571 .B mhbuild
572 will look for the environment variable
573 .BR $MHBUILD .
574 If present, this specifies the name of an additional user profile which
575 should be read. Hence, when a user logs in on a particular machine,
576 this environment variable should be set to refer to a file containing
577 definitions useful for that machine.
578 .PP
579 Finally,
580 .B mhbuild
581 will attempt to consult a global
582 .B mhbuild
583 user profile, e.g.,
584 .PP
585 .RS 5
586 %etcdir%/mhn.defaults
587 .RE
588 .PP
589 if it exists.
590 .SS "Syntax of Composition Files"
591 The following is the formal syntax of a
592 .B mhbuild
593 \*(lqcomposition file\*(rq.
594 .PP
595 .RS 5
596 .nf
597 body ::= 1*(content | EOL)
598
599 content ::= directive | plaintext
600
601 directive ::= "#" type "/" subtype
602 0*(";" attribute "=" value)
603 [ "(" comment ")" ]
604 [ "<" id ">" ]
605 [ "[" description "]" ]
606 [ "{" disposition "}" ]
607 [ filename ]
608 EOL
609
610 | "#@" type "/" subtype
611 0*(";" attribute "=" value)
612 [ "(" comment ")" ]
613 [ "<" id ">" ]
614 [ "[" description "]" ]
615 [ "{" disposition "}" ]
616 external-parameters
617 EOL
618
619 | "#forw"
620 [ "<" id ">" ]
621 [ "[" description "]" ]
622 [ "{" disposition "}" ]
623 [ "+"folder ] [ 0*msg ]
624 EOL
625
626 | "#begin"
627 [ "<" id ">" ]
628 [ "[" description "]" ]
629 [ "{" disposition "}" ]
630 [ "alternative"
631 | "parallel"
632 | something-else ]
633 EOL
634 1*body
635 "#end" EOL
636
637 plaintext ::= [ "Content-Description:"
638 description EOL EOL ]
639 1*line
640 [ "#" EOL ]
641
642 | "#<" type "/" subtype
643 0*(";" attribute "=" value)
644 [ "(" comment ")" ]
645 [ "[" description "]" ]
646 [ "{" disposition "}" ]
647 EOL
648 1*line
649 [ "#" EOL ]
650
651 line ::= "##" text EOL
652 -- interpreted as "#"text EOL
653 | text EOL
654 .fi
655 .RE
656 .SH FILES
657 .B mhbuild
658 looks for additional user profile files and mhn.defaults in multiple
659 locations: absolute pathnames are accessed directly, tilde expansion
660 is done on usernames, and files are searched for in the user's
661 .I Mail
662 directory as specified in their profile. If not found there, the directory
663 .RI \*(lq %etcdir% \*(rq
664 is checked.
665 .PP
666 .fc ^ ~
667 .nf
668 .ta \w'%etcdir%/ExtraBigFileName 'u
669 ^$HOME/\&.mh\(ruprofile~^The user profile
670 ^$MHBUILD~^Additional profile entries
671 ^%etcdir%/mhn.defaults~^System default MIME profile entries
672 .fi
673 .SH "PROFILE COMPONENTS"
674 .fc ^ ~
675 .nf
676 .ta 2.4i
677 .ta \w'ExtraBigProfileName 'u
678 ^Path:~^To determine the user's nmh directory
679 ^Current\-Folder:~^To find the default current folder
680 ^mhbuild-compose-<type>*~^Template for composing contents
681 .fi
682 .SH "SEE ALSO"
683 .IR mhlist (1),
684 .IR mhshow (1),
685 .IR mhstore (1)
686 .PP
687 .I "Proposed Standard for Message Encapsulation"
688 (RFC\-934),
689 .PP
690 .I "The Content-MD5 Header Field"
691 (RFC\-1864),
692 .PP
693 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
694 (RFC\-2045),
695 .PP
696 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
697 (RFC\-2046),
698 .PP
699 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
700 (RFC\-2047),
701 .PP
702 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
703 (RFC\-2048),
704 .PP
705 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
706 (RFC\-2049)
707 .I "Definition of the URL MIME External-Body Access-Type"
708 (RRC\-2017)
709 .SH DEFAULTS
710 .nf
711 .RB ` \-headers '
712 .RB ` \-realsize '
713 .RB ` \-norfc934mode '
714 .RB ` \-contentid '
715 .RB ` \-nocheck '
716 .RB ` \-noverbose '
717 .fi