omnicodec 0.2 → 0.3
raw patch · 3 files changed
+21/−9 lines, 3 filesdep ~basedep ~dataenc
Dependency ranges changed: base, dataenc
Files
- omnicodec.cabal +2/−2
- src/odec.hs +10/−4
- src/oenc.hs +9/−3
omnicodec.cabal view
@@ -1,5 +1,5 @@ name: omnicodec-version: 0.2+version: 0.3 license: GPL license-file: COPYING author: Magnus Therning@@ -7,7 +7,7 @@ copyright: Magnus Therning, 2007 synopsis: data encoding and decoding command line utilities description: Two simply command line tools built on dataenc.-build-depends: base, dataenc >= 0.11, directory, filepath, haskell98+build-depends: base >= 4.0.0 && < 4.2, dataenc >= 0.13, directory, filepath, haskell98 build-type: Simple category: Codec
src/odec.hs view
@@ -22,15 +22,18 @@ import Codec.Binary.DataEncoding import Data.Char import Data.Maybe+import Data.Version (showVersion) import Data.Word import System import System.Console.GetOpt import Control.Exception as CE import System.Directory -ver = "omnicode decode (odec) 0.1\n\- \Copyright 2007 Magnus Therning <magnus@therning.org>"+import Paths_omnicodec (version) +ver = "omnicode decode (odec) " ++ (showVersion version)+ ++ "\nCopyright 2007-2009 Magnus Therning <magnus@therning.org>"+ -- {{{1 Options data DecOptions = DecOptions { optDecode :: [String] -> [Maybe Word8],@@ -50,7 +53,7 @@ options :: [OptDescr (DecOptions -> IO DecOptions)] options = [ Option "o" ["output"] (ReqArg setOptOutput "FILE") "output to file",- Option "c" ["codec"] (ReqArg setOptCodec "CODEC") "use codec (uu,b85,b64,b64u,b32,b32h,b16)",+ Option "c" ["codec"] (ReqArg setOptCodec "CODEC") "use codec (uu,xx,qp,py,b85,b64,b64u,b32,b32h,b16)", Option "" ["version"] (NoArg optShowVersion) "", Option "h" ["help"] (NoArg optShowHelp) "" ]@@ -59,6 +62,9 @@ setOptOutput fn opts = return opts { optWrite = writeFile fn, fn = Just fn } setOptCodec codec opts = case codec of "uu" -> return opts { optDecode = decode' uu . unchop uu }+ "xx" -> return opts { optDecode = decode' xx . unchop xx }+ "qp" -> return opts { optDecode = decode' qp . unchop qp }+ "py" -> return opts { optDecode = decode' py . unchop py } "b85" -> return opts { optDecode = decode' base85 . unchop base85 } "b64" -> return opts { optDecode = decode' base64 . unchop base64 } "b64u" -> return opts { optDecode = decode' base64Url . unchop base64Url }@@ -84,4 +90,4 @@ let (actions, nonOpts, msgs) = getOpt RequireOrder options args opts <- foldl (>>=) (processFileName nonOpts) actions CE.catch (optRead opts >>= _decode opts >>= optWrite opts)- (\ e -> maybe (return ()) removeFile (fn opts) >> throwIO e)+ (\ (CE.SomeException e) -> maybe (return ()) removeFile (fn opts) >> throwIO e)
src/oenc.hs view
@@ -22,15 +22,18 @@ import Codec.Binary.DataEncoding import Control.Monad import Data.Char+import Data.Version (showVersion) import Data.Word import Numeric import System import System.Console.GetOpt import System.FilePath -ver = "omnicode encode (oenc) 0.1\n\- \Copyright 2007 Magnus Therning <magnus@therning.org>"+import Paths_omnicodec (version) +ver = "omnicode encode (oenc) " ++ (showVersion version)+ ++ "\nCopyright 2007-2009 Magnus Therning <magnus@therning.org>"+ -- {{{1 Options data EncOptions = EncOptions { optEncode :: [Word8] -> [String],@@ -47,7 +50,7 @@ options :: [OptDescr (EncOptions -> IO EncOptions)] options = [ Option "o" ["output"] (ReqArg setOptOutput "FILE") "output to file",- Option "c" ["codec"] (ReqArg setOptCodec "CODEC") "use codec (uu,b85,b64,b64u,b32,b32h,b16)",+ Option "c" ["codec"] (ReqArg setOptCodec "CODEC") "use codec (uu,xx,qp,py,b85,b64,b64u,b32,b32h,b16)", Option "" ["version"] (NoArg optShowVersion) "", Option "h" ["help"] (NoArg optShowHelp) "" ]@@ -55,6 +58,9 @@ -- {{{2 option actions setOptCodec codec opts = case codec of "uu" -> return opts { optEncode = chop uu 61 . encode uu }+ "xx" -> return opts { optEncode = chop xx 61 . encode xx }+ "qp" -> return opts { optEncode = chop qp 60 . encode qp }+ "py" -> return opts { optEncode = chop py 60 . encode py } "b85" -> return opts { optEncode = chop base85 60 . encode base85 } "b64" -> return opts { optEncode = chop base64 60 . encode base64 } "b64u" -> return opts { optEncode = chop base64Url 60 . encode base64Url }