blob: e5f3d0a0618a7f0903dc3c0f1f9a035663440d4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
--- mgetty-1.1.30.old/samples/new_fax.mime4 1999-04-17 06:38:50.000000000 -0400
+++ mgetty-1.1.30/samples/new_fax.mime4 2003-07-01 23:45:07.000000000 -0400
@@ -37,13 +37,14 @@
PATH=/usr/sbin:/usr/local/bin:/usr/bin:/bin:$PATH
# Select image type by uncommenting one of the following lines:
-#PBMTOX=pnmtopng ; MIME_TYPE="image/png" ; FILE_EXTN=png
-PBMTOX=ppmtogif ; MIME_TYPE="image/gif" ; FILE_EXTN=gif
+PBMTOX=pnmtopng ; MIME_TYPE="image/png" ; FILE_EXTN=png
+#PBMTOX=ppmtogif ; MIME_TYPE="image/gif" ; FILE_EXTN=gif
#PBMTOX=pnmtotiff ; MIME_TYPE="image/tiff" ; FILE_EXTN=tif
# PBM files may be huge
#PBMTOX=cat ; MIME_TYPE="image/x-portable-bitmap" ; FILE_EXTN=pbm
# compressed PBM files
#PBMTOX=gzip ; MIME_TYPE="application/octet-stream"; FILE_EXTN=pbm.gz
+#PBMTOX=NONE ; MIME_TYPE="image/fax-g3"; FILE_EXTN=g3
# The binaries we need; please check carefully !!!
BASENAME=basename
@@ -63,14 +64,23 @@
# Some miscellaneous data and filenames.
TMP=/tmp
-MAIL_MESS=$TMP/MESS_$$
-ERRO_MESS=$TMP/ERRO_$$
-IMAG_FILE=$TMP/TIFF_$$
-MIME_MESS=$TMP/MAIL_$$
+MAIL_MESS=`/bin/tempfile -pMESS_`
+ERRO_MESS=`/bin/tempfile -pERRO_`
+IMAG_FILE=`/bin/tempfile -pTIFF_`
+MIME_MESS=`/bin/tempfile -pMAIL_`
+if [ ! -f $MAIL_MESS ] ||\
+ [ ! -f $ERRO_MESS ] ||\
+ [ ! -f $IMAG_FILE ] ||\
+ [ ! -f $MIME_MESS ]
+then
+ echo "Could not create one of the temporary files. Aborting...";
+ exit 1;
+fi
+
umask 077
# Clean up from previous invocations and trap errors
-$RM -f $MAIL_MESS $ERRO_MESS $IMAG_FILE $MIME_MESS
+# $RM -f $MAIL_MESS $ERRO_MESS $IMAG_FILE $MIME_MESS
trap "$RM -f $MAIL_MESS $ERRO_MESS $IMAG_FILE $MIME_MESS; exit" 0 1 2 15
# Essential lines to put into the header of a MIME mail.
@@ -86,7 +96,7 @@
ATTACHMENT_ENDLINE="--attachment--"
# Now we build our MIME mailheader using commandline arguments.
-$ECHO "Subject: incoming FAX from $2 with $3 pages" > $MAIL_MESS
+$ECHO "Subject: incoming FAX from $2 with $3 pages" >> $MAIL_MESS
$ECHO "$HEADERLINE_1" >> $MAIL_MESS
$ECHO "$HEADERLINE_2" >> $MAIL_MESS
$ECHO "" >> $MAIL_MESS
@@ -109,6 +119,9 @@
#
for i in $@
do
+if [ "$PBMTOX" = "NONE" ]; then
+ IMAG_FILE=$i
+else
# We use the second character in the filename to identify the
# resolution of our incoming fax, so we can easily scale the fax for
# display on a screen.
@@ -126,7 +139,8 @@
# handle standard input correctly.
$CAT $i 2>> $ERRO_MESS \
| $G3TOPBM $STRETCH 2>> $ERRO_MESS \
- | $PBMTOX >> $IMAG_FILE 2>> $ERRO_MESS
+ | $PBMTOX > $IMAG_FILE 2>> $ERRO_MESS
+fi
#
# Now we put the header for each attachment into our MIME mail.
$ECHO "$ATTACHMENT_HEADERLINE_1" >> $MIME_MESS
|