magic-haskell (1.0.8-8) direct (non packaging) changes

Summary

 INSTALL             |   18 ++++++++++++
 Makefile            |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 README              |   53 ++++++++++++++++++++++++++++++++++++
 testsrc/Inittest.hs |   15 ++++++++++
 testsrc/Tests.hs    |   18 ++++++++++++
 testsrc/runtests.hs |   11 +++++++
 utils/genconsts.hs  |   66 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 257 insertions(+)

    
download this patch

Patch contents

--- magic-haskell-1.0.8.orig/README
+++ magic-haskell-1.0.8/README
@@ -0,0 +1,53 @@
+-------------------------
+What is magic-haskell?
+-------------------------
+
+It is a binding to the C libmagic library.  It allows you to determine
+the type of a file not by looking at its name or extension, but rather
+by examining the contents itself.
+
+libmagic can provide either a textual description or a MIME content
+type (and, occasionally, also a character set.)
+
+The Haskell binding can also provide reports over Haskell strings.
+
+-------------------------
+Quick Start
+-------------------------
+
+See the file INSTALL.
+
+-------------------------
+Usage in programs
+-------------------------
+
+You can simply use -package magic in ghc to enable
+this library.  
+
+The API docs can be built with "make doc", or you can find them at:
+
+http://quux.org/devel/magic-haskell
+
+-------------------------
+Author & Homepage
+-------------------------
+
+magic-haskell was written by John Goerzen <jgoerzen@complete.org>.
+
+The latest version may be obtained at:
+
+   gopher://quux.org/1/devel/magic-haskell
+
+or:
+
+   http://quux.org/devel/magic-haskell
+
+Documentation is also available on that page.
+
+You can also obtain the darcs tree with:
+
+   darcs get --partial http://darcs.complete.org/magic-haskell
+
+This program is copyrighted.
+See the COPYRIGHT and COPYING files for more details.
+
--- magic-haskell-1.0.8.orig/Makefile
+++ magic-haskell-1.0.8/Makefile
@@ -0,0 +1,76 @@
+# Copyright (C) 2004 - 2005 John Goerzen <jgoerzen@complete.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+PROJECT := magic
+
+.PHONY: all
+all: setup
+	./setup configure
+	./setup build
+
+PYTHON ?= python
+setup: Setup.lhs $(PROJECT).cabal
+	ghc -package Cabal Setup.lhs -o setup
+
+
+doc: setup
+	./setup haddock
+
+clean:
+	-./setup clean
+	-rm -rf html `find . -name "*.o"` `find . -name "*.hi"` \
+		`find . -name "*~"` *.a setup dist testsrc/runtests \
+		local-pkg
+	-cd doc && $(MAKE) clean
+
+.PHONY: local-pkg
+local-pkg: all
+	echo "[" > local-pkg
+	cat .installed-pkg-config >> local-pkg
+	echo "]" >> local-pkg
+
+testsrc/runtests: all $(shell find . -name "*.hs") \
+			$(shell find . -name "*.hsc")
+	ghc6 -O2 -o testsrc/runtests -Ldist/build -odir dist/build \
+	   -hidir dist/build -package mtl -idist/build -itestsrc \
+	   -L/usr/lib -L/usr/lib/python2.3/site-packages \
+	   -I/usr/include/python2.3 \
+		-package HUnit --make testsrc/runtests.hs \
+		dist/build/glue/glue.o dist/build/glue/excglue.o -lpython2.3
+
+# dist/build/libHSMissingPy-*
+test-ghc6: testsrc/runtests
+	testsrc/runtests 
+
+test-hugs:
+	runhugs -98 +o -P$(PWD)/libsrc:$(PWD)/testsrc: testsrc/runtests.hs
+
+interact-hugs:
+	hugs -98 +o -Pdist/build:
+
+interact-ghci: all
+	ghci -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -ilibsrc
+
+interact: interact-hugs
+
+test: test-ghc6
+
+genexceptions:
+	runhugs genexceptions.hs
+
+data:
+	runhugs utils/genconsts.hs > Magic/Data.hsc
+
--- magic-haskell-1.0.8.orig/INSTALL
+++ magic-haskell-1.0.8/INSTALL
@@ -0,0 +1,18 @@
+INSTALLATION INSTRUCTIONS
+-------------------------
+
+Before you start, you will need to have libmagic installed.  I have tested
+this package with version 4.12; earlier versions may or may not work.
+
+libmagic is part of the "file" package and can be found at
+ftp://ftp.astron.com/pub/file/.
+
+Now, run "make setup" (you may need to edit the Makefile if you don't
+use GHC or if your GHC is at an unusual location).
+
+Then:
+
+ ./setup configure
+ ./setup build
+ ./setup install
+ 
--- magic-haskell-1.0.8.orig/testsrc/Tests.hs
+++ magic-haskell-1.0.8/testsrc/Tests.hs
@@ -0,0 +1,18 @@
+{- arch-tag: Tests main file
+Copyright (C) 2005 John Goerzen <jgoerzen@complete.org>
+
+This code is under a 3-clause BSD license; see COPYING for details.
+-}
+
+module Tests(tests) where
+import Test.HUnit
+import qualified Inittest
+
+test1 = TestCase ("x" @=? "x")
+
+tests = TestList [TestLabel "test1" test1,
+                  TestLabel "init" Inittest.tests
+                 ]
+
+
+
--- magic-haskell-1.0.8.orig/testsrc/runtests.hs
+++ magic-haskell-1.0.8/testsrc/runtests.hs
@@ -0,0 +1,11 @@
+{- arch-tag: Test runner
+Copyright (C) 2005 John Goerzen <jgoerzen@complete.org>
+-}
+
+module Main where 
+
+import Test.HUnit
+import Tests
+
+main = runTestTT tests
+
--- magic-haskell-1.0.8.orig/testsrc/Inittest.hs
+++ magic-haskell-1.0.8/testsrc/Inittest.hs
@@ -0,0 +1,15 @@
+{-
+Copyright (C) 2005 John Goerzen <jgoerzen@complete.org>
+
+This code is under a 3-clause BSD license; see COPYING for details.
+-}
+
+module Inittest(tests) where
+import Test.HUnit
+import Magic
+
+test_base =
+    let f 
+
+
+tests = [
\ No newline at end of file
--- magic-haskell-1.0.8.orig/utils/genconsts.hs
+++ magic-haskell-1.0.8/utils/genconsts.hs
@@ -0,0 +1,66 @@
+{- -*- Mode: haskell; -*-
+Haskell Magic Interface
+Copyright (C) 2005 John Goerzen <jgoerzen@complete.org>
+
+This code is under a 3-clause BSD license; see COPYING for details.
+-}
+
+import Data.Char
+import Data.List
+
+const2HS (x:xs) =
+    x : c2hs xs
+    where c2hs [] = []
+          c2hs ('_':x:xs) = x : c2hs xs
+          c2hs (x:xs) = toLower x : c2hs xs
+
+getC const = "#{const " ++ const ++ "}"
+
+errorClause name consts =
+    "data " ++ name ++ " =\n   " ++
+    concat (intersperse "\n | " (map toDecl consts)) ++
+    "\n | Unknown" ++ name ++ " Int\n" ++
+    "\n deriving (Show)" ++
+    "\n\ninstance Enum " ++ name ++ " where\n" ++
+    concat (intersperse "\n" (map toenums consts)) ++
+    "\n toEnum x = Unknown" ++ name ++ " x\n" ++
+    "\n" ++ concat (intersperse "\n" (map fromenums consts)) ++
+    "\n fromEnum (Unknown" ++ name ++ " x) = x\n" ++
+    "\ninstance Ord " ++ name ++ " where\n" ++
+    " compare x y = compare (fromEnum x) (fromEnum y)\n\n" ++
+    "instance Eq " ++ name ++ " where\n" ++
+    " x == y = (fromEnum x) == (fromEnum y)\n\n"
+    where
+    toDecl = const2HS
+    toenums i = 
+        " toEnum (" ++ getC i ++ ") = " ++ (const2HS i)
+    fromenums i = 
+        " fromEnum " ++ (const2HS i) ++ " = (" ++ getC i ++ ")"
+
+modHeader = 
+ "-- AUTO-GENERATED FILE, DO NOT EDIT.  GENERATED BY utils/genconsts.hs\n" ++
+ "{- |\n" ++
+ "   Module     : Magic.Data\n" ++
+ "   Copyright  : Copyright (C) 2005 John Goerzen\n" ++
+ "   License    : BSD\n" ++
+ "\n" ++
+ "   Maintainer : John Goerzen,\n" ++
+ "   Maintainer : jgoerzen@complete.org\n" ++
+ "   Stability  : provisional\n" ++
+ "   Portability: portable\n" ++
+ "\n" ++
+ "Haskell types for libmagic constants\n" ++
+ "\n" ++
+ "Written by John Goerzen, jgoerzen\\@complete.org\n" ++
+ "-}\n\n" ++
+ "module Magic.Data (module Magic.Data) where\n" ++
+ "\n#include \"magic.h\"\n\n"
+
+main = 
+    do putStrLn modHeader
+       putStrLn (errorClause "MagicFlag" magicFlags)
+
+magicFlags = ["MAGIC_NONE", "MAGIC_DEBUG", "MAGIC_SYMLINK",
+              "MAGIC_COMPRESS", "MAGIC_DEVICES", "MAGIC_MIME",
+              "MAGIC_CONTINUE", "MAGIC_CHECK",
+              "MAGIC_PRESERVE_ATIME", "MAGIC_RAW", "MAGIC_ERROR"]