vt100/hs/NativeMain.hs
main
1module Main (main) where23-- The Therac-25 console program on a real terminal (vt100/src/native_tty.c).45import Foreign.C.Types (CInt (..))6import System.Environment (getArgs)7import System.Exit (ExitCode (..), die, exitWith)89foreign import ccall safe "therac_native_main" nativeMain :: CInt -> IO CInt1011main :: IO ()12main = do13 args <- getArgs14 baud <- case args of15 [] -> pure 960016 ["--baud", n] | [(b, "")] <- reads n, b >= 0 -> pure b17 _ -> die "usage: therac-vt100 [--baud N] (default 9600; 0 = as fast as the terminal takes it)"18 r <- nativeMain (fromIntegral (baud :: Int))19 exitWith (if r == 0 then ExitSuccess else ExitFailure (fromIntegral r))