summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DNSKey.hs5
-rw-r--r--lib/CommandLine.hs2
-rw-r--r--lib/Hosts.hs4
-rw-r--r--lib/PEM.hs2
4 files changed, 11 insertions, 2 deletions
diff --git a/DNSKey.hs b/DNSKey.hs
index 5c71c16..03767cf 100644
--- a/DNSKey.hs
+++ b/DNSKey.hs
@@ -5,8 +5,7 @@ import Data.Binary.Get
5import Data.Binary.Put 5import Data.Binary.Put
6import Data.Bits 6import Data.Bits
7import qualified Data.ByteString as B 7import qualified Data.ByteString as B
8import qualified Data.ByteString.Lazy as L 8import Data.Int
9import Data.Word
10 9
11-- RSA n e 10-- RSA n e
12-- n = modulus 11-- n = modulus
@@ -14,6 +13,7 @@ import Data.Word
14data RSA = RSA Integer Integer 13data RSA = RSA Integer Integer
15 deriving (Eq,Show) 14 deriving (Eq,Show)
16 15
16getRSA :: Int64 -> Get RSA
17getRSA len = do 17getRSA len = do
18 elen <- do 18 elen <- do
19 tog <- get 19 tog <- get
@@ -27,6 +27,7 @@ getRSA len = do
27 n = snd $ B.foldl' (\(c,a) w8 -> (c-1, a + 256^c * fromIntegral w8)) (nlen-1,0) nbs 27 n = snd $ B.foldl' (\(c,a) w8 -> (c-1, a + 256^c * fromIntegral w8)) (nlen-1,0) nbs
28 return $ RSA n e 28 return $ RSA n e
29 29
30putRSA :: RSA -> PutM ()
30putRSA (RSA n e) = do 31putRSA (RSA n e) = do
31 if elen > 255 || elen==0 32 if elen > 255 || elen==0
32 then do 33 then do
diff --git a/lib/CommandLine.hs b/lib/CommandLine.hs
index 55b77b3..ea5d6b8 100644
--- a/lib/CommandLine.hs
+++ b/lib/CommandLine.hs
@@ -286,6 +286,7 @@ vanilla flags = ArgsStyle { parseInvocation = parse flags }
286-- 286--
287-- * default polyvariadic - Implicit polyvariadic option if no other option is specified. 287-- * default polyvariadic - Implicit polyvariadic option if no other option is specified.
288-- 288--
289fancy :: [([Char], Int)] -> [[Char]] -> [Char] -> ArgsStyle
289fancy sargspsec polyVariadicArgs defaultPoly = ArgsStyle 290fancy sargspsec polyVariadicArgs defaultPoly = ArgsStyle
290 { parseInvocation = parse sargspsec polyVariadicArgs defaultPoly } 291 { parseInvocation = parse sargspsec polyVariadicArgs defaultPoly }
291 where 292 where
@@ -436,6 +437,7 @@ sortOn f =
436#endif 437#endif
437#endif 438#endif
438 439
440removeIntersection :: Ord a => [a] -> [a] -> ([a], [a])
439removeIntersection (x:xs) (y:ys) 441removeIntersection (x:xs) (y:ys)
440 | x == y = removeIntersection xs ys 442 | x == y = removeIntersection xs ys
441 | x < y = first (x :) $ removeIntersection xs (y:ys) 443 | x < y = first (x :) $ removeIntersection xs (y:ys)
diff --git a/lib/Hosts.hs b/lib/Hosts.hs
index 5f09de1..0f1d9a6 100644
--- a/lib/Hosts.hs
+++ b/lib/Hosts.hs
@@ -162,6 +162,7 @@ chaddr n addr hosts =
162 where oo = (.) . (.) 162 where oo = (.) . (.)
163 (a,ws') = splitAt 2 ws 163 (a,ws') = splitAt 2 ws
164 164
165isLonerName :: L.ByteString -> Bool
165isLonerName line = length ws' <= 2 166isLonerName line = length ws' <= 2
166 where (x,_) = L.break (=='#') line 167 where (x,_) = L.break (=='#') line
167 ws = L.groupBy ( (==EQ) `oo` comparing isSpace) x 168 ws = L.groupBy ( (==EQ) `oo` comparing isSpace) x
@@ -186,12 +187,15 @@ cannonizeName name line = scrubName f line
186 where 187 where
187 (pre,rst) = break (==name) ws 188 (pre,rst) = break (==name) ws
188 189
190removeName :: L.ByteString -> Hosts -> Hosts
189removeName name hosts = hosts' 191removeName name hosts = hosts'
190 where 192 where
191 hosts' = scrubTrailingEmpties (maybe hosts (removeName0 name hosts) ns) 193 hosts' = scrubTrailingEmpties (maybe hosts (removeName0 name hosts) ns)
192 ns = Map.lookup name (namenum hosts) 194 ns = Map.lookup name (namenum hosts)
193 195
194 196
197removeName0 :: Foldable t =>
198 L.ByteString -> Hosts -> t Int -> Hosts
195removeName0 name hosts nums = hosts 199removeName0 name hosts nums = hosts
196 { namenum = Map.delete name (namenum hosts) 200 { namenum = Map.delete name (namenum hosts)
197 , numline = foldl' scrub (numline hosts) nums 201 , numline = foldl' scrub (numline hosts) nums
diff --git a/lib/PEM.hs b/lib/PEM.hs
index fd2fe98..003f4ff 100644
--- a/lib/PEM.hs
+++ b/lib/PEM.hs
@@ -20,6 +20,8 @@ data PEMBlob = PEMBlob { pemType :: L.ByteString
20 } 20 }
21 deriving (Eq,Show) 21 deriving (Eq,Show)
22 22
23pemParser :: Maybe L.ByteString
24 -> ScanningParser L.ByteString PEMBlob
23pemParser mtyp = ScanningParser (maybe fndany fndtyp mtyp) pbdy 25pemParser mtyp = ScanningParser (maybe fndany fndtyp mtyp) pbdy
24 where 26 where
25 hdr typ = "-----BEGIN " <> typ <> "-----" 27 hdr typ = "-----BEGIN " <> typ <> "-----"