summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-12-04 18:43:33 -0500
committerjoe <joe@jerkface.net>2013-12-04 18:43:33 -0500
commitc4a30e4caf683cadff73dd5658bf76ad379310a7 (patch)
treeb0843c472f96ba64bb6cd9378b7b49c599cf6fe7
parent0319f5ac37d0d76ad7c0d7d37b9f66a46ee053c8 (diff)
Implemented --import
-rw-r--r--kiki.hs28
1 files 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
1214 1214
1215 cross_merge keyrings $ \(secfile,fstkey) db -> do 1215 cross_merge keyrings $ \(secfile,fstkey) db -> do
1216 let grip = grip0 `mplus` (fingerprint <$> fstkey) 1216 let grip = grip0 `mplus` (fingerprint <$> fstkey)
1217
1218 let get_use_db = maybe (return db) import_db
1219 $ Map.lookup "--import" margs
1220 import_db _ = do
1221 forM_ to_alters $ \(_,KeyData c _ _ _) ->
1222 warn $ pubring ++ ": new "++showPacket (packet c)
1223 let db' = Map.union (Map.fromList altered)
1224 db
1225 return db'
1226 where
1227 to_alters = filter (dont_have . snd) $ Map.toList db
1228 altered = map (second append_loc) to_alters
1229 append_loc (KeyData p a b c) = KeyData p' a b c
1230 where p' = p { locations = Map.insert pubring
1231 (origin (packet p) (-1))
1232 (locations p)
1233 }
1234 dont_have (KeyData p _ _ _) = not . Map.member pubring
1235 $ locations p
1236 use_db <- get_use_db
1237
1238 let ret_db = Just use_db
1239
1217 let shspec = Map.fromList [("--show-wk", show_wk secfile grip) 1240 let shspec = Map.fromList [("--show-wk", show_wk secfile grip)
1218 ,("--show-all",show_all )] 1241 ,("--show-all",show_all )]
1219 shargs = mapMaybe (\x -> listToMaybe x >>= \x ->Map.lookup x shspec) sargs 1242 shargs = mapMaybe (\x -> listToMaybe x >>= \x ->Map.lookup x shspec) sargs
1220 forM_ shargs $ \cmd -> cmd db 1243
1221 return . Just $ db 1244 forM_ shargs $ \cmd -> cmd use_db
1245 return $ ret_db
1222 1246
1223 return() 1247 return()
1224 where 1248 where