OpenAFP-Utils 1.3 → 1.3.1
raw patch · 6 files changed
+47/−46 lines, 6 filesdep +iconvdep −haskell98dep −uconvdep ~OpenAFPdep ~base
Dependencies added: iconv
Dependencies removed: haskell98, uconv
Dependency ranges changed: OpenAFP, base
Files
- LICENSE +4/−18
- OpenAFP-Utils.cabal +20/−16
- afp-dump.hs +14/−5
- afp-replace.hs +1/−0
- afp-scanudc.hs +6/−5
- afp-validate.hs +2/−2
LICENSE view
@@ -1,20 +1,6 @@-Copyright 2004-2008 by Audrey Tang--Permission is hereby granted, free of charge, to any person obtaining-a copy of this software and associated documentation files (the-"Software"), to deal in the Software without restriction, including-without limitation the rights to use, copy, modify, merge, publish,-distribute, sublicense, and/or sell copies of the Software, and to-permit persons to whom the Software is furnished to do so, subject to-the following conditions:+To the extent possible under law, 唐鳳 has waived all copyright and+related or neighboring rights to OpenAFP-Utils. -The above copyright notice and this permission notice shall be-included in all copies or substantial portions of the Software.+This work is published from Taiwan. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.+<http://creativecommons.org/publicdomain/zero/1.0>
OpenAFP-Utils.cabal view
@@ -1,6 +1,6 @@ Name: OpenAFP-Utils-Version: 1.3-License: BSD3+Version: 1.3.1+License: PublicDomain License-file: LICENSE Author: Audrey Tang Maintainer: audreyt@audreyt.org@@ -8,64 +8,68 @@ Description: Assorted utilities to work with AFP data streams Category: Data Build-type: Simple-Cabal-Version: >= 1.2+Cabal-Version: >= 1.6 Executable afp2line2pdf Main-is: afp2line2pdf.hs- Build-depends: OpenAFP >= 1.2, haskell98, base, line2pdf >= 0.0.7+ Build-depends: OpenAFP >= 1.3, base, line2pdf >= 0.0.7 Extensions: StandaloneDeriving, GeneralizedNewtypeDeriving, ImplicitParams, ExistentialQuantification, PatternGuards Executable afp-olndump Main-is: afp-olndump.hs- Build-depends: OpenAFP >= 1.2, haskell98, base, bytestring, containers, binary+ Build-depends: OpenAFP >= 1.3, base, bytestring, containers, binary Executable afp-dump Main-is: afp-dump.hs- Build-depends: OpenAFP >= 1.2, haskell98, base, bytestring, containers, uconv, xhtml+ Build-depends: OpenAFP >= 1.3, base, bytestring, containers, iconv, xhtml Extensions: DeriveDataTypeable, PatternGuards Executable afp-page Main-is: afp-page.hs- Build-depends: OpenAFP >= 1.2, haskell98, base+ Build-depends: OpenAFP >= 1.3, base Executable afp-replace Main-is: afp-replace.hs- Build-depends: OpenAFP >= 1.2, haskell98, base+ Build-depends: OpenAFP >= 1.3, base Extensions: DeriveDataTypeable, FlexibleContexts, PatternGuards Executable afp-scanudc Main-is: afp-scanudc.hs- Build-depends: OpenAFP >= 1.2, haskell98, base>=3 && <4, directory+ Build-depends: OpenAFP >= 1.3, base >= 4 && < 5, directory Extensions: BangPatterns, PatternGuards Executable afp-split Main-is: afp-split.hs- Build-depends: OpenAFP >= 1.2, haskell98, base+ Build-depends: OpenAFP >= 1.3, base Executable afp-split-scb Main-is: afp-split-scb.hs- Build-depends: OpenAFP >= 1.2, haskell98, base+ Build-depends: OpenAFP >= 1.3, base Executable afp-split-tcb Main-is: afp-split-tcb.hs- Build-depends: OpenAFP >= 1.2, haskell98, base, filepath+ Build-depends: OpenAFP >= 1.3, base, filepath Extensions: ImplicitParams Executable afp-type Main-is: afp-type.hs- Build-depends: OpenAFP >= 1.2, haskell98, base+ Build-depends: OpenAFP >= 1.3, base Executable afp-udcfix Main-is: afp-udcfix.hs- Build-depends: OpenAFP >= 1.2, haskell98, base, regex-base, regex-posix+ Build-depends: OpenAFP >= 1.3, base, regex-base, regex-posix Extensions: DeriveDataTypeable, MultiParamTypeClasses, FlexibleContexts, PatternGuards, RankNTypes Executable afp-validate Main-is: afp-validate.hs- Build-depends: OpenAFP >= 1.2, haskell98, base>=3 && <4+ Build-depends: OpenAFP >= 1.3, base >= 4 && < 5 Executable afp2line Main-is: afp2line.hs- Build-depends: OpenAFP >= 1.2, haskell98, base+ Build-depends: OpenAFP >= 1.3, base Extensions: GeneralizedNewtypeDeriving ++source-repository head+ type: git+ location: git://github.com/audreyt/openafp-utils.git
afp-dump.hs view
@@ -1,9 +1,10 @@ module Main where import Text.XHtml-import Codec.Text.UConv+import Codec.Text.IConv import OpenAFP hiding ((!)) import qualified Data.Set as Set import qualified Data.ByteString as S+import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Char8 as C import qualified Data.HashTable as H @@ -154,25 +155,33 @@ typeHtml' t = thediv << (typeStr +++ primHtml " — " +++ typeDesc) where typeStr = bold << reverse (takeWhile (/= '.') (reverse typeRepr))- typeDesc = stringToHtml $ descLookup (MkChunkType $ typeInt t)+ typeDesc = stringToHtml $ descLookup (mkChunkType t) typeRepr = show t ptxHtml :: [N1] -> [Html] ptxHtml nstr = [table << textHtml] where textHtml = textLine ++ [ nstrLine ]- textLine = [ fieldHtml (ViewField (C.pack $ "(" ++ n ++ ")") (ViewString (typeOf ()) (C.pack txt))) | (n, txt) <- texts nstr ]+ textLine = [ fieldHtml (ViewField (C.pack $ "(" ++ n ++ ")") (ViewString (typeOf ()) txt)) | (n, txt) <- texts nstr ] nstrLine = tr << td ! [colspan 2] << thespan << nstrHtml nstr +texts :: [N1] -> [(String, ByteString)] texts nstr = maybeToList $ msum [ maybe Nothing (Just . ((,) cp)) $ conv (codeName cp) | cp <- encs ] where conv c@"ibm-937"- | (even $ length nstr) = convert c "utf8" (packNStr $ toNStr (0x0E : nstr))+ | (even $ length nstr) = convert' c "utf8" (packNStr $ toNStr (0x0E : nstr)) | otherwise = Nothing- conv c = convert c "utf8" (packNStr $ toNStr nstr)+ conv c = convert' c "utf8" (packNStr $ toNStr nstr) codeName c | isJust $ find (not . isDigit) c = c | otherwise = "ibm-" ++ c++convert' :: String -> String -> ByteString -> Maybe ByteString+convert' from to str = case convertStrictly from to strLazy of+ Left resLazy -> Just $ S.concat (L.toChunks resLazy)+ _ -> Nothing+ where+ strLazy = L.fromChunks [str] fieldsHtml :: [ViewField] -> [Html] fieldsHtml fs = [table << fsHtml] ++ membersHtml
afp-replace.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable, FlexibleContexts #-} module Main where import OpenAFP import qualified Data.ByteString.Lazy as L
afp-scanudc.hs view
@@ -48,18 +48,19 @@ scanUDC :: FilePath -> IO Bool scanUDC file = do- rv <- E.try $ readAFP file+ rv <- E.try $ readAFP file :: IO (Either SomeException [AFP_]) case rv of Right cs -> (`E.catch` hdl) $ do let ptxs = length cs `seq` filter (~~ _PTX) cs mapM_ (scanPTX . decodeChunk) ptxs return False- _ -> return False -- skip non-afp files+ _ -> return False -- skip non-afp files where tryOpen = openBinaryFile file ReadMode `E.catch` tryErr- tryErr (E.IOException ioe) | isFullError ioe = threadDelay 200 >> tryOpen- tryErr e = E.throwIO e- hdl (E.IOException ioe) | Just e <- cast ioe, isUserError e = return True+ tryErr e | Just ioe <- cast e, isFullError ioe = threadDelay 200 >> tryOpen+ tryErr e = E.throwIO (e :: SomeException)+ hdl :: SomeException -> IO Bool+ hdl e | Just ioe <- cast e, isUserError ioe = return True hdl _ = return False scanPTX :: PTX -> IO ()
afp-validate.hs view
@@ -1,7 +1,7 @@ module Main where import OpenAFP import System.Exit-import qualified Control.Exception as E (try, catch, throwIO)+import qualified Control.Exception as E (try, catch, throwIO, SomeException) main :: IO () main = do@@ -26,7 +26,7 @@ case rv of Right ok -> return ok Left err -> do- print err+ print (err :: E.SomeException) return False if and oks then exitWith ExitSuccess