1 |
#!/usr/bin/perl |
2 |
|
3 |
$systype = $ARGV[0] || die "usage: $0 systype\n"; |
4 |
if ($ARGV[1]) { |
5 |
$sysname = $ARGV[1]; |
6 |
} else { |
7 |
$sysname = $systype; |
8 |
} |
9 |
|
10 |
open(VERSION, "version.h") || die "can't read version.h: $!\n"; |
11 |
while (<VERSION>) { |
12 |
$version = $1 if /^#define MPACK_VERSION "(.*)"\n/; |
13 |
} |
14 |
die "Can't find version number in version.h\n" if !defined($version); |
15 |
|
16 |
$hdr = "mpack/munpack version $version for $sysname\n"; |
17 |
|
18 |
print " " x ((75-length($hdr))/2), $hdr; |
19 |
|
20 |
$dooutput = 1; |
21 |
while (<DATA>) { |
22 |
if (/^=/) { |
23 |
$dooutput = /\W$systype\W/; |
24 |
} elsif (/^!/) { |
25 |
$dooutput = !/\W$systype\W/; |
26 |
} elsif ($dooutput) { |
27 |
s/^\.//; |
28 |
print; |
29 |
} |
30 |
} |
31 |
|
32 |
exit 0; |
33 |
|
34 |
__END__ |
35 |
|
36 |
Mpack and munpack are utilities for encoding and decoding |
37 |
(respectively) binary files in MIME (Multipurpose Internet Mail |
38 |
Extensions) format mail messages. For compatibility with older forms |
39 |
of transferring binary files, the munpack program can also decode |
40 |
messages in split-uuencoded format. The Macintosh version can also |
41 |
decode messages in split-BinHex format. |
42 |
|
43 |
=arc |
44 |
The Archimedes port interworks with Marcel (ANT's RISC OS MIME-compliant |
45 |
MUA) to preserve filetypes, timestamps and access permissions. munpack |
46 |
should correctly unpack any Marcel message. At present, mpack doesn't |
47 |
include the filetype, etc. information. This may be implemented in a |
48 |
future release. |
49 |
|
50 |
! |
51 |
The canonical FTP site for this software is ftp.andrew.cmu.edu:pub/mpack/ |
52 |
Binaries are no longer provided. The pc, os2, amiga and archimedes ports |
53 |
have been removed. The mac version probably doesn't compile anymore, but |
54 |
is still included (MacOS X users can use the unix version...) |
55 |
|
56 |
This MIME implementation is intended to be as simple and portable as |
57 |
possible. For a slightly more sophisticated MIME implementation, see |
58 |
the program MetaMail, available via anonymous FTP to |
59 |
thumper.bellcore.com, in directory pub/nsb |
60 |
|
61 |
|
62 |
Decoding MIME messages: |
63 |
|
64 |
=unix |
65 |
First, you have to compile the munpack program. See the instructions |
66 |
in the section "Compilation" below. If, after reading the |
67 |
instructions, you are still unsure as to how to compile munpack, |
68 |
please try to find someone locally to help you. |
69 |
|
70 |
! |
71 |
To decode a MIME message, first save it to a text file. If possible, |
72 |
!mac |
73 |
save it with all headers included. Munpack can decode some MIME files |
74 |
=mac |
75 |
save it with all headers included. Mpack can decode some MIME files |
76 |
! |
77 |
when the headers are missing or incomplete, other files it cannot |
78 |
decode without having the information in the headers. In general, |
79 |
messages which have a statement at the beginning that they are in MIME |
80 |
format can be decoded without the headers. Messages which have been |
81 |
split into multiple parts generally require all headers in order to be |
82 |
reassembled and decoded. |
83 |
|
84 |
Some LAN-based mail systems and some mail providers (including America |
85 |
Online, as of the writing of this document) place the mail headers at |
86 |
the bottom of the message, instead of at the top of the message. If |
87 |
you are having problems decoding a MIME message on such a system, you |
88 |
need to convert the mail back into the standard format by removing the |
89 |
system's nonstandard headers and moving the standard Internet headers |
90 |
to the top of the message (separated from the message body with a |
91 |
blank line). |
92 |
|
93 |
!mac |
94 |
There must be exactly one message per file. Munpack cannot deal with |
95 |
multiple messages in a single file, to decode things correctly it must |
96 |
know when one message ends and the next one begins. |
97 |
|
98 |
To decode a message, run the command: |
99 |
|
100 |
munpack file |
101 |
|
102 |
where "file" is the name of the file containing the message. More than |
103 |
one filename may be specified, munpack will try to decode the message in |
104 |
each file. For more information on ways to run munpack, see the section |
105 |
"Using munpack" below. |
106 |
|
107 |
=mac |
108 |
There must be exactly one message per file. Mpack cannot deal with |
109 |
multiple messages in a single file, to decode things correctly it must |
110 |
know when one message ends and the next one begins. |
111 |
|
112 |
The Macintosh version of mpack/munpack is a single standalone |
113 |
application. A text file may be decoded either by drag & drop, or by |
114 |
choosing the "Decode Files..." item from the application's File menu. |
115 |
Non-text files may be encoded either by drag & drop, or by choosing |
116 |
the "Encode Files..." item from the application's File menu. |
117 |
|
118 |
The Macintosh version of mpack/munpack supports the new MacMIME |
119 |
standard (RFC 1740). This allows cross-platform transport of |
120 |
Macintosh files to any MIME-capable machine, and also preserves |
121 |
Macintosh specific file attributes between two Macintoshes. Mpack |
122 |
will use MacMIME for any unrecognized Macintosh file, and regular MIME |
123 |
for standard MIME types. |
124 |
|
125 |
For more details and descriptions of the preferences, see the "Help |
126 |
Using Mpack..." menu item in mpack which can be found under the help |
127 |
menu in systems 7 and above, and under the apple menu in older |
128 |
systems. |
129 |
! |
130 |
|
131 |
Reporting bugs: |
132 |
|
133 |
Bugs and comments should be reported to mpack-bugs@andrew.cmu.edu. |
134 |
When reporting bugs or other problems, please include the following |
135 |
information: |
136 |
|
137 |
* The version number of Mpack |
138 |
* The platform (Unix, PC, OS/2, Mac, Amiga, Archimedes) |
139 |
* The EXACT output of any unsuccessful attempts. |
140 |
* If having a problem decoding, the first couple of lines |
141 |
of the input file. |
142 |
|
143 |
|
144 |
Compilation: |
145 |
|
146 |
=unix |
147 |
Mpack uses autoconf and automake on unix. |
148 |
refer to INSTALL for more information |
149 |
|
150 |
=pc |
151 |
The pc sources have been compiled with Microsoft C version 7.0. The |
152 |
project files "mpack.mak" and "munpack.mak" are for mpack.exe and |
153 |
munpack.exe, respectively. |
154 |
|
155 |
=os2 |
156 |
The os2 sources have been compiled with IBM Cset++ version 2.1. The |
157 |
makefiles "mpack.os2" and "munpack.os2" are for mpack.exe and |
158 |
munpack.exe, respectively. Both makefiles also include statements to |
159 |
compile the sources with EMX 0.9a from Eberhard Mattes. |
160 |
|
161 |
=amiga |
162 |
The amiga sources have been compiled with SAS/C version 6.3. To compile |
163 |
with SAS/C, use the command "smake". |
164 |
|
165 |
=arc |
166 |
The RISC OS sources have been compiled with Acorn C version 4.0 and |
167 |
UnixLib 3.6e (ftp-able from micros.hensa.ac.uk). |
168 |
|
169 |
=mac |
170 |
Mpack was compiled with THINK C 6.0 with the 4-byte int option turned |
171 |
on (and the ANSI-small library compiled with the 4-byte int option) |
172 |
and prototype enforcement turned off. Included with this distribution |
173 |
should be the files "macproj.hqx" which is a BinHex4 version of the |
174 |
THINK C 6.0 project file, and "macrsrc.hqx" which is a BinHex4 version |
175 |
of the resources file. |
176 |
|
177 |
Mpack checks for the existence of "Internet Config", and if it is |
178 |
available, mpack uses it to translate MIME types to and from Macintosh |
179 |
type/creator codes. Included is the file "macICglue.hqx" which is a |
180 |
BinHex4 version of Internet Config's MPW object file library. This |
181 |
needs to be linked with the application. |
182 |
|
183 |
Using mpack: |
184 |
|
185 |
See the "Help Using Mpack..." menu item in the application. |
186 |
|
187 |
!mac |
188 |
Using mpack: |
189 |
|
190 |
Mpack is used to encode a file into one or more MIME format messages. |
191 |
The program is invoked with: |
192 |
|
193 |
mpack [options] -o outputfile file |
194 |
|
195 |
=unix os2 amiga |
196 |
or |
197 |
|
198 |
mpack [options] file address... |
199 |
|
200 |
or |
201 |
|
202 |
mpack [options] -n newsgroups file |
203 |
|
204 |
!mac |
205 |
Where "[options]" is one or more optional switches described below. |
206 |
"-o outputfile" is also described below. "file" is the name of the |
207 |
!mac unix os2 amiga |
208 |
file to encode. |
209 |
=unix os2 amiga |
210 |
file to encode, "address..." is one or more e-mail address to mail the |
211 |
resulting messages to and "newsgroups" is a comma-separated list of |
212 |
newsgroups to post the resulting messages to. |
213 |
|
214 |
=amiga |
215 |
There is extra flexibility in the options and addresses. Use "mpack |
216 |
?" for a list of options; a second "?" will print more information. |
217 |
AmigaDOS 2.0 or later is required to run mpack. |
218 |
|
219 |
!mac |
220 |
The possible options are: |
221 |
|
222 |
-s subject |
223 |
Set the Subject header field to Subject. By default, |
224 |
mpack will prompt for the contents of the subject |
225 |
header. |
226 |
|
227 |
-d descriptionfile |
228 |
Include the contents of the file descriptionfile in an |
229 |
introductory section at the beginning of the first |
230 |
generated message. |
231 |
|
232 |
-m maxsize |
233 |
Split the message (if necessary) into partial messages, |
234 |
each not exceeding maxsize characters. The default |
235 |
limit is the value of the SPLITSIZE environment |
236 |
variable, or no limit if the environment variable |
237 |
does not exist. Specifying a maxsize of 0 means there |
238 |
is no limit to the size of the generated message. |
239 |
|
240 |
-c content-type |
241 |
Label the included file as being of MIME type |
242 |
content-type, which must be a subtype of application, |
243 |
audio, image, or video. If this switch is not given, |
244 |
mpack examines the file to determine its type. |
245 |
|
246 |
-o outputfile |
247 |
Write the generated message to the file outputfile. If |
248 |
the message has to be split, the partial messages will |
249 |
!mac arc |
250 |
instead be written to the files outputfile.01, |
251 |
outputfile.02, etc. |
252 |
|
253 |
=arc |
254 |
instead be written to the files outputfile/01, |
255 |
outputfile/02, etc. |
256 |
|
257 |
=os2 |
258 |
-f username |
259 |
Specifies the user name to be used for mail or news. If |
260 |
this option is ommitted, the environment variable LOGNAME |
261 |
will be used to determine the user name. |
262 |
|
263 |
!mac |
264 |
The environment variables which control mpack's behavior are: |
265 |
|
266 |
SPLITSIZE |
267 |
Default value of the -m switch. Default "0". |
268 |
|
269 |
=unix |
270 |
TMPDIR |
271 |
Directory to store temporary files. Default "/tmp". |
272 |
|
273 |
=pc os2 amiga |
274 |
HOSTNAME |
275 |
Fully qualified domain name to use in generated message-ids. |
276 |
Default "random-pc" or "random-amiga". |
277 |
|
278 |
=arc |
279 |
HOSTNAME |
280 |
Fully qualified domain name to use in generated message-ids. |
281 |
Default "random-arc". |
282 |
|
283 |
=os2 amiga |
284 |
DOMAINNAME |
285 |
If $HOSTNAME does not have a '.' in it, this is appended to |
286 |
$HOSTNAME to get the domain to use. Default is |
287 |
"random-domain". |
288 |
|
289 |
=amiga |
290 |
POSTNEWS |
291 |
Command to use to post news. Compatible with Dillon UUCP usage. |
292 |
|
293 |
SENDMAIL |
294 |
Command to use to send mail. Compatible with Dillon UUCP usage. |
295 |
|
296 |
=os2 |
297 |
POSTNEWS |
298 |
Command to use to post news. Compatible with UUPC inews. |
299 |
|
300 |
SENDMAIL |
301 |
Command to use to send mail. Compatible with IBM sendmail. |
302 |
|
303 |
LOGNAME |
304 |
User name for sending mail or posting news. Defaults to |
305 |
"postmaster". |
306 |
|
307 |
!mac |
308 |
|
309 |
Using munpack: |
310 |
|
311 |
Munpack is used to decode one or more messages in MIME or |
312 |
split-uuencoded format and extract the embedded files. The program is |
313 |
invoked with: |
314 |
|
315 |
munpack [options] filename... |
316 |
|
317 |
!mac pc arc |
318 |
which reads the messages in the files "filename...". Munpack may also |
319 |
be invoked with just: |
320 |
=pc arc |
321 |
which reads the messages in the files "filename...". Wildcards are |
322 |
accepted. Munpack may also be invoked with just: |
323 |
!mac |
324 |
|
325 |
munpack [options] |
326 |
|
327 |
which reads a message from the standard input. |
328 |
|
329 |
=amiga |
330 |
Munpack does not accept wildcards. Under AmigaDOS prior to 2.0, only |
331 |
filenames are allowed. Under AmigaDOS 2.0 or later, the options |
332 |
described later are supported, with extra flexibility. Use |
333 |
"munpack ?" for a list of options; a second "?" will print more |
334 |
information. |
335 |
|
336 |
!mac |
337 |
If the message suggests a file name to use for the imbedded part, that |
338 |
name is cleaned of potential problem characters and used for the |
339 |
output file. If the suggested filename includes subdirectories, they |
340 |
will be created as necessary. If the message does not suggest a file |
341 |
name, the names "part1", "part2", etc are used in sequence. |
342 |
|
343 |
If the imbedded part was preceded with textual information, that |
344 |
information is also written to a file. The file is named the same as |
345 |
the imbedded part, with any filename extension replaced with |
346 |
!mac pc os2 arc |
347 |
".desc" |
348 |
=pc os2 |
349 |
".dsc" |
350 |
=arc |
351 |
"/dsc" |
352 |
!mac |
353 |
|
354 |
The possible options are: |
355 |
|
356 |
-f |
357 |
Forces the overwriting of existing files. If a message |
358 |
suggests a file name of an existing file, the file will be |
359 |
=unix amiga |
360 |
overwritten. Without this flag, munpack appends ".1", ".2", |
361 |
etc to find a nonexistent file. |
362 |
=pc os2 |
363 |
overwritten. Without this flag, munpack replaces any |
364 |
filename extension with ".1", ".2", etc to find a |
365 |
nonexistent file. |
366 |
=arc |
367 |
overwritten. Without this flag, munpack appends "/1", "/2", |
368 |
etc to find a nonexistent file. |
369 |
!mac |
370 |
|
371 |
-t |
372 |
Also unpack the text parts of multipart messages to files. |
373 |
By default, text parts that do not have a filename parameter |
374 |
do not get unpacked. |
375 |
|
376 |
-q |
377 |
Be quiet--suppress messages about saving partial messages. |
378 |
|
379 |
-C directory |
380 |
Change the current directory to "directory" before reading |
381 |
any files. This is useful when invoking munpack |
382 |
from a mail or news reader. |
383 |
=os2 |
384 |
|
385 |
-e |
386 |
Writes the MIME content type into the extended attribute |
387 |
"MIME-TYPE". This extended attribute can be used by any |
388 |
software that post processes the decoded files. The |
389 |
following is an example program how to read this extended |
390 |
attribute in Rexx: |
391 |
|
392 |
---------------------------cut here--------------------------------- |
393 |
/* This Rexx program demonstrates how to read the MIME-type * |
394 |
* parameter out of the EA of the decoded file. Note, that the * |
395 |
* options '-e' must be used to write this EA. */ |
396 |
|
397 |
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' |
398 |
call SysLoadFuncs |
399 |
|
400 |
parse ARG name |
401 |
|
402 |
if SysGetEA(name, "MIME-TYPE", "TYPEINFO") = 0 then |
403 |
parse var typeinfo 4 type |
404 |
else |
405 |
type = "undefined" |
406 |
|
407 |
say "MIME content-type is" type |
408 |
---------------------------cut here--------------------------------- |
409 |
!mac |
410 |
|
411 |
The environment variables which control munpack's behavior are: |
412 |
|
413 |
=unix |
414 |
TMPDIR |
415 |
Root of directory to store partial messages awaiting |
416 |
reassembly. Default is "/var/tmp". Partial messages |
417 |
are stored in subdirectories of $TMPDIR/m-prts-$USER/ |
418 |
|
419 |
=pc os2 |
420 |
TMP |
421 |
Root of directory to store partial messages awaiting |
422 |
reassembly. Default is "\tmp". Partial messages are |
423 |
stored in subdirectories of $TMP\parts\ |
424 |
|
425 |
=arc |
426 |
Wimp$ScrapDir |
427 |
Root of directory to store partial messages awaiting |
428 |
reassembly. Default is "/tmp" which UnixLib should do |
429 |
something sensible with. Partial messages are |
430 |
stored in subdirectories of <Wimp$ScrapDir>.parts |
431 |
|
432 |
=amiga |
433 |
METAMAIL_P_DIR [amiga version only] |
434 |
Root of directory to store partial messages awaiting |
435 |
reassembly. Default is "t:". Partial messages are |
436 |
stored in subdirectories of METAMAIL_P_DIR. |
437 |
|
438 |
USER, USERNAME |
439 |
Subdirectory of METMAIL_P_DIR where mime parts are stored. USER |
440 |
is checked first, then USERNAME. Default "anonymous". |
441 |
|
442 |
If the shared library netsupport.library is available, it will be used |
443 |
to get the value of the environment variables. This allows them to be |
444 |
set in uulib:config file instead of in the environment. If this |
445 |
library not present, then a warning that the library was not found is |
446 |
printed. You may ignore this warning. |
447 |
! |
448 |
|
449 |
Acknowledgements: |
450 |
|
451 |
Written by John G. Myers, jgm+@cmu.edu |
452 |
|
453 |
The mac version was written by Christopher J. Newman, chrisn+@cmu.edu |
454 |
|
455 |
Send all bug reports to mpack-bugs@andrew.cmu.edu |
456 |
|
457 |
Thanks to Nathaniel Borenstein for testing early versions of mpack and |
458 |
for making many helpful suggestions. |
459 |
|
460 |
|
461 |
PGP signature: |
462 |
|
463 |
The mpack 1.6 distribution is not pgp signed. |
464 |
|
465 |
Legalese: |
466 |
|
467 |
(C) Copyright 1993,1994 by Carnegie Mellon University |
468 |
All Rights Reserved. |
469 |
|
470 |
Permission to use, copy, modify, distribute, and sell this software |
471 |
and its documentation for any purpose is hereby granted without fee, |
472 |
provided that the above copyright notice appear in all copies and that |
473 |
both that copyright notice and this permission notice appear in |
474 |
supporting documentation, and that the name of Carnegie Mellon |
475 |
University not be used in advertising or publicity pertaining to |
476 |
distribution of the software without specific, written prior |
477 |
permission. Carnegie Mellon University makes no representations about |
478 |
the suitability of this software for any purpose. It is provided "as |
479 |
is" without express or implied warranty. |
480 |
|
481 |
CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO |
482 |
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
483 |
AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE |
484 |
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
485 |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
486 |
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
487 |
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
488 |
SOFTWARE. |
489 |
|
490 |
Portions of this software are derived from code written by Bell |
491 |
Communications Research, Inc. (Bellcore) and by RSA Data Security, |
492 |
Inc. and bear similar copyrights and disclaimers of warranty. |
493 |
|