diff options
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 3f6dcaf4..232abd6e 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -68,6 +68,7 @@ import Data.Time.Clock.POSIX | |||
68 | showReport :: [(String,String)] -> String | 68 | showReport :: [(String,String)] -> String |
69 | showReport kvs = showColumns $ map (\(x,y)->[x,y]) kvs | 69 | showReport kvs = showColumns $ map (\(x,y)->[x,y]) kvs |
70 | 70 | ||
71 | showColumns :: [[[Char]]] -> [Char] | ||
71 | showColumns rows = do | 72 | showColumns rows = do |
72 | let cols = transpose rows | 73 | let cols = transpose rows |
73 | ws = map (maximum . map (succ . length)) cols | 74 | ws = map (maximum . map (succ . length)) cols |
@@ -247,6 +248,8 @@ forkSearch method nid DHTQuery{qsearch,qshowTok,qshowR} dhtSearches dhtBuckets | |||
247 | modifyTVar' dhtSearches $ Map.insert (method,nid) new | 248 | modifyTVar' dhtSearches $ Map.insert (method,nid) new |
248 | writeTVar kvar $ Just $ searchLoop qsearch nid storeResult st | 249 | writeTVar kvar $ Just $ searchLoop qsearch nid storeResult st |
249 | 250 | ||
251 | reportSearchResults :: (Show t, Ord t1, Ord t, Hashable t) => | ||
252 | String -> Handle -> DHTSearch t1 t -> IO () | ||
250 | reportSearchResults meth h DHTSearch{searchShowTok,searchState,searchResults} = do | 253 | reportSearchResults meth h DHTSearch{searchShowTok,searchState,searchResults} = do |
251 | (ns,rs) <- atomically $ do | 254 | (ns,rs) <- atomically $ do |
252 | mm <- readTVar $ searchInformant searchState | 255 | mm <- readTVar $ searchInformant searchState |
@@ -269,6 +272,7 @@ data Session = Session | |||
269 | , signalQuit :: MVar () | 272 | , signalQuit :: MVar () |
270 | } | 273 | } |
271 | 274 | ||
275 | clientSession :: Session -> t1 -> t -> Handle -> IO () | ||
272 | clientSession s@Session{..} sock cnum h = do | 276 | clientSession s@Session{..} sock cnum h = do |
273 | line <- map toLower . dropWhile isSpace <$> hGetLine h | 277 | line <- map toLower . dropWhile isSpace <$> hGetLine h |
274 | let (c,args) = second (dropWhile isSpace) $ break isSpace line | 278 | let (c,args) = second (dropWhile isSpace) $ break isSpace line |
@@ -464,8 +468,10 @@ readExternals vars = do | |||
464 | -- TODO: Filter to only global addresses? | 468 | -- TODO: Filter to only global addresses? |
465 | return $ filter (not . unspecified) as | 469 | return $ filter (not . unspecified) as |
466 | 470 | ||
471 | defaultPort :: String | ||
467 | defaultPort = "6881" | 472 | defaultPort = "6881" |
468 | 473 | ||
474 | main :: IO () | ||
469 | main = do | 475 | main = do |
470 | args <- getArgs | 476 | args <- getArgs |
471 | p <- case take 2 (dropWhile (/="-p") args) of | 477 | p <- case take 2 (dropWhile (/="-p") args) of |