Created
July 17, 2011 05:53
-
-
Save mitsuji/1087248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HDaemon.Foreign where | |
import System.Environment | |
import Foreign | |
import HDaemon.Server | |
foreignStart :: IO(StablePtr(SHandle)) | |
foreignStart = do | |
logPath <- getLogPath | |
handle <- start logPath | |
ptr <- newStablePtr handle | |
return ptr | |
where | |
getLogPath :: IO(String) | |
getLogPath = do | |
args <- getArgs | |
return(args !! 0) | |
foreignStop :: StablePtr(SHandle) -> IO() | |
foreignStop ptr = do | |
handle <- deRefStablePtr ptr | |
stop handle | |
freeStablePtr ptr | |
foreign export stdcall foreignStart :: IO (StablePtr (SHandle)) | |
foreign export stdcall foreignStop :: StablePtr (SHandle) -> IO() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment