From c4a30e4caf683cadff73dd5658bf76ad379310a7 Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 4 Dec 2013 18:43:33 -0500 Subject: Implemented --import --- kiki.hs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/kiki.hs b/kiki.hs index 7b35ec4..26618c1 100644 --- a/kiki.hs +++ b/kiki.hs @@ -1214,11 +1214,35 @@ main = do cross_merge keyrings $ \(secfile,fstkey) db -> do let grip = grip0 `mplus` (fingerprint <$> fstkey) + + let get_use_db = maybe (return db) import_db + $ Map.lookup "--import" margs + import_db _ = do + forM_ to_alters $ \(_,KeyData c _ _ _) -> + warn $ pubring ++ ": new "++showPacket (packet c) + let db' = Map.union (Map.fromList altered) + db + return db' + where + to_alters = filter (dont_have . snd) $ Map.toList db + altered = map (second append_loc) to_alters + append_loc (KeyData p a b c) = KeyData p' a b c + where p' = p { locations = Map.insert pubring + (origin (packet p) (-1)) + (locations p) + } + dont_have (KeyData p _ _ _) = not . Map.member pubring + $ locations p + use_db <- get_use_db + + let ret_db = Just use_db + let shspec = Map.fromList [("--show-wk", show_wk secfile grip) ,("--show-all",show_all )] shargs = mapMaybe (\x -> listToMaybe x >>= \x ->Map.lookup x shspec) sargs - forM_ shargs $ \cmd -> cmd db - return . Just $ db + + forM_ shargs $ \cmd -> cmd use_db + return $ ret_db return() where -- cgit v1.2.3