Showing preview only (341K chars total). Download the full file or copy to clipboard to get everything.
Repository: arimus/jmimemagic
Branch: master
Commit: d6dd3092cc2a
Files: 71
Total size: 323.5 KB
Directory structure:
gitextract_a6vz6836/
├── .gitignore
├── Changelog
├── INFO
├── LICENSE
├── LICENSE_HEADER
├── NOTICE
├── README
├── TODO
├── checkstyle.xml
├── maven.xml
├── pom.xml
├── project.properties
├── project.xml
├── src/
│ ├── main/
│ │ ├── filters/
│ │ │ └── filter.properties
│ │ ├── java/
│ │ │ └── net/
│ │ │ └── sf/
│ │ │ └── jmimemagic/
│ │ │ ├── Magic.java
│ │ │ ├── MagicDetector.java
│ │ │ ├── MagicException.java
│ │ │ ├── MagicMatch.java
│ │ │ ├── MagicMatchNotFoundException.java
│ │ │ ├── MagicMatcher.java
│ │ │ ├── MagicParseException.java
│ │ │ ├── MagicParser.java
│ │ │ ├── UnsupportedTypeException.java
│ │ │ ├── detectors/
│ │ │ │ ├── TextFileDetector.java
│ │ │ │ └── package.html
│ │ │ └── package.html
│ │ └── resources/
│ │ ├── log4j.properties
│ │ ├── magic.dtd
│ │ ├── magic.xml
│ │ ├── magic.xml.basic
│ │ ├── magic.xml.verified
│ │ ├── magic_1_0.dtd
│ │ └── template.xml
│ └── test/
│ └── java/
│ └── net/
│ └── sf/
│ └── jmimemagic/
│ └── MagicTest.java
├── test
└── test_docs/
├── test.au
├── test.dtd
├── test.emf
├── test.eps
├── test.fli
├── test.java
├── test.odt
├── test.ogg
├── test.pcx
├── test.pl
├── test.pnm
├── test.ppm
├── test.ppt
├── test.ps
├── test.psd
├── test.py
├── test.rtf
├── test.sh
├── test.tga
├── test.txt
├── test.wmf
├── test.xcf
├── test.xml
├── test.xpm
├── test_excel.xlsm
├── test_excel.xlsx
├── test_excel_2000.xls
├── test_excel_spreadsheet.xml
├── test_excel_web_archive.mht
├── test_nocompress.tif
├── test_powerpoint.pptm
├── test_powerpoint.pptx
├── test_word.docm
├── test_word.docx
├── test_word_2000.doc
└── test_word_6.0_95.doc
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
build.properties
target
.project
.classpath
*.log
log
================================================
FILE: Changelog
================================================
Changelog
---------
Changes since 0.1.2
* changing license over to the Apache license, retro-active to
0.1.2, since I don't want anyone to have to fetch a new package
for a simple license change.
* sonatype fixes
* TIFF additions
Changes since 0.1.1
* remove log4j.properties from jar file
Changes since 0.1.0
* changes for target source level
* adjustment for maven 1.1
* project.xml cleanup
* documentation fixes
* various other types of cleanup
Changes since 0.0.4a
* migrated build system to maven 1.x
* moved to subversion
* added hinting flag for file extensions hints
* ability to disable submatches for mime-only detection, which
* which still needs work (e.g. submatch until a mime is found)
* content detection plugins now supported
* logging switched over to commons-logging
* cleaned up javadoc and enabled site generation
* misc other cleanup
Changes since 0.0.3
* added more unit tests
* fixed sub-matches, adjusted magic.xml DTD
* new magic.xml file converted from unix magic file
* created testByte and testString from testByteArray
* testByte is now available and properly applies bitmask
* api reworking
Changes since 0.0.2
* added junit tests
* removed UTF8 encoding from byte array to String conversions
Changes since 0.0.1
* cleaned up a lot of the code
* added some mime types to the magic file
* have regexes available for magic detection
* misc other fixes
================================================
FILE: INFO
================================================
http://sf.net/projects/jmimemagic/
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: LICENSE_HEADER
================================================
/*
jMimeMagic(TM) is a Java library for determining the content type of files or
streams. For more information, please email arimus@users.sourceforge.net
Copyright 2003-2012 David Castro
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
================================================
FILE: NOTICE
================================================
jMimeMagic
Copyright 2003-2017 David Castro
Contributions:
Thanks to the MMBase team (http://www.mmbase.org/) for doing the work of
creating the original basis for the XML version of the magic file.
To contribute code or other help, send an email to arimus@users.sourceforge.net
or submit patches/bug reports/etc on the jMimeMagic project page:
https://github.com/arimus/jmimemagic
Developers:
David Castro <arimus@users.sourceforge.net>
Nate Jones <ndjones@users.sourceforge.net>
Problems/questions/suggestions:
David Castro <arimus@user.sourceforge.net>
================================================
FILE: README
================================================
jMimeMagic (TM) v0.1.5
Copyright (C) 2003-2017, David Castro
Contact: David Castro <arimus@users.sourceforge.net>
jMimeMagic is a Java library for determining the MIME type of files or streams.
Please see LICENSE in this directory for jMimeMagic licensing information. See
LICENSE_log4j, LICENSE_oro, LICENSE_xerces, LICENSE_junit respectively for
Log4j, ORO, Xerces2 and JUnit licensing information. Log4j, ORO, Xerces2 and
JUnit are bundled with jMimeMagic for convenience.
** NOTE **
This API absolutely will change until there is a stable release! Relying on it
to not change is probably NOT a safe bet. It is an initial release, given as a
(hopefully) better than nothing option. The plan is for this library to become
much cleaner and well-architected, but only time will tell. The more you show
interest in this library/nudge me, the more likely that will be the case.
Comments and feedback greatly welcome.
Requirements:
Java 2 SDK 1.3+
Apache Maven 1.0.2+
JUnit 3.8.x
Jakarta ORO 2.0.x
Commons Logging 1.0.x
Log4j 1.2.x
Xerces 2.4.0 (optional)
Building:
type 'mvn clean jar:jar'
should have your jar file in ./target
Testing:
Log4j setting can be modified in resources/log4j.properties
Run all unit tests
------------------
edit build.properties and create the line 'maven.test.skip=true'
type 'maven clean test'
Run test against a particular file
----------------------------------
type 'maven clean run -Dclass=net.sf.jmimemagic.Magic -Dargs=<file to test>'
- or - simply ./test <file to test> in a unix shell
(this is similar to the 'file' command in *nix)
Maven:
To add jMimeMagic as a dependency in a Maven project, you can use the
following in the dependencies section of your pom.xml.
<dependency>
<groupId>net.sf.jmimemagic</groupId>
<artifactId>jmimemagic</artifactId>
<version>0.1.3</version>
</dependency>
Contributions:
Thanks to the MMBase team (http://www.mmbase.org/) for doing the work of
creating the original basis for the XML version of the magic file.
To contribute code or other help, send an email to arimus@users.sourceforge.net
or submit patches/bug reports/etc on the jMimeMagic project page:
http://sf.net/projects/jmimemagic/
Notes:
Remember that you will need the proper libraries (XML Parser/Xerces2, Log4j,
Commons Logging, and ORO) in the classpath for any applications that use
jMimeMagic. If you want to run any of the jUnit tests, then you will also
need JUnit in the classpath.
Developers:
David Castro <arimus@users.sourceforge.net>
Nate Jones <ndjones@users.sourceforge.net>
Problems/questions/suggestions:
David Castro <arimus@user.sourceforge.net>
================================================
FILE: TODO
================================================
document the new properties concept
in getProperties() for MagicMatch, return all the submatch properties as well
need to fix all matchers that are currently invalid for one reason or another,
possibly spitting out to the logs why they are invalid, which would help the
process and anyone who happens to misconfigure a match in the magic.xml file
need to convert the old magic file to the new magic file, enable validation
fix sub-match detection (partially fixed, cleanup and add unit tests!!!)
need to add more unit tests
need to audit code and ensure that a properly crafted file can't be used to
cause some security issues and/or system degredation (will always be a prob)
make the regular expression syntax pluggable, so those who would rather a regex
style other than perl can have it their way
files that have multiple matches based on the magic file
we can take the first match in one mode and return a collection of matches
in another.
add in support for % variables in magic file, so that matched data can be used
in the description, printf style?
support a test token that is a placeholder for the data being able to be
any value and can then be used in a description for subtype. Or find
another way to do this...via plugins???
support for indirect offsets?
support for &, ^ comparators
support for multiple string encoding
support which allows multiple matches at the same level to be combined for a
full description
Need to fix problems with some of the type detection. Dates haven't really
been worked on.
Create a tool for analyzing repositories of multiple file types, which will
help determine a proper file "tag" that uniquely identifies a file type.
Possibly flesh out the magic file format. Need support multiple tests to
make a definitive determination of file type.
Support some form of lexical parsing to determine valid source file from
code snippets, etc?
Lots of other stuff todo, just not listed yet.
==== DONE ====
flag to take hints from file extension as to which matches should be ran first?
flag to run in MIME matching mode, no logic other than what is necessary to
to determine MIME type
switch to commons-logging
support for additional info map, allowing additional information to not be
displayed in the description, but be available. For instance, MP3 file
ID3 tags could be made available for mp3 files
* New properties now in matchers
basic: now have properties in the style <property name="" value=""/>
possible for any match. These will then be available in the
returned MagicMatch as a java Map. This way, descriptions for a
match can be freeform such as "ID3 Tag", but you end up with
id3=true as a key/value pair in the map and don't have to do a silly
string test or assign a new mime type to the submatch. This will
also support plugins, allowing them to add new properties
dynamically as needed for the match/submatch.
add "plugin" match type by which data will be processed through a plugin for
complicated matches and assistance of third-party tools. (detectors)
================================================
FILE: checkstyle.xml
================================================
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.1//EN"
"http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
<module name="Checker">
<!-- Checks that a package.html file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
<module name="PackageHtml"/>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<!--
<module name="Translation"/>
-->
<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!-- ************************************************************** -->
<!-- Default Sun coding conventions checks -->
<!-- ************************************************************** -->
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<!--<module name="JavadocVariable"/>-->
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="MemberName"/>
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Miscellaneous other checks. -->
<module name="TodoComment"/>
</module>
</module>
================================================
FILE: maven.xml
================================================
<project xmlns:maven="jelly:maven"
xmlns:ant="jelly:ant"
xmlns:j="jelly:core"
xmlns:u="jelly:util"
xmlns:artifact="artifact">
<goal name="run">
<attainGoal name="jar:jar"/>
<echo message="Running ${class} ${args}"/>
<java fork="true" dir="${basedir}" classname="${class}">
<arg line="${args}"/>
<ant:classpath>
<ant:path refid="maven.dependency.classpath"/>
<ant:pathelement path="${target.dir}/classes"/>
</ant:classpath>
</java>
</goal>
</project>
================================================
FILE: pom.xml
================================================
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- General for All Maven projects (lib and proj) -->
<groupId>net.sf.jmimemagic</groupId>
<artifactId>jmimemagic</artifactId>
<version>0.1.5</version>
<packaging>jar</packaging>
<name>jMimeMagic</name>
<url>http://github.com/arimus/jmimemagic/</url>
<description>jMimeMagic is a Java library for determining the content type of files or streams.</description>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/arimus/jmimemagic.git</connection>
<developerConnection>scm:git:git://github.com/arimus/jmimemagic.git</developerConnection>
<url>https://github.com/arimus/jmimemagic</url>
</scm>
<developers>
<developer>
<id>arimus</id>
<name>David Castro</name>
<email>arimus@users.sourceforge.net</email>
<roles>
<role>Developer</role>
</roles>
<organization>jmimemagic</organization>
<timezone>-7</timezone>
</developer>
<developer>
<id>ndjones</id>
<name>Nate Jones</name>
<email>ndjones@users.sourceforge.net</email>
<roles>
<role>Developer</role>
</roles>
<organization>jmimemagic</organization>
<timezone>-7</timezone>
</developer>
</developers>
<!-- use the following if you're not using a snapshot version. -->
<distributionManagement>
<repository>
<id>ossrh</id>
<name>jMimeMagic Repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>ossrh</id>
<name>jMimeMagic Repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<!-- Repositories, currently used to make hibernate3:schema-export and jalopy work -->
<!--
<repositories>
<repository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>
<repository>
<id>repository.jboss.com</id>
<name>JBoss Repository for Maven</name>
<url>http://repository.jboss.com/maven2</url>
<layout>default</layout>
</repository>
</repositories>
-->
<!-- Repositories, currently used to make hibernate3:schema-export work -->
<!--
<pluginRepositories>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
-->
<build>
<!-- turning filter on for resources and test, note - test resources dir will override any file with the same name in main resources when a test is ran. -->
<filters>
<filter>src/main/filters/filter.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
<include>*.xml</include>
<include>*.dtd</include>
<include>*.json</include>
</includes>
<excludes>
<exclude>log4j.properties</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
<testResource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<!-- Code format java files, use mvn jalopy:format -->
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jalopy-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<convention>geekoffice/jalopy.xml</convention>
<failOnError>false</failOnError>
<fileFormat>UNIX</fileFormat>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
-->
<!-- compile in jdk 1.5 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.2</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-5</version>
</extension>
</extensions>
</build>
<!-- dependencies need by both lib and proj -->
<dependencies>
<!-- common compile time dependencies -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
<!-- common runtime only dependencies -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.8</version>
<scope>runtime</scope>
</dependency>
<!-- common testing only dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.3</version>
<scope>compile</scope>
</dependency>-->
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>
================================================
FILE: project.properties
================================================
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
# CVS project
maven.scm.cvs.module=jmimemagic
# User Interface
maven.repo.remote=http://repo1.maven.org/maven
maven.xdoc.date=left
maven.xdoc.date.format=dd MMMM yyyy HH:mm
maven.xdoc.version=${pom.currentVersion}
maven.license.licenseFile=${basedir}/LICENSE
maven.ui.body.background=white
maven.ui.body.foreground=black
maven.ui.banner.background=white
# Overrides
maven.jar.override=on
#maven.jar.oro=${basedir}/lib/jakarta-oro-2.0.7.jar
# FAQ
maven.faq.src.file=${basedir}/xdocs/faq.fml
maven.faq.dest.file=${basedir}/xdocs/faq.xml
# Checkstyle
maven.checkstyle.header.file=${basedir}/LICENSE_HEADER
maven.checkstyle.properties=${basedir}/checkstyle.xml
# Changelog
maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
maven.changelog.range=90
# Site generation
maven.site.failonerror=false
# Provided documentation
maven.docs.src=${basedir}/xdocs
# Remove non-needed links
maven.xdoc.developmentProcessUrl=
maven.xdoc.poweredby.image=
maven.xdoc.poweredby.title=
maven.xdoc.poweredby.url=
# Maven compilation
maven.compile.debug=on
maven.compile.deprecation=off
maven.compile.optimize=on
#maven.compile.executable=jikes
maven.compile.target=1.2
maven.compile.source=1.2
# Desired coding conventions for checkstyle
maven.checkstyle.format=sun
target.dir=target
maven.test.skip=true
#maven.junit.dir=${maven.test.dest}
================================================
FILE: project.xml
================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<id>jmimemagic</id>
<name>Java Mime Magic Library</name>
<currentVersion>0.1.2</currentVersion>
<organization>
<name>none</name>
</organization>
<inceptionYear>2003</inceptionYear>
<package>net.sf.jmimemagic</package>
<shortDescription>Determine the content type of files or streams.</shortDescription>
<description>
jMimeMagic is a Java library for determining the content type of files or streams.
</description>
<repository>
<connection>
scm:svn:https://svn.sourceforge.net/svnroot/jmimemagic/trunk
</connection>
<developerConnection>
scm:svn:https://svn.sourceforge.net/svnroot/jmimemagic/trunk
</developerConnection>
<url>
http://svn.sourceforge.net/viewvc/jmimemagic/
</url>
</repository>
<build>
<nagEmailAddress>arimus@users.sourceforge.net</nagEmailAddress>
<sourceDirectory>${basedir}/src/java</sourceDirectory>
<defaultGoal>jar</defaultGoal>
<unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
<include>*.xml</include>
<include>*.dtd</include>
</includes>
</resource>
</resources>
</unitTest>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
<include>*.xml</include>
<include>*.dtd</include>
</includes>
<excludes>
<exclude>log4j.properties</exclude>
</excludes>
</resource>
</resources>
</build>
<developers>
<developer>
<name>David Castro</name>
<id>arimus</id>
<email>arimus@users.sourceforge.net</email>
<organization>jmimemagic</organization>
</developer>
<developer>
<name>Nate Jones</name>
<id>ndjones</id>
<email>ndjones@users.sourceforge.net</email>
<organization>jmimemagic</organization>
</developer>
</developers>
<!-- J A R R E S O U R C E S -->
<!-- Resources that are packaged up inside the JAR file -->
<!--
<resources>
<resource>
<targetPath>/</targetPath>
<directory>resources</directory>
<includes>
<include>*.properties</include>
<include>*.xml</include>
</includes>
</resource>
</resources>
-->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<properties>
<scope>test</scope>
</properties>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
<properties>
<scope>compile</scope>
</properties>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<properties>
<scope>compile</scope>
</properties>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.8</version>
<properties>
<scope>runtime</scope>
</properties>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
<properties>
<scope>runtime</scope>
</properties>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.7.1</version>
<properties>
<scope>runtime</scope>
</properties>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
<properties>
<scope>compile</scope>
</properties>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xmlParserAPIs</artifactId>
<version>2.0.2</version>
<properties>
<scope>compile</scope>
</properties>
</dependency>
</dependencies>
</project>
================================================
FILE: src/main/filters/filter.properties
================================================
================================================
FILE: src/main/java/net/sf/jmimemagic/Magic.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* This class is the primary class for jMimeMagic
*
* @author $Author: arimus $
* @version $Revision: 1.8 $
*/
public class Magic
{
private static Log log = LogFactory.getLog(Magic.class);
private static boolean initialized = false;
private static MagicParser magicParser = null;
private static Map<String,List<MagicMatcher>> hintMap = new HashMap<String, List<MagicMatcher>>();
/**
* constructor
*/
public Magic()
{
log.debug("instantiated");
}
/**
* Add a hint to use the specified matcher for the given extension
*
* @param extension DOCUMENT ME!
* @param matcher DOCUMENT ME!
*/
private static void addHint(String extension, MagicMatcher matcher)
{
if (hintMap.keySet().contains(extension)) {
List<MagicMatcher> a = hintMap.get(extension);
a.add(matcher);
} else {
List<MagicMatcher> a = new ArrayList<MagicMatcher>();
a.add(matcher);
hintMap.put(extension, a);
}
}
/**
* create a parser and initialize it
*
* @throws MagicParseException DOCUMENT ME!
*/
public static synchronized void initialize()
throws MagicParseException
{
log.debug("initialize()");
if (!initialized) {
log.debug("initializing");
magicParser = new MagicParser();
magicParser.initialize();
// build hint map
Iterator<MagicMatcher> i = magicParser.getMatchers().iterator();
while (i.hasNext()) {
MagicMatcher matcher = i.next();
String ext = matcher.getMatch().getExtension();
if ((ext != null) && !ext.trim().equals("")) {
if (log.isDebugEnabled()) {
log.debug("adding hint mapping for extension '" + ext + "'");
}
addHint(ext, matcher);
} else if (matcher.getMatch().getType().equals("detector")) {
String[] exts = matcher.getDetectorExtensions();
for (int j = 0; j < exts.length; j++) {
if (log.isDebugEnabled()) {
log.debug("adding hint mapping for extension '" + exts[j] + "'");
}
addHint(exts[j], matcher);
}
}
}
initialized = true;
}
}
/**
* return the parsed MagicMatch objects that were created from the magic.xml
* definitions
*
* @return the parsed MagicMatch objects
*
* @throws MagicParseException DOCUMENT ME!
*/
public static Collection<MagicMatcher> getMatchers()
throws MagicParseException
{
log.debug("getMatchers()");
if (!initialized) {
initialize();
}
Iterator<MagicMatcher> i = magicParser.getMatchers().iterator();
List<MagicMatcher> m = new ArrayList<MagicMatcher>();
while (i.hasNext()) {
MagicMatcher matcher = (MagicMatcher) i.next();
try {
m.add(matcher.clone());
} catch (CloneNotSupportedException e) {
log.error("failed to clone matchers");
throw new MagicParseException("failed to clone matchers");
}
}
return m;
}
/**
* get a match from a stream of data
*
* @param data DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws MagicParseException DOCUMENT ME!
* @throws MagicMatchNotFoundException DOCUMENT ME!
* @throws MagicException DOCUMENT ME!
*/
public static MagicMatch getMagicMatch(byte[] data)
throws MagicParseException, MagicMatchNotFoundException, MagicException
{
return getMagicMatch(data, false);
}
/**
* get a match from a stream of data
*
* @param data DOCUMENT ME!
* @param onlyMimeMatch DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws MagicParseException DOCUMENT ME!
* @throws MagicMatchNotFoundException DOCUMENT ME!
* @throws MagicException DOCUMENT ME!
*/
public static MagicMatch getMagicMatch(byte[] data, boolean onlyMimeMatch)
throws MagicParseException, MagicMatchNotFoundException, MagicException
{
log.debug("getMagicMatch(byte[])");
if (!initialized) {
initialize();
}
Collection<MagicMatcher> matchers = magicParser.getMatchers();
log.debug("getMagicMatch(byte[]): have " + matchers.size() + " matchers");
MagicMatcher matcher = null;
MagicMatch match = null;
Iterator<MagicMatcher> i = matchers.iterator();
while (i.hasNext()) {
matcher = i.next();
log.debug("getMagicMatch(byte[]): trying to match: " +
matcher.getMatch().getMimeType());
try {
if ((match = matcher.test(data, onlyMimeMatch)) != null) {
log.debug("getMagicMatch(byte[]): matched " + matcher.getMatch().getMimeType());
return match;
}
} catch (IOException e) {
log.error("getMagicMatch(byte[]): " + e);
throw new MagicException(e);
} catch (UnsupportedTypeException e) {
log.error("getMagicMatch(byte[]): " + e);
throw new MagicException(e);
}
}
throw new MagicMatchNotFoundException();
}
/**
* get a match from a file
*
* @param file the file to match content in
* @param extensionHints whether or not to use extension to optimize order of content tests
*
* @return the MagicMatch object representing a match in the file
*
* @throws MagicParseException DOCUMENT ME!
* @throws MagicMatchNotFoundException DOCUMENT ME!
* @throws MagicException DOCUMENT ME!
*/
public static MagicMatch getMagicMatch(File file, boolean extensionHints)
throws MagicParseException, MagicMatchNotFoundException, MagicException
{
return getMagicMatch(file, extensionHints, false);
}
/**
* get a match from a file
*
* @param file the file to match content in
* @param extensionHints whether or not to use extension to optimize order of content tests
* @param onlyMimeMatch only try to get mime type, no submatches are processed when true
*
* @return the MagicMatch object representing a match in the file
*
* @throws MagicParseException DOCUMENT ME!
* @throws MagicMatchNotFoundException DOCUMENT ME!
* @throws MagicException DOCUMENT ME!
*/
public static MagicMatch getMagicMatch(File file, boolean extensionHints, boolean onlyMimeMatch)
throws MagicParseException, MagicMatchNotFoundException, MagicException
{
log.debug("getMagicMatch(File)");
if (!initialized) {
initialize();
}
long start = System.currentTimeMillis();
MagicMatcher matcher = null;
MagicMatch match = null;
// check for extension hints
List<MagicMatcher> checked = new ArrayList<MagicMatcher>();
if (extensionHints) {
log.debug("trying to use hints first");
String name = file.getName();
int pos = name.lastIndexOf('.');
if (pos > -1) {
String ext = name.substring(pos + 1, name.length());
if ((ext != null) && !ext.equals("")) {
if (log.isDebugEnabled()) {
log.debug("using extension '" + ext + "' for hinting");
}
Collection<MagicMatcher> c = hintMap.get(ext);
if (c != null) {
Iterator<MagicMatcher> i = c.iterator();
while (i.hasNext()) {
matcher = (MagicMatcher) i.next();
log.debug("getMagicMatch(File): trying to match: " +
matcher.getMatch().getDescription());
try {
if ((match = matcher.test(file, onlyMimeMatch)) != null) {
log.debug("getMagicMatch(File): matched " +
matcher.getMatch().getDescription());
if (log.isDebugEnabled()) {
long end = System.currentTimeMillis();
log.debug("found match in '" + (end - start) +
"' milliseconds");
}
return match;
}
} catch (UnsupportedTypeException e) {
log.error("getMagicMatch(File): " + e);
throw new MagicException(e);
} catch (IOException e) {
log.error("getMagicMatch(File): " + e);
throw new MagicException(e);
}
// add to the already checked list
checked.add(matcher);
}
}
} else {
log.debug("no file extension, ignoring hints");
}
} else {
log.debug("no file extension, ignoring hints");
}
}
Collection<MagicMatcher> matchers = magicParser.getMatchers();
log.debug("getMagicMatch(File): have " + matchers.size() + " matches");
Iterator<MagicMatcher> i = matchers.iterator();
while (i.hasNext()) {
matcher = (MagicMatcher) i.next();
if (!checked.contains(matcher)) {
log.debug("getMagicMatch(File): trying to match: " +
matcher.getMatch().getDescription());
try {
if ((match = matcher.test(file, onlyMimeMatch)) != null) {
log.debug("getMagicMatch(File): matched " +
matcher.getMatch().getDescription());
if (log.isDebugEnabled()) {
long end = System.currentTimeMillis();
log.debug("found match in '" + (end - start) + "' milliseconds");
}
return match;
}
} catch (UnsupportedTypeException e) {
log.error("getMagicMatch(File): " + e);
throw new MagicException(e);
} catch (IOException e) {
log.error("getMagicMatch(File): " + e);
throw new MagicException(e);
}
} else {
log.debug("getMagicMatch(File): already checked, skipping: " +
matcher.getMatch().getDescription());
}
}
throw new MagicMatchNotFoundException();
}
/**
* print the contents of a magic file
*
* @param stream DOCUMENT ME!
*
* @throws MagicParseException DOCUMENT ME!
*/
public static void printMagicFile(PrintStream stream)
throws MagicParseException
{
if (!initialized) {
initialize();
}
Collection<MagicMatcher> matchers = Magic.getMatchers();
log.debug("have " + matchers.size() + " matches");
MagicMatcher matcher = null;
Iterator<MagicMatcher> i = matchers.iterator();
while (i.hasNext()) {
matcher = (MagicMatcher) i.next();
log.debug("printing");
printMagicMatcher(stream, matcher, "");
}
}
/**
* print a magic match
*
* @param stream DOCUMENT ME!
* @param matcher DOCUMENT ME!
* @param spacing DOCUMENT ME!
*/
private static void printMagicMatcher(PrintStream stream, MagicMatcher matcher, String spacing)
{
stream.println(spacing + "name: " + matcher.getMatch().getDescription());
stream.println(spacing + "children: ");
Collection<MagicMatcher> matchers = matcher.getSubMatchers();
Iterator<MagicMatcher> i = matchers.iterator();
while (i.hasNext()) {
printMagicMatcher(stream, (MagicMatcher) i.next(), spacing + " ");
}
}
/**
* print a magic match
*
* @param stream DOCUMENT ME!
* @param match DOCUMENT ME!
* @param spacing DOCUMENT ME!
*/
public static void printMagicMatch(PrintStream stream, MagicMatch match, String spacing)
{
stream.println(spacing + "=============================");
stream.println(spacing + "mime type: " + match.getMimeType());
stream.println(spacing + "description: " + match.getDescription());
stream.println(spacing + "extension: " + match.getExtension());
stream.println(spacing + "test: " + new String(match.getTest().array()));
stream.println(spacing + "bitmask: " + match.getBitmask());
stream.println(spacing + "offset: " + match.getOffset());
stream.println(spacing + "length: " + match.getLength());
stream.println(spacing + "type: " + match.getType());
stream.println(spacing + "comparator: " + match.getComparator());
stream.println(spacing + "=============================");
Collection<MagicMatch> submatches = match.getSubMatches();
Iterator<MagicMatch> i = submatches.iterator();
while (i.hasNext()) {
printMagicMatch(stream, (MagicMatch) i.next(), spacing + " ");
}
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args)
{
try {
if (args.length == 0) {
System.err.println("usage: test <file>");
System.exit(1);;
}
File f = new File(args[0]);
if (f.exists()) {
MagicMatch match = Magic.getMagicMatch(f, true, false);
System.out.println("filename: " + args[0]);
printMagicMatch(System.out, match, "");
} else {
System.err.println("file '" + f.getCanonicalPath() + "' not found");
}
} catch (MagicMatchNotFoundException e) {
System.out.println("no match found");
} catch (Exception e) {
System.err.println("error: " + e);
e.printStackTrace(System.err);
}
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicDetector.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
import java.io.File;
import java.util.Map;
/**
* DOCUMENT ME!
*
* @author $Author$
* @version $Revision$
*/
public interface MagicDetector
{
// get the short name of this detector
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getName();
// get the display name of this detector
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getDisplayName();
// get the version of this plugin
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getVersion();
// get a list of types this detector handles
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] getHandledTypes();
// get a list of file extensions this detector typically deals with
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] getHandledExtensions();
// process the stream and return all matching content types
/**
* DOCUMENT ME!
*
* @param data DOCUMENT ME!
* @param offset DOCUMENT ME!
* @param length DOCUMENT ME!
* @param bitmask DOCUMENT ME!
* @param comparator DOCUMENT ME!
* @param mimeType DOCUMENT ME!
* @param params DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] process(byte[] data, int offset, int length, long bitmask, char comparator,
String mimeType, Map<String,String> params);
// process the file and return all matching content types
/**
* DOCUMENT ME!
*
* @param file DOCUMENT ME!
* @param offset DOCUMENT ME!
* @param length DOCUMENT ME!
* @param bitmask DOCUMENT ME!
* @param comparator DOCUMENT ME!
* @param mimeType DOCUMENT ME!
* @param params DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] process(File file, int offset, int length, long bitmask, char comparator,
String mimeType, Map<String,String> params);
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicException.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
/**
* Basic JMimeMagic parse exception. This is simply a holder to identify a parsing problem. It
* should be extended to identify more specific issues.
*
* @author $Author: arimus $
* @version $Revision: 1.1 $
*/
public class MagicException extends Exception
{
/**
* Default constructor
*/
public MagicException()
{
super();
}
/**
* Create exception with error message
*
* @param message The error message for this exception
*/
public MagicException(String message)
{
super(message);
}
/**
* Create exception based on an existing Throwable
*
* @param cause The throwable on which we'll base this exception
*/
public MagicException(Throwable cause)
{
super(cause);
}
/**
* Create an exception with custom message and throwable info
*
* @param message The message
* @param cause The target Throwable
*/
public MagicException(String message, Throwable cause)
{
super(message, cause);
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicMatch.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* This class represents a single match test
*
* @author $Author: arimus $
* @version $Revision: 1.10 $
*/
public class MagicMatch implements Cloneable
{
private static Log log = LogFactory.getLog(MagicMatch.class);
private String mimeType = null;
private String extension = null;
private String description = null;
private ByteBuffer test = null;
private int offset = 0;
private int length = 0;
// possible types:
// byte, short, long, string, date, beshort, belong, bedate, leshort,
// lelong, ledate, regex
private String type = "";
private long bitmask = 0xFFFFFFFFL;
private char comparator = '\0';
private List<MagicMatch> subMatches = new ArrayList<MagicMatch>(0);
private Map<String,String> properties;
/**
* constructor
*/
public MagicMatch()
{
log.debug("instantiated");
}
/**
* print information about this match
*
* @return DOCUMENT ME!
*/
public String print()
{
StringBuffer string = new StringBuffer();
string.append("\n");
string.append("mime type: ").append(mimeType).append("\n");
string.append("description: ").append(description).append("\n");
string.append("extension: ").append(extension).append("\n");
string.append("offset: ").append(offset).append("\n");
string.append("length: ").append(length).append("\n");
string.append("test: ").append(new String(test.array())).append("\n");
string.append("type: ").append(type).append("\n");
string.append("comparator: ").append(comparator).append("\n");
string.append("bitmask: ").append(bitmask);
return string.toString();
}
/**
* set the mime type for this magic match
*
* @param value DOCUMENT ME!
*/
public void setMimeType(String value)
{
mimeType = value;
}
/**
* get the magic match for this magic match
*
* @return the mime type for this magic match
*/
public String getMimeType()
{
return mimeType;
}
/**
* set the extension for this magic match
*
* @param value DOCUMENT ME!
*/
public void setExtension(String value)
{
extension = value;
}
/**
* get the extension for this magic match
*
* @return the extension for this magic match
*/
public String getExtension()
{
return extension;
}
/**
* set the description for this magic match
*
* @param value DOCUMENT ME!
*/
public void setDescription(String value)
{
description = value;
}
/**
* get the description for this magic match
*
* @return the description for thie magic match
*/
public String getDescription()
{
return description;
}
/**
* set the test value for thie magic match
*
* @param value DOCUMENT ME!
*/
public void setTest(ByteBuffer value)
{
test = value;
}
/**
* get the test value for this magic match
*
* @return DOCUMENT ME!
*/
public ByteBuffer getTest()
{
return test;
}
/**
* set the offset in the stream we are comparing to the test value for this magic match
*
* @param value DOCUMENT ME!
*/
public void setOffset(int value)
{
this.offset = value;
}
/**
* get the offset in the stream we are comparing to the test value for this magic match
*
* @return the offset for this magic match
*/
public int getOffset()
{
return offset;
}
/**
* set the length we are restricting the comparison to for this magic match
*
* @param value DOCUMENT ME!
*/
public void setLength(int value)
{
this.length = value;
}
/**
* get the length we are restricting the comparison to for this magic match
*
* @return DOCUMENT ME!
*/
public int getLength()
{
return length;
}
/**
* set the type of match to perform for this magic match
*
* @param value DOCUMENT ME!
*/
public void setType(String value)
{
this.type = value;
}
/**
* get the type of match for this magic match
*
* @return DOCUMENT ME!
*/
public String getType()
{
return type;
}
/**
* set the bitmask that will be applied for this magic match
*
* @param value DOCUMENT ME!
*/
public void setBitmask(String value)
{
if (value != null) {
this.bitmask = Long.decode(value).intValue();
}
}
/**
* get the bitmask that will be applied for this magic match
*
* @return the bitmask for this magic match
*/
public long getBitmask()
{
return bitmask;
}
/**
* set the comparator for this magic match
*
* @param value DOCUMENT ME!
*/
public void setComparator(String value)
{
this.comparator = value.charAt(0);
}
/**
* get the comparator for this magic match
*
* @return the comparator for this magic match
*/
public char getComparator()
{
return comparator;
}
/**
* set the properties for this magic match
*
* @param properties DOCUMENT ME!
*/
public void setProperties(Map<String,String> properties)
{
this.properties = properties;
}
/**
* get the properties for this magic match
*
* @return the properties for this magic match
*/
public Map<String,String> getProperties()
{
return properties;
}
/**
* add a submatch to this magic match
*
* @param m a magic match
*/
public void addSubMatch(MagicMatch m)
{
log.debug("adding submatch '" + m.getDescription() + "' to '" + getDescription() + "'");
subMatches.add(m);
}
/**
* set all submatches
*
* @param a a collection of submatches
*/
public void setSubMatches(Collection<MagicMatch> a)
{
log.debug("setting submatches for '" + getDescription() + "'");
subMatches.clear();
subMatches.addAll(a);
}
/**
* get all submatches for this magic match
*
* @return a collection of submatches
*/
public Collection<MagicMatch> getSubMatches()
{
return subMatches;
}
/**
* determine if this match or any submatches has the description
*
* @param desc DOCUMENT ME!
*
* @return whether or not the description matches
*/
public boolean descriptionMatches(String desc)
{
if ((description != null) && description.equals(desc)) {
return true;
}
Collection<MagicMatch> submatches = getSubMatches();
Iterator<MagicMatch> i = submatches.iterator();
MagicMatch m = null;
while (i.hasNext()) {
m = (MagicMatch) i.next();
if (m.descriptionMatches(desc)) {
return true;
}
}
return false;
}
/**
* determine if this match or any submatches has the description
*
* @param desc DOCUMENT ME!
*
* @return whether or not the description matches
*/
public boolean mimeTypeMatches(String desc)
{
if ((mimeType != null) && mimeType.equals(desc)) {
return true;
}
Collection<MagicMatch> submatches = getSubMatches();
Iterator<MagicMatch> i = submatches.iterator();
MagicMatch m = null;
while (i.hasNext()) {
m = (MagicMatch) i.next();
if (m.mimeTypeMatches(desc)) {
return true;
}
}
return false;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws CloneNotSupportedException DOCUMENT ME!
*/
protected Object clone()
throws CloneNotSupportedException
{
MagicMatch clone = new MagicMatch();
clone.setBitmask(Long.toString(bitmask, 8));
clone.setComparator("" + comparator);
clone.setDescription(description);
clone.setExtension(extension);
clone.setLength(length);
clone.setMimeType(mimeType);
clone.setOffset(offset);
// these properties should only be String types, so we shouldn't have to clone them
if(properties!= null) {
Map<String,String> m = new HashMap<String, String>();
m.putAll(properties);
clone.setProperties(m);
}
Iterator<MagicMatch> i = subMatches.iterator();
List<MagicMatch> a = new ArrayList<MagicMatch>();
while (i.hasNext()) {
MagicMatch mm = i.next();
a.add(mm);
}
clone.setSubMatches(a);
clone.setTest(test);
clone.setType(type);
// TODO Auto-generated method stub
return clone;
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicMatchNotFoundException.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
/**
* Basic JMimeMagic parse exception. This is simply a holder to identify a parsing problem. It
* should be extended to identify more specific issues.
*
* @author $Author: arimus $
* @version $Revision: 1.1 $
*/
public class MagicMatchNotFoundException extends Exception
{
/**
* constructor
*/
public MagicMatchNotFoundException()
{
super();
}
/**
* Create exception with error message
*
* @param message The error message for this exception
*/
public MagicMatchNotFoundException(String message)
{
super(message);
}
/**
* Create exception based on an existing Throwable
*
* @param cause The throwable on which we'll base this exception
*/
public MagicMatchNotFoundException(Throwable cause)
{
super(cause);
}
/**
* Create an exception with custom message and throwable info
*
* @param message The message
* @param cause The target Throwable
*/
public MagicMatchNotFoundException(String message, Throwable cause)
{
super(message, cause);
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicMatcher.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
/**
* This class represents a single match test
*
* @author $Author: arimus $
* @version $Revision: 1.1 $
*/
public class MagicMatcher implements Cloneable
{
private static Log log = LogFactory.getLog(MagicMatcher.class);
private List<MagicMatcher> subMatchers = new ArrayList<MagicMatcher>(0);
private MagicMatch match = null;
/**
* constructor
*/
public MagicMatcher()
{
log.debug("instantiated");
}
/**
* DOCUMENT ME!
*
* @param match DOCUMENT ME!
*/
public void setMatch(MagicMatch match)
{
log.debug("setMatch()");
this.match = match;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public MagicMatch getMatch()
{
log.debug("getMatch()");
return this.match;
}
/**
* test to see if everything is in order for this match
*
* @return whether or not this match has enough data to be valid
*/
public boolean isValid()
{
log.debug("isValid()");
if ((match == null) || (match.getTest() == null)) {
return false;
}
String type = new String(match.getTest().array());
char comparator = match.getComparator();
String description = match.getDescription();
String test = new String(match.getTest().array());
if ((type != null) && !type.equals("") && (comparator != '\0') &&
((comparator == '=') || (comparator == '!') || (comparator == '>') ||
(comparator == '<')) && (description != null) && !description.equals("") &&
(test != null) && !test.equals("")) {
return true;
}
return false;
}
/**
* add a submatch to this magic match
*
* @param m a magic match
*/
public void addSubMatcher(MagicMatcher m)
{
log.debug("addSubMatcher()");
subMatchers.add(m);
}
/**
* set all submatches
*
* @param a a collection of submatches
*/
public void setSubMatchers(Collection<MagicMatcher> a)
{
log.debug("setSubMatchers(): for match '" + match.getDescription() + "'");
subMatchers.clear();
subMatchers.addAll(a);
}
/**
* get all submatches for this magic match
*
* @return a collection of submatches
*/
public Collection<MagicMatcher> getSubMatchers()
{
log.debug("getSubMatchers()");
return subMatchers;
}
/**
* test to see if this match or any submatches match
*
* @param f the file that should be used to test the match
* @param onlyMimeMatch DOCUMENT ME!
*
* @return the deepest magic match object that matched
*
* @throws IOException DOCUMENT ME!
* @throws UnsupportedTypeException DOCUMENT ME!
*/
public MagicMatch test(File f, boolean onlyMimeMatch)
throws IOException, UnsupportedTypeException
{
log.debug("test(File)");
int offset = match.getOffset();
String description = match.getDescription();
String type = match.getType();
log.debug("test(File): testing '" + f.getName() + "' for '" + description + "'");
log.debug("test(File): \n=== BEGIN MATCH INFO ==");
log.debug(match.print());
log.debug("test(File): \n=== END MATCH INFO ====\n");
RandomAccessFile file = null;
file = new RandomAccessFile(f, "r");
try {
int length = 0;
if (type.equals("byte")) {
length = 1;
} else if (type.equals("short") || type.equals("leshort") || type.equals("beshort")) {
length = 4;
} else if (type.equals("long") || type.equals("lelong") || type.equals("belong")) {
length = 8;
} else if (type.equals("string")) {
length = match.getTest().capacity();
} else if (type.equals("regex")) {
final int matchLength = match.getLength();
length = (matchLength == 0) ? (int) file.length() - offset : matchLength;
if (length < 0) {
length = 0;
}
} else if (type.equals("detector")) {
length = (int) file.length() - offset;
if (length < 0) {
length = 0;
}
} else {
throw new UnsupportedTypeException("unsupported test type '" + type + "'");
}
// we know this match won't work since there isn't enough data for the test
if (length > (file.length() - offset)) {
return null;
}
byte[] buf = new byte[length];
file.seek(offset);
int bytesRead = 0;
int size = 0;
boolean gotAllBytes = false;
boolean done = false;
while (!done) {
size = file.read(buf, 0, length - bytesRead);
if (size == -1) {
throw new IOException("reached end of file before all bytes were read");
}
bytesRead += size;
if (bytesRead == length) {
gotAllBytes = true;
done = true;
}
}
log.debug("test(File): stream size is '" + buf.length + "'");
MagicMatch match = null;
MagicMatch submatch = null;
if (testInternal(buf)) {
// set the top level match to this one
try {
match = getMatch() != null ? (MagicMatch) getMatch()
.clone() : null;
} catch (CloneNotSupportedException e) {
// noop
}
log.debug("test(File): testing matched '" + description + "'");
// set the data on this match
if ((onlyMimeMatch == false) && (subMatchers != null) && (subMatchers.size() > 0)) {
log.debug("test(File): testing " + subMatchers.size() + " submatches for '" +
description + "'");
for (int i = 0; i < subMatchers.size(); i++) {
log.debug("test(File): testing submatch " + i);
MagicMatcher m = (MagicMatcher) subMatchers.get(i);
if ((submatch = m.test(f, false)) != null) {
log.debug("test(File): submatch " + i + " matched with '" +
submatch.getDescription() + "'");
match.addSubMatch(submatch);
} else {
log.debug("test(File): submatch " + i + " doesn't match");
}
}
}
}
return match;
} finally {
try {
file.close();
} catch (Exception fce) {
}
}
}
/**
* test to see if this match or any submatches match
*
* @param data the data that should be used to test the match
* @param onlyMimeMatch DOCUMENT ME!
*
* @return the deepest magic match object that matched
*
* @throws IOException DOCUMENT ME!
* @throws UnsupportedTypeException DOCUMENT ME!
*/
public MagicMatch test(byte[] data, boolean onlyMimeMatch)
throws IOException, UnsupportedTypeException
{
log.debug("test(byte[])");
int offset = match.getOffset();
String description = match.getDescription();
String type = match.getType();
String test = new String(match.getTest().array());
String mimeType = match.getMimeType();
log.debug("test(byte[]): testing byte[] data for '" + description + "'");
log.debug("test(byte[]): \n=== BEGIN MATCH INFO ==");
log.debug(match.print());
log.debug("test(byte[]): \n=== END MATCH INFO ====\n");
int length = 0;
if (type.equals("byte")) {
length = 1;
} else if (type.equals("short") || type.equals("leshort") || type.equals("beshort")) {
length = 4;
} else if (type.equals("long") || type.equals("lelong") || type.equals("belong")) {
length = 8;
} else if (type.equals("string")) {
length = match.getTest().capacity();
} else if (type.equals("regex")) {
// FIXME - something wrong here, shouldn't have to subtract 1???
length = data.length - offset - 1;
if (length < 0) {
length = 0;
}
} else if (type.equals("detector")) {
// FIXME - something wrong here, shouldn't have to subtract 1???
length = data.length - offset - 1;
if (length < 0) {
length = 0;
}
} else {
throw new UnsupportedTypeException("unsupported test type " + type);
}
byte[] buf = new byte[length];
log.debug("test(byte[]): offset=" + offset + ",length=" + length + ",data length=" +
data.length);
if ((offset + length) < data.length) {
System.arraycopy(data, offset, buf, 0, length);
log.debug("test(byte[]): stream size is '" + buf.length + "'");
MagicMatch match = null;
MagicMatch submatch = null;
if (testInternal(buf)) {
// set the top level match to this one
try {
match = getMatch() != null ? (MagicMatch) getMatch()
.clone() : null;
} catch (CloneNotSupportedException e) {
// noop
}
log.debug("test(byte[]): testing matched '" + description + "'");
// set the data on this match
if ((onlyMimeMatch == false) && (subMatchers != null) && (subMatchers.size() > 0)) {
log.debug("test(byte[]): testing " + subMatchers.size() + " submatches for '" +
description + "'");
for (int i = 0; i < subMatchers.size(); i++) {
log.debug("test(byte[]): testing submatch " + i);
MagicMatcher m = (MagicMatcher) subMatchers.get(i);
if ((submatch = m.test(data, false)) != null) {
log.debug("test(byte[]): submatch " + i + " matched with '" +
submatch.getDescription() + "'");
match.addSubMatch(submatch);
} else {
log.debug("test(byte[]): submatch " + i + " doesn't match");
}
}
}
}
return match;
} else {
return null;
}
}
/**
* internal test switch
*
* @param data DOCUMENT ME!
* @return DOCUMENT ME!
*/
private boolean testInternal(byte[] data)
{
log.debug("testInternal(byte[])");
if (data.length == 0) {
return false;
}
String type = match.getType();
String test = new String(match.getTest().array());
String mimeType = match.getMimeType();
String description = match.getDescription();
ByteBuffer buffer = ByteBuffer.allocate(data.length);
if ((type != null) && (test != null) && (test.length() > 0)) {
if (type.equals("string")) {
buffer = buffer.put(data);
return testString(buffer);
} else if (type.equals("byte")) {
buffer = buffer.put(data);
return testByte(buffer);
} else if (type.equals("short")) {
buffer = buffer.put(data);
return testShort(buffer);
} else if (type.equals("leshort")) {
buffer = buffer.put(data);
buffer.order(ByteOrder.LITTLE_ENDIAN);
return testShort(buffer);
} else if (type.equals("beshort")) {
buffer = buffer.put(data);
buffer.order(ByteOrder.BIG_ENDIAN);
return testShort(buffer);
} else if (type.equals("long")) {
buffer = buffer.put(data);
return testLong(buffer);
} else if (type.equals("lelong")) {
buffer = buffer.put(data);
buffer.order(ByteOrder.LITTLE_ENDIAN);
return testLong(buffer);
} else if (type.equals("belong")) {
buffer = buffer.put(data);
buffer.order(ByteOrder.BIG_ENDIAN);
return testLong(buffer);
} else if (type.equals("regex")) {
return testRegex(new String(data));
} else if (type.equals("detector")) {
buffer = buffer.put(data);
return testDetector(buffer);
// } else if (type.equals("date")) {
// return testDate(data, BIG_ENDIAN);
// } else if (type.equals("ledate")) {
// return testDate(data, LITTLE_ENDIAN);
// } else if (type.equals("bedate")) {
// return testDate(data, BIG_ENDIAN);
} else {
log.error("testInternal(byte[]): invalid test type '" + type + "'");
}
} else {
log.error("testInternal(byte[]): type or test is empty for '" + mimeType + " - " +
description + "'");
}
return false;
}
/**
* test the data against the test byte
*
* @param data the data we are testing
*
* @return if we have a match
*/
private boolean testByte(ByteBuffer data)
{
log.debug("testByte()");
String test = new String(match.getTest().array());
char comparator = match.getComparator();
long bitmask = match.getBitmask();
String s = test;
byte b = data.get(0);
b = (byte) (b & bitmask);
log.debug("testByte(): decoding '" + test + "' to byte");
int tst = Integer.decode(test).byteValue();
byte t = (byte) (tst & 0xff);
log.debug("testByte(): applying bitmask '" + bitmask + "' to '" + tst + "', result is '" +
t + "'");
log.debug("testByte(): comparing byte '" + b + "' to '" + t + "'");
switch (comparator) {
case '=':
return t == b;
case '!':
return t != b;
case '>':
return t > b;
case '<':
return t < b;
}
return false;
}
/**
* test the data against the byte array
*
* @param data the data we are testing
*
* @return if we have a match
*/
private boolean testString(ByteBuffer data)
{
log.debug("testString()");
ByteBuffer test = match.getTest();
char comparator = match.getComparator();
byte[] b = data.array();
byte[] t = test.array();
boolean diff = false;
int i = 0;
for (i = 0; i < t.length; i++) {
log.debug("testing byte '" + b[i] + "' from '" + new String(data.array()) +
"' against byte '" + t[i] + "' from '" + new String(test.array()) + "'");
if (t[i] != b[i]) {
diff = true;
break;
}
}
switch (comparator) {
case '=':
return !diff;
case '!':
return diff;
case '>':
return t[i] > b[i];
case '<':
return t[i] < b[i];
}
return false;
}
/**
* test the data against a short
*
* @param data the data we are testing
*
* @return if we have a match
*/
private boolean testShort(ByteBuffer data)
{
log.debug("testShort()");
short val = 0;
String test = new String(match.getTest().array());
char comparator = match.getComparator();
long bitmask = match.getBitmask();
val = byteArrayToShort(data);
// apply bitmask before the comparison
val = (short) (val & (short) bitmask);
short tst = 0;
try {
tst = Integer.decode(test).shortValue();
} catch (NumberFormatException e) {
log.error("testShort(): " + e);
return false;
//if (test.length() == 1) {
// tst = new Integer(Character.getNumericValue(test.charAt(0))).shortValue();
//}
}
log.debug("testShort(): testing '" + Long.toHexString(val) + "' against '" +
Long.toHexString(tst) + "'");
switch (comparator) {
case '=':
return val == tst;
case '!':
return val != tst;
case '>':
return val > tst;
case '<':
return val < tst;
}
return false;
}
/**
* test the data against a long
*
* @param data the data we are testing
*
* @return if we have a match
*/
private boolean testLong(ByteBuffer data)
{
log.debug("testLong()");
long val = 0;
String test = new String(match.getTest().array());
char comparator = match.getComparator();
long bitmask = match.getBitmask();
val = byteArrayToLong(data);
// apply bitmask before the comparison
val = val & bitmask;
long tst = Long.decode(test).longValue();
log.debug("testLong(): testing '" + Long.toHexString(val) + "' against '" + test +
"' => '" + Long.toHexString(tst) + "'");
switch (comparator) {
case '=':
return val == tst;
case '!':
return val != tst;
case '>':
return val > tst;
case '<':
return val < tst;
}
return false;
}
/**
* test the data against a regex
*
* @param text the data we are testing
*
* @return if we have a match
*/
private boolean testRegex(String text)
{
log.debug("testRegex()");
String test = new String(match.getTest().array());
char comparator = match.getComparator();
log.debug("testRegex(): searching for '" + test + "'");
if (comparator == '=') {
if (Pattern.matches(test, text)) {
return true;
} else {
return false;
}
} else if (comparator == '!') {
if (Pattern.matches(test, text)) {
return false;
} else {
return true;
}
}
return false;
}
/**
* test the data using a detector
*
* @param data the data we are testing
*
* @return if we have a match
*/
private boolean testDetector(ByteBuffer data)
{
log.debug("testDetector()");
String detectorClass = new String(match.getTest().array());
try {
log.debug("loading class: " + detectorClass);
Class<?> c = Class.forName(detectorClass);
MagicDetector detector = (MagicDetector) c.newInstance();
String[] types = detector.process(data.array(), match.getOffset(), match.getLength(),
match.getBitmask(), match.getComparator(), match.getMimeType(),
match.getProperties());
if ((types != null) && (types.length > 0)) {
// the match object has no mime type set, so set from the detector class processing
match.setMimeType(types[0]);
return true;
}
} catch (ClassNotFoundException e) {
log.error("failed to load detector: " + detectorClass, e);
} catch (InstantiationException e) {
log.error("specified class is not a valid detector class: " + detectorClass, e);
} catch (IllegalAccessException e) {
log.error("specified class cannot be accessed: " + detectorClass, e);
}
return false;
}
/**
* Get the extensions for the underlying detectory
*
* @return DOCUMENT ME!
*/
public String[] getDetectorExtensions()
{
log.debug("testDetector()");
String detectorClass = new String(match.getTest().array());
try {
log.debug("loading class: " + detectorClass);
Class<?> c = Class.forName(detectorClass);
MagicDetector detector = (MagicDetector) c.newInstance();
return detector.getHandledTypes();
} catch (ClassNotFoundException e) {
log.error("failed to load detector: " + detectorClass, e);
} catch (InstantiationException e) {
log.error("specified class is not a valid detector class: " + detectorClass, e);
} catch (IllegalAccessException e) {
log.error("specified class cannot be accessed: " + detectorClass, e);
}
return new String[0];
}
/**
* encode a byte as an octal string
*
* @param b a byte of data
*
* @return an octal representation of the byte data
*/
private String byteToOctalString(byte b)
{
int n1;
int n2;
int n3;
n1 = (b / 32) & 7;
n2 = (b / 8) & 7;
n3 = b & 7;
return String.valueOf(n1) + String.valueOf(n2) + String.valueOf(n3);
}
/**
* convert a byte array to a short
*
* @param data buffer of byte data
*
* @return byte array converted to a short
*/
private short byteArrayToShort(ByteBuffer data)
{
return data.getShort(0);
}
/**
* convert a byte array to a long
*
* @param data buffer of byte data
*
* @return byte arrays (high and low bytes) converted to a long value
*/
private long byteArrayToLong(ByteBuffer data)
{
return (long) data.getInt(0);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws CloneNotSupportedException DOCUMENT ME!
*/
protected MagicMatcher clone()
throws CloneNotSupportedException
{
MagicMatcher clone = new MagicMatcher();
clone.setMatch((MagicMatch) match.clone());
Iterator<MagicMatcher> i = subMatchers.iterator();
List<MagicMatcher> sub = new ArrayList<MagicMatcher>();
while (i.hasNext()) {
MagicMatcher m = (MagicMatcher) i.next();
sub.add(m.clone());
}
clone.setSubMatchers(sub);
return clone;
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicParseException.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
/**
* Basic JMimeMagic parse exception. This is simply a holder to identify a parsing problem. It
* should be extended to identify more specific issues.
*
* @author $Author: arimus $
* @version $Revision: 1.1 $
*/
public class MagicParseException extends Exception
{
/**
* Default constructor
*/
public MagicParseException()
{
super();
}
/**
* Create exception with error message
*
* @param message The error message for this exception
*/
public MagicParseException(String message)
{
super(message);
}
/**
* Create exception based on an existing Throwable
*
* @param cause The throwable on which we'll base this exception
*/
public MagicParseException(Throwable cause)
{
super(cause);
}
/**
* Create an exception with custom message and throwable info
*
* @param message The message
* @param cause The target Throwable
*/
public MagicParseException(String message, Throwable cause)
{
super(message, cause);
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/MagicParser.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.ByteArrayOutputStream;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* DOCUMENT ME!
*
* @author $Author$
* @version $Revision$
*/
public class MagicParser extends DefaultHandler implements ContentHandler, ErrorHandler
{
private static String magicFile = "/magic.xml";
private static Log log = LogFactory.getLog(MagicParser.class);
// Namespaces feature id (http://xml.org/sax/features/namespaces).
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
// Validation feature id (http://xml.org/sax/features/validation).
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
// Schema validation feature id (http://apache.org/xml/features/validation/schema).
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
// Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).
protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
// Default parser name.
protected static final String DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
// Default namespaces support (true).
protected static final boolean DEFAULT_NAMESPACES = true;
// Default validation support (false).
protected static final boolean DEFAULT_VALIDATION = false;
// Default Schema validation support (false).
protected static final boolean DEFAULT_SCHEMA_VALIDATION = false;
// Default Schema full checking support (false).
protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
private boolean initialized = false;
private XMLReader parser = null;
private List<MagicMatcher> stack = new ArrayList<MagicMatcher>();
private Collection<MagicMatcher> matchers = new ArrayList<MagicMatcher>();
private MagicMatcher matcher = null;
private MagicMatch match = null;
private Map<String,String> properties = null;
private String finalValue = "";
private boolean isMimeType = false;
private boolean isExtension = false;
private boolean isDescription = false;
private boolean isTest = false;
/**
* constructor
*/
public MagicParser()
{
log.debug("instantiated");
}
/**
* parse the xml file and create our MagicMatcher object list
*
* @throws MagicParseException DOCUMENT ME!
*/
public synchronized void initialize()
throws MagicParseException
{
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
if (!initialized) {
// use default parser
try {
parser = XMLReaderFactory.createXMLReader();
} catch (Exception e) {
try {
log.debug("falling back to default parser: " + DEFAULT_PARSER_NAME);
parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME);
} catch (Exception ee) {
throw new MagicParseException("unable to instantiate parser");
}
}
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
} catch (SAXException e) {
log.debug("initialize(): warning: Parser does not support feature (" +
NAMESPACES_FEATURE_ID + ")");
}
try {
parser.setFeature(VALIDATION_FEATURE_ID, validation);
} catch (SAXException e) {
log.debug("initialize(): warning: Parser does not support feature (" +
VALIDATION_FEATURE_ID + ")");
}
try {
parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, schemaValidation);
} catch (SAXNotRecognizedException e) {
// ignore
} catch (SAXNotSupportedException e) {
log.debug("initialize(): warning: Parser does not support feature (" +
SCHEMA_VALIDATION_FEATURE_ID + ")");
}
try {
parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
} catch (SAXNotRecognizedException e) {
// ignore
} catch (SAXNotSupportedException e) {
log.debug("initialize(): warning: Parser does not support feature (" +
SCHEMA_FULL_CHECKING_FEATURE_ID + ")");
}
// set handlers
parser.setErrorHandler(this);
parser.setContentHandler(this);
// parse file
try {
// get the magic file URL
URL resource = MagicParser.class.getResource(magicFile);
String magicURL = resource.toString();
if (magicURL == null) {
log.error("initialize(): couldn't load '" + magicURL + "'");
throw new MagicParseException("couldn't load '" + magicURL + "'");
}
parser.parse(magicURL);
} catch (SAXParseException e) {
// ignore
} catch (Exception e) {
e.printStackTrace();
throw new MagicParseException("parse error occurred - " + e.getMessage());
}
initialized = true;
}
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Collection<MagicMatcher> getMatchers()
{
return matchers;
}
/**
* DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void startDocument()
throws SAXException
{
log.debug("startDocument()");
}
/**
* DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void endDocument()
throws SAXException
{
log.debug("endDocument()");
}
/**
* DOCUMENT ME!
*
* @param target DOCUMENT ME!
* @param data DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void processingInstruction(String target, String data)
throws SAXException
{
// do nothing
}
/**
* DOCUMENT ME!
*
* @param ch DOCUMENT ME!
* @param offset DOCUMENT ME!
* @param length DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void characters(char[] ch, int offset, int length)
throws SAXException
{
String value = new String(ch, offset, length);
log.debug("characters(): value is '" + value + "'");
finalValue += value;
}
/**
* DOCUMENT ME!
*
* @param ch DOCUMENT ME!
* @param offset DOCUMENT ME!
* @param length DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void ignorableWhitespace(char[] ch, int offset, int length)
throws SAXException
{
// do nothing
}
/**
* DOCUMENT ME!
*
* @param uri DOCUMENT ME!
* @param localName DOCUMENT ME!
* @param qname DOCUMENT ME!
* @param attributes DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void startElement(String uri, String localName, String qname, Attributes attributes)
throws SAXException
{
log.debug("startElement()");
log.debug("startElement(): localName is '" + localName + "'");
// create a new matcher
if (localName.equals("match")) {
log.debug("startElement(): creating new matcher");
// match to hold data
match = new MagicMatch();
// our matcher
matcher = new MagicMatcher();
matcher.setMatch(match);
}
// these are subelements of matcher, but also occur elsewhere
if (matcher != null) {
if (localName.equals("mimetype")) {
isMimeType = true;
} else if (localName.equals("extension")) {
isExtension = true;
} else if (localName.equals("description")) {
isDescription = true;
} else if (localName.equals("test")) {
isTest = true;
int length = attributes.getLength();
for (int i = 0; i < length; i++) {
String attrLocalName = attributes.getLocalName(i);
String attrValue = attributes.getValue(i);
if (attrLocalName.equals("offset")) {
if (!attrValue.equals("")) {
match.setOffset(new Integer(attrValue).intValue());
log.debug("startElement(): setting offset to '" + attrValue + "'");
}
} else if (attrLocalName.equals("length")) {
if (!attrValue.equals("")) {
match.setLength(new Integer(attrValue).intValue());
log.debug("startElement(): setting length to '" + attrValue + "'");
}
} else if (attrLocalName.equals("type")) {
match.setType(attrValue);
log.debug("startElement(): setting type to '" + attrValue + "'");
} else if (attrLocalName.equals("bitmask")) {
if (!attrValue.equals("")) {
match.setBitmask(attrValue);
log.debug("startElement(): setting bitmask to '" + attrValue + "'");
}
} else if (attrLocalName.equals("comparator")) {
match.setComparator(attrValue);
log.debug("startElement(): setting comparator to '" + attrValue + "'");
}
}
} else if (localName.equals("property")) {
int length = attributes.getLength();
String name = null;
String value = null;
for (int i = 0; i < length; i++) {
String attrLocalName = attributes.getLocalName(i);
String attrValue = attributes.getValue(i);
if (attrLocalName.equals("name")) {
if (!attrValue.equals("")) {
name = attrValue;
}
} else if (attrLocalName.equals("value")) {
if (!attrValue.equals("")) {
value = attrValue;
}
}
}
// save the property to our map
if ((name != null) && (value != null)) {
if (properties == null) {
properties = new HashMap<String, String>();
}
if (!properties.containsKey(name)) {
properties.put(name, value);
log.debug("startElement(): setting property '" + name + "'='" + value +
"'");
} else {
log.debug("startElement(): not setting property '" + name +
"', duplicate key");
}
}
} else if (localName.equals("match-list")) {
log.debug("startElement(): found submatcher list");
// this means we are processing a child match, so we need to push
// the existing match on the stack
log.debug("startElement(): pushing current matcher to stack");
stack.add(matcher);
} else {
// we don't care about this type
}
}
}
/**
* DOCUMENT ME!
*
* @param uri DOCUMENT ME!
* @param localName DOCUMENT ME!
* @param qname DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void endElement(String uri, String localName, String qname)
throws SAXException
{
log.debug("endElement()");
log.debug("endElement(): localName is '" + localName + "'");
// determine which tag these chars are for and save them
if (isMimeType) {
isMimeType = false;
match.setMimeType(finalValue);
log.debug("characters(): setting mimetype to '" + finalValue + "'");
} else if (isExtension) {
isExtension = false;
match.setExtension(finalValue);
log.debug("characters(): setting extension to '" + finalValue + "'");
} else if (isDescription) {
isDescription = false;
match.setDescription(finalValue);
log.debug("characters(): setting description to '" + finalValue + "'");
} else if (isTest) {
isTest = false;
match.setTest(convertOctals(finalValue));
log.debug("characters(): setting test to '" + convertOctals(finalValue) + "'");
} else {
// do nothing
}
finalValue = "";
// need to save the current matcher here if it is filled out enough and
// we have an /matcher
if (localName.equals("match")) {
// FIXME - make sure the MagicMatcher isValid() test works
if (matcher.isValid()) {
// set the collected properties on this matcher
match.setProperties(properties);
// add root match
if (stack.size() == 0) {
log.debug("endElement(): adding root matcher");
matchers.add(matcher);
} else {
// we need to add the match to it's parent which is on the
// stack
log.debug("endElement(): adding sub matcher");
MagicMatcher m = (MagicMatcher) stack.get(stack.size() - 1);
m.addSubMatcher(matcher);
}
} else {
// don't add invalid matchers
log.info("endElement(): not adding invalid matcher '" + match.getDescription() +
"'");
}
matcher = null;
properties = null;
// restore matcher from the stack if we have an /matcher-list
} else if (localName.equals("match-list")) {
if (stack.size() > 0) {
log.debug("endElement(): popping from the stack");
matcher = (MagicMatcher) stack.get(stack.size() - 1);
// pop from the stack
stack.remove(matcher);
}
} else if (localName.equals("mimetype")) {
isMimeType = false;
} else if (localName.equals("extension")) {
isExtension = false;
} else if (localName.equals("description")) {
isDescription = false;
} else if (localName.equals("test")) {
isTest = false;
}
}
/**
* DOCUMENT ME!
*
* @param ex DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void warning(SAXParseException ex)
throws SAXException
{
// FIXME
}
/**
* DOCUMENT ME!
*
* @param ex DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void error(SAXParseException ex)
throws SAXException
{
// FIXME
throw ex;
}
/**
* DOCUMENT ME!
*
* @param ex DOCUMENT ME!
*
* @throws SAXException DOCUMENT ME!
*/
public void fatalError(SAXParseException ex)
throws SAXException
{
// FIXME
throw ex;
}
/**
* replaces octal representations of bytes, written as \ddd to actual byte values.
*
* @param s a string with encoded octals
*
* @return string with all octals decoded
*/
private ByteBuffer convertOctals(String s)
{
int beg = 0;
int end = 0;
int chr;
ByteArrayOutputStream buf = new ByteArrayOutputStream();
while ((end = s.indexOf('\\', beg)) != -1) {
if (s.charAt(end + 1) != '\\') {
//log.debug("appending chunk '"+s.substring(beg, end)+"'");
for (int z = beg; z < end; z++) {
buf.write((int) s.charAt(z));
}
//log.debug("found \\ at position "+end);
//log.debug("converting octal '"+s.substring(end, end+4)+"'");
if ((end + 4) <= s.length()) {
try {
chr = Integer.parseInt(s.substring(end + 1, end + 4), 8);
//log.debug("converted octal '"+s.substring(end+1,end+4)+"' to '"+chr);
//log.debug("converted octal back to '"+Integer.toOctalString(chr));
//log.debug("converted '"+s.substring(end+1,end+4)+"' to "+chr+"/"+((char)chr));
buf.write(chr);
beg = end + 4;
end = beg;
} catch (NumberFormatException nfe) {
//log.debug("not an octal");
buf.write((int) '\\');
beg = end + 1;
end = beg;
}
} else {
//log.debug("not an octal, not enough chars left in string");
buf.write((int) '\\');
beg = end + 1;
end = beg;
}
} else {
//log.debug("appending \\");
buf.write((int) '\\');
beg = end + 1;
end = beg;
}
}
if (end < s.length()) {
for (int z = beg; z < s.length(); z++) {
buf.write((int) s.charAt(z));
}
}
try {
log.debug("convertOctals(): returning buffer size '" + buf.size() + "'");
ByteBuffer b = ByteBuffer.allocate(buf.size());
return b.put(buf.toByteArray());
} catch (Exception e) {
log.error("convertOctals(): error parsing string: " + e);
return ByteBuffer.allocate(0);
}
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/UnsupportedTypeException.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic;
/**
* JMimeMagic unsupported test type exception. This exception is thrown when an unsupported
* test type is specified in a mime magic test
*
* @author $Author: arimus $
* @version $Revision: 1.1 $
*/
public class UnsupportedTypeException extends Exception
{
/**
* Default constructor
*/
public UnsupportedTypeException()
{
super();
}
/**
* Create exception with error message
*
* @param message The error message for this exception
*/
public UnsupportedTypeException(String message)
{
super(message);
}
/**
* Create exception based on an existing Throwable
*
* @param cause The throwable on which we'll base this exception
*/
public UnsupportedTypeException(Throwable cause)
{
super(cause);
}
/**
* Create an exception with custom message and throwable info
*
* @param message The message
* @param cause The target Throwable
*/
public UnsupportedTypeException(String message, Throwable cause)
{
super(message, cause);
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/detectors/TextFileDetector.java
================================================
/*
jMimeMagic (TM) is a Java Library for determining the content type of files or streams
Copyright (C) 2003-2017 David Castro
*/
package net.sf.jmimemagic.detectors;
import net.sf.jmimemagic.MagicDetector;
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BOMInputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.*;
import java.util.Map;
import java.util.regex.Pattern;
/**
* DOCUMENT ME!
*
* @author $Author$
* @version $Revision$
*/
public class TextFileDetector implements MagicDetector
{
private static Log log = LogFactory.getLog(TextFileDetector.class);
/**
* Creates a new TextFileDetector object.
*/
public TextFileDetector()
{
super();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getDisplayName()
{
return "Text File Detector";
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getVersion()
{
return "0.1";
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] getHandledExtensions()
{
return new String[] { "txt", "text" };
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] getHandledTypes()
{
return new String[] { "text/plain" };
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getName()
{
return "textfiledetector";
}
/**
* DOCUMENT ME!
*
* @param data DOCUMENT ME!
* @param offset DOCUMENT ME!
* @param length DOCUMENT ME!
* @param bitmask DOCUMENT ME!
* @param comparator DOCUMENT ME!
* @param mimeType DOCUMENT ME!
* @param params DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] process(byte[] data, int offset, int length, long bitmask, char comparator,
String mimeType, Map<String,String> params)
{
log.debug("processing stream data");
BOMInputStream bomIn = null;
try {
bomIn = new BOMInputStream(new ByteArrayInputStream(data), ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE);
if (bomIn.hasBOM()) {
return new String[] { "text/plain" };
}
} catch (IOException e) {
log.error("TextFileDetector: error detecting byte order mark");
} finally {
IOUtils.closeQuietly(bomIn);
}
try {
String s = new String(data, "UTF-8");
if (!Pattern.matches("/[^[:ascii:][:space:]]/", s)) {
return new String[] { "text/plain" };
}
} catch (UnsupportedEncodingException e) {
log.error("TextFileDetector: failed to process data");
}
return null;
}
/**
* DOCUMENT ME!
*
* @param file DOCUMENT ME!
* @param offset DOCUMENT ME!
* @param length DOCUMENT ME!
* @param bitmask DOCUMENT ME!
* @param comparator DOCUMENT ME!
* @param mimeType DOCUMENT ME!
* @param params DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String[] process(File file, int offset, int length, long bitmask, char comparator,
String mimeType, Map<String,String> params)
{
log.debug("processing file data");
BufferedInputStream is =null;
try {
is = new BufferedInputStream(new FileInputStream(file));
byte[] b = new byte[length];
int n = is.read(b, offset, length);
if (n > 0) {
return process(b, offset, length, bitmask, comparator, mimeType, params);
}
} catch (IOException e) {
log.error("TextFileDetector: error", e);
} finally {
IOUtils.closeQuietly(is);
}
return null;
}
}
================================================
FILE: src/main/java/net/sf/jmimemagic/detectors/package.html
================================================
<html>
<body>
<h1>net.sf.jmimemagic</h1>
This package contains detectors for jmimemagic
</body>
</html>
================================================
FILE: src/main/java/net/sf/jmimemagic/package.html
================================================
<html>
<body>
<h1>net.sf.jmimemagic.detectors</h1>
This package contains the main classes for jmimemagic
</body>
</html>
================================================
FILE: src/main/resources/log4j.properties
================================================
log4j.rootCategory=ERROR, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=jmimemagic.log
log4j.appender.file.MaxFileSize=10000KB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
# Print only messages of priority WARN or above in the package com.foo.
log4j.category.net.sf.jmimemagic=ERROR
================================================
FILE: src/main/resources/magic.dtd
================================================
<!ELEMENT magic (info?,detectorlist)>
<!ELEMENT info (version?,author?,description?)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT detectorlist (detector*)>
<!ELEMENT detector (mimetype,extension,designation,test,childlist?)>
<!ELEMENT extension (#PCDATA)>
<!ELEMENT mimetype (#PCDATA)>
<!ELEMENT designation (#PCDATA)>
<!ELEMENT test (#PCDATA)>
<!ATTLIST test offset CDATA "0">
<!ATTLIST test type CDATA "string">
<!ATTLIST test comparator CDATA "=">
<!ELEMENT childlist (detector+)>
================================================
FILE: src/main/resources/magic.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE magic PUBLIC "-//jmimemagic//DTD magic config 1.0//EN" "magic_1_0.dtd">
<magic>
<info>
<version>0.2</version>
<author>dcastro</author>
<description>magic file</description>
</info>
<match-list>
<match>
<mimetype>audio/mp3</mimetype>
<extension></extension>
<description>MP3</description>
<test type="beshort" offset="0" length="" bitmask="0xfffe" comparator="=">0xfffa</test>
<match-list>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 32 kBits</description>
<property name="bitrate" value="32"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x10</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 40 kBits</description>
<property name="bitrate" value="40"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x20</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 48 kBits</description>
<property name="bitrate" value="48"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x30</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 56 kBits</description>
<property name="bitrate" value="56"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x40</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 64 kBits</description>
<property name="bitrate" value="64"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x50</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 80 kBits</description>
<property name="bitrate" value="80"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x60</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 96 kBits</description>
<property name="bitrate" value="96"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x70</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 112 kBits</description>
<property name="bitrate" value="112"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x80</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 128 kBits</description>
<property name="bitrate" value="128"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0x90</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 160 kBits</description>
<property name="bitrate" value="160"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0xA0</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 192 kBits</description>
<property name="bitrate" value="192"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0xB0</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 224 kBits</description>
<property name="bitrate" value="224"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0xC0</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 256 kBits</description>
<property name="bitrate" value="256"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0xD0</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 320 kBits</description>
<property name="bitrate" value="320"/>
<test type="byte" offset="2" length="" bitmask="0xf0" comparator="=">0xE0</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 44.1 kHz</description>
<property name="samplingrate" value="44.1"/>
<test type="byte" offset="2" length="" bitmask="0x0C" comparator="=">0x00</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 48 kHz</description>
<property name="samplingrate" value="48"/>
<test type="byte" offset="2" length="" bitmask="0x0C" comparator="=">0x04</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, 32 kHz</description>
<property name="samplingrate" value="32"/>
<test type="byte" offset="2" length="" bitmask="0x0C" comparator="=">0x08</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, Stereo</description>
<property name="channels" value="stereo"/>
<test type="byte" offset="3" length="" bitmask="0xC0" comparator="=">0x00</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, JStereo</description>
<property name="channels" value="jstereo"/>
<test type="byte" offset="3" length="" bitmask="0xC0" comparator="=">0x40</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, Dual-Ch</description>
<property name="channels" value="dual"/>
<test type="byte" offset="3" length="" bitmask="0xC0" comparator="=">0x80</test>
</match>
<match>
<mimetype></mimetype>
<extension></extension>
<description>b, Mono</description>
<property name="channels" value="mono"/>
<test type="byte" offset="3" length="" bitmask="0xC0" comparator="=">0xC0</test>
</match>
</match-list>
</match>
<match>
<mimetype>image/gif</mimetype>
<extension></extension>
<description>GIF image data</description>
<test type="string" offset="0" length="" bitmask="" comparator="=">GIF8</test>
<match-list>
<match>
<mimetype>b, version 8%s,</mimetype>
<extension></extension>
<description>b, version 8%s,</description>
<test type="string" offset="4" length="" bitmask="" comparator="=">7a</test>
</match>
<match>
<mimetype>b, version 8%s,</mimetype>
<extension></extension>
<description>b, version 8%s,</description>
<test type="string" offset="4" length="" bitmask="" comparator="=">9a</test>
</match>
</match-list>
</match>
<match>
<mimetype>video/mpeg</mimetype>
<extension>mpg</extension>
<description>MPEG video stream data</description>
<test offset="0" type="belong" comparator="=">0x1b3</test>
</match>
<match>
<mimetype>video/mpeg</mimetype>
<extension>mpg</extension>
<description>MPEG system stream data</description>
<test offset="0" type="belong" comparator="=">0x1ba</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MP</description>
<test offset="0" type="beshort" comparator="&">0xfff0</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b</description>
<test offset="1" type="byte" comparator="=">0x8</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b3</description>
<test offset="1" type="byte" comparator="&">0x2</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 32 kBits</description>
<test offset="2" type="byte" comparator="=">0x10</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 40 kBits</description>
<test offset="2" type="byte" comparator="=">0x20</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 48 kBits</description>
<test offset="2" type="byte" comparator="=">0x30</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 56 kBits</description>
<test offset="2" type="byte" comparator="=">0x40</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 64 kBits</description>
<test offset="2" type="byte" comparator="=">0x50</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 80 kBits</description>
<test offset="2" type="byte" comparator="=">0x60</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 96 kBits</description>
<test offset="2" type="byte" comparator="=">0x70</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>112 kBits</description>
<test offset="2" type="byte" comparator="=">0x80</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>128 kBits</description>
<test offset="2" type="byte" comparator="=">0x90</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>160 kBits</description>
<test offset="2" type="byte" comparator="=">0xa0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>192 kBits</description>
<test offset="2" type="byte" comparator="=">0xb0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>224 kBits</description>
<test offset="2" type="byte" comparator="=">0xc0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>256 kBits</description>
<test offset="2" type="byte" comparator="=">0xd0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>320 kBits</description>
<test offset="2" type="byte" comparator="=">0xe0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b2</description>
<test offset="1" type="byte" comparator="&">0x4</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 32 kBits</description>
<test offset="2" type="byte" comparator="=">0x10</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 48 kBits</description>
<test offset="2" type="byte" comparator="=">0x20</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 56 kBits</description>
<test offset="2" type="byte" comparator="=">0x30</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 64 kBits</description>
<test offset="2" type="byte" comparator="=">0x40</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 80 kBits</description>
<test offset="2" type="byte" comparator="=">0x50</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 96 kBits</description>
<test offset="2" type="byte" comparator="=">0x60</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>112 kBits</description>
<test offset="2" type="byte" comparator="=">0x70</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>128 kBits</description>
<test offset="2" type="byte" comparator="=">0x80</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>160 kBits</description>
<test offset="2" type="byte" comparator="=">0x90</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>192 kBits</description>
<test offset="2" type="byte" comparator="=">0xa0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>224 kBits</description>
<test offset="2" type="byte" comparator="=">0xb0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>256 kBits</description>
<test offset="2" type="byte" comparator="=">0xc0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>320 kBits</description>
<test offset="2" type="byte" comparator="=">0xd0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>384 kBits</description>
<test offset="2" type="byte" comparator="=">0xe0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>44.1 kHz</description>
<test offset="2" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>48 kHz</description>
<test offset="2" type="byte" comparator="=">0x4</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>32 kHz</description>
<test offset="2" type="byte" comparator="=">0x8</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b</description>
<test offset="1" type="byte" comparator="=">0x0</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b3</description>
<test offset="1" type="byte" comparator="&">0x2</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b2</description>
<test offset="1" type="byte" comparator="&">0x4</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 8 kBits</description>
<test offset="2" type="byte" comparator="=">0x10</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 16 kBits</description>
<test offset="2" type="byte" comparator="=">0x20</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 24 kBits</description>
<test offset="2" type="byte" comparator="=">0x30</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 32 kBits</description>
<test offset="2" type="byte" comparator="=">0x40</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 40 kBits</description>
<test offset="2" type="byte" comparator="=">0x50</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 48 kBits</description>
<test offset="2" type="byte" comparator="=">0x60</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 56 kBits</description>
<test offset="2" type="byte" comparator="=">0x70</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 64 kBits</description>
<test offset="2" type="byte" comparator="=">0x80</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 80 kBits</description>
<test offset="2" type="byte" comparator="=">0x90</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description> 96 kBits</description>
<test offset="2" type="byte" comparator="=">0xa0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>112 kBits</description>
<test offset="2" type="byte" comparator="=">0xb0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>128 kBits</description>
<test offset="2" type="byte" comparator="=">0xc0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>144 kBits</description>
<test offset="2" type="byte" comparator="=">0xd0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>160 kBits</description>
<test offset="2" type="byte" comparator="=">0xe0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>22.05 kHz</description>
<test offset="2" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>24 kHz</description>
<test offset="2" type="byte" comparator="=">0x4</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>16 kHz</description>
<test offset="2" type="byte" comparator="=">0x8</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Stereo</description>
<test offset="3" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>JStereo</description>
<test offset="3" type="byte" comparator="=">0x40</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Dual-Ch</description>
<test offset="3" type="byte" comparator="=">0x80</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Mono</description>
<test offset="3" type="byte" comparator="=">0xc0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FLI file</description>
<test offset="4" type="leshort" comparator="=">0xaf11</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>- %d frames,</description>
<test offset="6" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>width=%d pixels,</description>
<test offset="8" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>height=%d pixels,</description>
<test offset="10" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>depth=%d,</description>
<test offset="12" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>ticks/frame=%d</description>
<test offset="16" type="leshort" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FLC file</description>
<test offset="4" type="leshort" comparator="=">0xaf12</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>- %d frames</description>
<test offset="6" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>width=%d pixels,</description>
<test offset="8" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>height=%d pixels,</description>
<test offset="10" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>depth=%d,</description>
<test offset="12" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>ticks/frame=%d</description>
<test offset="16" type="leshort" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Silicon Graphics movie file</description>
<test offset="0" type="string" comparator="=">MOVI</test>
</match>
<match>
<mimetype>video/quicktime</mimetype>
<extension>mov</extension>
<description>Apple QuickTime movie file (moov)</description>
<test offset="4" type="string" comparator="=">moov</test>
</match>
<match>
<mimetype>video/quicktime</mimetype>
<extension>mov</extension>
<description>Apple QuickTime movie file (mdat)</description>
<test offset="4" type="string" comparator="=">mdat</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Applixware</description>
<test offset="0" type="string" comparator="=">*BEGIN</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Words Document</description>
<test offset="7" type="string" comparator="=">WORDS</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Graphic</description>
<test offset="7" type="string" comparator="=">GRAPHICS</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Bitmap</description>
<test offset="7" type="string" comparator="=">RASTER</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Spreadsheet</description>
<test offset="7" type="string" comparator="=">SPREADSHEETS</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Macro</description>
<test offset="7" type="string" comparator="=">MACRO</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Builder Object</description>
<test offset="7" type="string" comparator="=">BUILDER</test>
</match>
</match-list>
</match>
<match>
<mimetype>application/x-tar</mimetype>
<extension>tar</extension>
<description>POSIX tar archive</description>
<test offset="257" type="string" comparator="=">ustar </test>
</match>
<match>
<mimetype>application/x-tar</mimetype>
<extension>tar</extension>
<description>tar archive</description>
<test offset="257" type="string" comparator="=">ustar \000GNU</test>
</match>
<match>
<mimetype>application/vnd.openxmlformats-officedocument.wordprocessingml.document</mimetype>
<extension>docx</extension>
<description>Microsoft Office Open XML Document</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
</match>
<match>
<mimetype>application/vnd.openxmlformats-officedocument.wordprocessingml.document</mimetype>
<extension>docm</extension>
<description>Microsoft Office Open XML Document</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
</match>
<match>
<mimetype>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mimetype>
<extension>xlsx</extension>
<description>Microsoft Office Open XML Workbook</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
</match>
<match>
<mimetype>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mimetype>
<extension>xlsm</extension>
<description>Microsoft Office Open XML Workbook</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
</match>
<match>
<mimetype>application/vnd.openxmlformats-officedocument.presentationml.presentation</mimetype>
<extension>pptx</extension>
<description>Microsoft Office Open XML Workbook</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
</match>
<match>
<mimetype>application/vnd.openxmlformats-officedocument.presentationml.presentation</mimetype>
<extension>pptm</extension>
<description>Microsoft Office Open XML Workbook</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
</match>
<match>
<mimetype>application/zip</mimetype>
<extension>zip</extension>
<description>Zip archive data</description>
<test offset="0" type="string" comparator="=">PK\003\004</test>
<match-list>
<match>
<mimetype>application/zip</mimetype>
<extension>zip</extension>
<description>at least v0.9 to extract</description>
<test offset="4" type="byte" comparator="=">0x9</test>
</match>
<match>
<mimetype>application/zip</mimetype>
<extension>zip</extension>
<description>at least v1.0 to extract</description>
<test offset="4" type="byte" comparator="=">0xa</test>
</match>
<match>
<mimetype>application/zip</mimetype>
<extension>zip</extension>
<description>at least v1.1 to extract</description>
<test offset="4" type="byte" comparator="=">0xb</test>
</match>
<match>
<mimetype>application/zip</mimetype>
<extension>zip</extension>
<description>at least v2.0 to extract</description>
<test offset="4" type="byte" comparator="=">0x14</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Standard MIDI data</description>
<test offset="0" type="string" comparator="=">MThd</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(format %d)</description>
<test offset="9" type="byte" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>using %d tracks</description>
<test offset="11" type="byte" comparator=">">0x1</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Creative Music (CMF) data</description>
<test offset="0" type="string" comparator="=">CTMF</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>SoundBlaster instrument data</description>
<test offset="0" type="string" comparator="=">SBI</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Creative Labs voice data</description>
<test offset="0" type="string" comparator="=">Creative Voice File</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description></description>
<test offset="19" type="byte" comparator="=">0x1a</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>- version %d</description>
<test offset="23" type="byte" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b.%d</description>
<test offset="22" type="byte" comparator=">">0x0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Extended MOD sound data,</description>
<test offset="0" type="string" comparator="=">EMOD</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>version %d</description>
<test offset="4" type="byte" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>\b.%d,</description>
<test offset="4" type="byte" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d instruments</description>
<test offset="45" type="byte" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(module)</description>
<test offset="83" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(song)</description>
<test offset="83" type="byte" comparator="=">0x1</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>realaudio sound file</description>
<test offset="0" type="belong" comparator="=">0x2e7261fd</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>file </description>
<test offset="0" type="string" comparator="=">.RMF\000\000\000realmedia</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>data</description>
<test offset="0" type="string" comparator="=">\037\235compress'd</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>block compressed</description>
<test offset="2" type="byte" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d bits</description>
<test offset="2" type="byte" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>gzip compressed data</description>
<test offset="0" type="string" comparator="=">\037\213</test>
<match-list>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>reserved method,</description>
<test offset="2" type="byte" comparator="<">0x8</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>deflated,</description>
<test offset="2" type="byte" comparator="=">0x8</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>ASCII,</description>
<test offset="3" type="byte" comparator="&">0x1</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>continuation,</description>
<test offset="3" type="byte" comparator="&">0x2</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>extra field,</description>
<test offset="3" type="byte" comparator="&">0x4</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>original filename,</description>
<test offset="3" type="byte" comparator="&">0x8</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>comment,</description>
<test offset="3" type="byte" comparator="&">0x10</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>encrypted,</description>
<test offset="3" type="byte" comparator="&">0x20</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>last modified: %s,</description>
<test offset="4" type="ledate" comparator="="></test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>max compression,</description>
<test offset="8" type="byte" comparator="=">0x2</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>max speed,</description>
<test offset="8" type="byte" comparator="=">0x4</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: MS-DOS</description>
<test offset="9" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: Amiga</description>
<test offset="9" type="byte" comparator="=">0x1</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: VMS</description>
<test offset="9" type="byte" comparator="=">0x2</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: Unix</description>
<test offset="9" type="byte" comparator="=">0x3</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: Atari</description>
<test offset="9" type="byte" comparator="=">0x5</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: OS/2</description>
<test offset="9" type="byte" comparator="=">0x6</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: MacOS</description>
<test offset="9" type="byte" comparator="=">0x7</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: Tops/20</description>
<test offset="9" type="byte" comparator="=">0xa</test>
</match>
<match>
<mimetype>application/x-gzip</mimetype>
<extension>gz</extension>
<description>os: Win/32</description>
<test offset="9" type="byte" comparator="=">0xb</test>
</match>
</match-list>
</match>
<match>
<mimetype>application/x-bzip2</mimetype>
<extension>bz2</extension>
<description>bzip2 compressed data</description>
<test offset="0" type="string" comparator="=">BZh</test>
<match-list>
<match>
<mimetype>application/x-bzip2</mimetype>
<extension>bz2</extension>
<description>block size = %c00k</description>
<test offset="3" type="byte" comparator=">">0x2f</test>
</match>
</match-list>
</match>
<match>
<mimetype>application/x-shockwave-flash</mimetype>
<extension>swf</extension>
<description>Macromedia Flash data,</description>
<test offset="0" type="string" comparator="=">FWS</test>
<match-list>
<match>
<mimetype>application/x-shockwave-flash</mimetype>
<extension>swf</extension>
<description>version %d</description>
<test offset="3" type="byte" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PostScript Type 1 font text</description>
<test offset="0" type="string" comparator="=">%!PS-AdobeFont-1.</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(%s)</description>
<test offset="20" type="string" comparator=">">\000</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PostScript Type 1 font program data</description>
<test offset="6" type="string" comparator="=">%!PS-AdobeFont-1.0</test>
</match>
<match>
<mimetype>application/postscript</mimetype>
<extension>ps</extension>
<description>PostScript Level 2 program data</description>
<test offset="0" type="string" comparator="=">%!PS-Adobe-2.0</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>FrameMaker document</description>
<test offset="0" type="string" comparator="="><MakerFile</test>
<match-list>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>(5.5</description>
<test offset="11" type="string" comparator="=">5.5</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>(5.0</description>
<test offset="11" type="string" comparator="=">5.0</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>(4.0</description>
<test offset="11" type="string" comparator="=">4.0</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>(3.0</description>
<test offset="11" type="string" comparator="=">3.0</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>(2.0</description>
<test offset="11" type="string" comparator="=">2.0</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>(1.0</description>
<test offset="11" type="string" comparator="=">1.0</test>
</match>
<match>
<mimetype>application/vnd.framemaker</mimetype>
<extension>???</extension>
<description>%c)</description>
<test offset="14" type="byte" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FrameMaker MIF (ASCII) file</description>
<test offset="0" type="string" comparator="="><MIFFile</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(4.0)</description>
<test offset="9" type="string" comparator="=">4.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(3.0)</description>
<test offset="9" type="string" comparator="=">3.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(2.0)</description>
<test offset="9" type="string" comparator="=">2.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(1.x)</description>
<test offset="9" type="string" comparator="=">1.0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FrameMaker Dictionary text</description>
<test offset="0" type="string" comparator="="><MakerDictionary</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(3.0)</description>
<test offset="17" type="string" comparator="=">3.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(2.0)</description>
<test offset="17" type="string" comparator="=">2.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(1.x)</description>
<test offset="17" type="string" comparator="=">1.0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FrameMaker Font file</description>
<test offset="0" type="string" comparator="="><MakerScreenFont</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(%s)</description>
<test offset="17" type="string" comparator="=">1.01</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FrameMaker MML file</description>
<test offset="0" type="string" comparator="="><MML</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>FrameMaker Book file</description>
<test offset="0" type="string" comparator="="><BookFile</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(3.0</description>
<test offset="10" type="string" comparator="=">3.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(2.0</description>
<test offset="10" type="string" comparator="=">2.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>(1.0</description>
<test offset="10" type="string" comparator="=">1.0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%c)</description>
<test offset="13" type="byte" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Intermediate Print File FrameMaker IPL file</description>
<test offset="0" type="string" comparator="="><Maker</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>GIMP gradient data</description>
<test offset="0" type="string" comparator="=">GIMP Gradient</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>GIMP XCF image data,</description>
<test offset="0" type="string" comparator="=">gimp xcf file</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%ld x</description>
<test offset="14" type="belong" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%ld,</description>
<test offset="18" type="belong" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>RGB Color</description>
<test offset="22" type="belong" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Greyscale</description>
<test offset="22" type="belong" comparator="=">0x1</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Indexed Color</description>
<test offset="22" type="belong" comparator="=">0x2</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>GIMP pattern data,</description>
<test offset="20" type="string" comparator="=">GPAT</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="24" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>GIMP brush data</description>
<test offset="20" type="string" comparator="=">GIMP</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PBM image text</description>
<test offset="0" type="string" comparator="=">P1</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PGM image text</description>
<test offset="0" type="string" comparator="=">P2</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PPM image text</description>
<test offset="0" type="string" comparator="=">P3</test>
</match>
<match>
<mimetype>image/x-portable-bitmap</mimetype>
<extension>pbm</extension>
<description>PBM "rawbits" image data</description>
<test offset="0" type="string" comparator="=">P4</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PGM "rawbits" image data</description>
<test offset="0" type="string" comparator="=">P5</test>
</match>
<match>
<mimetype>image/x-portable-graymap</mimetype>
<extension>???</extension>
<description>PPM "rawbits" image data</description>
<test offset="0" type="string" comparator="=">P6</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>NIFF image data</description>
<test offset="0" type="string" comparator="=">IIN1</test>
</match>
<match>
<mimetype>image/tiff</mimetype>
<extension>tif</extension>
<description>TIFF image data, big-endian</description>
<test offset="0" type="string" comparator="=">MM\000\052</test>
</match>
<match>
<mimetype>image/tiff</mimetype>
<extension>tif</extension>
<description>TIFF image data, little-endian</description>
<test offset="0" type="string" comparator="=">II\052\000</test>
</match>
<match>
<mimetype>image/tiff</mimetype>
<extension>tiff</extension>
<description>TIFF image data, big-endian</description>
<test offset="0" type="string" comparator="=">MM\000\052</test>
</match>
<match>
<mimetype>image/tiff</mimetype>
<extension>tiff</extension>
<description>TIFF image data, little-endian</description>
<test offset="0" type="string" comparator="=">II\052\000</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>PNG image data,</description>
<test offset="0" type="string" comparator="=">\211NG</test>
<match-list>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>CORRUPTED,</description>
<test offset="4" type="belong" comparator="=">0xd0a1a0a</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description></description>
<test offset="4" type="belong" comparator="=">0xd0a1a0a</test>
<match-list>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>%ld x</description>
<test offset="16" type="belong" comparator="="></test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>%ld,</description>
<test offset="20" type="belong" comparator="="></test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>%d-bit</description>
<test offset="24" type="byte" comparator="="></test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>grayscale,</description>
<test offset="25" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>\b/color RGB,</description>
<test offset="25" type="byte" comparator="=">0x2</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>colormap,</description>
<test offset="25" type="byte" comparator="=">0x3</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>gray+alpha,</description>
<test offset="25" type="byte" comparator="=">0x4</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>\b/color RGBA,</description>
<test offset="25" type="byte" comparator="=">0x6</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>non-interlaced</description>
<test offset="28" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>interlaced</description>
<test offset="28" type="byte" comparator="=">0x1</test>
</match>
</match-list>
</match>
</match-list>
</match>
<match>
<mimetype>image/png</mimetype>
<extension>png</extension>
<description>PNG image data, CORRUPTED</description>
<test offset="1" type="string" comparator="=">PNG</test>
</match>
<match>
<mimetype>image/gif</mimetype>
<extension>gif</extension>
<description>GIF image data</description>
<test offset="0" type="string" comparator="=">GIF8</test>
<match-list>
<match>
<mimetype>image/gif</mimetype>
<extension>gif</extension>
<description>version 8%s,</description>
<test offset="4" type="string" comparator="=">7a</test>
</match>
<match>
<mimetype>image/gif</mimetype>
<extension>gif</extension>
<description>version 8%s,</description>
<test offset="4" type="string" comparator="=">9a</test>
</match>
<match>
<mimetype>image/gif</mimetype>
<extension>gif</extension>
<description>%hd x</description>
<test offset="6" type="leshort" comparator=">">0x0</test>
</match>
<match>
<mimetype>image/gif</mimetype>
<extension>gif</extension>
<description>%hd,</description>
<test offset="8" type="leshort" comparator=">">0x0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>window manager raster image data</description>
<test offset="0" type="string" comparator="=">\361\000@\273CMU</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d x</description>
<test offset="4" type="lelong" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d,</description>
<test offset="8" type="lelong" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d-bit</description>
<test offset="12" type="lelong" comparator=">">0x0</test>
</match>
</match-list>
</match>
<match>
<mimetype>application/x-miff</mimetype>
<extension>miff</extension>
<description>MIFF image data</description>
<test offset="0" type="string" comparator="=">id=ImageMagick</test>
</match>
<match>
<mimetype>image/g3fax</mimetype>
<extension>fax</extension>
<description>group 3 fax data</description>
<test offset="1" type="string" comparator="=">PC Research, Inc</test>
<match-list>
<match>
<mimetype>image/g3fax</mimetype>
<extension>fax</extension>
<description>normal resolution (204x98 DPI)</description>
<test offset="29" type="byte" comparator="=">0x0</test>
</match>
<match>
<mimetype>image/g3fax</mimetype>
<extension>fax</extension>
<description>fine resolution (204x196 DPI)</description>
<test offset="29" type="byte" comparator="=">0x1</test>
</match>
</match-list>
</match>
<match>
<mimetype>image/jpeg</mimetype>
<extension>jpg</extension>
<description>JPEG image data</description>
<test offset="0" type="beshort" comparator="=">0xffd8</test>
<match-list>
<match>
<mimetype>image/jpeg</mimetype>
<extension>jpg</extension>
<description>JFIF standard</description>
<test offset="6" type="string" comparator="=">JFIF</test>
</match>
</match-list>
</match>
<match>
<mimetype>image/jpeg</mimetype>
<extension>jpg</extension>
<description>JPEG image data, HSI proprietary</description>
<test offset="0" type="string" comparator="=">hsi1</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PC icon data</description>
<test offset="0" type="string" comparator="=">IC</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PC pointer image data</description>
<test offset="0" type="string" comparator="=">PI</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PC color icon data</description>
<test offset="0" type="string" comparator="=">CI</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PC color pointer image data</description>
<test offset="0" type="string" comparator="=">CP</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>X pixmap image text</description>
<test offset="0" type="string" comparator="=">/* XPM */</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>iff image data</description>
<test offset="0" type="string" comparator="=">Imagefile version-</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="10" type="string" comparator=">">\000</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Kodak Photo CD image pack file</description>
<test offset="2048" type="string" comparator="=">PCD_IPI</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Kodak Photo CD overview pack file</description>
<test offset="0" type="string" comparator="=">PCD_OPA</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="1536" type="string" comparator="=">Visio (TM) Drawing</test>
</match>
<match>
<mimetype>application/java</mimetype>
<extension>class</extension>
<description>Compiled Java Class Data</description>
<test offset="0" type="belong" comparator="=">0xcafebabe</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Java Class Version 1.2</description>
<test offset="4" type="belong" comparator="=">0x0000002e</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Java Class Version 1.3</description>
<test offset="4" type="belong" comparator="=">0x0000002f</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Java Class Version 1.4</description>
<test offset="4" type="belong" comparator="=">0x00000030</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Java Class Version 1.5</description>
<test offset="4" type="belong" comparator="=">0x00000031</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Java serialization data</description>
<test offset="0" type="beshort" comparator="=">0xaced</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>version %d</description>
<test offset="2" type="beshort" comparator=">">0x4</test>
</match>
</match-list>
</match>
<match>
<mimetype>application/mac-binhex40</mimetype>
<extension>???</extension>
<description>BinHex binary text</description>
<test offset="11" type="string" comparator="=">must be converted with BinHex</test>
<match-list>
<match>
<mimetype>application/mac-binhex40</mimetype>
<extension>???</extension>
<description>version %.3s</description>
<test offset="41" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>StuffIt Archive (data)</description>
<test offset="0" type="string" comparator="=">SIT!</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>StuffIt Archive (rsrc + data)</description>
<test offset="65" type="string" comparator="=">SIT!</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>StuffIt Deluxe (data)</description>
<test offset="0" type="string" comparator="=">SITD</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>StuffIt Deluxe (rsrc + data)</description>
<test offset="65" type="string" comparator="=">SITD</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>StuffIt Deluxe Segment (data)</description>
<test offset="0" type="string" comparator="=">Seg</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>StuffIt Deluxe Segment (rsrc + data)</description>
<test offset="65" type="string" comparator="=">Seg</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>Macintosh PDF File (data)</description>
<test offset="0" type="string" comparator="=">PDF</test>
<match-list>
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>Macintosh PDF File(rsrc + data)</description>
<test offset="65" type="string" comparator="=">PDF</test>
<match-list>
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>: %s</description>
<test offset="2" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MIME entity text</description>
<test offset="0" type="string" comparator="=">MIME-Version:</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description></description>
<test offset="0" type="string" comparator="=">Content-Type:</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="14" type="string" comparator=">">\000</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description></description>
<test offset="0" type="string" comparator="=">Content-Type</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="13" type="string" comparator=">">\000</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MS-DOS batch file text</description>
<test offset="0" type="string" comparator="=">@echo off</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Windows PE</description>
<test offset="128" type="string" comparator="=">PE\000\000MS</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>32-bit</description>
<test offset="150" type="leshort" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>unknown processor</description>
<test offset="132" type="leshort" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Intel 80386</description>
<test offset="132" type="leshort" comparator="=">0x14c</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MIPS R4000</description>
<test offset="132" type="leshort" comparator="=">0x166</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Alpha</description>
<test offset="132" type="leshort" comparator="=">0x184</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Motorola 68000</description>
<test offset="132" type="leshort" comparator="=">0x268</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PowerPC</description>
<test offset="132" type="leshort" comparator="=">0x1f0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PA-RISC</description>
<test offset="132" type="leshort" comparator="=">0x290</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description></description>
<test offset="148" type="leshort" comparator=">">0x1b</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>unknown subsystem</description>
<test offset="220" type="leshort" comparator="=">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>native</description>
<test offset="220" type="leshort" comparator="=">0x1</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>GUI</description>
<test offset="220" type="leshort" comparator="=">0x2</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>console</description>
<test offset="220" type="leshort" comparator="=">0x3</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>POSIX</description>
<test offset="220" type="leshort" comparator="=">0x7</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>executable</description>
<test offset="150" type="leshort" comparator="=">0x0</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>not relocatable</description>
<test offset="150" type="leshort" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>system file</description>
<test offset="150" type="leshort" comparator=">">0x0</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>DLL</description>
<test offset="150" type="leshort" comparator=">">0x0</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>not relocatable</description>
<test offset="150" type="leshort" comparator=">">0x0</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>system file</description>
<test offset="150" type="leshort" comparator=">">0x0</test>
</match>
</match-list>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MS Windows COFF Intel 80386 object file</description>
<test offset="0" type="leshort" comparator="=">0x14c</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MS-DOS executable (EXE)</description>
<test offset="0" type="string" comparator="=">MZ</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>OS/2 or MS Windows</description>
<test offset="24" type="string" comparator="=">@</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="231" type="string" comparator="=">LH/2 Self-Extract</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="233" type="string" comparator="=">PKSFX2</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="122" type="string" comparator="=">Windows self-extracting ZIP</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>ARJ SFX</description>
<test offset="28" type="string" comparator="=">RJSX\377\377b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>diet compressed</description>
<test offset="28" type="string" comparator="=">diet\371\234b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PKSFX</description>
<test offset="30" type="string" comparator="=">Copyright 1989-1990 PKWARE Inc.</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%.6s compressed</description>
<test offset="30" type="string" comparator="=">PKLITE Copr.</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%.15s</description>
<test offset="36" type="string" comparator="=">LHa's SFX</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%.15s</description>
<test offset="36" type="string" comparator="=">LHA's SFX</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>LHa SFX archive v2.13S</description>
<test offset="1638" type="string" comparator="=">-lh5-</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>RAR self-extracting archive</description>
<test offset="7195" type="string" comparator="=">Rar!</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PKZIP SFX archive v1.1</description>
<test offset="11696" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PKZIP SFX archive v1.93a</description>
<test offset="13297" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PKZIP2 SFX archive v1.09</description>
<test offset="15588" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PKZIP SFX archive v2.04g</description>
<test offset="15770" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PKZIP2 SFX archive v1.02</description>
<test offset="28374" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Info-ZIP SFX archive v5.12</description>
<test offset="25115" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Info-ZIP SFX archive v5.12 w/decryption</description>
<test offset="26331" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Info-ZIP SFX archive v5.12</description>
<test offset="47031" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Info-ZIP SFX archive v5.12 w/decryption</description>
<test offset="49845" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Info-ZIP NT SFX archive v5.12 w/decryption</description>
<test offset="69120" type="string" comparator="=">PK\003\004b,</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>CODEC archive v3.21</description>
<test offset="49801" type="string" comparator="=">y\377\200\377v\377b,</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>1 file</description>
<test offset="49824" type="leshort" comparator="=">0x1</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%u files</description>
<test offset="49824" type="leshort" comparator=">">0x1</test>
</match>
</match-list>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MS-DOS executable (built-in)</description>
<test offset="0" type="string" comparator="=">LZ</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Windows NT Registry file</description>
<test offset="0" type="string" comparator="=">regf</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>%s</description>
<test offset="2080" type="string" comparator="=">Microsoft Word 6.0 Document</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Spanish Microsoft Word 6 document data</description>
<test offset="2080" type="string" comparator="=">Documento Microsoft Word 6</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Microsoft Word document data</description>
<test offset="2112" type="string" comparator="=">MSWordDoc</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Microsoft Word Document</description>
<test offset="0" type="belong" comparator="=">0x31be0000</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Microsoft Word 6.0 Document</description>
<test offset="0" type="string" comparator="=">PO^Q`</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Microsoft Office Document</description>
<test offset="0" type="string" comparator="=">\376\067\000\043</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Microsoft Office Document</description>
<test offset="0" type="string" comparator="=">\320\317\021\340\241\261</test>
</match>
<match>
<mimetype>application/msword</mimetype>
<extension>doc</extension>
<description>Microsoft Office Document</description>
<test offset="0" type="string" comparator="=">\333\245-\000\000\000</test>
</match>
<match>
<mimetype>application/msexcel</mimetype>
<extension>???</extension>
<description>%s</description>
<test offset="2080" type="string" comparator="=">Microsoft Excel 5.0 Worksheet</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Microsoft Excel 5.0 Worksheet</description>
<test offset="2114" type="string" comparator="=">Biff5</test>
</match>
<match>
<mimetype>text/xml</mimetype>
<extension>???</extension>
<description>XML 1.0 Document</description>
<test offset="0" type="string" comparator="="><?xml version="1.0"?></test>
<match-list>
<match>
<mimetype>application/msexcel</mimetype>
<extension>???</extension>
<description>Microsoft Excel Spreadsheet</description>
<test offset="23" type="string" comparator="="><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Lotus 1-2-3</description>
<test offset="0" type="belong" comparator="=">0x1a00</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>wk3 document data</description>
<test offset="4" type="belong" comparator="=">0x100400</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>wk4 document data</description>
<test offset="4" type="belong" comparator="=">0x2100400</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>fm3 or fmb document data</description>
<test offset="4" type="belong" comparator="=">0x7800100</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>fm3 or fmb document data</description>
<test offset="4" type="belong" comparator="=">0x7800000</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Lotus 1-2-3</description>
<test offset="0" type="belong" comparator="=">0x200</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>wk1 document data</description>
<test offset="4" type="belong" comparator="=">0x6040600</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>fmt document data</description>
<test offset="4" type="belong" comparator="=">0x6800200</test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>WordPerfect document</description>
<test offset="1" type="string" comparator="=">WPC</test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>MS Windows Help Data</description>
<test offset="0" type="string" comparator="=">?_\003\000</test>
</match>
<!--<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>"compact bitmap" format (Poskanzer)</description>
<test offset="0" type="short" comparator="="></test>
</match>-->
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>PDF document</description>
<test offset="0" type="string" comparator="=">%PDF-</test>
<match-list>
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>version %c</description>
<test offset="5" type="byte" comparator="="></test>
</match>
<match>
<mimetype>application/pdf</mimetype>
<extension>pdf</extension>
<description>\b.%c</description>
<test offset="7" type="byte" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>DOS EPS Binary File</description>
<test offset="0" type="belong" comparator="=">0xc5d0d3c6</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Postscript starts at byte %d</description>
<test offset="4" type="long" comparator=">"></test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>length %d</description>
<test offset="8" type="long" comparator=">"></test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Metafile starts at byte %d</description>
<test offset="12" type="long" comparator=">"></test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>length %d</description>
<test offset="16" type="long" comparator=">"></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>TIFF starts at byte %d</description>
<test offset="20" type="long" comparator=">"></test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>length %d</description>
<test offset="24" type="long" comparator=">"></test>
</match>
</match-list>
</match>
</match-list>
</match>
</match-list>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>PPD file</description>
<test offset="0" type="string" comparator="=">*PPD-Adobe:</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>ve</description>
<test offset="13" type="string" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>RIFF (little-endian) data</description>
<test offset="0" type="string" comparator="=">RIFF</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>palette</description>
<test offset="8" type="string" comparator="=">PAL</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>version %d</description>
<test offset="16" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d entries</description>
<test offset="18" type="leshort" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>device-independent bitmap</description>
<test offset="8" type="string" comparator="=">RDIB</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description></description>
<test offset="16" type="string" comparator="=">BM</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>OS/2 1.x format</description>
<test offset="30" type="leshort" comparator="=">0xc</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d x</description>
<test offset="34" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d</description>
<test offset="36" type="leshort" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>OS/2 2.x format</description>
<test offset="30" type="leshort" comparator="=">0x40</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d x</description>
<test offset="34" type="leshort" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d</description>
<test offset="36" type="leshort" comparator="="></test>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>Windows 3.x format</description>
<test offset="30" type="leshort" comparator="=">0x28</test>
<match-list>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d x</description>
<test offset="34" type="lelong" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d x</description>
<test offset="38" type="lelong" comparator="="></test>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<description>%d</description>
<test offset="44" type="leshort" comparator="="></test>
</match>
</match-list>
</match>
</match-list>
</match>
</match-list>
</match>
<match>
<mimetype>???</mimetype>
<extension>???</extension>
<descript
gitextract_a6vz6836/
├── .gitignore
├── Changelog
├── INFO
├── LICENSE
├── LICENSE_HEADER
├── NOTICE
├── README
├── TODO
├── checkstyle.xml
├── maven.xml
├── pom.xml
├── project.properties
├── project.xml
├── src/
│ ├── main/
│ │ ├── filters/
│ │ │ └── filter.properties
│ │ ├── java/
│ │ │ └── net/
│ │ │ └── sf/
│ │ │ └── jmimemagic/
│ │ │ ├── Magic.java
│ │ │ ├── MagicDetector.java
│ │ │ ├── MagicException.java
│ │ │ ├── MagicMatch.java
│ │ │ ├── MagicMatchNotFoundException.java
│ │ │ ├── MagicMatcher.java
│ │ │ ├── MagicParseException.java
│ │ │ ├── MagicParser.java
│ │ │ ├── UnsupportedTypeException.java
│ │ │ ├── detectors/
│ │ │ │ ├── TextFileDetector.java
│ │ │ │ └── package.html
│ │ │ └── package.html
│ │ └── resources/
│ │ ├── log4j.properties
│ │ ├── magic.dtd
│ │ ├── magic.xml
│ │ ├── magic.xml.basic
│ │ ├── magic.xml.verified
│ │ ├── magic_1_0.dtd
│ │ └── template.xml
│ └── test/
│ └── java/
│ └── net/
│ └── sf/
│ └── jmimemagic/
│ └── MagicTest.java
├── test
└── test_docs/
├── test.au
├── test.dtd
├── test.emf
├── test.eps
├── test.fli
├── test.java
├── test.odt
├── test.ogg
├── test.pcx
├── test.pl
├── test.pnm
├── test.ppm
├── test.ppt
├── test.ps
├── test.psd
├── test.py
├── test.rtf
├── test.sh
├── test.tga
├── test.txt
├── test.wmf
├── test.xcf
├── test.xml
├── test.xpm
├── test_excel.xlsm
├── test_excel.xlsx
├── test_excel_2000.xls
├── test_excel_spreadsheet.xml
├── test_excel_web_archive.mht
├── test_nocompress.tif
├── test_powerpoint.pptm
├── test_powerpoint.pptx
├── test_word.docm
├── test_word.docx
├── test_word_2000.doc
└── test_word_6.0_95.doc
SYMBOL INDEX (158 symbols across 13 files)
FILE: src/main/java/net/sf/jmimemagic/Magic.java
class Magic (line 28) | public class Magic
method Magic (line 38) | public Magic()
method addHint (line 49) | private static void addHint(String extension, MagicMatcher matcher)
method initialize (line 66) | public static synchronized void initialize()
method getMatchers (line 114) | public static Collection<MagicMatcher> getMatchers()
method getMagicMatch (line 151) | public static MagicMatch getMagicMatch(byte[] data)
method getMagicMatch (line 169) | public static MagicMatch getMagicMatch(byte[] data, boolean onlyMimeMa...
method getMagicMatch (line 221) | public static MagicMatch getMagicMatch(File file, boolean extensionHints)
method getMagicMatch (line 240) | public static MagicMatch getMagicMatch(File file, boolean extensionHin...
method printMagicFile (line 362) | public static void printMagicFile(PrintStream stream)
method printMagicMatcher (line 389) | private static void printMagicMatcher(PrintStream stream, MagicMatcher...
method printMagicMatch (line 409) | public static void printMagicMatch(PrintStream stream, MagicMatch matc...
method main (line 436) | public static void main(String[] args)
FILE: src/main/java/net/sf/jmimemagic/MagicDetector.java
type MagicDetector (line 18) | public interface MagicDetector
method getName (line 26) | public String getName();
method getDisplayName (line 34) | public String getDisplayName();
method getVersion (line 42) | public String getVersion();
method getHandledTypes (line 50) | public String[] getHandledTypes();
method getHandledExtensions (line 58) | public String[] getHandledExtensions();
method process (line 74) | public String[] process(byte[] data, int offset, int length, long bitm...
method process (line 91) | public String[] process(File file, int offset, int length, long bitmas...
FILE: src/main/java/net/sf/jmimemagic/MagicException.java
class MagicException (line 14) | public class MagicException extends Exception
method MagicException (line 19) | public MagicException()
method MagicException (line 29) | public MagicException(String message)
method MagicException (line 39) | public MagicException(Throwable cause)
method MagicException (line 50) | public MagicException(String message, Throwable cause)
FILE: src/main/java/net/sf/jmimemagic/MagicMatch.java
class MagicMatch (line 26) | public class MagicMatch implements Cloneable
method MagicMatch (line 48) | public MagicMatch()
method print (line 58) | public String print()
method setMimeType (line 80) | public void setMimeType(String value)
method getMimeType (line 90) | public String getMimeType()
method setExtension (line 100) | public void setExtension(String value)
method getExtension (line 110) | public String getExtension()
method setDescription (line 120) | public void setDescription(String value)
method getDescription (line 130) | public String getDescription()
method setTest (line 140) | public void setTest(ByteBuffer value)
method getTest (line 150) | public ByteBuffer getTest()
method setOffset (line 160) | public void setOffset(int value)
method getOffset (line 170) | public int getOffset()
method setLength (line 180) | public void setLength(int value)
method getLength (line 190) | public int getLength()
method setType (line 200) | public void setType(String value)
method getType (line 210) | public String getType()
method setBitmask (line 220) | public void setBitmask(String value)
method getBitmask (line 232) | public long getBitmask()
method setComparator (line 242) | public void setComparator(String value)
method getComparator (line 252) | public char getComparator()
method setProperties (line 262) | public void setProperties(Map<String,String> properties)
method getProperties (line 272) | public Map<String,String> getProperties()
method addSubMatch (line 282) | public void addSubMatch(MagicMatch m)
method setSubMatches (line 293) | public void setSubMatches(Collection<MagicMatch> a)
method getSubMatches (line 305) | public Collection<MagicMatch> getSubMatches()
method descriptionMatches (line 317) | public boolean descriptionMatches(String desc)
method mimeTypeMatches (line 345) | public boolean mimeTypeMatches(String desc)
method clone (line 373) | protected Object clone()
FILE: src/main/java/net/sf/jmimemagic/MagicMatchNotFoundException.java
class MagicMatchNotFoundException (line 14) | public class MagicMatchNotFoundException extends Exception
method MagicMatchNotFoundException (line 19) | public MagicMatchNotFoundException()
method MagicMatchNotFoundException (line 29) | public MagicMatchNotFoundException(String message)
method MagicMatchNotFoundException (line 39) | public MagicMatchNotFoundException(Throwable cause)
method MagicMatchNotFoundException (line 50) | public MagicMatchNotFoundException(String message, Throwable cause)
FILE: src/main/java/net/sf/jmimemagic/MagicMatcher.java
class MagicMatcher (line 30) | public class MagicMatcher implements Cloneable
method MagicMatcher (line 39) | public MagicMatcher()
method setMatch (line 49) | public void setMatch(MagicMatch match)
method getMatch (line 60) | public MagicMatch getMatch()
method isValid (line 72) | public boolean isValid()
method addSubMatcher (line 100) | public void addSubMatcher(MagicMatcher m)
method setSubMatchers (line 111) | public void setSubMatchers(Collection<MagicMatcher> a)
method getSubMatchers (line 123) | public Collection<MagicMatcher> getSubMatchers()
method test (line 141) | public MagicMatch test(File f, boolean onlyMimeMatch)
method test (line 274) | public MagicMatch test(byte[] data, boolean onlyMimeMatch)
method testInternal (line 375) | private boolean testInternal(byte[] data)
method testByte (line 458) | private boolean testByte(ByteBuffer data)
method testString (line 501) | private boolean testString(ByteBuffer data)
method testShort (line 549) | private boolean testShort(ByteBuffer data)
method testLong (line 604) | private boolean testLong(ByteBuffer data)
method testRegex (line 647) | private boolean testRegex(String text)
method testDetector (line 680) | private boolean testDetector(ByteBuffer data)
method getDetectorExtensions (line 717) | public String[] getDetectorExtensions()
method byteToOctalString (line 748) | private String byteToOctalString(byte b)
method byteArrayToShort (line 767) | private short byteArrayToShort(ByteBuffer data)
method byteArrayToLong (line 779) | private long byteArrayToLong(ByteBuffer data)
method clone (line 791) | protected MagicMatcher clone()
FILE: src/main/java/net/sf/jmimemagic/MagicParseException.java
class MagicParseException (line 14) | public class MagicParseException extends Exception
method MagicParseException (line 19) | public MagicParseException()
method MagicParseException (line 29) | public MagicParseException(String message)
method MagicParseException (line 39) | public MagicParseException(Throwable cause)
method MagicParseException (line 50) | public MagicParseException(String message, Throwable cause)
FILE: src/main/java/net/sf/jmimemagic/MagicParser.java
class MagicParser (line 38) | public class MagicParser extends DefaultHandler implements ContentHandle...
method MagicParser (line 85) | public MagicParser()
method initialize (line 95) | public synchronized void initialize()
method getMatchers (line 181) | public Collection<MagicMatcher> getMatchers()
method startDocument (line 191) | public void startDocument()
method endDocument (line 202) | public void endDocument()
method processingInstruction (line 216) | public void processingInstruction(String target, String data)
method characters (line 231) | public void characters(char[] ch, int offset, int length)
method ignorableWhitespace (line 249) | public void ignorableWhitespace(char[] ch, int offset, int length)
method startElement (line 265) | public void startElement(String uri, String localName, String qname, A...
method endElement (line 378) | public void endElement(String uri, String localName, String qname)
method warning (line 462) | public void warning(SAXParseException ex)
method error (line 475) | public void error(SAXParseException ex)
method fatalError (line 489) | public void fatalError(SAXParseException ex)
method convertOctals (line 503) | private ByteBuffer convertOctals(String s)
FILE: src/main/java/net/sf/jmimemagic/UnsupportedTypeException.java
class UnsupportedTypeException (line 14) | public class UnsupportedTypeException extends Exception
method UnsupportedTypeException (line 19) | public UnsupportedTypeException()
method UnsupportedTypeException (line 29) | public UnsupportedTypeException(String message)
method UnsupportedTypeException (line 39) | public UnsupportedTypeException(Throwable cause)
method UnsupportedTypeException (line 50) | public UnsupportedTypeException(String message, Throwable cause)
FILE: src/main/java/net/sf/jmimemagic/detectors/TextFileDetector.java
class TextFileDetector (line 27) | public class TextFileDetector implements MagicDetector
method TextFileDetector (line 34) | public TextFileDetector()
method getDisplayName (line 44) | public String getDisplayName()
method getVersion (line 54) | public String getVersion()
method getHandledExtensions (line 64) | public String[] getHandledExtensions()
method getHandledTypes (line 74) | public String[] getHandledTypes()
method getName (line 84) | public String getName()
method process (line 102) | public String[] process(byte[] data, int offset, int length, long bitm...
method process (line 145) | public String[] process(File file, int offset, int length, long bitmas...
FILE: src/test/java/net/sf/jmimemagic/MagicTest.java
class MagicTest (line 6) | public class MagicTest extends TestCase {
method main (line 32) | public static void main(String args[]) {
method testGIF (line 38) | public void testGIF() {
method testPNG (line 58) | public void testPNG() {
method testTIF (line 78) | public void testTIF() {
method testJPEG (line 98) | public void testJPEG() {
method testText (line 120) | public void testText() {
method testOfficeOpenXmlDocument (line 140) | public void testOfficeOpenXmlDocument() {
method testOfficeOpenXmlDocument2 (line 160) | public void testOfficeOpenXmlDocument2() {
method testWord2K (line 180) | public void testWord2K() {
method testWord95 (line 200) | public void testWord95() {
method testRTF (line 220) | public void testRTF() {
method testOfficeOpenXmlWorkbook (line 240) | public void testOfficeOpenXmlWorkbook() {
method testOfficeOpenXmlWorkbook2 (line 260) | public void testOfficeOpenXmlWorkbook2() {
method testExcel2K (line 280) | public void testExcel2K() {
method testOfficeOpenXmlPresentation (line 301) | public void testOfficeOpenXmlPresentation() {
method testOfficeOpenXmlPresentation2 (line 321) | public void testOfficeOpenXmlPresentation2() {
method testPDF (line 343) | public void testPDF() {
method testPostscript (line 363) | public void testPostscript() {
method testJavaClass12 (line 383) | public void testJavaClass12() {
method testJavaClass13 (line 403) | public void testJavaClass13() {
method testJavaClass14 (line 423) | public void testJavaClass14() {
method testMP3 (line 443) | public void testMP3() {
method testWave (line 463) | public void testWave() {
method testOdt (line 485) | public void testOdt(){
method testZip (line 506) | public void testZip(){
method testSubMatches (line 527) | public void testSubMatches(){
FILE: test_docs/test.java
class test (line 1) | public class test {
method main (line 2) | public static void main(String[] args) {
FILE: test_docs/test.py
function makepath (line 68) | def makepath(*paths):
function _init_pathinfo (line 105) | def _init_pathinfo():
function addsitedir (line 114) | def addsitedir(sitedir):
function addpackage (line 135) | def addpackage(sitedir, name):
class _Printer (line 216) | class _Printer:
method __init__ (line 219) | def __init__(self, name, data, files=(), dirs=()):
method __setup (line 226) | def __setup(self):
method __repr__ (line 247) | def __repr__(self):
method __call__ (line 254) | def __call__(self):
class _Helper (line 293) | class _Helper:
method __repr__ (line 294) | def __repr__(self):
method __call__ (line 297) | def __call__(self, *args, **kwds):
function _test (line 358) | def _test():
Condensed preview — 71 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (384K chars).
[
{
"path": ".gitignore",
"chars": 54,
"preview": "build.properties\ntarget\n.project\n.classpath\n*.log\nlog\n"
},
{
"path": "Changelog",
"chars": 1428,
"preview": "Changelog\n---------\n\nChanges since 0.1.2\n\t* changing license over to the Apache license, retro-active to \n\t 0.1.2, sinc"
},
{
"path": "INFO",
"chars": 36,
"preview": "\nhttp://sf.net/projects/jmimemagic/\n"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "LICENSE_HEADER",
"chars": 717,
"preview": "/*\njMimeMagic(TM) is a Java library for determining the content type of files or\nstreams. For more information, please "
},
{
"path": "NOTICE",
"chars": 582,
"preview": "jMimeMagic\nCopyright 2003-2017 David Castro\n\nContributions:\n Thanks to the MMBase team (http://www.mmbase.org/) for doi"
},
{
"path": "README",
"chars": 2717,
"preview": "jMimeMagic (TM) v0.1.5\nCopyright (C) 2003-2017, David Castro\nContact: David Castro <arimus@users.sourceforge.net>\n\njMim"
},
{
"path": "TODO",
"chars": 3101,
"preview": "document the new properties concept\n\nin getProperties() for MagicMatch, return all the submatch properties as well\n\nneed"
},
{
"path": "checkstyle.xml",
"chars": 2255,
"preview": "<?xml version=\"1.0\"?>\n<!DOCTYPE module PUBLIC\n \"-//Puppy Crawl//DTD Check Configuration 1.1//EN\"\n \"http://www.pupp"
},
{
"path": "maven.xml",
"chars": 513,
"preview": "<project xmlns:maven=\"jelly:maven\" \r\n\txmlns:ant=\"jelly:ant\" \r\n\txmlns:j=\"jelly:core\" \r\n\txmlns:u=\"jelly:util\" \r\n\txmlns:art"
},
{
"path": "pom.xml",
"chars": 8956,
"preview": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLoc"
},
{
"path": "project.properties",
"chars": 1529,
"preview": "# -------------------------------------------------------------------\n# P R O J E C T P R O P E R T I E S\n# -----------"
},
{
"path": "project.xml",
"chars": 4163,
"preview": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<project>\n\t<pomVersion>3</pomVersion>\n\t<id>jmimemagic</id>\n\t<name>Java Mime "
},
{
"path": "src/main/filters/filter.properties",
"chars": 0,
"preview": ""
},
{
"path": "src/main/java/net/sf/jmimemagic/Magic.java",
"chars": 15298,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicDetector.java",
"chars": 2162,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicException.java",
"chars": 1271,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicMatch.java",
"chars": 9488,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicMatchNotFoundException.java",
"chars": 1286,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicMatcher.java",
"chars": 23453,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicParseException.java",
"chars": 1252,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/MagicParser.java",
"chars": 19368,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/UnsupportedTypeException.java",
"chars": 1265,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/detectors/TextFileDetector.java",
"chars": 3997,
"preview": "/*\njMimeMagic (TM) is a Java Library for determining the content type of files or streams\nCopyright (C) 2003-2017 David "
},
{
"path": "src/main/java/net/sf/jmimemagic/detectors/package.html",
"chars": 106,
"preview": "<html>\n<body>\n\t<h1>net.sf.jmimemagic</h1>\n\tThis package contains detectors for jmimemagic\n</body>\n</html>\n"
},
{
"path": "src/main/java/net/sf/jmimemagic/package.html",
"chars": 123,
"preview": "<html>\n<body>\n\t<h1>net.sf.jmimemagic.detectors</h1>\n\tThis package contains the main classes for jmimemagic\n</body>\n</htm"
},
{
"path": "src/main/resources/log4j.properties",
"chars": 631,
"preview": "log4j.rootCategory=ERROR, file\n\nlog4j.appender.stdout=org.apache.log4j.ConsoleAppender\nlog4j.appender.stdout.layout=org."
},
{
"path": "src/main/resources/magic.dtd",
"chars": 565,
"preview": "<!ELEMENT magic (info?,detectorlist)>\n<!ELEMENT info (version?,author?,description?)>\n<!ELEMENT version (#PCDATA)>\n<!ELE"
},
{
"path": "src/main/resources/magic.xml",
"chars": 111077,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE magic PUBLIC \"-//jmimemagic//DTD magic config 1.0//EN\" \"magic_1_0.dtd\">"
},
{
"path": "src/main/resources/magic.xml.basic",
"chars": 1451,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE magic PUBLIC \"-//jMimeMagic//DTD magic config 1.0//EN\" \"magic_1_0.dtd\">"
},
{
"path": "src/main/resources/magic.xml.verified",
"chars": 17017,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE magic PUBLIC \"-//jmimemagic//DTD magic config 1.0//EN\" \"magic_1_0.dtd\">"
},
{
"path": "src/main/resources/magic_1_0.dtd",
"chars": 593,
"preview": "<!ELEMENT magic (info?,match-list)>\n<!ELEMENT info (version?,author?,description?)>\n<!ELEMENT version (#PCDATA)>\n<!ELEME"
},
{
"path": "src/main/resources/template.xml",
"chars": 3200,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE magic PUBLIC \"-//jmimemagic//DTD magic config 1.0//EN\" \"magic_1_0.dtd\">"
},
{
"path": "src/test/java/net/sf/jmimemagic/MagicTest.java",
"chars": 18157,
"preview": "package net.sf.jmimemagic;\r\n\r\nimport junit.framework.*;\r\nimport java.io.File;\r\n\r\npublic class MagicTest extends TestCase"
},
{
"path": "test",
"chars": 85,
"preview": "#!/bin/sh\n\nmvn exec:java -Dexec.mainClass=\"net.sf.jmimemagic.Magic\" -Dexec.args=\"$1\"\n"
},
{
"path": "test_docs/test.dtd",
"chars": 593,
"preview": "<!ELEMENT magic (info?,match-list)>\n<!ELEMENT info (version?,author?,description?)>\n<!ELEMENT version (#PCDATA)>\n<!ELEME"
},
{
"path": "test_docs/test.eps",
"chars": 6018,
"preview": "%!PS-Adobe-3.0 EPSF-3.0\n%%Creator: GIMP PostScript file plugin V 1.16 by Peter Kirchgessner\n%%Title: /home/arimus/test.e"
},
{
"path": "test_docs/test.java",
"chars": 124,
"preview": "public class test {\n\tpublic static void main(String[] args) {\n\t\tSystem.out.println(\"this is a test java source file\");\n\t"
},
{
"path": "test_docs/test.pl",
"chars": 71,
"preview": "#!/usr/bin/perl -w\n\nuse strict;\n\nprint \"this is a test perl script\\n\";\n"
},
{
"path": "test_docs/test.pnm",
"chars": 2154,
"preview": "P6\n100 100\n255\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
},
{
"path": "test_docs/test.ppm",
"chars": 2154,
"preview": "P6\n100 100\n255\n\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
},
{
"path": "test_docs/test.ps",
"chars": 4296,
"preview": "%!PS-Adobe-2.0\n%%DocumentFonts: Courier Times-Bold\n%%Title: <stdin> (mpage)\n%%Creator: mpage 2.5.1pre2 March 1998\n%%Crea"
},
{
"path": "test_docs/test.py",
"chars": 12091,
"preview": "\"\"\"Append module search paths for third-party packages to sys.path.\n\n***************************************************"
},
{
"path": "test_docs/test.rtf",
"chars": 3244,
"preview": "{\\rtf1\\ansi\\ansicpg1252\\uc1\\deff0\\stshfdbch0\\stshfloch0\\stshfhich0\\stshfbi0\\deflang1033\\deflangfe1033{\\fonttbl{\\f0\\froma"
},
{
"path": "test_docs/test.sh",
"chars": 47,
"preview": "#!/bin/bash\n\necho \"this is a test bash script\"\n"
},
{
"path": "test_docs/test.txt",
"chars": 26,
"preview": "This is a plain text file\n"
},
{
"path": "test_docs/test.xml",
"chars": 1451,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE magic PUBLIC \"-//jMimeMagic//DTD magic config 1.0//EN\" \"magic_1_0.dtd\">"
},
{
"path": "test_docs/test.xpm",
"chars": 22889,
"preview": "/* XPM */\nstatic char * test_xpm[] = {\n\"100 100 152 2\",\n\" \tc #FFFFFF\",\n\". \tc #000000\",\n\"+ \tc #FAFAFA\",\n\"@ \tc #ABABAB\",\n"
},
{
"path": "test_docs/test_excel_spreadsheet.xml",
"chars": 2316,
"preview": "<?xml version=\"1.0\"?>\r\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n xmlns:o=\"urn:schemas-microsoft-c"
},
{
"path": "test_docs/test_excel_web_archive.mht",
"chars": 4579,
"preview": "MIME-Version: 1.0\r\nX-Document-Type: Worksheet\r\nContent-Location: file:///C:/2A65B325/test_excel_web_archive.htm\r\nContent"
}
]
// ... and 21 more files (download for full content)
About this extraction
This page contains the full source code of the arimus/jmimemagic GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 71 files (323.5 KB), approximately 92.6k tokens, and a symbol index with 158 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.