head	1.3;
access;
symbols
	file-4_20:1.3
	rpm-4_4_8-release:1.2
	rpm-4_4_7-release:1.2
	rpm-4_4_6-release:1.2
	rpm-4_4_5-release:1.2
	rpm-4_4_4-release:1.2
	rpm-4_4_3-release:1.2
	file-4_16:1.2
	jbj_before_tklcpatches:1.2
	rpm-4_4_2-release:1.2
	file-4_14:1.2
	pjones-sparse-experiment:1.2.0.4
	rpm-4_4_1-release:1.2
	file-4_12:1.2
	rpm-4_4-release:1.2
	rpm-4_4:1.2.0.2
	file-4_10:1.2
	file-4_09:1.2
	rpm-file-before:1.1
	rpm42-file-before:1.1
	rpm43-file-before:1.1
	rpm-4_3_1-start:1.1
	rpm-4_3:1.1.0.4
	rpm-4_2:1.1.0.2;
locks; strict;
comment	@# @;
expand	@o@;


1.3
date	2007.05.09.19.38.33;	author jbj;	state Exp;
branches;
next	1.2;

1.2
date	2004.08.03.20.16.18;	author jbj;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2003.04.15.17.01.30;	author jbj;	state Exp;
branches
	1.1.2.1
	1.1.4.1;
next	;

1.2.2.1
date	2007.05.10.17.39.22;	author jbj;	state Exp;
branches;
next	;

1.1.2.1
date	2003.12.01.21.20.02;	author jbj;	state Exp;
branches;
next	;

1.1.4.1
date	2004.12.07.00.57.38;	author jbj;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Virgin file-4.20.
@
text
@#! /usr/bin/env perl
# -*- PERL -*-
# $File: magic2mime,v 1.4 2006/11/25 18:36:10 christos Exp $
# Copyright (c) 1996, 1997 vax@@linkdead.paranoia.com (VaX#n8)
#
# Usage: echo 'your-file-output-here' | file_to_ctype.pl
#        file -b files... | file_to_ctype.pl
# It acts like a filter, reading from STDIN and any files on the command
# line, printing to STDOUT.

## refs
# http://www.faqs.org/faqs/mail/mime-faq/part1/index.html
#  comp.mail.mime FAQ
# ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/media-types
#  assigned content-types
# ftp://ftp.uu.net/inet/rfc/rfc-index
#  RFC index; search for MIME

@@mapping =
(
	# defaults
    'data', 'application/octet-stream',
    'text', 'text/plain',
	# more specific
	'^Rich Text Format data', 'text/richtext',
	'^HTML document text', 'text/html',
	'^exported SGML document text', 'text/sgml',
	'mail text', 'message/rfc822',
	'news text', 'message/news',
	'^PostScript document text', 'application/postscript',
	'^BinHex binary text', 'application/mac-binhex40',
	'^Zip archive data', 'application/zip',
	'^Microsoft Word', 'application/msword',
	'^PGP key', 'application/pgp-keys',
	'^PGP encrypted', 'application/pgp-encrypted',
	'^PGP armored data signature', 'application/pgp-signature',
    '^JPEG image', 'image/jpeg',
    '^GIF image', 'image/gif',
	'^PNG image', 'image/png',
    '^TIFF image', 'image/tiff',
	'Computer Graphics Metafile', 'image/cgf',
	'^Sun/NeXT audio data', 'audio/basic',
    '^MPEG', 'video/mpeg',
    '^Apple QuickTime movie', 'video/quicktime',
    '^DICOM medical imaging data', 'application/dicom',
	# made up by me
    '^bitmap', 'image/x-bitmap',
    '^PC bitmap data, Windows 3.x format', 'image/x-msw3bmp',
    '^FLI', 'video/x-fli',
    '^FLC', 'video/x-flc',
    'AVI data', 'video/x-avi',
    'WAVE', 'audio/x-wav',
    'VOC', 'audio/x-voc',
);

local($mimetype,$index,$regexp);
while (<>)
  {
    chop;
    $index = $#mapping - 1;
    while ($index > -1 && !defined($mimetype))
      {
         $mimetype = $mapping[$index + 1] if (/$mapping[$index]/);
         $index -= 2;
      }
    print "$mimetype\n";
	undef $mimetype; # hack
  }
0;
@


1.2
log
@Upgrade to file-4.09.
@
text
@d1 1
a1 1
#! /usr/local/bin/perl
d3 1
a3 1
# $Id: magic2mime,v 1.2 2003/03/23 04:17:27 christos Exp $
d45 1
@


1.2.2.1
log
@Upgrade to file-4.20 internal.
@
text
@d1 1
a1 1
#! /usr/bin/env perl
d3 1
a3 1
# $File: magic2mime,v 1.4 2006/11/25 18:36:10 christos Exp $
a44 1
    '^DICOM medical imaging data', 'application/dicom',
@


1.1
log
@Move magic generation to sub-directory.
@
text
@d3 1
a3 1
# Id: magic2mime,v 1.1 1998/02/15 23:18:53 christos Exp 
@


1.1.4.1
log
@- port to internal file-4.10 libmagic rather than libfmagic.
@
text
@d3 1
a3 1
# $Id: magic2mime,v 1.2 2003/03/23 04:17:27 christos Exp $
@


1.1.2.1
log
@Merge from top-of-stack.
@
text
@@

