]> diplodocus.org Git - nmh/blob - etc/mhn.defaults.sh
In expand_pseudoheader(), set Content-Type to 7-bit for ASCII text.
[nmh] / etc / mhn.defaults.sh
1 #!/bin/sh
2 #
3 # mhn.defaults.sh -- create extra profile file for MIME handling
4 #
5 # USAGE: mhn.defaults.sh [ search-path [ search-prog ]]
6
7 # If a search path is passed to the script, we
8 # use that, else we use a default search path.
9 if [ -n "$1" ]; then
10 SEARCHPATH=$1
11 else
12 SEARCHPATH="$PATH"
13 fi
14
15 # If a search program is passed to the script, we
16 # use that, else we use a default search program.
17 if [ -n "$2" ]; then
18 SEARCHPROG=$2
19 else
20 SEARCHPROG="mhn.find.sh"
21 fi
22
23 # put output into a temporary file, so we
24 # can sort it before output.
25 TMP=/tmp/nmh_temp.$$
26 trap "rm -f $TMP" 0 1 2 3 13 15
27
28 if [ ! -z `$SEARCHPROG "$SEARCHPATH" par` ]; then
29 #### The widths here correspond to those for the text browsers below.
30 textfmt=' | par 64'
31 replfmt=" | sed 's/^\(.\)/> \1/; s/^$/>/;' | par 64"
32 elif [ ! -z `$SEARCHPROG "$SEARCHPATH" fmt` ]; then
33 textfmt=' | fmt'
34 replfmt=" | fmt | sed 's/^\(.\)/> \1/; s/^$/>/;'"
35 else
36 textfmt=
37 replfmt=
38 fi
39 [ ! -z `$SEARCHPROG "$SEARCHPATH" iconv` ] &&
40 charsetconv=' | iconv -f ${charset:-us-ascii} -t utf-8'"${textfmt}" ||
41 charsetconv=
42
43 cat >>"$TMP" <<'EOF'
44 mhstore-store-text: %m%P.txt
45 mhstore-store-text/html: %m%P.html
46 mhstore-store-text/richtext: %m%P.rt
47 mhstore-store-video/mpeg: %m%P.mpg
48 mhstore-store-application/PostScript: %m%P.ps
49 EOF
50
51 PGM=`$SEARCHPROG "$SEARCHPATH" xwud`
52 if [ ! -z "$PGM" ]; then
53 XWUD="$PGM" X11DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
54 else
55 XWUD= X11DIR=
56 fi
57
58 PGM=`$SEARCHPROG "$SEARCHPATH" pnmtoxwd`
59 if [ ! -z "$PGM" ]; then
60 NETPBM="$PGM" NETPBMDIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
61 else
62 NETPBM= NETPBMDIR=
63 fi
64
65 PGM=`$SEARCHPROG "$SEARCHPATH" xv`
66 if [ ! -z "$PGM" ]; then
67 echo "mhshow-show-image: %l$PGM -geometry =-0+0 %f" >> $TMP
68 elif [ ! -z $"NETPBM" -a ! -z "$XWUD" ]; then
69 echo "mhshow-show-image/gif: %l${NETPBMDIR}giftopnm | ${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
70 echo "mhshow-show-image/x-pnm: %l${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
71 echo "mhshow-show-image/x-pgm: %l${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
72 echo "mhshow-show-image/x-ppm: %l${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
73 echo "mhshow-show-image/x-xwd: %l$XWUD -geometry =-0+0" >> $TMP
74
75 PGM=`$SEARCHPROG "$SEARCHPATH" djpeg`
76 if [ ! -z "$PGM" ]; then
77 echo "mhshow-show-image/jpeg: %l$PGM -Pg | ${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
78 fi
79 fi
80
81 if [ -f "/dev/audioIU" ]; then
82 PGM=`$SEARCHPROG "$SEARCHPATH" recorder`
83 if [ ! -z "$PGM" ]; then
84 echo "mhstore-store-audio/basic: %m%P.au" >> $TMP
85 echo "mhbuild-compose-audio/basic: ${AUDIODIR}recorder %f -au -pause > /dev/tty" >> $TMP
86 echo "mhshow-show-audio/basic: %l${AUDIODIR}splayer -au" >> $TMP
87 fi
88 elif [ -f "/dev/audio" ]; then
89 PGM=`$SEARCHPROG "$SEARCHPATH" raw2audio`
90 if [ ! -z "$PGM" ]; then
91 AUDIODIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
92 echo "mhstore-store-audio/basic: | ${AUDIODIR}raw2audio -e ulaw -s 8000 -c 1 > %m%P.au" >> $TMP
93 echo "mhstore-store-audio/x-next: %m%P.au" >> $TMP
94 AUDIOTOOL=`$SEARCHPROG "$SEARCHPATH" audiotool`
95 if [ ! -z "$AUDIOTOOL" ]; then
96 echo "mhbuild-compose-audio/basic: $AUDIOTOOL %f && ${AUDIODIR}raw2audio -F < %f" >> $TMP
97 else
98 echo "mhbuild-compose-audio/basic: trap \"exit 0\" 2 && ${AUDIODIR}record | ${AUDIODIR}raw2audio -F" >> $TMP
99 fi
100 echo "mhshow-show-audio/basic: %l${AUDIODIR}raw2audio 2>/dev/null | ${AUDIODIR}play" >> $TMP
101
102 PGM=`$SEARCHPROG "$SEARCHPATH" adpcm_enc`
103 if [ ! -z "$PGM" ]; then
104 DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
105 if [ ! -z "$AUDIOTOOL" ]; then
106 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL %f && ${DIR}adpcm_enc < %f" >> $TMP
107 else
108 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record | ${DIR}adpcm_enc" >> $TMP
109 fi
110 echo "mhshow-show-audio/x-next: %l${DIR}adpcm_dec | ${AUDIODIR}play" >> $TMP
111 else
112 if [ ! -z "$AUDIOTOOL" ]; then
113 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL %f" >> $TMP
114 else
115 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record" >> $TMP
116 fi
117 echo "mhshow-show-audio/x-next: %l${AUDIODIR}play" >> $TMP
118 fi
119 else
120 echo "mhbuild-compose-audio/basic: cat < /dev/audio" >> $TMP
121 echo "mhshow-show-audio/basic: %lcat > /dev/audio" >> $TMP
122 fi
123 fi
124
125 ####
126 #### mhbuild-disposition-<type>[/<subtype>] entries are used by the
127 #### WhatNow attach for deciding whether the Content-Disposition
128 #### should be 'attachment' or 'inline'. Only those values are
129 #### supported. mhbuild-convert-text/html is defined below.
130 ####
131 cat <<EOF >>${TMP}
132 mhbuild-convert-text: charset=%{charset}; iconv -f \${charset:-us-ascii} -t utf-8 %F${replfmt}
133 mhbuild-disposition-text/calendar: inline
134 mhbuild-disposition-message/rfc822: inline
135 EOF
136
137 PGM=`$SEARCHPROG "$SEARCHPATH" mpeg_play`
138 if [ ! -z "$PGM" ]; then
139 echo "mhshow-show-video/mpeg: %l$PGM %f" >> $TMP
140 fi
141
142 PGM=`$SEARCHPROG "$SEARCHPATH" okular`
143 if [ ! -z "$PGM" ]; then
144 echo "mhshow-show-application/PostScript: %l$PGM %F" >> $TMP
145 else
146 PGM=`$SEARCHPROG "$SEARCHPATH" evince`
147 if [ ! -z "$PGM" ]; then
148 echo "mhshow-show-application/PostScript: %l$PGM %F" >> $TMP
149 else
150 PGM=`$SEARCHPROG "$SEARCHPATH" gv`
151 if [ ! -z "$PGM" ]; then
152 echo "mhshow-show-application/PostScript: %l$PGM %F" >> $TMP
153 fi
154 fi
155 fi
156
157 PGM=`$SEARCHPROG "$SEARCHPATH" acroread`
158 if [ ! -z "$PGM" ]; then
159 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
160 else
161 PGM=`$SEARCHPROG "$SEARCHPATH" okular`
162 if [ ! -z "$PGM" ]; then
163 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
164 else
165 PGM=`$SEARCHPROG "$SEARCHPATH" evince`
166 if [ ! -z "$PGM" ]; then
167 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
168 else
169 PGM=`$SEARCHPROG "$SEARCHPATH" xpdf`
170 if [ ! -z "$PGM" ]; then
171 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
172 else
173 PGM=`$SEARCHPROG "$SEARCHPATH" gv`
174 if [ ! -z "$PGM" ]; then
175 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
176 fi
177 fi
178 fi
179 fi
180 fi
181
182 PGM=`$SEARCHPROG "$SEARCHPATH" ivs_replay`
183 if [ ! -z "$PGM" ]; then
184 echo "mhshow-show-application/x-ivs: %l$PGM -o %F" >> $TMP
185 fi
186
187 # The application/vnd.openxmlformats-officedocument.wordprocessingml.document
188 # through application/onenote associations are from
189 # http://technet.microsoft.com/en-us/library/cc179224.aspx
190
191 cat <<EOF >> ${TMP}
192 mhshow-suffix-application/msword: .doc
193 mhshow-suffix-application/ogg: .ogg
194 mhshow-suffix-application/pdf: .pdf
195 mhshow-suffix-application/postscript: .ps
196 mhshow-suffix-application/rtf: .rtf
197 mhshow-suffix-application/vnd.ms-excel: .xla
198 mhshow-suffix-application/vnd.ms-excel: .xlc
199 mhshow-suffix-application/vnd.ms-excel: .xld
200 mhshow-suffix-application/vnd.ms-excel: .xll
201 mhshow-suffix-application/vnd.ms-excel: .xlm
202 mhshow-suffix-application/vnd.ms-excel: .xls
203 mhshow-suffix-application/vnd.ms-excel: .xlt
204 mhshow-suffix-application/vnd.ms-excel: .xlw
205 mhshow-suffix-application/vnd.ms-powerpoint: .pot
206 mhshow-suffix-application/vnd.ms-powerpoint: .pps
207 mhshow-suffix-application/vnd.ms-powerpoint: .ppt
208 mhshow-suffix-application/vnd.ms-powerpoint: .ppz
209 mhshow-suffix-application/vnd.openxmlformats-officedocument.wordprocessingml.document: .docx
210 mhshow-suffix-application/vnd.ms-word.document.macroEnabled.12: .docm
211 mhshow-suffix-application/vnd.openxmlformats-officedocument.wordprocessingml.template: .dotx
212 mhshow-suffix-application/vnd.ms-word.template.macroEnabled.12: .dotm
213 mhshow-suffix-application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: .xlsx
214 mhshow-suffix-application/vnd.ms-excel.sheet.macroEnabled.12: .xlsm
215 mhshow-suffix-application/vnd.openxmlformats-officedocument.spreadsheetml.template: .xltx
216 mhshow-suffix-application/vnd.ms-excel.template.macroEnabled.12: .xltm
217 mhshow-suffix-application/vnd.ms-excel.sheet.binary.macroEnabled.12: .xlsb
218 mhshow-suffix-application/vnd.ms-excel.addin.macroEnabled.12: .xlam
219 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.presentation: .pptx
220 mhshow-suffix-application/vnd.ms-powerpoint.presentation.macroEnabled.12: .pptm
221 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.slideshow: .ppsx
222 mhshow-suffix-application/vnd.ms-powerpoint.slideshow.macroEnabled.12: .ppsm
223 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.template: .potx
224 mhshow-suffix-application/vnd.ms-powerpoint.template.macroEnabled.12: .potm
225 mhshow-suffix-application/vnd.ms-powerpoint.addin.macroEnabled.12: .ppam
226 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.slide: .sldx
227 mhshow-suffix-application/vnd.ms-powerpoint.slide.macroEnabled.12: .sldm
228 mhshow-suffix-application/onenote: .onetoc
229 mhshow-suffix-application/onenote: .onetoc2
230 mhshow-suffix-application/onenote: .onetmp
231 mhshow-suffix-application/onenote: .onepkg
232 mhshow-suffix-application/x-bzip2: .bz2
233 mhshow-suffix-application/x-cpio: .cpio
234 mhshow-suffix-application/x-dvi: .dvi
235 mhshow-suffix-application/x-gzip: .gz
236 mhshow-suffix-application/x-java-archive: .jar
237 mhshow-suffix-application/x-javascript: .js
238 mhshow-suffix-application/x-latex: .latex
239 mhshow-suffix-application/x-sh: .sh
240 mhshow-suffix-application/x-tar: .tar
241 mhshow-suffix-application/x-texinfo: .texinfo
242 mhshow-suffix-application/x-tex: .tex
243 mhshow-suffix-application/x-troff-man: .man
244 mhshow-suffix-application/x-troff-me: .me
245 mhshow-suffix-application/x-troff-ms: .ms
246 mhshow-suffix-application/x-troff: .t
247 mhshow-suffix-application/zip: .zip
248 mhshow-suffix-audio/basic: .au
249 mhshow-suffix-audio/midi: .midi
250 mhshow-suffix-audio/mpeg: .mp3
251 mhshow-suffix-audio/mpeg: .mpg
252 mhshow-suffix-audio/x-ms-wma: .wma
253 mhshow-suffix-audio/x-wav: .wav
254 mhshow-suffix-image/gif: .gif
255 mhshow-suffix-image/jpeg: .jpeg
256 mhshow-suffix-image/jpeg: .jpg
257 mhshow-suffix-image/png: .png
258 mhshow-suffix-image/tiff: .tif
259 mhshow-suffix-image/tiff: .tiff
260 mhshow-suffix-text/calendar: .ics
261 mhshow-suffix-text/css: .css
262 mhshow-suffix-text/html: .html
263 mhshow-suffix-text/rtf: .rtf
264 mhshow-suffix-text/sgml: .sgml
265 mhshow-suffix-text/xml: .xml
266 mhshow-suffix-video/mpeg: .mpeg
267 mhshow-suffix-video/mpeg: .mpg
268 mhshow-suffix-video/quicktime: .moov
269 mhshow-suffix-video/quicktime: .mov
270 mhshow-suffix-video/quicktime: .qt
271 mhshow-suffix-video/quicktime: .qtvr
272 mhshow-suffix-video/x-msvideo: .avi
273 mhshow-suffix-video/x-ms-wmv: .wmv
274 EOF
275
276 # I'd like to check if netscape is available and use it preferentially to lynx,
277 # but only once I've added a new %-escape that makes more permanent temp files,
278 # so netscape -remote can be used (without -remote you get a complaint dialog
279 # that another netscape is already running and certain things can't be done).
280 PGM=`$SEARCHPROG "$SEARCHPATH" w3m`
281 if [ ! -z "$PGM" ]; then
282 echo 'mhshow-show-text/html: charset=%{charset}; '"\
283 %l$PGM"' -dump ${charset:+-I "$charset"} -T text/html %F' >> $TMP
284 echo 'mhfixmsg-format-text/html: charset=%{charset}; '"\
285 $PGM "'-dump ${charset:+-I "$charset"} -O utf-8 -T text/html %F' >> $TMP
286 echo 'mhbuild-convert-text/html: charset=%{charset}; '"\
287 $PGM "'-dump ${charset:+-I "$charset"} -O utf-8 -T text/html %F '"\
288 ${replfmt}" >> $TMP
289 else
290 PGM=`$SEARCHPROG "$SEARCHPATH" lynx`
291 if [ ! -z "$PGM" ]; then
292 echo 'mhshow-show-text/html: charset=%{charset}; '"\
293 %l$PGM"' -child -dump -force-html ${charset:+--assume_charset "$charset"} %F' >> $TMP
294 #### lynx indents with 3 spaces, remove them and any trailing spaces.
295 echo 'mhfixmsg-format-text/html: charset=%{charset}; '"\
296 $PGM "'-child -dump -force_html ${charset:+--assume_charset "$charset"} %F | '"\
297 expand | sed -e 's/^ //' -e 's/ *$//'" >> $TMP
298 echo 'mhbuild-convert-text/html: charset=%{charset}; '"\
299 $PGM "'-child -dump -force_html ${charset:+--assume_charset "$charset"} '"\
300 %F${replfmt}" >> $TMP
301 else
302 PGM=`$SEARCHPROG "$SEARCHPATH" elinks`
303 if [ ! -z "$PGM" ]; then
304 echo "mhshow-show-text/html: $PGM -dump -force-html \
305 -eval 'set document.browse.margin_width = 0' %F" >> $TMP
306 echo "mhfixmsg-format-text/html: $PGM -dump -force-html \
307 -no-numbering -eval 'set document.browse.margin_width = 0' %F" >> $TMP
308 echo "mhbuild-convert-text/html: $PGM -dump -force-html \
309 -no-numbering -eval 'set document.browse.margin_width = 0' %F${replfmt}" >> $TMP
310 else
311 echo 'mhbuild-convert-text/html: cat %F' >> $TMP
312 fi
313 fi
314 fi
315
316 PGM=`$SEARCHPROG "$SEARCHPATH" richtext`
317 if [ ! -z "$PGM" ]; then
318 echo "mhshow-show-text/richtext: %l$PGM -p %F" >> $TMP
319 else
320 PGM=`$SEARCHPROG "$SEARCHPATH" rt2raw`
321 if [ ! -z "$PGM" ]; then
322 echo "mhshow-show-text/richtext: %l$PGM < %f | fmt -78 | more" >> $TMP
323 fi
324 fi
325
326 # staroffice to read .doc files
327 PGM=`$SEARCHPROG "$SEARCHPATH" soffice`
328 if [ ! -z "$PGM" ]; then
329 echo "mhshow-show-application/msword: %l$PGM %F" >> $TMP
330 fi
331
332 # This entry is used to retrieve external-body types that use a "url"
333 # access-type.
334 case "`uname`" in
335 FreeBSD)
336 echo "nmh-access-url: fetch -o -" >> $TMP
337 ;;
338 *)
339 PGM=`$SEARCHPROG "$SEARCHPATH" curl`
340 if [ ! -z "$PGM" ]; then
341 echo "nmh-access-url: $PGM -L" >> $TMP
342 fi
343 ;;
344 esac
345
346 # output a sorted version of the file
347 sort < $TMP
348
349 exit 0
350
351
352 ###############################################################################
353 ###############################################################################
354 ####
355 #### Note the exit 0 above; everything below is unused.
356 ####
357 ###############################################################################
358 ###############################################################################
359
360 : have to experiment more with this
361
362 PGM=`$SEARCHPROG "$SEARCHPATH" ivs_record`
363 if [ ! -z "$PGM" ]; then
364 echo "mhbuild-compose-application/x-ivs: $PGM -u localhost %F" >> $TMP
365 fi