Corrected code in case it helps anyone looking at ccall and cfunction for
the first time (fixed unnecessary parens and void return type in functions)
> Using Match
>
> typealias Handle Ptr{Void}
> typealias SessionStatus Cint
>
> lib = string(lib_path,"/../lib/libXC")
>
> dlopen(lib)
>
> function getstatusdescription(v)
> @match v begin
> 0 => "Disconnected"
> 1 => "Connecting"
> 2 => "Connected"
> 3 => "Reconnecting"
> 4 => "Disconnecting"
> 5 => "SessionLost"
> _ => "Unknown Status Returned!"
> end
> end
>
> function onsessionstatuschanged(eSessionStatus::SessionStatus)
> status = getstatusdescription(eSessionStatus)
> println("SessionStatus: $status")
> return
> end
>
> function onloginfailed(error_str::Ptr{Uint8})
> login_error = bytestring(error_str)
>
println("Error: $login_error")
> return
> end
>
>
> const onsessionstatuschanged_c = cfunction(onsessionstatuschanged, Void, (
> SessionStatus,))
> const onloginfailed_c = cfunction(onloginfailed, Void, (Ptr{Uint8},))
>
>
> h_session_listener = ccall((:SessionStatusListener_create, "libXC"),
> Handle, (Ptr{Void}, Ptr{Void}), onsessionstatuschanged_c, onloginfailed_c)
>