changeset 2305 | a51f5f88f3cf |
parent 2304 | a6e733ad0366 |
child 2309 | 1c106b0d36da |
2304:a6e733ad0366 | 2305:a51f5f88f3cf |
---|---|
37 isLegalNetCommand :: String -> Bool |
37 isLegalNetCommand :: String -> Bool |
38 isLegalNetCommand msg = test decoded |
38 isLegalNetCommand msg = test decoded |
39 where |
39 where |
40 decoded = fromEngineMsg msg |
40 decoded = fromEngineMsg msg |
41 test Nothing = False |
41 test Nothing = False |
42 test (Just "") = False |
|
43 test (Just (m:ms)) = m `Set.member` legalMessages |
42 test (Just (m:ms)) = m `Set.member` legalMessages |
44 legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sFNpPwtghb12345" ++ slotMessages |
43 test _ = False |
44 legalMessages = Set.fromList $ "M#+RrUuDdZzAaSjJ,sFNpPwtghb12345" ++ slotMessages |
|
45 slotMessages = ['\128', '\129', '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137', '\138'] |
45 slotMessages = ['\128', '\129', '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137', '\138'] |
46 |
46 |
47 maybeRead :: Read a => String -> Maybe a |
47 maybeRead :: Read a => String -> Maybe a |
48 maybeRead s = case reads s of |
48 maybeRead s = case reads s of |
49 [(x, rest)] | all isSpace rest -> Just x |
49 [(x, rest)] | all isSpace rest -> Just x |