From 23dfd840a059877af0ff2538b2d46d85a0842ed9 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 12 Apr 2014 16:47:14 -0400 Subject: changed type of callback passed to cross_merge --- kiki.hs | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/kiki.hs b/kiki.hs index 5fcef99..217f70f 100644 --- a/kiki.hs +++ b/kiki.hs @@ -1324,7 +1324,7 @@ cross_merge doDecrypt keyrings wallets kd f = do let readp n = fmap (n,) (readPacketsFromFile n) readw wk n = fmap (n,) (readPacketsFromWallet wk n) - let pass n = do + let pass = do ms <- mapM readp (rtRings rt) let grip = rtGrip rt `mplus` (fingerprint <$> fstkey) where @@ -1380,24 +1380,13 @@ cross_merge doDecrypt keyrings wallets kd f = do hPutStrLn fh wip db' <- f (rtSecring rt,grip) db (rtPubring rt) - maybe (if n==0 then pass 1 else return (rtRings rt,db)) - (return . (rtRings rt,)) - db' - (fsns,db) <- pass 0 + return (rtRings rt,db') + (fsns,db) <- pass let lkmap = Map.fromList $ map (,()) fsns writeOutKeyrings lkmap db -{- -data Arguments = - Cross_Merge { homedir :: Maybe FilePath - , passphrase_fd :: Maybe Int - , files :: [FilePath] - } - deriving (Show, Data, Typeable) --} - toLast f [] = [] toLast f [x] = [f x] toLast f (x:xs) = x : toLast f xs @@ -1420,11 +1409,7 @@ show_wk secring_file grip db = do show_all db = do let Message packets = flattenKeys True db - -- let ks = filter isKey packets - -- forM_ ks (warn . showPacket) - -- warn $ "BEGIN LIST "++show (length packets)++" packets." putStrLn $ listKeys packets - -- warn $ "END LIST "++show (length packets)++" packets." show_whose_key input_key db = do flip (maybe $ return ()) input_key $ \input_key -> do @@ -1553,8 +1538,6 @@ doExport doDecrypt (db,use_db) (fname,subspec,ms,cmd) = ExitFailure num -> noop $ fname ++ ": failed external (code="++show num++")" ExitSuccess -> do warn $ fname ++ ": generated" - -- return (Nothing,use_db) -- need another pass - -- flip (maybe $ return (Nothing,use_db)) db $ \db -> do db' <- doImport doDecrypt db (fname,subspec,ms,cmd) return (db', use_db) export = do @@ -2451,7 +2434,7 @@ main = do use_db <- foldM (doBTCImport decrypt) use_db pbtcs - (Just -> ret_db,_) <- foldM (doExport decrypt) (use_db,use_db) (map snd exports) + (ret_db,_) <- foldM (doExport decrypt) (use_db,use_db) (map snd exports) use_db <- flip (maybe $ return use_db) @@ -2469,9 +2452,10 @@ main = do use_db <- markForImport margs grip pubring use_db - ret_db <- return $ fmap (const use_db) ret_db + ret_db <- return use_db - ret_db <- flip (maybe $ return ret_db) ret_db $ \db -> do + ret_db <- do + let db = ret_db let hns = maybe [] id $ Map.lookup "--hosts" margs hostdbs0 <- mapM (fmap Hosts.decode . L.readFile) hns @@ -2538,11 +2522,9 @@ main = do when (not $ null d) $ L.writeFile fname $ Hosts.encode h return () - return (Just db') - - flip (maybe $ return ()) ret_db . const $ do + return db' - + do -- On last pass, interpret --show-* commands. let shspec = Map.fromList [("--show-wk", const $ show_wk secfile grip) ,("--show-all",const $ show_all) -- cgit v1.2.3