From: markus schnalke Date: Fri, 9 Mar 2012 11:25:06 +0000 (+0100) Subject: Added new helper `print-mimetype' and added Mime-Type-Query to man page. X-Git-Tag: mmh-thesis-end~294 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=4b5944268ea0da7bb30598a27857304758ea9b44;p=mmh Added new helper `print-mimetype' and added Mime-Type-Query to man page. Print-mimetype is useful if you don't have GNU file(1). --- diff --git a/.gitignore b/.gitignore index 6dffc55..d840b61 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ /uip/packf /uip/pick /uip/post +/uip/print-mimetype /uip/prompter /uip/rcvdist /uip/rcvpack diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index 2f67c63..b90cd97 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -181,6 +181,19 @@ If you like to type a lot, name it `X-MH-Attachment'. (profile, default: `Attach') .RE .PP +.BR Mime-Type-Query : +file \-b \-\-mime +.RS 5 +A command that prints the MIME type of a file. +The file name gets appended to the command line. +Note: Older GNU versions of file(1) won't generate the desired +output. GNU file-4.26, for instance, omits a required semicolon. +GNU file-5.04 is known to work. Non-GNU version likely need different +options or don't provide this function at all. Alternatively, you can use +.BR print\-mimetype , +which is part of mmh, but guesses MIME types by file name extensions only. +.RE +.PP .BR Msg\-Protect : 644 .RS 5 diff --git a/uip/Makefile.in b/uip/Makefile.in index 8d16759..7dcbb85 100644 --- a/uip/Makefile.in +++ b/uip/Makefile.in @@ -50,8 +50,8 @@ SETGID_MAIL = @SETGID_MAIL@ # commands to build CMDS = ali anno burst comp dist flist folder forw mmh mark mhbuild mhl \ - mhlist mhmail mhparam mhpath mhshow mhstore msgchk \ - new packf pick prompter refile repl rmf rmm scan send sendfiles show \ + mhlist mhmail mhparam mhpath mhshow mhstore msgchk new packf pick \ + print-mimetype prompter refile repl rmf rmm scan send sendfiles show \ sortm whatnow # commands that are links to other commands @@ -71,7 +71,7 @@ SRCS = ali.c aliasbr.c anno.c annosbr.c ap.c burst.c comp.c \ mhbuildsbr.c mhcachesbr.c mhfree.c mhl.c mhlist.c mhlistsbr.c \ mhmail.c mhmisc.c mhoutsbr.c mhparam.c mhparse.c \ mhpath.c mhshow.c mhshowsbr.c mhstore.c mhstoresbr.c mhtest.c \ - msgchk.c new.c packf.c pick.c \ + msgchk.c new.c packf.c pick.c print-mimetype.sh \ prompter.c rcvdist.c rcvpack.c rcvstore.c \ refile.c repl.c rmf.c rmm.c scan.c scansbr.c send.c \ sendfiles.sh show.c slocal.c sortm.c spost.c termsbr.c \ @@ -174,6 +174,10 @@ packf: packf.o dropsbr.o $(LOCALLIBS) pick: pick.o $(LOCALLIBS) $(LINK) pick.o $(LINKLIBS) +print-mimetype: print-mimetype.sh + cp print-mimetype.sh print-mimetype + chmod +x print-mimetype + prompter: prompter.o $(LOCALLIBS) $(LINK) prompter.o $(LINKLIBS) diff --git a/uip/print-mimetype.sh b/uip/print-mimetype.sh new file mode 100755 index 0000000..2149902 --- /dev/null +++ b/uip/print-mimetype.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# +# print mime type of file, depending on file name extension + +if [ $# -eq 0 ] ; then + echo "Usage: $0 FILE..." >&2 + exit 1 +fi + +for i do + +case "$i" in +*.xls) type=application/excel;; +*.ppt) type=application/mspowerpoint;; +*.doc) type=application/msword;; +*.pdf) type=application/pdf;; +*.deb) type=application/x-debian-package;; +*.tar) type=application/x-tar;; +*.[1-9]) type=application/x-troff-man;; +*.zip) type=application/zip;; +*.au) type=audio/basic;; +*.gif) type=image/gif;; +*.jpg|*.jpeg) type=image/jpeg;; +*.png) type=image/png;; +*.ps) type=application/postscript;; +*.eps) type=image/eps;; +*.tif|*.tiff) type=image/tiff;; +*.ico) type=image/x-icon;; +*.bmp) type=image/x-ms-bmp;; +*.pnm) type=image/x-portable-anymap;; +*.pbm) type=image/x-portable-bitmap;; +*.pgm) type=image/x-portable-graymap;; +*.ppm) type=image/x-portable-pixmap;; +*.xbm) type=image/x-xbitmap;; +*.xpm) type=image/x-xpixmap;; +*.xwd) type=image/x-xwindowdump;; +*.eml) type=message/rfc822;; +*.rtf) type=text/richtext;; +*.html|*.htm) type=text/html;; +*.txt) type=text/plain;; +*.mpg|*.mpeg) video/mpeg;; +*) + if file "$i" | grep -q ' text$' ; then + type=text/plain;; + else + type=application/octet-stream;; + fi +esac +echo "$type" + +done +