;;; -*- mode: Lisp -*-
	
  This file is part of CL - SMTP , the Lisp SMTP Client 


  Copyright ( C ) 2004/2005/2006/2007/2008/2009/2010 Jan Idzikowski 

;;; This library is free software; you can redistribute it and/or
  modify it under the terms of the Lisp Lesser General Public License 
;;; (), known as the LLGPL.

;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; Lisp Lesser GNU General Public License for more details.

;;; File: attachments.lisp
;;; Description: encoding and transmitting login to include a mime attachment

;;;
  Contributed by   
;;;
(in-package :cl-smtp)

(eval-when (:compile-toplevel :load-toplevel)
;;;  Some of the most common file extensions with the mime types and descriptions. 
;;; Extracted from numberous webpages. 
  (defparameter *mime-type-descriptions*
    '(("386" "application/octet-stream" 
       "Windows Enhanced Mode Driver or Swap File")
      ("001" "application/x-001" "FAX Datafile")
      ("3GPP" "audio/3gpp" 
       "3rd
Generation Partnership Project. Multimedia over 3rd generation wireless
networks. H.263 video is the mandatory video format in 3GPP and AMR is
the main audio/speech format.")
      ("7CB" "application/vnd.ecdis-update" 
       "Electronic Chart Display and Information System (ECDIS)")
      ("aa" "audio/audible" "Audible file format (audio books)")
      ("aab" "application/x-authorware-bin" "Macromedia Authorware Binary")
      ("aac" "audio/aac" 
       "Advanced Audio Coding File. Part of  MPEG-2 and MPEG-4 standard.  (Apple iTunes Store)")
      ("aam" "application/x-authorware-map" "Authorware Map (Shockwave?)")
      ("aas" "application/x-authorware-seg" 
       "Authorware Shocked Packet (Segment) ")
      ("aba" "text/x-palm-aba" "AddressBook Archive (Palm)")
      ("ac3" "audio/ac3" 
       "Adaptive Transform Coder 3 (relates to the bitstream format of Dolby Digital)")
      ("adr" "application/x-msaddr" "Address Book")
      ("aexpk" "application/pgp-keys" "Armored extracted public key (PGP)")
      ("afl" "video/animaflex" "Font file (for Allways) (Lotus 1-2-3)")
      ("ahtml" "magnus-internal/cgi-advertiser" "&nbsp;")
      ("ai" "application/postscript" 
       "Encapsulated PostScript (metafile) (Adobe Illustrator)")
      ("aif" "audio/x-aiff" "Audio Interchange File Format")
      ("aifc" "audio/x-aiff" "Audio Interchange File Format")
      ("aiff" "audio/x-aiff" "Audio Interchange File Format")
      ("aim" "application/x-aim" "AIM file - AOL Instant Messanger")
      ("alt" "application/x-up-alert" "Menu file (WordPerfect Library)")
      ("aos" "application/x-nokia-" "Add-On Software (Nokia 9000)")
      ("arj" "application/x-arj" 
       "Compressed file archive created by ARJ or winzip")
      ("art" "image/x-jg" 
       "AOL Johnson-Grace Compressed File and Another Ray Tracer Format")
      ("asc" "application/pgp-encrypted" "Armored Encrypted file (PGP)")
      ("asd" "application/astound" "Autosave file (Word for Windows)")
      ("asf" "application/vnd.ms-asf video/x-ms-asf  video/x-ms-wm"
       "Windows Media file - Advanced Streaming Format (ASF), NetShow")
      ("asn" "application/astound" "&nbsp;")
      ("asp" "text/html" 
       "Active Server Pages - standard HTML documents interlaced with ActiveX script code ")
      ("asr" "video/x-ms-asf" "Microsoft NetShow")
      ("asx" "video/x-ms-asf application/x-mplayer2" 
       "VXtreme (Microsoft streaming AV)")
      ("asz" "application/astound" "&nbsp;")
      ("au" "audio/basic" "8-bit u-law [PCM] / 8000 Hz")
      ("avi" "video/x-msvideo" "Windows Video file")
      ("axs" "application/olescript" "&nbsp;")
      ("bas" "text/plain" "BASIC program")
      ("bat" "application/octet-stream" "DOS BAT (Batch) file.")
      ("bcpio" "application/x-bcpio" "Old Binary CPIO")
      ("bexpk" "application/pgp-keys" "binary extracted public key (PGP)")
      ("bin" "application/octet-stream" "Uninterpreted Binary Data")
      ("bk" "application/vnd.framemaker" "FrameMaker book ")
      ("bleep" "application/bleeper" "&nbsp;")
      ("bmp" "image/x-bmp" "Windows Bitmap (PaintBrush)")
      ("btf" "image/prs.btf" "NationsBank Check Images (also .btif)")
      ("c" "text/plain" "C program")
      ("c++" "text/plain" "C program")
      ("cab" "application/cab" 
       "Cabinet file Microsoft installation archive. opersyss=win32, mac cpu=x86, ppc, mips, alpha")
      ("cal" "application/x-msschedplus" "MS schedplus or calendar")
      ("cat" "application/pdf" 
       "PDF Catalog (Used with Acrobat Reader and Search plug-in)")
      ("cat" "application/vnd.ms-pki.seccat" "Security Catalog")
      ("ccs" "text/ccs" 
       "Cluster Configuration System used with the Global File System (GFS) in Red Hat Linux")
      ("cdda" "audio/aiff" "CD Audio Track")
      ("cda" "audio/x-cda" "CD Audio Track")
      ("cdf" "text/plain" "Channel Definition Format - MS push std")
      ("cdr" "application/x-coreldrw" "Corel Draw (metafile)")
      ("cer" " application/pkix-cert" "Certificatefile")
      ("cfm" "wwwserver/wsapi" "Cold Fusion Markup")
      ("cgi" "magnus-internal/cgi" "Common Gateway Interface")
      ("cgm" "image/cgm" "Computer Graphics Metafile ")
      ("chat" "application/x-chat" "&nbsp;")
      ("che" "application/x-up-cacheop" "&nbsp;")
      ("cht" "audio/x-dspeech" 
       "Chart (Harvard Graphics 2.0 - SoftCraft Presenter)")
      ("cil" "application/vnd.ms-artgalry" "Clip Gallery Download Packages")
      ("class" "application/java-vm" "Java")
      ("cli" "application/vnd.ms-artgalry" "&nbsp;")
      ("clp" "application/x-msclip" "Windows Clipboard (metafile)")
      ("cmx" "image/x-cmx" "&nbsp;")
      ("cnc" "application/x-cnc" "CNC general program data")
      ("cod" "image/cis-cod" 
       "Datafile (Forecast Plus - MS Multiplan - StatPac Gold)")
      ("coda" "application/x-coda" "&nbsp;")
      ("com" "application/octet-stream" 
       "DOS COM Executable (similar to exe, but a direct memory image)")
      ("cpi" "image/cpi" "ColorLab Processed Image ")
      ("cpio" "application/x-cpio" "IEEE Std1003.2 (`POSIX') CPIO")
      ("cpt" "application/mac-compactpro" "Compact Pro Archive")
      ("crd" "application/x-mscardfile" "MS cardfile")
      ("crt" "application/x-x509-ca-cert" "Certificatefile")
      ("csh" "application/x-csh" "CSH Script")
      ("csm" "application/x-cu-seeme" "Precompiled headers (Borland C++ 4.5)")
      ("css" "text/css" "Cascading Style Sheets")
      ("csv" "text/csv" 
       "Comma-Separated Values (Excel, Lotus 123, FoxPro, MS Outlook)")
      ("ct" "image/" "Iris CT Graphic or Scitex CT Handshake Bitmap ")
      ("cu" "application/x-cu-seeme" "&nbsp;")
      ("cut" "image/x-halo-cut" "Bitmap graphics")
      ("dat" "application/octet-stream" 
       "Data file. Can be anything, text, graphics, binary, ...")
      ("dba" "text/x-palm-dba" "DateBook Archive (Palm)")
      ("dbf" "application/octet-stream" "DataBase File (FoxPro, dBase) ")
      ("dbm" "wwwserver/wsapi" "ColdFusion IIS Plugin")
      ("dca" "application/dca-rft" "IBM Doc Content Arch")
      ("dcr" "application/x-director" "Macromedia Director (Shockwave)")
      ("deb" "application/octet-stream" "Binary for debian UNIX")
      ("der" "application/x-x509-ca-cert" "Certificatefile")
      ("dir" "application/x-director" "Macromedia Director (Shockwave)")
      ("dll" "application/x-msdownload"
       "Dynamically Linked Library (DOS) pe-portable executable opersys=win32, mac cpu=x86, ppc, mips, alpha")
      ("dms" "application/octet-stream" 
       "Compressed Amiga file archive created by DISKMASHER")
      ("doc" "application/msword" "MS Word") 
      ("dot" "application/msword" "MS Word (Template)")
      ("dsf" "image/x-mgx-dsf" "Micrografx Designer 6 (metafile)")
      ("dst" "application/tajima" "PC-RDist Distribution file ")
      ("dtd" "text/xml" "SGML Document (Type) Definition file")
      ("dus" "audio/x-dspeech" "Readiris font dictionary")
      ("dvi" "application/x-dvi" "TeX DVI (Device Independent)")
      ("dwc" "application/dwc" "compressed archive")
      ("dwf" "drawing/x-dwf" "Autodesk WHIP! Drawing Web file")
      ("dwg" "application/x-acad" "AutoCAD Drawing")
      ("dxf" "application/vnd.dxf" 
       "Drawing eXchange Format, Data Exchange File, AutoCAD (vector)")
      ("dxr" "application/x-director" "Macromedia Director (Shockwave)")
      ("ebk" "application/x-expandedbook" "&nbsp;")
      ("emf" "image/x-emf" 
       "Enhanced metafile created in Microsoft Windows and Visio 2002 applications")
      ("eml" "message/rfc822" 
       "MS Internet Mail Message (Outlook Express and others)")
      ("enc" "application/pre-encrypted" 
       "Pre-encrypted Data (also Sniffer trace)")
      ("eps" "application/postscript" "Encapsulated PostScript (raster)")
      ("erf" "application/x-hsp-erf" "&nbsp;")
      ("es" "audio/echospeech" "&nbsp;")
      ("etf" "image/x-etf" "Enriched Text file")
      ("etx" "text/x-setext" "Structure Enchanced Text")
      ("evy" "application/x-envoy" "Document (WordPerfect Envoy)")
      ("exe" "application/x-pe-" 
       "pe-portable executable opersys=win32, mac cpu=x86, ppc, mips, alpha")
      ("fdf" "application/vnd.fdf" "acrobat reader")
      ("fh4" "image/x-freehand" "Vector graphics (Aldus FreeHand 4.x)")
      ("fh5" "image/x-freehand" "Freehand 5")
      ("fhc" "image/x-freehand" "Freehand")
      ("fif" "image/fif" "Fractal Image Format file")
      ("fla" "application/x-shockwave-flash" "&nbsp;")
      ("flac" "audio/flac" "Free Lossless Audio Codec")
      ("flc" "video/flc " "FLIC Animated Picture 	Autodesk ")
      ("fli" "video/fli " "FLIC Animated Picture 	Autodesk ")
      ("fm" "application/vnd.framemaker " "FrameMaker Document")
      ("fm3" "application/x-maker " "FrameMaker")
      ("fm4" "application/vnd.framemaker" "FrameMaker")
      ("fm5" "application/vnd.framemaker" "FrameMaker")
      ("fml" "application/fml" "&nbsp;")
      ("fp5" "application/filemaker5" "FileMaker Pro")
      ("frl" "application/freeloader" "FormFlow file")
      ("frm" "application/vnd.framemaker" "FrameMaker")
      ("fs" "application/X-FSRecipe" "&nbsp;")
      ("g3f" "image/g3fax" "Group III FAX")
      ("gb" "application/chinese-gb" "Chinese Text")
      ("gif" "image/gif" 
       "GIF - Graphics Interchange Format - Compuserve (raster)")
      ("gsd" "audio/x-gsm" "GSM Internet Realtime Audio ")
      ("gsm" "audio/x-gsm" "Raw GSM 6.10 Audio Stream ")
      ("gtar" "application/x-gtar" "Gnu Tar")
      ("gz" "application/x-gzip" "Unix Gzip (gnu-compress ecnapsulation)")
      ("hdf" "application/x-hdf" "NCSA HDF (Hierarchical Data Format)")
      ("hdml" "text/x-hdml" "&nbsp;")
      ("hlb" "vms/help" "VMS help libraries")
      ("hlp" "application/x-mshelp" "Windows Help")
      ("hpgl" "application/vnd.hp-HPGL" "HP Graphic Language")
      ("hqx" "application/mac-binhex40" 
       "BinHex 4.0 Format - Macintosh Binary to ASCII conversion.")
      ("htm" "text/html" "HTML - HyperText Markup Language")
      ("html" "text/html" "HTML - HyperText Markup Language")
      ("hz" "application/chinese-hz" "Chinese")
      ("ica" "application/x-ica" 
       "Bitmap graphics (Image Object Content Architecture)")
      ("ice" "x-conference/x-cooltalk" "&nbsp;")
      ("ico" "image/ico" "Windows icon") 
      ("icq" "application/x-icq" "Saved ")
      ("ics" "text/calendar" "iCalendar Calendar Data (Mac)")
      ("ief" "image/ief" "Image Exchange Format")
      ("iff" "image/iff " "Amiga Bitmap Graphic ")
      ("iges" "model/iges" "&nbsp;")
      ("img" "image/img" 
       "Venture Publisher, GEM Draw (bit mapped), AutoCAD CAD-Camera, others")
      ("inc" "text/plain" "&nbsp;")
      ("inf" "application/x-setupscript"
       "Setup scripts (For Installing Drivers, etc.), Autorun - auto-start file for a CD-ROM")
      ("ins" "application/x-NET-Install" "Data (WordPerfect)")
      ("ipx" "application/x-ipix" "IPIX AV file")
      ("isapi" "wwwserver/isapi" 
       "Internet Server API - Application Program(ming) Interface")
      ("ivr" "i-world/i-vrml" "Virtual Reality World Live Picture ")
      ("jar" "application/java-archive" "&nbsp;")
      ("java" "text/plain" "&nbsp;")
      ("jfx" "application/octet-stream" 
       "eFax Fax Document (J2 Global Communications ")
      ("jpe" "image/jpeg" "JPEG-JFIF - Joint Photographic Experts Group")
      ("jpeg" "image/jpeg" "JPEG-JFIF - Joint Photographic Experts Group")
      ("jpg" "image/jpeg" 
       "JPEG-JFIF - Joint Photographic Experts Group (raster)")
      ("jps" "image/x-jps" "Stereo Image")
      ("js" "application/x-javascript" "Java Script")
      ("jsc" "application/x-javascript-config" "&nbsp;")
      ("jsp" "magnus-internal/jsp" "Java Script")
      ("la" "audio/nspaudio" "Netscape Packetized audio ")
      ("latex" "application/x-latex" "LaTeX Source")
      ("ldif" "text/x-ldif" 
       "LDAP Data Interchange Format ( Netscape Address Book)")
      ("lha" "application/octet-stream" "LHA Archive") 
      ("lisp" "text/plain" "Lisp Files")
      ("lma" "audio/nspaudio" "Netscape Packetized audio ")
      ("loe" "application/vnd.framemaker" "FrameMaker list of exhibits ")
      ("lof" "application/vnd.framemaker" "FrameMaker list of figures ")
      ("lot" "application/vnd.framemaker" "FrameMaker list of tables ")
      ("lwp" "WordPro 9.5 " "&nbsp;")
      ("lzh" "application/octet-stream" "compressed")
      ("lzs" "application/octet-stream" "compressed")
      ("lzx" "application/octet-stream" "compressed")
      ("m13" "application/x-msmediaview" "MS mediaview")
      ("m14" "application/x-msmediaview" "MS mediaview")
      ("m3u" "audio/x-mpegurl" "Music Playlist (Winamp)")
      ("m4a" "audio/" "Apple iTunes AAC and ALE unprotected")
      ("ma" "application/mathmetica" "Mathmetica Notebook")
      ("m4p" "audio/" "Apple iTunes AAC protected")
      ("m4b" "audio/" "Apple iTunes AAC protected autiobook")
      ("man" "application/x-troff-man" "Troff w/MAN Macros")
      ("map" "application/x-httpd-imap" "Image Configuration File (HTML Image Map)")
      ("mbd" "application/mbedlet" "&nbsp;")
      ("mcf" "image/vasa" "Mathcad font")
      ("mda" "application/x-msaccess" "MS Access  (May not be desirable)")
      ("mdb" "application/x-msaccess" "MS access")
      ("me" "application/x-troff-me" "Troff w/ME Macros")
      ("mesh" "model/mesh" "&nbsp;")
      ("mfp" "application/mirage" "&nbsp;")
      ("mht" "message/rfc822" "Microsoft Web Archiv")
      ("mid" "audio/x-midi" "MIDI")
      ("midi" "audio/x-midi" "MIDI")
      ("mif" "application/vnd.mif" "Maker Interchange Format (FrameMaker)")
      ("mime" "message/rfc822" 
       "base64 (6-bit) is the standard for encoding binary attachme")
      ("mk" "application/vnd.framemaker" "FrameMaker")
      ("mmf" "application/x-smaf application/vnd.smaf"
       "SMAF = \"Synthetic music Mobile Application Format\" - Polyphonic Ringtone File for Phones - Yamaha")
      ("mmm" "application/pdf" "Acrobat Media Clip")
      ("mny" "application/x-msmoney" "MS money")
      ("mocha" "application/x-javascript" "Java Script")
      ("mol" "chemical/x-mdl-molfile" "MDL Molfile ")
      ("mov" "video/quicktime" "QuickTime digital video")
      ("movie" "video/x-sgi-movie" "SGI \"movieplayer\" movie")
      ("mp2" "audio/mpeg" "MPEG Audio Stream, Layer II ")
      ("mp3" "audio/mpeg" "MPEG Audio Stream, Layer III ")
      ("mp4" "video/mp4v-es" 
       "MPEG Audio Stream, Layer IV (QuickTime and RealPlayer)")
      ("mpa" "audio/mpeg" "MPEG Audio Stream, Layer I, II or III ")
      ("mpe" "video/mpeg" "MPEG - Motion Picture Experts Group")
      ("mpeg" "video/mpeg" "MPEG - Motion Picture Experts Group")
      ("mpg" "video/mpeg" "MPEG - Motion Picture Experts Group")
      ("mpga" "audio/mpeg" "&nbsp;")
      ("mpire" "application/x-mpire" "&nbsp;")
      ("mpl" "application/x-mpire" "&nbsp;")
      ("mpp" "application/vnd.ms-project" "MS Project")
      ("mpt" "application/vnd.ms-project" "MS Project")
      ("mpv" "application/vnd.ms-project" "MS Project view")
      ("mpw" "application/vnd.ms-project" "MS Project")
      ("mpx" "application/vnd.ms-project" "MS Project")
      ("ms" "application/x-troff-ms" "Troff w/MS Macros")
      ("msh" "model/mesh" "2 and 2-D visualization")
      ("n2p" "application/n2p" "&nbsp;")
      ("nc" "application/x-netcdf" "Unidata netCDF data file")
      ("npx" "application/x-netfpx" "&nbsp;")
      ("nsc" "application/x-nschat" "Noder file (Polish)")
      ("nsf" "application/x-notes" "Lotus Notes ")
      ("ntf" "application/x-notes" "Lotus Notes ")
      ("ocx" "application/x-oleobject" 
       "Object Linking and Embedding (OLE) Control Extension  (ActiveX Control)")
      ("oda" "application/oda" "ODA/ODIF Open Document Architecture ") 
      ("ods" "application/vnd.oasis.opendocument.spreadsheet" 
       "Open Office Version 2 spreedsheet")
      ("odt" "application/vnd.oasis.opendocument.text;" 
       "Open Office Version 2 writer")
      ("odp" "application/vnd.oasis.opendocument.presentation" 
       "Open Office Version 2 presentor")
      ("ofml" "application/fml" "&nbsp;")
      ("ogg" "audio/x-ogg" "Ogg Vorbis open-source audio format")
      ("olb" "vms/olb" "Vax Object Library or MS Project Object Library")
      ("or2" "application/x-organizer" "Lotus Organizer")
      ("ovl" "application/octet-stream" "PC OVL File")
      ("pac" "application/x-ns-proxy-autoconfig" "&nbsp;")
      ("page" "application/x-coda" "&nbsp;")
      ("pbd" "application/vnd.powerbuilder6" "Phone book (FaxNOW! - Faxit)")
      ("pbm" "image/x-portable-bitmap" "PBM Bitmap Format")
      ("pcd" "image/x-photo-cd" "Kodak Photo CD (raster)")
      ("pcl" "application/pcl" "
Printer Control Language (HP)")
      ("pcx" "image/pcx" "PC Paintbrush (ZSoft Image)")
      ("pdb" "text/x-palm-pdb" "Palm Database File")
      ("pdf" "application/pdf" "Portable Document Format (Adobe Acrobat)")
      ("pfm" "application/pdf" "Acrobat Font")
      ("pfr" "application/font-tdpfr" "&nbsp;")
      ("pgm" "image/x-portable-graymap" "PBM Graymap Format")
      ("pgp" "application/pgp-encrypted" "PGP Encrypted file ")
      ("pgr" "text/parsnegar-document" "&nbsp;")
      ("php3" "application/x-httpd-php3" "&nbsp;")
      ("phtml" "application/x-httpd-php" "PHP Script ")
      ("pic" "image/pict" "Macintosh QuickDraw format (metafile)")
      ("pict" "image/pict" "Macintosh QuickDraw format (metafile)")
      ("pif" "application/x-mspif" "Program Information File (Windows)")
      ("pkr" "application/pgp-keys" "Public Keyring (PGP)")
      ("pnc" "text/x-palm-pnc" "Palm Network Configuration File")
      ("png" "image/png" "Portable Network Graphics")
      ("pnm" "image/x-portable-anymap" "PBM Anymap Format")
      ("pot" "application/ms-powerpoint" "MS PowerPoint template")
      ("ppa" "application/vnd.ms-powerpoint" "MS PowerPoint addin")
      ("ppm" "image/x-portable-pixmap" "PBM Pixmap Format")
      ("pps" "application/ms-powerpoint" "MS PowerPoint Slideshow")
      ("ppt" "application/ms-powerpoint" "MS PowerPoint Presentation")
      ("ppz" "applications/ms-powerpoint" "MS PowerPoint Animation")
      ("pqa" "text/x-palm-pqa" "Palm Query Application")
      ("pqf" "application/x-cprplayer" "&nbsp;")
      ("pqi" "application/cprplayer" "Power Quest Drive imaging")
      ("prc" "text/x-palm-prc" "Palm Application")
      ("prvkr" "application/pgp-keys" "Private Keyring (PGP)")
      ("ps" "application/postscript" "PostScript")
      ("psd" "image/x-photoshop" "Adobe PhotoShop Image")
      ("psr" "application/datawindow" "Project Scheduler Resource file")
      ("ptlk" "application/listenup" "&nbsp;")
      ("pub" "application/x-mspublisher" "MS publisher or PageMaker 2")
      ("pubkr" "application/pgp-keys" "Public Keyring (PGP)")
      ("push" "multipart/x-mixed-replace" "&nbsp;")
      ("qd3" "x-world/x-3dmf" "Data file - segment 3 (Omnis Quartz)")
      ("qd3d" "x-world/x-3dmf" "&nbsp;")
      ("qrt" "application/quest" "Qrt ray tracing graphics")
      ("qt" "video/quicktime" "QuickTime")
      ("ra" "audio/x-realaudio" "Music (RealAudio)")
      ("ram" "audio/x-pn-realaudio" "Real Audio Player")
      ("ras" "image/x-cmu-raster" "Sun Raster Format (raster)")
      ("rax" "audio/" "RealAudio 10 - RealMedia Streaming File")
      ("rgb" "image/x-rgb" "RGB Color Image")
      ("rip" "image/rip" "Graphics (Remote Access)")
      ("rm" "audio/x-pn-realaudio" "&nbsp;")
      ("rmf" "audio/x-rmf" "Rich Music Format audio file from Beatnik")
      ("rmi" "audio/mid" "MIDI File ")
      ("roff" "application/x-troff" "Troff")
      ("rpm" "audio/x-pn-realaudio-plugin" 
       "Real Audio Plugin and RedHat Package Manager")
      ("rrf" "application/x-InstallFromTheWeb" "&nbsp;")
      ("rtc" "application/rtc" "&nbsp;")
      ("rtf" "application/rtf" "Rich Text Format (Microsoft)")
      ("rtx" "text/richtext" "MIME Richtext format (see also rtf)")
      ("rtsp" "application/x-rtsp" 
       "QuickTime Real-Time Streaming Protocol File ")
      ("sb" "application/x-xsb" "Superbook")
      ("sbx" "application/x-xsb" 
       "ArcView Spatial Index For Read-Write Shapefiles ")
      ("sca" "application/x-supercard" "Datafile (SCA)")
      ("scp" "text/x-palm-scp" "Palm Network Script File")
      ("sdp" "application/sdp" "Scalable Multicast (RealNetworks)")
      ("ser" "application/java-" "&nbsp;")
      ("sgm" "text/x-sgml" "Standard Generalized Markup Lang (SGML)")
      ("sgml" "text/x-sgml" "Standard Generalized Markup Lang (SGML)")
      ("sh" "application/x-sh" "SH Script")
      ("shar" "application/x-shar" "Sh Shar")
      ("shtml" "magnus-internal/parsed-html" "&nbsp;")
      ("shw" "application/presentations" 
       "Presentation (Harvard Graphics 2.0 - CorelShow)")
      ("sig" "application/pgp-signature" "Detached signature file (PGP)")
      ("silo" "model/mesh" "&nbsp;")
      ("sit" "application/x-stuffit" 
       "StuffIt - Macintosh Compression Format. By Aladdin for Mac.")
      ("sitx" "application/x-stuffit"
       "StuffIt X file format integrates compression with security and safety options. By Aladdin for Mac.")
      ("skd" "application/x-koan" "&nbsp;")
      ("skm" "application/x-koan" "&nbsp;")
      ("skp" "application/x-koan" "&nbsp;")
      ("skr" "application/pgp-keys" "Private Keyring (PGP)")
      ("skt" "application/x-koan" "&nbsp;")
      ("smil" "application/smil" 
       "SMIL Synchronized Multimedia Integration Language. App:RealPlayer")
      ("sml" "application/smil" 
       "SMIL Synchronized Multimedia Integration Language")
      ("smp" "application/studiom" "Sample (sound file)")
      ("snd" "audio/basic" "8-bit u-law [PCM] / 8000 Hz Audio")
      ("spc" "text/x-palm-spc" "Palm Configuration File")
      ("spl" "application/futuresplash" "FutureSplash from FutureWave Sftwr")
      ("spr" "application/x-sprite" "Document letter (Sprint)")
      ("sprite" "application/x-sprite" "&nbsp;")
      ("src" "application/x-wais-source" "WAIS Source")
      ("stk" "application/hstu" "&nbsp;")
      ("stream" "audio/x-qt-stream" "&nbsp;")
      ("sty" "application/msword" "MS Word Style sheet")
      ("sv4cpio" "application/x-sv4cpio" "SVR4 CPIO")
      ("sv4crc" "application/x-sv4crc" "SVR4 CPIO w/CRC")
      ("svf" "image/vnd" "&nbsp;")
      ("svh" "image/svh" "&nbsp;")
      ("svr" "x-world/x-svr" "&nbsp;")
      ("swf" "application/x-shockwave-flash" 
       "Macromedia Flash Format File for animations")
      ("sxc" "application/vnd.sun.xml.calc" 
       "Open Office Version 1 Spreedsheet")
      ("sxi" "application/vnd.sun.xml.impress" 
       "Open Office Version 1 Presentations")
      ("sxw" " application/vnd.sun.xml.writer" 
       "Open Office Version 1 Writer")
      ("syl" "application/sylk" 
       "SYLK - Symbolic Link WingZ/Excel/Lotus (old MultiPlan form")
      ("sys" "application/octet-stream" "PC System File")
      ("talk" "application/talker" "Text to Speech ")
      ("tar" "application/x-tar" "4.3BSD Tar ")
      ("targa" "image/targa" "Targa Image File")
      ("tbk" "application/toolbook" "Memo backup (dBASE IV - FoxPro)")
      ("tcl" "application/x-tcl" "TCL Script")
      ("tda" "text/x-palm-tda" "ToDo Archive (Palm)")
      ("tex" "application/x-tex" "TeX Source")
      ("texi" "application/x-texinfo" "Texinfo")
      ("texinfo" "application/x-texinfo" "Texinfo")
      ("tga" "image/targa" "Targa/Truevision Image File")
      ("tgz" "application/x-gzip" "UNIX GTar Arvhive")
      ("tif" "image/tiff" "TIFF - Tag Image File Format")
      ("tiff" "image/tiff" "TIFF - Tagged Image File Format")
      ("tlk" "application/x-tlk" "&nbsp;")
      ("tmv" "application/x-Parable-Thing" "Template (TextMaker)")
      ("toc" "application/vnd.framemaker" "FrameMaker TOC")
      ("tr" "application/x-troff" "Troff")
      ("trm" "application/x-msterminal" "MS terminal")
      ("tsi" "audio/tsplayer" "&nbsp;")
      ("tsp" "application/dsptype" "Windows Telephony Service Provider")
      ("tsv" "text/tab-separated-values" "Tab Separated Values") 
      ("txt" "text/plain" "Plain Text")
      ("uin" "application/x-icq" "ICQ 2001+ Saved ICQ Contact Information ")
      ("url" "application/x-url" 
       "wwwserver/redirection  application/internet-shortcut "
       "Uniform resource Locator (Internet Address)")
      ("ustar" "application/x-ustar" "IEEE Std1003.2 (``POSIX'') Tar")
      ("v5d" "application/vis5d" "5-D data set visualization")
      ("vbd" "application/activexdocument" "ActiveX file")
      ("vcs" "text/x-vcalendar" 
       "Personal Data Interchange (PDI) Calendar entry - Outlook")
      ("vcd" "application/x-cdlink" "VirtualDrive CD Image File ")
      ("vcf" "text/x-vcard" "vCard (Business Card)")
      ("vdo" "video/vdo" "VDOLive Script Video image (Story Board)")
      ("vgm" "video/x-videogram" "&nbsp;")
      ("vgp" "video/x-videogram-plugin" "&nbsp;")
      ("vgx" "video/x-videogram" "&nbsp;")
      ("viv" "video/vnd.vivo" "VivoActive Player Video file")
      ("vivo" "video/vnd.vivo" "&nbsp;")
      ("vmd" "application/vocaltec-media-desc" "&nbsp;")
      ("vmf" "application/vocaltec-media-file" 
       "Font characteristics (Ventura Publisher)")
      ("vob" "video/dvd" "DVD Video Movie File")
      ("vox" "audio/voxware" "Vox Audio")
      ("vqe" "audio/x-twinvq-plugin" "Yamaha Sound-VQ Locator file")
      ("vqf" "audio/x-twinvq" "Yamaha Sound-VQ file")
      ("vql" "audio/x-twinvq" "Yamaha Sound-VQ Locator file")
      ("vrml" "model/vrml" "&nbsp;") 
      ("vrt" "x-world/x-vrt" "&nbsp;")
      ("vts" "workbook/formulaone" 
       "Forumle One - A Java Spread sheet and report generator from ")
      ("waf" "plugin/wanimate" 
       "Mayim's WAF Compiler file for interactive 3D with Walkabout browser plug-in")
      ("wan" "plugin/wanimate" "&nbsp;")
      ("wav" "audio/x-wav" "Windows Audio File WAVE format")
      ("wax" "audio/x-ms-wax" "Windows Media Audio Redirector to WMA file.")
      ("wbmp" "image/vnd.wap.wbmp" 
       "Wireless Bitmap File Format - Mobil phones")
      ("wi" "image/wavelet" "&nbsp;")
      ("wid" "application/x-DemoShield" "Width table (Ventura Publisher)")
      ("wis" "application/x-InstallShield" "&nbsp;")
      ("wks" "application/x-msworks" "MS Works or Lotus 1-2-3 Worksheets")
      ("wlt" "application/x-mswallet" "eWallet file")
      ("wm" "video/x-ms-wm" "&nbsp;")
      ("wma" "audio/x-ms-wma" "Windows Media Audio. Stored in ASF.")
      ("wmf" "image/x-wmf" "Windows MetaFile vector graphics")
      ("wml" "text/vnd.wap.wml" "Wireless Markup Language File")
      ("wmv" "video/x-ms-wmv" "Windows Media Video (Stored in ASF format)")
      ("wp" "application/wordperfect" "WordPerfect")
      ("wpc" "application/wpc" 
       "Text-format converters used 1990-1997 by MS Word and Write")
      ("wpc" "application/pcms_wp" "WordPerfect Character Mapping File ")
      ("wpd," "application/wordperfect5.1" "Document (WordPerfect)")
      ("wps" "application/vnd.ms-works" "MS Works ")
      ("wri" "application/x-mswrite" "Write format (MS Windows)")
      ("wrl" "model/vrml" "Plain Text VRML File ")
      ("wrz" "x-world/x-vrml" "&nbsp;")
      ("wtx" "audio/x-wtx" "&nbsp;")
      ("wvx" "video/x-ms-wvx" "&nbsp;")
      ("xbm" "image/x-xbitmap" "X Bitmaps")
      ("xdr" "video/x-videogram" "&nbsp;")
      ("xla" "application/vnd.ms-excel" "MS Excel (Add in)")
      ("xlc" "application/vnd.ms-excel" "MS Excel (Chart)")
      ("xlm" "application/vnd.ms-excel" "MS Excel")
      ("xls" "application/vnd.ms-excel" "MS Excel")
      ("xlt" "application/vnd.ms-excel" "MS Excel (template)")
      ("xlw" "application/vnd.ms-excel" "MS Excel (workbook)")
      ("xml" "text/xml" "Extensible Markup Language")
      ("xpm" "image/x-xpixmap" "X Pixmap format")
      ("xsb" "application/x-xsb" "Superbook")
      ("xwd" "image/x-xwindowdump" "X Window Dump (xwd)")
      ("xyz" "chemical/x-pdb" "ASCII RPG Maker Graphic Format")
      ("zip" "application/zip" 
       "Compressed file archive created by PKZIP (pkz204g.exe)")
      ("zpa" "application/pcphoto" "&nbsp;")))

  (defvar *mime-types* (make-hash-table 
			:test #'equal 
			:size (length *mime-type-descriptions*)))
  
  ;;--- Initialize File extension/Mime Type hash table 
  (dolist (type-lst *mime-type-descriptions*)
    (setf (gethash (first type-lst) *mime-types*) (second type-lst))))

(defun lookup-mime-type (file-name 
			 &optional (default "application/octet-stream"))
  "Extract mime type based on file-extension"
  (let ((pos-ext (position #\. file-name :test #'char= :from-end t)))
    (when (and pos-ext
	       (< (1+ pos-ext) (length file-name)))
      (or (gethash (subseq file-name (1+ pos-ext)) *mime-types*)
	  default))))

 -*- mode: Lisp -*-
 This library is free software; you can redistribute it and/or
 (), known as the LLGPL.
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 Lisp Lesser GNU General Public License for more details.
 File: attachments.lisp
 Description: encoding and transmitting login to include a mime attachment


  Some of the most common file extensions with the mime types and descriptions. 
 Extracted from numberous webpages. 
--- Initialize File extension/Mime Type hash table 

	
  This file is part of CL - SMTP , the Lisp SMTP Client 


  Copyright ( C ) 2004/2005/2006/2007/2008/2009/2010 Jan Idzikowski 

  modify it under the terms of the Lisp Lesser General Public License 



  Contributed by   
(in-package :cl-smtp)

(eval-when (:compile-toplevel :load-toplevel)
  (defparameter *mime-type-descriptions*
    '(("386" "application/octet-stream" 
       "Windows Enhanced Mode Driver or Swap File")
      ("001" "application/x-001" "FAX Datafile")
      ("3GPP" "audio/3gpp" 
       "3rd
Generation Partnership Project. Multimedia over 3rd generation wireless
networks. H.263 video is the mandatory video format in 3GPP and AMR is
the main audio/speech format.")
      ("7CB" "application/vnd.ecdis-update" 
       "Electronic Chart Display and Information System (ECDIS)")
      ("aa" "audio/audible" "Audible file format (audio books)")
      ("aab" "application/x-authorware-bin" "Macromedia Authorware Binary")
      ("aac" "audio/aac" 
       "Advanced Audio Coding File. Part of  MPEG-2 and MPEG-4 standard.  (Apple iTunes Store)")
      ("aam" "application/x-authorware-map" "Authorware Map (Shockwave?)")
      ("aas" "application/x-authorware-seg" 
       "Authorware Shocked Packet (Segment) ")
      ("aba" "text/x-palm-aba" "AddressBook Archive (Palm)")
      ("ac3" "audio/ac3" 
       "Adaptive Transform Coder 3 (relates to the bitstream format of Dolby Digital)")
      ("adr" "application/x-msaddr" "Address Book")
      ("aexpk" "application/pgp-keys" "Armored extracted public key (PGP)")
      ("afl" "video/animaflex" "Font file (for Allways) (Lotus 1-2-3)")
      ("ahtml" "magnus-internal/cgi-advertiser" "&nbsp;")
      ("ai" "application/postscript" 
       "Encapsulated PostScript (metafile) (Adobe Illustrator)")
      ("aif" "audio/x-aiff" "Audio Interchange File Format")
      ("aifc" "audio/x-aiff" "Audio Interchange File Format")
      ("aiff" "audio/x-aiff" "Audio Interchange File Format")
      ("aim" "application/x-aim" "AIM file - AOL Instant Messanger")
      ("alt" "application/x-up-alert" "Menu file (WordPerfect Library)")
      ("aos" "application/x-nokia-" "Add-On Software (Nokia 9000)")
      ("arj" "application/x-arj" 
       "Compressed file archive created by ARJ or winzip")
      ("art" "image/x-jg" 
       "AOL Johnson-Grace Compressed File and Another Ray Tracer Format")
      ("asc" "application/pgp-encrypted" "Armored Encrypted file (PGP)")
      ("asd" "application/astound" "Autosave file (Word for Windows)")
      ("asf" "application/vnd.ms-asf video/x-ms-asf  video/x-ms-wm"
       "Windows Media file - Advanced Streaming Format (ASF), NetShow")
      ("asn" "application/astound" "&nbsp;")
      ("asp" "text/html" 
       "Active Server Pages - standard HTML documents interlaced with ActiveX script code ")
      ("asr" "video/x-ms-asf" "Microsoft NetShow")
      ("asx" "video/x-ms-asf application/x-mplayer2" 
       "VXtreme (Microsoft streaming AV)")
      ("asz" "application/astound" "&nbsp;")
      ("au" "audio/basic" "8-bit u-law [PCM] / 8000 Hz")
      ("avi" "video/x-msvideo" "Windows Video file")
      ("axs" "application/olescript" "&nbsp;")
      ("bas" "text/plain" "BASIC program")
      ("bat" "application/octet-stream" "DOS BAT (Batch) file.")
      ("bcpio" "application/x-bcpio" "Old Binary CPIO")
      ("bexpk" "application/pgp-keys" "binary extracted public key (PGP)")
      ("bin" "application/octet-stream" "Uninterpreted Binary Data")
      ("bk" "application/vnd.framemaker" "FrameMaker book ")
      ("bleep" "application/bleeper" "&nbsp;")
      ("bmp" "image/x-bmp" "Windows Bitmap (PaintBrush)")
      ("btf" "image/prs.btf" "NationsBank Check Images (also .btif)")
      ("c" "text/plain" "C program")
      ("c++" "text/plain" "C program")
      ("cab" "application/cab" 
       "Cabinet file Microsoft installation archive. opersyss=win32, mac cpu=x86, ppc, mips, alpha")
      ("cal" "application/x-msschedplus" "MS schedplus or calendar")
      ("cat" "application/pdf" 
       "PDF Catalog (Used with Acrobat Reader and Search plug-in)")
      ("cat" "application/vnd.ms-pki.seccat" "Security Catalog")
      ("ccs" "text/ccs" 
       "Cluster Configuration System used with the Global File System (GFS) in Red Hat Linux")
      ("cdda" "audio/aiff" "CD Audio Track")
      ("cda" "audio/x-cda" "CD Audio Track")
      ("cdf" "text/plain" "Channel Definition Format - MS push std")
      ("cdr" "application/x-coreldrw" "Corel Draw (metafile)")
      ("cer" " application/pkix-cert" "Certificatefile")
      ("cfm" "wwwserver/wsapi" "Cold Fusion Markup")
      ("cgi" "magnus-internal/cgi" "Common Gateway Interface")
      ("cgm" "image/cgm" "Computer Graphics Metafile ")
      ("chat" "application/x-chat" "&nbsp;")
      ("che" "application/x-up-cacheop" "&nbsp;")
      ("cht" "audio/x-dspeech" 
       "Chart (Harvard Graphics 2.0 - SoftCraft Presenter)")
      ("cil" "application/vnd.ms-artgalry" "Clip Gallery Download Packages")
      ("class" "application/java-vm" "Java")
      ("cli" "application/vnd.ms-artgalry" "&nbsp;")
      ("clp" "application/x-msclip" "Windows Clipboard (metafile)")
      ("cmx" "image/x-cmx" "&nbsp;")
      ("cnc" "application/x-cnc" "CNC general program data")
      ("cod" "image/cis-cod" 
       "Datafile (Forecast Plus - MS Multiplan - StatPac Gold)")
      ("coda" "application/x-coda" "&nbsp;")
      ("com" "application/octet-stream" 
       "DOS COM Executable (similar to exe, but a direct memory image)")
      ("cpi" "image/cpi" "ColorLab Processed Image ")
      ("cpio" "application/x-cpio" "IEEE Std1003.2 (`POSIX') CPIO")
      ("cpt" "application/mac-compactpro" "Compact Pro Archive")
      ("crd" "application/x-mscardfile" "MS cardfile")
      ("crt" "application/x-x509-ca-cert" "Certificatefile")
      ("csh" "application/x-csh" "CSH Script")
      ("csm" "application/x-cu-seeme" "Precompiled headers (Borland C++ 4.5)")
      ("css" "text/css" "Cascading Style Sheets")
      ("csv" "text/csv" 
       "Comma-Separated Values (Excel, Lotus 123, FoxPro, MS Outlook)")
      ("ct" "image/" "Iris CT Graphic or Scitex CT Handshake Bitmap ")
      ("cu" "application/x-cu-seeme" "&nbsp;")
      ("cut" "image/x-halo-cut" "Bitmap graphics")
      ("dat" "application/octet-stream" 
       "Data file. Can be anything, text, graphics, binary, ...")
      ("dba" "text/x-palm-dba" "DateBook Archive (Palm)")
      ("dbf" "application/octet-stream" "DataBase File (FoxPro, dBase) ")
      ("dbm" "wwwserver/wsapi" "ColdFusion IIS Plugin")
      ("dca" "application/dca-rft" "IBM Doc Content Arch")
      ("dcr" "application/x-director" "Macromedia Director (Shockwave)")
      ("deb" "application/octet-stream" "Binary for debian UNIX")
      ("der" "application/x-x509-ca-cert" "Certificatefile")
      ("dir" "application/x-director" "Macromedia Director (Shockwave)")
      ("dll" "application/x-msdownload"
       "Dynamically Linked Library (DOS) pe-portable executable opersys=win32, mac cpu=x86, ppc, mips, alpha")
      ("dms" "application/octet-stream" 
       "Compressed Amiga file archive created by DISKMASHER")
      ("doc" "application/msword" "MS Word") 
      ("dot" "application/msword" "MS Word (Template)")
      ("dsf" "image/x-mgx-dsf" "Micrografx Designer 6 (metafile)")
      ("dst" "application/tajima" "PC-RDist Distribution file ")
      ("dtd" "text/xml" "SGML Document (Type) Definition file")
      ("dus" "audio/x-dspeech" "Readiris font dictionary")
      ("dvi" "application/x-dvi" "TeX DVI (Device Independent)")
      ("dwc" "application/dwc" "compressed archive")
      ("dwf" "drawing/x-dwf" "Autodesk WHIP! Drawing Web file")
      ("dwg" "application/x-acad" "AutoCAD Drawing")
      ("dxf" "application/vnd.dxf" 
       "Drawing eXchange Format, Data Exchange File, AutoCAD (vector)")
      ("dxr" "application/x-director" "Macromedia Director (Shockwave)")
      ("ebk" "application/x-expandedbook" "&nbsp;")
      ("emf" "image/x-emf" 
       "Enhanced metafile created in Microsoft Windows and Visio 2002 applications")
      ("eml" "message/rfc822" 
       "MS Internet Mail Message (Outlook Express and others)")
      ("enc" "application/pre-encrypted" 
       "Pre-encrypted Data (also Sniffer trace)")
      ("eps" "application/postscript" "Encapsulated PostScript (raster)")
      ("erf" "application/x-hsp-erf" "&nbsp;")
      ("es" "audio/echospeech" "&nbsp;")
      ("etf" "image/x-etf" "Enriched Text file")
      ("etx" "text/x-setext" "Structure Enchanced Text")
      ("evy" "application/x-envoy" "Document (WordPerfect Envoy)")
      ("exe" "application/x-pe-" 
       "pe-portable executable opersys=win32, mac cpu=x86, ppc, mips, alpha")
      ("fdf" "application/vnd.fdf" "acrobat reader")
      ("fh4" "image/x-freehand" "Vector graphics (Aldus FreeHand 4.x)")
      ("fh5" "image/x-freehand" "Freehand 5")
      ("fhc" "image/x-freehand" "Freehand")
      ("fif" "image/fif" "Fractal Image Format file")
      ("fla" "application/x-shockwave-flash" "&nbsp;")
      ("flac" "audio/flac" "Free Lossless Audio Codec")
      ("flc" "video/flc " "FLIC Animated Picture 	Autodesk ")
      ("fli" "video/fli " "FLIC Animated Picture 	Autodesk ")
      ("fm" "application/vnd.framemaker " "FrameMaker Document")
      ("fm3" "application/x-maker " "FrameMaker")
      ("fm4" "application/vnd.framemaker" "FrameMaker")
      ("fm5" "application/vnd.framemaker" "FrameMaker")
      ("fml" "application/fml" "&nbsp;")
      ("fp5" "application/filemaker5" "FileMaker Pro")
      ("frl" "application/freeloader" "FormFlow file")
      ("frm" "application/vnd.framemaker" "FrameMaker")
      ("fs" "application/X-FSRecipe" "&nbsp;")
      ("g3f" "image/g3fax" "Group III FAX")
      ("gb" "application/chinese-gb" "Chinese Text")
      ("gif" "image/gif" 
       "GIF - Graphics Interchange Format - Compuserve (raster)")
      ("gsd" "audio/x-gsm" "GSM Internet Realtime Audio ")
      ("gsm" "audio/x-gsm" "Raw GSM 6.10 Audio Stream ")
      ("gtar" "application/x-gtar" "Gnu Tar")
      ("gz" "application/x-gzip" "Unix Gzip (gnu-compress ecnapsulation)")
      ("hdf" "application/x-hdf" "NCSA HDF (Hierarchical Data Format)")
      ("hdml" "text/x-hdml" "&nbsp;")
      ("hlb" "vms/help" "VMS help libraries")
      ("hlp" "application/x-mshelp" "Windows Help")
      ("hpgl" "application/vnd.hp-HPGL" "HP Graphic Language")
      ("hqx" "application/mac-binhex40" 
       "BinHex 4.0 Format - Macintosh Binary to ASCII conversion.")
      ("htm" "text/html" "HTML - HyperText Markup Language")
      ("html" "text/html" "HTML - HyperText Markup Language")
      ("hz" "application/chinese-hz" "Chinese")
      ("ica" "application/x-ica" 
       "Bitmap graphics (Image Object Content Architecture)")
      ("ice" "x-conference/x-cooltalk" "&nbsp;")
      ("ico" "image/ico" "Windows icon") 
      ("icq" "application/x-icq" "Saved ")
      ("ics" "text/calendar" "iCalendar Calendar Data (Mac)")
      ("ief" "image/ief" "Image Exchange Format")
      ("iff" "image/iff " "Amiga Bitmap Graphic ")
      ("iges" "model/iges" "&nbsp;")
      ("img" "image/img" 
       "Venture Publisher, GEM Draw (bit mapped), AutoCAD CAD-Camera, others")
      ("inc" "text/plain" "&nbsp;")
      ("inf" "application/x-setupscript"
       "Setup scripts (For Installing Drivers, etc.), Autorun - auto-start file for a CD-ROM")
      ("ins" "application/x-NET-Install" "Data (WordPerfect)")
      ("ipx" "application/x-ipix" "IPIX AV file")
      ("isapi" "wwwserver/isapi" 
       "Internet Server API - Application Program(ming) Interface")
      ("ivr" "i-world/i-vrml" "Virtual Reality World Live Picture ")
      ("jar" "application/java-archive" "&nbsp;")
      ("java" "text/plain" "&nbsp;")
      ("jfx" "application/octet-stream" 
       "eFax Fax Document (J2 Global Communications ")
      ("jpe" "image/jpeg" "JPEG-JFIF - Joint Photographic Experts Group")
      ("jpeg" "image/jpeg" "JPEG-JFIF - Joint Photographic Experts Group")
      ("jpg" "image/jpeg" 
       "JPEG-JFIF - Joint Photographic Experts Group (raster)")
      ("jps" "image/x-jps" "Stereo Image")
      ("js" "application/x-javascript" "Java Script")
      ("jsc" "application/x-javascript-config" "&nbsp;")
      ("jsp" "magnus-internal/jsp" "Java Script")
      ("la" "audio/nspaudio" "Netscape Packetized audio ")
      ("latex" "application/x-latex" "LaTeX Source")
      ("ldif" "text/x-ldif" 
       "LDAP Data Interchange Format ( Netscape Address Book)")
      ("lha" "application/octet-stream" "LHA Archive") 
      ("lisp" "text/plain" "Lisp Files")
      ("lma" "audio/nspaudio" "Netscape Packetized audio ")
      ("loe" "application/vnd.framemaker" "FrameMaker list of exhibits ")
      ("lof" "application/vnd.framemaker" "FrameMaker list of figures ")
      ("lot" "application/vnd.framemaker" "FrameMaker list of tables ")
      ("lwp" "WordPro 9.5 " "&nbsp;")
      ("lzh" "application/octet-stream" "compressed")
      ("lzs" "application/octet-stream" "compressed")
      ("lzx" "application/octet-stream" "compressed")
      ("m13" "application/x-msmediaview" "MS mediaview")
      ("m14" "application/x-msmediaview" "MS mediaview")
      ("m3u" "audio/x-mpegurl" "Music Playlist (Winamp)")
      ("m4a" "audio/" "Apple iTunes AAC and ALE unprotected")
      ("ma" "application/mathmetica" "Mathmetica Notebook")
      ("m4p" "audio/" "Apple iTunes AAC protected")
      ("m4b" "audio/" "Apple iTunes AAC protected autiobook")
      ("man" "application/x-troff-man" "Troff w/MAN Macros")
      ("map" "application/x-httpd-imap" "Image Configuration File (HTML Image Map)")
      ("mbd" "application/mbedlet" "&nbsp;")
      ("mcf" "image/vasa" "Mathcad font")
      ("mda" "application/x-msaccess" "MS Access  (May not be desirable)")
      ("mdb" "application/x-msaccess" "MS access")
      ("me" "application/x-troff-me" "Troff w/ME Macros")
      ("mesh" "model/mesh" "&nbsp;")
      ("mfp" "application/mirage" "&nbsp;")
      ("mht" "message/rfc822" "Microsoft Web Archiv")
      ("mid" "audio/x-midi" "MIDI")
      ("midi" "audio/x-midi" "MIDI")
      ("mif" "application/vnd.mif" "Maker Interchange Format (FrameMaker)")
      ("mime" "message/rfc822" 
       "base64 (6-bit) is the standard for encoding binary attachme")
      ("mk" "application/vnd.framemaker" "FrameMaker")
      ("mmf" "application/x-smaf application/vnd.smaf"
       "SMAF = \"Synthetic music Mobile Application Format\" - Polyphonic Ringtone File for Phones - Yamaha")
      ("mmm" "application/pdf" "Acrobat Media Clip")
      ("mny" "application/x-msmoney" "MS money")
      ("mocha" "application/x-javascript" "Java Script")
      ("mol" "chemical/x-mdl-molfile" "MDL Molfile ")
      ("mov" "video/quicktime" "QuickTime digital video")
      ("movie" "video/x-sgi-movie" "SGI \"movieplayer\" movie")
      ("mp2" "audio/mpeg" "MPEG Audio Stream, Layer II ")
      ("mp3" "audio/mpeg" "MPEG Audio Stream, Layer III ")
      ("mp4" "video/mp4v-es" 
       "MPEG Audio Stream, Layer IV (QuickTime and RealPlayer)")
      ("mpa" "audio/mpeg" "MPEG Audio Stream, Layer I, II or III ")
      ("mpe" "video/mpeg" "MPEG - Motion Picture Experts Group")
      ("mpeg" "video/mpeg" "MPEG - Motion Picture Experts Group")
      ("mpg" "video/mpeg" "MPEG - Motion Picture Experts Group")
      ("mpga" "audio/mpeg" "&nbsp;")
      ("mpire" "application/x-mpire" "&nbsp;")
      ("mpl" "application/x-mpire" "&nbsp;")
      ("mpp" "application/vnd.ms-project" "MS Project")
      ("mpt" "application/vnd.ms-project" "MS Project")
      ("mpv" "application/vnd.ms-project" "MS Project view")
      ("mpw" "application/vnd.ms-project" "MS Project")
      ("mpx" "application/vnd.ms-project" "MS Project")
      ("ms" "application/x-troff-ms" "Troff w/MS Macros")
      ("msh" "model/mesh" "2 and 2-D visualization")
      ("n2p" "application/n2p" "&nbsp;")
      ("nc" "application/x-netcdf" "Unidata netCDF data file")
      ("npx" "application/x-netfpx" "&nbsp;")
      ("nsc" "application/x-nschat" "Noder file (Polish)")
      ("nsf" "application/x-notes" "Lotus Notes ")
      ("ntf" "application/x-notes" "Lotus Notes ")
      ("ocx" "application/x-oleobject" 
       "Object Linking and Embedding (OLE) Control Extension  (ActiveX Control)")
      ("oda" "application/oda" "ODA/ODIF Open Document Architecture ") 
      ("ods" "application/vnd.oasis.opendocument.spreadsheet" 
       "Open Office Version 2 spreedsheet")
      ("odt" "application/vnd.oasis.opendocument.text;" 
       "Open Office Version 2 writer")
      ("odp" "application/vnd.oasis.opendocument.presentation" 
       "Open Office Version 2 presentor")
      ("ofml" "application/fml" "&nbsp;")
      ("ogg" "audio/x-ogg" "Ogg Vorbis open-source audio format")
      ("olb" "vms/olb" "Vax Object Library or MS Project Object Library")
      ("or2" "application/x-organizer" "Lotus Organizer")
      ("ovl" "application/octet-stream" "PC OVL File")
      ("pac" "application/x-ns-proxy-autoconfig" "&nbsp;")
      ("page" "application/x-coda" "&nbsp;")
      ("pbd" "application/vnd.powerbuilder6" "Phone book (FaxNOW! - Faxit)")
      ("pbm" "image/x-portable-bitmap" "PBM Bitmap Format")
      ("pcd" "image/x-photo-cd" "Kodak Photo CD (raster)")
      ("pcl" "application/pcl" "
Printer Control Language (HP)")
      ("pcx" "image/pcx" "PC Paintbrush (ZSoft Image)")
      ("pdb" "text/x-palm-pdb" "Palm Database File")
      ("pdf" "application/pdf" "Portable Document Format (Adobe Acrobat)")
      ("pfm" "application/pdf" "Acrobat Font")
      ("pfr" "application/font-tdpfr" "&nbsp;")
      ("pgm" "image/x-portable-graymap" "PBM Graymap Format")
      ("pgp" "application/pgp-encrypted" "PGP Encrypted file ")
      ("pgr" "text/parsnegar-document" "&nbsp;")
      ("php3" "application/x-httpd-php3" "&nbsp;")
      ("phtml" "application/x-httpd-php" "PHP Script ")
      ("pic" "image/pict" "Macintosh QuickDraw format (metafile)")
      ("pict" "image/pict" "Macintosh QuickDraw format (metafile)")
      ("pif" "application/x-mspif" "Program Information File (Windows)")
      ("pkr" "application/pgp-keys" "Public Keyring (PGP)")
      ("pnc" "text/x-palm-pnc" "Palm Network Configuration File")
      ("png" "image/png" "Portable Network Graphics")
      ("pnm" "image/x-portable-anymap" "PBM Anymap Format")
      ("pot" "application/ms-powerpoint" "MS PowerPoint template")
      ("ppa" "application/vnd.ms-powerpoint" "MS PowerPoint addin")
      ("ppm" "image/x-portable-pixmap" "PBM Pixmap Format")
      ("pps" "application/ms-powerpoint" "MS PowerPoint Slideshow")
      ("ppt" "application/ms-powerpoint" "MS PowerPoint Presentation")
      ("ppz" "applications/ms-powerpoint" "MS PowerPoint Animation")
      ("pqa" "text/x-palm-pqa" "Palm Query Application")
      ("pqf" "application/x-cprplayer" "&nbsp;")
      ("pqi" "application/cprplayer" "Power Quest Drive imaging")
      ("prc" "text/x-palm-prc" "Palm Application")
      ("prvkr" "application/pgp-keys" "Private Keyring (PGP)")
      ("ps" "application/postscript" "PostScript")
      ("psd" "image/x-photoshop" "Adobe PhotoShop Image")
      ("psr" "application/datawindow" "Project Scheduler Resource file")
      ("ptlk" "application/listenup" "&nbsp;")
      ("pub" "application/x-mspublisher" "MS publisher or PageMaker 2")
      ("pubkr" "application/pgp-keys" "Public Keyring (PGP)")
      ("push" "multipart/x-mixed-replace" "&nbsp;")
      ("qd3" "x-world/x-3dmf" "Data file - segment 3 (Omnis Quartz)")
      ("qd3d" "x-world/x-3dmf" "&nbsp;")
      ("qrt" "application/quest" "Qrt ray tracing graphics")
      ("qt" "video/quicktime" "QuickTime")
      ("ra" "audio/x-realaudio" "Music (RealAudio)")
      ("ram" "audio/x-pn-realaudio" "Real Audio Player")
      ("ras" "image/x-cmu-raster" "Sun Raster Format (raster)")
      ("rax" "audio/" "RealAudio 10 - RealMedia Streaming File")
      ("rgb" "image/x-rgb" "RGB Color Image")
      ("rip" "image/rip" "Graphics (Remote Access)")
      ("rm" "audio/x-pn-realaudio" "&nbsp;")
      ("rmf" "audio/x-rmf" "Rich Music Format audio file from Beatnik")
      ("rmi" "audio/mid" "MIDI File ")
      ("roff" "application/x-troff" "Troff")
      ("rpm" "audio/x-pn-realaudio-plugin" 
       "Real Audio Plugin and RedHat Package Manager")
      ("rrf" "application/x-InstallFromTheWeb" "&nbsp;")
      ("rtc" "application/rtc" "&nbsp;")
      ("rtf" "application/rtf" "Rich Text Format (Microsoft)")
      ("rtx" "text/richtext" "MIME Richtext format (see also rtf)")
      ("rtsp" "application/x-rtsp" 
       "QuickTime Real-Time Streaming Protocol File ")
      ("sb" "application/x-xsb" "Superbook")
      ("sbx" "application/x-xsb" 
       "ArcView Spatial Index For Read-Write Shapefiles ")
      ("sca" "application/x-supercard" "Datafile (SCA)")
      ("scp" "text/x-palm-scp" "Palm Network Script File")
      ("sdp" "application/sdp" "Scalable Multicast (RealNetworks)")
      ("ser" "application/java-" "&nbsp;")
      ("sgm" "text/x-sgml" "Standard Generalized Markup Lang (SGML)")
      ("sgml" "text/x-sgml" "Standard Generalized Markup Lang (SGML)")
      ("sh" "application/x-sh" "SH Script")
      ("shar" "application/x-shar" "Sh Shar")
      ("shtml" "magnus-internal/parsed-html" "&nbsp;")
      ("shw" "application/presentations" 
       "Presentation (Harvard Graphics 2.0 - CorelShow)")
      ("sig" "application/pgp-signature" "Detached signature file (PGP)")
      ("silo" "model/mesh" "&nbsp;")
      ("sit" "application/x-stuffit" 
       "StuffIt - Macintosh Compression Format. By Aladdin for Mac.")
      ("sitx" "application/x-stuffit"
       "StuffIt X file format integrates compression with security and safety options. By Aladdin for Mac.")
      ("skd" "application/x-koan" "&nbsp;")
      ("skm" "application/x-koan" "&nbsp;")
      ("skp" "application/x-koan" "&nbsp;")
      ("skr" "application/pgp-keys" "Private Keyring (PGP)")
      ("skt" "application/x-koan" "&nbsp;")
      ("smil" "application/smil" 
       "SMIL Synchronized Multimedia Integration Language. App:RealPlayer")
      ("sml" "application/smil" 
       "SMIL Synchronized Multimedia Integration Language")
      ("smp" "application/studiom" "Sample (sound file)")
      ("snd" "audio/basic" "8-bit u-law [PCM] / 8000 Hz Audio")
      ("spc" "text/x-palm-spc" "Palm Configuration File")
      ("spl" "application/futuresplash" "FutureSplash from FutureWave Sftwr")
      ("spr" "application/x-sprite" "Document letter (Sprint)")
      ("sprite" "application/x-sprite" "&nbsp;")
      ("src" "application/x-wais-source" "WAIS Source")
      ("stk" "application/hstu" "&nbsp;")
      ("stream" "audio/x-qt-stream" "&nbsp;")
      ("sty" "application/msword" "MS Word Style sheet")
      ("sv4cpio" "application/x-sv4cpio" "SVR4 CPIO")
      ("sv4crc" "application/x-sv4crc" "SVR4 CPIO w/CRC")
      ("svf" "image/vnd" "&nbsp;")
      ("svh" "image/svh" "&nbsp;")
      ("svr" "x-world/x-svr" "&nbsp;")
      ("swf" "application/x-shockwave-flash" 
       "Macromedia Flash Format File for animations")
      ("sxc" "application/vnd.sun.xml.calc" 
       "Open Office Version 1 Spreedsheet")
      ("sxi" "application/vnd.sun.xml.impress" 
       "Open Office Version 1 Presentations")
      ("sxw" " application/vnd.sun.xml.writer" 
       "Open Office Version 1 Writer")
      ("syl" "application/sylk" 
       "SYLK - Symbolic Link WingZ/Excel/Lotus (old MultiPlan form")
      ("sys" "application/octet-stream" "PC System File")
      ("talk" "application/talker" "Text to Speech ")
      ("tar" "application/x-tar" "4.3BSD Tar ")
      ("targa" "image/targa" "Targa Image File")
      ("tbk" "application/toolbook" "Memo backup (dBASE IV - FoxPro)")
      ("tcl" "application/x-tcl" "TCL Script")
      ("tda" "text/x-palm-tda" "ToDo Archive (Palm)")
      ("tex" "application/x-tex" "TeX Source")
      ("texi" "application/x-texinfo" "Texinfo")
      ("texinfo" "application/x-texinfo" "Texinfo")
      ("tga" "image/targa" "Targa/Truevision Image File")
      ("tgz" "application/x-gzip" "UNIX GTar Arvhive")
      ("tif" "image/tiff" "TIFF - Tag Image File Format")
      ("tiff" "image/tiff" "TIFF - Tagged Image File Format")
      ("tlk" "application/x-tlk" "&nbsp;")
      ("tmv" "application/x-Parable-Thing" "Template (TextMaker)")
      ("toc" "application/vnd.framemaker" "FrameMaker TOC")
      ("tr" "application/x-troff" "Troff")
      ("trm" "application/x-msterminal" "MS terminal")
      ("tsi" "audio/tsplayer" "&nbsp;")
      ("tsp" "application/dsptype" "Windows Telephony Service Provider")
      ("tsv" "text/tab-separated-values" "Tab Separated Values") 
      ("txt" "text/plain" "Plain Text")
      ("uin" "application/x-icq" "ICQ 2001+ Saved ICQ Contact Information ")
      ("url" "application/x-url" 
       "wwwserver/redirection  application/internet-shortcut "
       "Uniform resource Locator (Internet Address)")
      ("ustar" "application/x-ustar" "IEEE Std1003.2 (``POSIX'') Tar")
      ("v5d" "application/vis5d" "5-D data set visualization")
      ("vbd" "application/activexdocument" "ActiveX file")
      ("vcs" "text/x-vcalendar" 
       "Personal Data Interchange (PDI) Calendar entry - Outlook")
      ("vcd" "application/x-cdlink" "VirtualDrive CD Image File ")
      ("vcf" "text/x-vcard" "vCard (Business Card)")
      ("vdo" "video/vdo" "VDOLive Script Video image (Story Board)")
      ("vgm" "video/x-videogram" "&nbsp;")
      ("vgp" "video/x-videogram-plugin" "&nbsp;")
      ("vgx" "video/x-videogram" "&nbsp;")
      ("viv" "video/vnd.vivo" "VivoActive Player Video file")
      ("vivo" "video/vnd.vivo" "&nbsp;")
      ("vmd" "application/vocaltec-media-desc" "&nbsp;")
      ("vmf" "application/vocaltec-media-file" 
       "Font characteristics (Ventura Publisher)")
      ("vob" "video/dvd" "DVD Video Movie File")
      ("vox" "audio/voxware" "Vox Audio")
      ("vqe" "audio/x-twinvq-plugin" "Yamaha Sound-VQ Locator file")
      ("vqf" "audio/x-twinvq" "Yamaha Sound-VQ file")
      ("vql" "audio/x-twinvq" "Yamaha Sound-VQ Locator file")
      ("vrml" "model/vrml" "&nbsp;") 
      ("vrt" "x-world/x-vrt" "&nbsp;")
      ("vts" "workbook/formulaone" 
       "Forumle One - A Java Spread sheet and report generator from ")
      ("waf" "plugin/wanimate" 
       "Mayim's WAF Compiler file for interactive 3D with Walkabout browser plug-in")
      ("wan" "plugin/wanimate" "&nbsp;")
      ("wav" "audio/x-wav" "Windows Audio File WAVE format")
      ("wax" "audio/x-ms-wax" "Windows Media Audio Redirector to WMA file.")
      ("wbmp" "image/vnd.wap.wbmp" 
       "Wireless Bitmap File Format - Mobil phones")
      ("wi" "image/wavelet" "&nbsp;")
      ("wid" "application/x-DemoShield" "Width table (Ventura Publisher)")
      ("wis" "application/x-InstallShield" "&nbsp;")
      ("wks" "application/x-msworks" "MS Works or Lotus 1-2-3 Worksheets")
      ("wlt" "application/x-mswallet" "eWallet file")
      ("wm" "video/x-ms-wm" "&nbsp;")
      ("wma" "audio/x-ms-wma" "Windows Media Audio. Stored in ASF.")
      ("wmf" "image/x-wmf" "Windows MetaFile vector graphics")
      ("wml" "text/vnd.wap.wml" "Wireless Markup Language File")
      ("wmv" "video/x-ms-wmv" "Windows Media Video (Stored in ASF format)")
      ("wp" "application/wordperfect" "WordPerfect")
      ("wpc" "application/wpc" 
       "Text-format converters used 1990-1997 by MS Word and Write")
      ("wpc" "application/pcms_wp" "WordPerfect Character Mapping File ")
      ("wpd," "application/wordperfect5.1" "Document (WordPerfect)")
      ("wps" "application/vnd.ms-works" "MS Works ")
      ("wri" "application/x-mswrite" "Write format (MS Windows)")
      ("wrl" "model/vrml" "Plain Text VRML File ")
      ("wrz" "x-world/x-vrml" "&nbsp;")
      ("wtx" "audio/x-wtx" "&nbsp;")
      ("wvx" "video/x-ms-wvx" "&nbsp;")
      ("xbm" "image/x-xbitmap" "X Bitmaps")
      ("xdr" "video/x-videogram" "&nbsp;")
      ("xla" "application/vnd.ms-excel" "MS Excel (Add in)")
      ("xlc" "application/vnd.ms-excel" "MS Excel (Chart)")
      ("xlm" "application/vnd.ms-excel" "MS Excel")
      ("xls" "application/vnd.ms-excel" "MS Excel")
      ("xlt" "application/vnd.ms-excel" "MS Excel (template)")
      ("xlw" "application/vnd.ms-excel" "MS Excel (workbook)")
      ("xml" "text/xml" "Extensible Markup Language")
      ("xpm" "image/x-xpixmap" "X Pixmap format")
      ("xsb" "application/x-xsb" "Superbook")
      ("xwd" "image/x-xwindowdump" "X Window Dump (xwd)")
      ("xyz" "chemical/x-pdb" "ASCII RPG Maker Graphic Format")
      ("zip" "application/zip" 
       "Compressed file archive created by PKZIP (pkz204g.exe)")
      ("zpa" "application/pcphoto" "&nbsp;")))

  (defvar *mime-types* (make-hash-table 
			:test #'equal 
			:size (length *mime-type-descriptions*)))
  
  (dolist (type-lst *mime-type-descriptions*)
    (setf (gethash (first type-lst) *mime-types*) (second type-lst))))

(defun lookup-mime-type (file-name 
			 &optional (default "application/octet-stream"))
  "Extract mime type based on file-extension"
  (let ((pos-ext (position #\. file-name :test #'char= :from-end t)))
    (when (and pos-ext
	       (< (1+ pos-ext) (length file-name)))
      (or (gethash (subseq file-name (1+ pos-ext)) *mime-types*)
	  default))))
