packages feed

curlhs (empty) → 0.0.1

raw patch · 10 files changed

+3845/−0 lines, 10 filesdep +basedep +bytestringdep +timebuild-type:Customsetup-changed

Dependencies added: base, bytestring, time

Files

+ LICENSE view
@@ -0,0 +1,13 @@+Copyright (c) 2012 Krzysztof Kardzis++Permission to use, copy, modify, and/or distribute this software for any+purpose with or without fee is hereby granted, provided that the above+copyright notice and this permission notice appear in all copies.++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ Network/Curlhs/Base.hsc view
@@ -0,0 +1,1819 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  Network.Curlhs.Base+-- Copyright   :  Copyright © 2012 Krzysztof Kardzis+-- License     :  ISC License (MIT/BSD-style, see LICENSE file for details)+-- +-- Maintainer  :  Krzysztof Kardzis <kkardzis@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+--+--+-- Module "Network.Curlhs.Base" provides a direct low-level bindings to+-- @libcurl@. It is basically a 1:1 mapping of the @libcurl@'s C API,+-- a direct translation of \"curl/curl.h\" header files to Haskell FFI.+-- A higher level interface, without ubiquitous pointers and all of that+-- C stuff, is provided through the module "Network.Curlhs.Core".+--+-- Documentation about the library and/or particular functions may be found+-- in the @libcurl@'s manual pages or on the @libcurl@'s project site+-- (<http://curl.haxx.se/libcurl/>). Because API of this module mirrors API+-- of the external library, particular symbols may exist or not,+-- dependently of that, which version of @libcurl@ is used during compilation+-- of the package. The module as closely as possible tries to follow+-- the original @libcurl@ API. The main differences are in types of functions+-- such as @curl_easy_setopt@ and @curl_easy_getinfo@. Besides that all+-- symbol names are prefixed with \'c\' or \'C\'. +--+-- As the name of the module may suggest, this module is a basis for the+-- rest of @curlhs@ package. For now exposed API is somewhat incomplete,+-- still lacks some things (like the \"multi interface\"), but the aim is+-- to provide here a complete API of @libcurl@, as defined in its C headers.+--+-------------------------------------------------------------------------------++{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE EmptyDataDecls           #-}++module Network.Curlhs.Base where++import Foreign.C.Types  (CChar, CInt, CUInt, CLong, CLLong, CDouble)+import Foreign.C.Types  (CSize, CFile, CTime)+import Foreign.Ptr      (Ptr, FunPtr, castPtr)+import Foreign.Storable (Storable (..))++import Control.Applicative ((<$>), (<*>))++#if defined(WIN32) && !defined(__LWIP_OPT_H__)+import Foreign.C.Types  (CUIntPtr)+#endif+++-------------------------------------------------------------------------------+#{let alignof type = "(%ld)", (long) offsetof (struct {char x; type y;}, y)}++#define CURL_NO_OLDIES+#include "curl/curl.h"++#define hsc_symbol(name, type) \+  printf("c" #name " :: C" #type "\n"); \+  printf("c" #name " =  C" #type " "); hsc_const(name);++#define hsc_cconst(name, type) \+  printf("c" #name " :: " #type "\n"); \+  printf("c" #name " =  "); hsc_const(name);+++-------------------------------------------------------------------------------+-- * Definitions from \"curl/curlver.h\"+-------------------------------------------------------------------------------+libCURL_COPYRIGHT :: String+libCURL_COPYRIGHT = #{const_str LIBCURL_COPYRIGHT}++libCURL_TIMESTAMP :: String+libCURL_TIMESTAMP = #{const_str LIBCURL_TIMESTAMP}++libCURL_VERSION   :: String+libCURL_VERSION   = #{const_str LIBCURL_VERSION  }++libCURL_VERSION_NUM   :: Int+libCURL_VERSION_NUM   = #{const LIBCURL_VERSION_NUM  }++libCURL_VERSION_MAJOR :: Int+libCURL_VERSION_MAJOR = #{const LIBCURL_VERSION_MAJOR}++libCURL_VERSION_MINOR :: Int+libCURL_VERSION_MINOR = #{const LIBCURL_VERSION_MINOR}++libCURL_VERSION_PATCH :: Int+libCURL_VERSION_PATCH = #{const LIBCURL_VERSION_PATCH}+++-------------------------------------------------------------------------------+-- * Definitions from \"curl/curlbuild.h\"+-------------------------------------------------------------------------------+type CCURL_off_t = CLLong  -- ??+++-------------------------------------------------------------------------------+-- * Definitions from \"curl/curlrules.h\"+-------------------------------------------------------------------------------+-- todo+++-------------------------------------------------------------------------------+-- * Definitions from \"curl/curl.h\"+-------------------------------------------------------------------------------+data CCURL+++-------------------------------------------------------------------------------+#if defined(WIN32) && !defined(__LWIP_OPT_H__)+type CCURL_socket_t = CUIntPtr -- SOCKET??+#else+type CCURL_socket_t = CInt+#endif++#{cconst CURL_SOCKET_BAD, CCURL_socket_t}+++-------------------------------------------------------------------------------+-- ** CURL_httppost+-------------------------------------------------------------------------------+data CCURL_httppost = CCURL_httppost+  { ccurl_httppost_next           :: Ptr CCURL_httppost+  , ccurl_httppost_name           :: Ptr CChar+  , ccurl_httppost_namelength     :: CLong+  , ccurl_httppost_contents       :: Ptr CChar+  , ccurl_httppost_contentslength :: CLong+  , ccurl_httppost_buffer         :: Ptr CChar+  , ccurl_httppost_bufferlength   :: CLong+  , ccurl_httppost_contenttype    :: Ptr CChar+  , ccurl_httppost_contentheader  :: Ptr CCURL_slist+  , ccurl_httppost_more           :: Ptr CCURL_httppost+  , ccurl_httppost_flags          :: CLong+  , ccurl_httppost_showfilename   :: Ptr CChar+  , ccurl_httppost_userp          :: Ptr ()+  } deriving (Show)++-- instance Storable CCURL_httppost where+--   sizeOf _    = #{size    struct curl_httppost}+--   alignment _ = #{alignof struct curl_httppost}+--   poke _ _    = undefined+--   peek _      = undefined++#{cconst HTTPPOST_FILENAME   , CLong}+#{cconst HTTPPOST_READFILE   , CLong}+#{cconst HTTPPOST_PTRNAME    , CLong}+#{cconst HTTPPOST_PTRCONTENTS, CLong}+#{cconst HTTPPOST_BUFFER     , CLong}+#{cconst HTTPPOST_PTRBUFFER  , CLong}+#{cconst HTTPPOST_CALLBACK   , CLong}+ +-------------------------------------------------------------------------------+-- ** Callbacks+-------------------------------------------------------------------------------+-- *** CURL_progress_callback+-------------------------------------------------------------------------------+type CCURL_progress_callback+  = Ptr () -> CDouble -> CDouble -> CDouble -> CDouble -> IO CInt++foreign import ccall "wrapper"+  wrap_ccurl_progress_callback+    :: CCURL_progress_callback+    -> IO (FunPtr CCURL_progress_callback)+++-------------------------------------------------------------------------------+-- *** CURL_write_callback+-------------------------------------------------------------------------------+#{cconst CURL_MAX_WRITE_SIZE , CSize}+#{cconst CURL_MAX_HTTP_HEADER, CSize}+#{cconst CURL_WRITEFUNC_PAUSE, CSize}++type CCURL_write_callback+  = Ptr CChar -> CSize -> CSize -> Ptr () -> IO CSize++foreign import ccall "wrapper"+  wrap_ccurl_write_callback+    :: CCURL_write_callback+    -> IO (FunPtr CCURL_write_callback)+++-------------------------------------------------------------------------------+-- ** CURL_fileinfo+-------------------------------------------------------------------------------+newtype CCURLfiletype = CCURLfiletype CInt deriving (Eq, Show)   |7210:----|++#{symbol CURLFILETYPE_FILE        , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_DIRECTORY   , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_SYMLINK     , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_DEVICE_BLOCK, CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_DEVICE_CHAR , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_NAMEDPIPE   , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_SOCKET      , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_DOOR        , CURLfiletype}                |7210:----|+#{symbol CURLFILETYPE_UNKNOWN     , CURLfiletype}                |7210:----|++#{cconst CURLFINFOFLAG_KNOWN_FILENAME  , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_FILETYPE  , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_TIME      , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_PERM      , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_UID       , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_GID       , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_SIZE      , CUInt}                  |7210:----|+#{cconst CURLFINFOFLAG_KNOWN_HLINKCOUNT, CUInt}                  |7210:----|++data CCURL_fileinfo = CCURL_fileinfo                             |7210:----|+  { ccurl_fileinfo_filename       :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_filetype       :: CCURLfiletype               |7210:----|+  , ccurl_fileinfo_time           :: CTime                       |7210:----|+  , ccurl_fileinfo_perm           :: CUInt                       |7210:----|+  , ccurl_fileinfo_uid            :: CInt                        |7210:----|+  , ccurl_fileinfo_gid            :: CInt                        |7210:----|+  , ccurl_fileinfo_size           :: CCURL_off_t                 |7210:----|+  , ccurl_fileinfo_hardlinks      :: CLong                       |7210:----|+  , ccurl_fileinfo_strings_time   :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_strings_perm   :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_strings_user   :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_strings_group  :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_strings_target :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_flags          :: CUInt                       |7210:----|+  , ccurl_fileinfo_b_data         :: Ptr CChar                   |7210:----|+  , ccurl_fileinfo_b_size         :: CSize                       |7210:----|+  , ccurl_fileinfo_b_used         :: CSize                       |7210:----|+  } deriving (Show)                                              |7210:----|++-- instance Storable CCURL_fileinfo where                        |7210:----|+--   sizeOf _    = #{size    struct curl_fileinfo}               |7210:----|+--   alignment _ = #{alignof struct curl_fileinfo}               |7210:----|+--   poke _ _    = undefined                                     |7210:----|+--   peek _      = undefined                                     |7210:----|++ +-------------------------------------------------------------------------------+-- ** Callbacks+-------------------------------------------------------------------------------+-- *** CURL_chunk_bgn_callback+-------------------------------------------------------------------------------+#{cconst CURL_CHUNK_BGN_FUNC_OK  , CLong}                        |7210:----|+#{cconst CURL_CHUNK_BGN_FUNC_FAIL, CLong}                        |7210:----|+#{cconst CURL_CHUNK_BGN_FUNC_SKIP, CLong}                        |7210:----|++type CCURL_chunk_bgn_callback                                    |7210:----|+  = Ptr () -> Ptr () -> CInt -> IO CLong                         |7210:----|++foreign import ccall "wrapper"                                   |7210:----|+  wrap_ccurl_chunk_bgn_callback                                  |7210:----|+    :: CCURL_chunk_bgn_callback                                  |7210:----|+    -> IO (FunPtr CCURL_chunk_bgn_callback)                      |7210:----|+++-------------------------------------------------------------------------------+-- *** CURL_chunk_end_callback+-------------------------------------------------------------------------------+#{cconst CURL_CHUNK_END_FUNC_OK  , CLong}                        |7210:----|+#{cconst CURL_CHUNK_END_FUNC_FAIL, CLong}                        |7210:----|++type CCURL_chunk_end_callback                                    |7210:----|+  = Ptr () -> IO CLong                                           |7210:----|++foreign import ccall "wrapper"                                   |7210:----|+  wrap_ccurl_chunk_end_callback                                  |7210:----|+    :: CCURL_chunk_end_callback                                  |7210:----|+    -> IO (FunPtr CCURL_chunk_end_callback)                      |7210:----|++ +-------------------------------------------------------------------------------+-- *** CURL_fnmatch_callback+-------------------------------------------------------------------------------+#{cconst CURL_FNMATCHFUNC_MATCH  , CInt}                         |7210:----|+#{cconst CURL_FNMATCHFUNC_NOMATCH, CInt}                         |7210:----|+#{cconst CURL_FNMATCHFUNC_FAIL   , CInt}                         |7210:----|++type CCURL_fnmatch_callback                                      |7210:----|+  = Ptr () -> Ptr CChar -> Ptr CChar -> IO CInt                  |7210:----|++foreign import ccall "wrapper"                                   |7210:----|+  wrap_ccurl_fnmatch_callback                                    |7210:----|+    :: CCURL_fnmatch_callback                                    |7210:----|+    -> IO (FunPtr CCURL_fnmatch_callback)                        |7210:----|++ +-------------------------------------------------------------------------------+-- *** CURL_seek_callback+-------------------------------------------------------------------------------+#{cconst CURL_SEEKFUNC_OK      , CInt}+#{cconst CURL_SEEKFUNC_FAIL    , CInt}+#{cconst CURL_SEEKFUNC_CANTSEEK, CInt}++type CCURL_seek_callback+  = Ptr () -> CCURL_off_t -> CInt -> IO CInt++foreign import ccall "wrapper"+  wrap_ccurl_seek_callback+    :: CCURL_seek_callback+    -> IO (FunPtr CCURL_seek_callback)+++-------------------------------------------------------------------------------+-- *** CURL_read_callback+-------------------------------------------------------------------------------+#{cconst CURL_READFUNC_ABORT, CSize}+#{cconst CURL_READFUNC_PAUSE, CSize}++type CCURL_read_callback+  = Ptr CChar -> CSize -> CSize -> Ptr () -> IO CSize++foreign import ccall "wrapper"+  wrap_ccurl_read_callback+    :: CCURL_read_callback+    -> IO (FunPtr CCURL_read_callback)+++-------------------------------------------------------------------------------+-- *** CURL_sockopt_callback+-------------------------------------------------------------------------------+newtype CCURLsocktype = CCURLsocktype CInt deriving (Eq, Show)++#{symbol CURLSOCKTYPE_IPCXN, CURLsocktype}++#{cconst CURL_SOCKOPT_OK               , CInt}                   |7215:----|+#{cconst CURL_SOCKOPT_ERROR            , CInt}                   |7215:----|+#{cconst CURL_SOCKOPT_ALREADY_CONNECTED, CInt}                   |7215:----|++type CCURL_sockopt_callback+  = Ptr () -> CCURL_socket_t -> CCURLsocktype -> IO CInt++foreign import ccall "wrapper"+  wrap_ccurl_sockopt_callback+    :: CCURL_sockopt_callback+    -> IO (FunPtr CCURL_sockopt_callback)+++-------------------------------------------------------------------------------+-- *** CURL_opensocket_callback+-------------------------------------------------------------------------------+data CCURL_sockaddr = CCURL_sockaddr+  { ccurl_sockaddr_family   :: CInt+  , ccurl_sockaddr_socktype :: CInt+  , ccurl_sockaddr_protocol :: CInt+  , ccurl_sockaddr_addrlen  :: CUInt+  , ccurl_sockaddr_addr     :: Ptr ()  -- sockaddr?? TODO+  } deriving (Show)++-- instance Storable CCURL_sockaddr where+--   sizeOf _    = #{size    struct curl_sockaddr}+--   alignment _ = #{alignof struct curl_sockaddr}+--   poke _ _    = undefined+--   peek _      = undefined++type CCURL_opensocket_callback+  = Ptr () -> CCURLsocktype -> Ptr CCURL_sockaddr -> IO CCURL_socket_t++foreign import ccall "wrapper"+  wrap_ccurl_opensocket_callback+    :: CCURL_opensocket_callback+    -> IO (FunPtr CCURL_opensocket_callback)+++-------------------------------------------------------------------------------+-- *** CURL_closesocket_callback+-------------------------------------------------------------------------------+type CCURL_closesocket_callback                                  |7217:----|+  = Ptr () -> CCURL_socket_t -> IO CInt                          |7217:----|++foreign import ccall "wrapper"                                   |7217:----|+  wrap_ccurl_closesocket_callback                                |7217:----|+    :: CCURL_closesocket_callback                                |7217:----|+    -> IO (FunPtr CCURL_closesocket_callback)                    |7217:----|++ +-------------------------------------------------------------------------------+-- *** CURL_ioctl_callback+-------------------------------------------------------------------------------+newtype CCURLioerr = CCURLioerr CInt deriving (Eq, Show)++#{symbol CURLIOE_OK           , CURLioerr}+#{symbol CURLIOE_UNKNOWNCMD   , CURLioerr}+#{symbol CURLIOE_FAILRESTART  , CURLioerr}++newtype CCURLiocmd = CCURLiocmd CInt deriving (Eq, Show)++#{symbol CURLIOCMD_NOP        , CURLiocmd}+#{symbol CURLIOCMD_RESTARTREAD, CURLiocmd}++type CCURL_ioctl_callback+  = Ptr CCURL -> CCURLiocmd -> Ptr () -> IO CCURLioerr++foreign import ccall "wrapper"+  wrap_ccurl_ioctl_callback+    :: CCURL_ioctl_callback+    -> IO (FunPtr CCURL_ioctl_callback)+++-------------------------------------------------------------------------------+-- *** CURL_malloc_callback+-------------------------------------------------------------------------------+type CCURL_malloc_callback+  = CSize -> IO (Ptr ())++foreign import ccall "wrapper"+  wrap_ccurl_malloc_callback+    :: CCURL_malloc_callback+    -> IO (FunPtr CCURL_malloc_callback)+++-------------------------------------------------------------------------------+-- *** CURL_free_callback+-------------------------------------------------------------------------------+type CCURL_free_callback+  = Ptr () -> IO ()++foreign import ccall "wrapper"+  wrap_ccurl_free_callback+    :: CCURL_free_callback+    -> IO (FunPtr CCURL_free_callback)+++-------------------------------------------------------------------------------+-- *** CURL_realloc_callback+-------------------------------------------------------------------------------+type CCURL_realloc_callback+  = Ptr () -> CSize -> IO (Ptr ())++foreign import ccall "wrapper"+  wrap_ccurl_realloc_callback+    :: CCURL_realloc_callback+    -> IO (FunPtr CCURL_realloc_callback)+++-------------------------------------------------------------------------------+-- *** CURL_strdup_callback+-------------------------------------------------------------------------------+type CCURL_strdup_callback+  = Ptr CChar -> IO (Ptr CChar)++foreign import ccall "wrapper"+  wrap_ccurl_strdup_callback+    :: CCURL_strdup_callback+    -> IO (FunPtr CCURL_strdup_callback)+++-------------------------------------------------------------------------------+-- *** CURL_calloc_callback+-------------------------------------------------------------------------------+type CCURL_calloc_callback+  = CSize -> CSize -> IO (Ptr ())++foreign import ccall "wrapper"+  wrap_ccurl_calloc_callback+    :: CCURL_calloc_callback+    -> IO (FunPtr CCURL_calloc_callback)++ +-------------------------------------------------------------------------------+-- *** CURL_debug_callback+-------------------------------------------------------------------------------+newtype CCURL_infotype = CCURL_infotype CInt deriving (Eq, Show)++#{symbol CURLINFO_TEXT        , CURL_infotype}+#{symbol CURLINFO_HEADER_IN   , CURL_infotype}+#{symbol CURLINFO_HEADER_OUT  , CURL_infotype}+#{symbol CURLINFO_DATA_IN     , CURL_infotype}+#{symbol CURLINFO_DATA_OUT    , CURL_infotype}+#{symbol CURLINFO_SSL_DATA_IN , CURL_infotype}+#{symbol CURLINFO_SSL_DATA_OUT, CURL_infotype}+#{symbol CURLINFO_END         , CURL_infotype}++type CCURL_debug_callback+  = Ptr CCURL -> CCURL_infotype -> Ptr CChar -> CSize -> Ptr () -> IO CInt++foreign import ccall "wrapper"+  wrap_ccurl_debug_callback+    :: CCURL_debug_callback+    -> IO (FunPtr CCURL_debug_callback)+++-------------------------------------------------------------------------------+-- ** Constants+-------------------------------------------------------------------------------+-- *** CURLcode+-------------------------------------------------------------------------------+newtype CCURLcode = CCURLcode CInt deriving (Eq, Show)++#{symbol CURLE_OK                      , CURLcode}+#{symbol CURLE_UNSUPPORTED_PROTOCOL    , CURLcode}+#{symbol CURLE_FAILED_INIT             , CURLcode}+#{symbol CURLE_URL_MALFORMAT           , CURLcode}+#{symbol CURLE_NOT_BUILT_IN            , CURLcode} |7215:----|+#{symbol CURLE_COULDNT_RESOLVE_PROXY   , CURLcode}+#{symbol CURLE_COULDNT_RESOLVE_HOST    , CURLcode}+#{symbol CURLE_COULDNT_CONNECT         , CURLcode}+#{symbol CURLE_FTP_WEIRD_SERVER_REPLY  , CURLcode}+#{symbol CURLE_REMOTE_ACCESS_DENIED    , CURLcode}+#{symbol CURLE_FTP_ACCEPT_FAILED       , CURLcode} |7240:----|+#{symbol CURLE_FTP_WEIRD_PASS_REPLY    , CURLcode}+#{symbol CURLE_FTP_ACCEPT_TIMEOUT      , CURLcode} |7240:----|+#{symbol CURLE_FTP_WEIRD_PASV_REPLY    , CURLcode}+#{symbol CURLE_FTP_WEIRD_227_FORMAT    , CURLcode}+#{symbol CURLE_FTP_CANT_GET_HOST       , CURLcode}+#{symbol CURLE_FTP_COULDNT_SET_TYPE    , CURLcode}+#{symbol CURLE_PARTIAL_FILE            , CURLcode}+#{symbol CURLE_FTP_COULDNT_RETR_FILE   , CURLcode}+#{symbol CURLE_QUOTE_ERROR             , CURLcode}+#{symbol CURLE_HTTP_RETURNED_ERROR     , CURLcode}+#{symbol CURLE_WRITE_ERROR             , CURLcode}+#{symbol CURLE_UPLOAD_FAILED           , CURLcode}+#{symbol CURLE_READ_ERROR              , CURLcode}+#{symbol CURLE_OUT_OF_MEMORY           , CURLcode}+#{symbol CURLE_OPERATION_TIMEDOUT      , CURLcode}+#{symbol CURLE_FTP_PORT_FAILED         , CURLcode}+#{symbol CURLE_FTP_COULDNT_USE_REST    , CURLcode}+#{symbol CURLE_RANGE_ERROR             , CURLcode}+#{symbol CURLE_HTTP_POST_ERROR         , CURLcode}+#{symbol CURLE_SSL_CONNECT_ERROR       , CURLcode}+#{symbol CURLE_BAD_DOWNLOAD_RESUME     , CURLcode}+#{symbol CURLE_FILE_COULDNT_READ_FILE  , CURLcode}+#{symbol CURLE_LDAP_CANNOT_BIND        , CURLcode}+#{symbol CURLE_LDAP_SEARCH_FAILED      , CURLcode}+#{symbol CURLE_FUNCTION_NOT_FOUND      , CURLcode}+#{symbol CURLE_ABORTED_BY_CALLBACK     , CURLcode}+#{symbol CURLE_BAD_FUNCTION_ARGUMENT   , CURLcode}+#{symbol CURLE_INTERFACE_FAILED        , CURLcode}+#{symbol CURLE_TOO_MANY_REDIRECTS      , CURLcode}+#{symbol CURLE_UNKNOWN_TELNET_OPTION   , CURLcode} |----:7214|+#{symbol CURLE_UNKNOWN_OPTION          , CURLcode} |7215:----|+#{symbol CURLE_TELNET_OPTION_SYNTAX    , CURLcode}+#{symbol CURLE_PEER_FAILED_VERIFICATION, CURLcode}+#{symbol CURLE_GOT_NOTHING             , CURLcode}+#{symbol CURLE_SSL_ENGINE_NOTFOUND     , CURLcode}+#{symbol CURLE_SSL_ENGINE_SETFAILED    , CURLcode}+#{symbol CURLE_SEND_ERROR              , CURLcode}+#{symbol CURLE_RECV_ERROR              , CURLcode}+#{symbol CURLE_SSL_CERTPROBLEM         , CURLcode}+#{symbol CURLE_SSL_CIPHER              , CURLcode}+#{symbol CURLE_SSL_CACERT              , CURLcode}+#{symbol CURLE_BAD_CONTENT_ENCODING    , CURLcode}+#{symbol CURLE_LDAP_INVALID_URL        , CURLcode}+#{symbol CURLE_FILESIZE_EXCEEDED       , CURLcode}+#{symbol CURLE_USE_SSL_FAILED          , CURLcode}+#{symbol CURLE_SEND_FAIL_REWIND        , CURLcode}+#{symbol CURLE_SSL_ENGINE_INITFAILED   , CURLcode}+#{symbol CURLE_LOGIN_DENIED            , CURLcode}+#{symbol CURLE_TFTP_NOTFOUND           , CURLcode}+#{symbol CURLE_TFTP_PERM               , CURLcode}+#{symbol CURLE_REMOTE_DISK_FULL        , CURLcode}+#{symbol CURLE_TFTP_ILLEGAL            , CURLcode}+#{symbol CURLE_TFTP_UNKNOWNID          , CURLcode}+#{symbol CURLE_REMOTE_FILE_EXISTS      , CURLcode}+#{symbol CURLE_TFTP_NOSUCHUSER         , CURLcode}+#{symbol CURLE_CONV_FAILED             , CURLcode}+#{symbol CURLE_CONV_REQD               , CURLcode}+#{symbol CURLE_SSL_CACERT_BADFILE      , CURLcode}+#{symbol CURLE_REMOTE_FILE_NOT_FOUND   , CURLcode}+#{symbol CURLE_SSH                     , CURLcode}+#{symbol CURLE_SSL_SHUTDOWN_FAILED     , CURLcode}+#{symbol CURLE_AGAIN                   , CURLcode}+#{symbol CURLE_SSL_CRL_BADFILE         , CURLcode}+#{symbol CURLE_SSL_ISSUER_ERROR        , CURLcode}+#{symbol CURLE_FTP_PRET_FAILED         , CURLcode}+#{symbol CURLE_RTSP_CSEQ_ERROR         , CURLcode}+#{symbol CURLE_RTSP_SESSION_ERROR      , CURLcode}+#{symbol CURLE_FTP_BAD_FILE_LIST       , CURLcode} |7210:----|+#{symbol CURLE_CHUNK_FAILED            , CURLcode} |7210:----|+++-------------------------------------------------------------------------------+-- ** Callbacks+-------------------------------------------------------------------------------+-- *** CURL_conv_callback+-------------------------------------------------------------------------------+type CCURL_conv_callback+  = Ptr CChar -> CSize -> IO CCURLcode++foreign import ccall "wrapper"+  wrap_ccurl_conv_callback+    :: CCURL_conv_callback+    -> IO (FunPtr CCURL_conv_callback)+++-------------------------------------------------------------------------------+-- *** CURL_ssl_ctx_callback+-------------------------------------------------------------------------------+type CCURL_ssl_ctx_callback+  = Ptr CCURL -> Ptr () -> Ptr () -> IO CCURLcode++foreign import ccall "wrapper"+  wrap_ccurl_ssl_ctx_callback+    :: CCURL_ssl_ctx_callback+    -> IO (FunPtr CCURL_ssl_ctx_callback)++ +-------------------------------------------------------------------------------+-- ** Constants+-------------------------------------------------------------------------------+-- *** CURLproxy+-------------------------------------------------------------------------------+#{cconst CURLPROXY_HTTP           , CLong}+#{cconst CURLPROXY_HTTP_1_0       , CLong}+#{cconst CURLPROXY_SOCKS4         , CLong}+#{cconst CURLPROXY_SOCKS5         , CLong}+#{cconst CURLPROXY_SOCKS4A        , CLong}+#{cconst CURLPROXY_SOCKS5_HOSTNAME, CLong}+++-------------------------------------------------------------------------------+-- *** CURLauth+-------------------------------------------------------------------------------+#{cconst CURLAUTH_NONE        , CLong}+#{cconst CURLAUTH_BASIC       , CLong}+#{cconst CURLAUTH_DIGEST      , CLong}+#{cconst CURLAUTH_GSSNEGOTIATE, CLong}+#{cconst CURLAUTH_NTLM        , CLong}+#{cconst CURLAUTH_DIGEST_IE   , CLong}+#{cconst CURLAUTH_NTLM_WB     , CLong} |7220:----|+#{cconst CURLAUTH_ONLY        , CLong} |7213:----|+#{cconst CURLAUTH_ANY         , CLong}+#{cconst CURLAUTH_ANYSAFE     , CLong}+++-------------------------------------------------------------------------------+-- *** CURLsshauth+-------------------------------------------------------------------------------+#{cconst CURLSSH_AUTH_ANY      , CLong}+#{cconst CURLSSH_AUTH_NONE     , CLong}+#{cconst CURLSSH_AUTH_PUBLICKEY, CLong}+#{cconst CURLSSH_AUTH_PASSWORD , CLong}+#{cconst CURLSSH_AUTH_HOST     , CLong}+#{cconst CURLSSH_AUTH_KEYBOARD , CLong}+#{cconst CURLSSH_AUTH_DEFAULT  , CLong}+++-------------------------------------------------------------------------------+-- *** CURLgssapi+-------------------------------------------------------------------------------+#{cconst CURLGSSAPI_DELEGATION_NONE       , CLong}               |7220:----|+#{cconst CURLGSSAPI_DELEGATION_POLICY_FLAG, CLong}               |7220:----|+#{cconst CURLGSSAPI_DELEGATION_FLAG       , CLong}               |7220:----|+++-------------------------------------------------------------------------------+-- *** CURL_error_size+-------------------------------------------------------------------------------+#{cconst CURL_ERROR_SIZE, CLong}+++-------------------------------------------------------------------------------+-- ** Callbacks+-------------------------------------------------------------------------------+-- *** CURL_sshkey_callback+-------------------------------------------------------------------------------+data CCURL_khkey = CCURL_khkey+  { ccurl_khkey_key     :: Ptr CChar+  , ccurl_khkey_len     :: CSize+  , ccurl_khkey_keytype :: CCURL_khtype+  } deriving (Show)++-- instance Storable CCURL_khkey where+--   sizeOf _    = #{size    struct curl_khkey}+--   alignment _ = #{alignof struct curl_khkey}+--   poke _ _    = undefined+--   peek _      = undefined++newtype CCURL_khtype = CCURL_khtype CInt deriving (Eq, Show)++#{symbol CURLKHTYPE_UNKNOWN, CURL_khtype}+#{symbol CURLKHTYPE_RSA1   , CURL_khtype}+#{symbol CURLKHTYPE_RSA    , CURL_khtype}+#{symbol CURLKHTYPE_DSS    , CURL_khtype}+ +newtype CCURL_khstat = CCURL_khstat CInt deriving (Eq, Show)++#{symbol CURLKHSTAT_FINE_ADD_TO_FILE, CURL_khstat}+#{symbol CURLKHSTAT_FINE            , CURL_khstat}+#{symbol CURLKHSTAT_REJECT          , CURL_khstat}+#{symbol CURLKHSTAT_DEFER           , CURL_khstat}++newtype CCURL_khmatch = CCURL_khmatch CInt deriving (Eq, Show)++#{symbol CURLKHMATCH_OK      , CURL_khmatch}+#{symbol CURLKHMATCH_MISMATCH, CURL_khmatch}+#{symbol CURLKHMATCH_MISSING , CURL_khmatch}+ +type CCURL_sshkey_callback+  = Ptr CCURL -> Ptr CCURL_khkey -> Ptr CCURL_khkey+    -> CCURL_khmatch -> Ptr () -> IO CCURL_khstat++foreign import ccall "wrapper"+  wrap_ccurl_sshkey_callback+    :: CCURL_sshkey_callback+    -> IO (FunPtr CCURL_sshkey_callback)++ +-------------------------------------------------------------------------------+-- ** Constants+-------------------------------------------------------------------------------+-- *** CURLusessl+-------------------------------------------------------------------------------+#{cconst CURLUSESSL_NONE   , CLong}+#{cconst CURLUSESSL_TRY    , CLong}+#{cconst CURLUSESSL_CONTROL, CLong}+#{cconst CURLUSESSL_ALL    , CLong}+++-------------------------------------------------------------------------------+-- *** CURLsslopt+-------------------------------------------------------------------------------+#{cconst CURLSSLOPT_ALLOW_BEAST, CLong}                          |7250:----|+++-------------------------------------------------------------------------------+-- *** CURLftpssl+-------------------------------------------------------------------------------+#{cconst CURLFTPSSL_CCC_NONE   , CLong}+#{cconst CURLFTPSSL_CCC_PASSIVE, CLong}+#{cconst CURLFTPSSL_CCC_ACTIVE , CLong}+ ++-------------------------------------------------------------------------------+-- *** CURLftpauth+-------------------------------------------------------------------------------+#{cconst CURLFTPAUTH_DEFAULT, CLong}+#{cconst CURLFTPAUTH_SSL    , CLong}+#{cconst CURLFTPAUTH_TLS    , CLong}+++-------------------------------------------------------------------------------+-- *** CURLftpcreate+-------------------------------------------------------------------------------+#{cconst CURLFTP_CREATE_DIR_NONE , CLong}+#{cconst CURLFTP_CREATE_DIR      , CLong}+#{cconst CURLFTP_CREATE_DIR_RETRY, CLong}+++-------------------------------------------------------------------------------+-- *** CURLftpmethod+-------------------------------------------------------------------------------+#{cconst CURLFTPMETHOD_DEFAULT  , CLong}+#{cconst CURLFTPMETHOD_MULTICWD , CLong}+#{cconst CURLFTPMETHOD_NOCWD    , CLong}+#{cconst CURLFTPMETHOD_SINGLECWD, CLong}+++-------------------------------------------------------------------------------+-- *** CURLproto+-------------------------------------------------------------------------------+#{cconst CURLPROTO_HTTP  , CLong}+#{cconst CURLPROTO_HTTPS , CLong}+#{cconst CURLPROTO_FTP   , CLong}+#{cconst CURLPROTO_FTPS  , CLong}+#{cconst CURLPROTO_SCP   , CLong}+#{cconst CURLPROTO_SFTP  , CLong}+#{cconst CURLPROTO_TELNET, CLong}+#{cconst CURLPROTO_LDAP  , CLong}+#{cconst CURLPROTO_LDAPS , CLong}+#{cconst CURLPROTO_DICT  , CLong}+#{cconst CURLPROTO_FILE  , CLong}+#{cconst CURLPROTO_TFTP  , CLong}+#{cconst CURLPROTO_IMAP  , CLong}+#{cconst CURLPROTO_IMAPS , CLong}+#{cconst CURLPROTO_POP3  , CLong}+#{cconst CURLPROTO_POP3S , CLong}+#{cconst CURLPROTO_SMTP  , CLong}+#{cconst CURLPROTO_SMTPS , CLong}+#{cconst CURLPROTO_RTSP  , CLong}+#{cconst CURLPROTO_RTMP  , CLong} |7210:----|+#{cconst CURLPROTO_RTMPT , CLong} |7210:----|+#{cconst CURLPROTO_RTMPE , CLong} |7210:----|+#{cconst CURLPROTO_RTMPTE, CLong} |7210:----|+#{cconst CURLPROTO_RTMPS , CLong} |7210:----|+#{cconst CURLPROTO_RTMPTS, CLong} |7210:----|+#{cconst CURLPROTO_GOPHER, CLong} |7212:----|+#{cconst CURLPROTO_ALL   , CLong}+++-------------------------------------------------------------------------------+-- *** CURLoption+-------------------------------------------------------------------------------+newtype CCURLoption'CLong   = CCURLoption'CLong   CInt deriving (Eq, Show)+newtype CCURLoption'Int64   = CCURLoption'Int64   CInt deriving (Eq, Show)+newtype CCURLoption'CString = CCURLoption'CString CInt deriving (Eq, Show)+newtype CCURLoption'CFile   = CCURLoption'CFile   CInt deriving (Eq, Show)+newtype CCURLoption'SList   = CCURLoption'SList   CInt deriving (Eq, Show)+newtype CCURLoption'HTTPP   = CCURLoption'HTTPP   CInt deriving (Eq, Show)+newtype CCURLoption'CURLSH  = CCURLoption'CURLSH  CInt deriving (Eq, Show)+newtype CCURLoption'UsrPtr  = CCURLoption'UsrPtr  CInt deriving (Eq, Show)+newtype CCURLoption'FunPtr  = CCURLoption'FunPtr  CInt deriving (Eq, Show)++#define hsc_curlopt(name, type) \+  printf("c" #name " :: CCURLoption'" #type "\n"); \+  printf("c" #name " =  CCURLoption'" #type " "); hsc_const(name);++#{curlopt CURLOPT_FILE                       , CFile   }+#{curlopt CURLOPT_URL                        , CString }+#{curlopt CURLOPT_PORT                       , CLong   }+#{curlopt CURLOPT_PROXY                      , CString }+#{curlopt CURLOPT_USERPWD                    , CString }+#{curlopt CURLOPT_PROXYUSERPWD               , CString }+#{curlopt CURLOPT_RANGE                      , CString }+#{curlopt CURLOPT_INFILE                     , CFile   }+#{curlopt CURLOPT_ERRORBUFFER                , CString }+#{curlopt CURLOPT_WRITEFUNCTION              , FunPtr  }+#{curlopt CURLOPT_READFUNCTION               , FunPtr  }+#{curlopt CURLOPT_TIMEOUT                    , CLong   }+#{curlopt CURLOPT_INFILESIZE                 , CLong   }+#{curlopt CURLOPT_POSTFIELDS                 , CString }  -- UsrPtr??+#{curlopt CURLOPT_REFERER                    , CString }+#{curlopt CURLOPT_FTPPORT                    , CString }+#{curlopt CURLOPT_USERAGENT                  , CString }+#{curlopt CURLOPT_LOW_SPEED_LIMIT            , CLong   }+#{curlopt CURLOPT_LOW_SPEED_TIME             , CLong   }+#{curlopt CURLOPT_RESUME_FROM                , CLong   }+#{curlopt CURLOPT_COOKIE                     , CString }+#{curlopt CURLOPT_HTTPHEADER                 , SList   }+#{curlopt CURLOPT_HTTPPOST                   , HTTPP   }+#{curlopt CURLOPT_SSLCERT                    , CString }+#{curlopt CURLOPT_KEYPASSWD                  , CString }+#{curlopt CURLOPT_CRLF                       , CLong   }+#{curlopt CURLOPT_QUOTE                      , SList   }+#{curlopt CURLOPT_WRITEHEADER                , CFile   }  -- UsrPtr??+#{curlopt CURLOPT_COOKIEFILE                 , CString }+#{curlopt CURLOPT_SSLVERSION                 , CLong   }+#{curlopt CURLOPT_TIMECONDITION              , CLong   }+#{curlopt CURLOPT_TIMEVALUE                  , CLong   }+#{curlopt CURLOPT_CUSTOMREQUEST              , CString }+#{curlopt CURLOPT_STDERR                     , CFile   }+#{curlopt CURLOPT_POSTQUOTE                  , SList   }+{-# DEPRECATED cCURLOPT_WRITEINFO                 "" #-} |7220:----|+#{curlopt CURLOPT_WRITEINFO                  , CString }+#{curlopt CURLOPT_VERBOSE                    , CLong   }+#{curlopt CURLOPT_HEADER                     , CLong   }+#{curlopt CURLOPT_NOPROGRESS                 , CLong   }+#{curlopt CURLOPT_NOBODY                     , CLong   }+#{curlopt CURLOPT_FAILONERROR                , CLong   }+#{curlopt CURLOPT_UPLOAD                     , CLong   }+#{curlopt CURLOPT_POST                       , CLong   }+#{curlopt CURLOPT_DIRLISTONLY                , CLong   }+#{curlopt CURLOPT_APPEND                     , CLong   }+#{curlopt CURLOPT_NETRC                      , CLong   }+#{curlopt CURLOPT_FOLLOWLOCATION             , CLong   }+#{curlopt CURLOPT_TRANSFERTEXT               , CLong   }+#{curlopt CURLOPT_PUT                        , CLong   }+#{curlopt CURLOPT_PROGRESSFUNCTION           , FunPtr  }+#{curlopt CURLOPT_PROGRESSDATA               , UsrPtr  }+#{curlopt CURLOPT_AUTOREFERER                , CLong   }+#{curlopt CURLOPT_PROXYPORT                  , CLong   }+#{curlopt CURLOPT_POSTFIELDSIZE              , CLong   }+#{curlopt CURLOPT_HTTPPROXYTUNNEL            , CLong   }+#{curlopt CURLOPT_INTERFACE                  , CString }+#{curlopt CURLOPT_KRBLEVEL                   , CString }+#{curlopt CURLOPT_SSL_VERIFYPEER             , CLong   }+#{curlopt CURLOPT_CAINFO                     , CString }+#{curlopt CURLOPT_MAXREDIRS                  , CLong   }+#{curlopt CURLOPT_FILETIME                   , CLong   }+#{curlopt CURLOPT_TELNETOPTIONS              , SList   }+#{curlopt CURLOPT_MAXCONNECTS                , CLong   }+{-# DEPRECATED cCURLOPT_CLOSEPOLICY               "" #-} |7217:----|+#{curlopt CURLOPT_CLOSEPOLICY                , CLong   }+#{curlopt CURLOPT_FRESH_CONNECT              , CLong   }+#{curlopt CURLOPT_FORBID_REUSE               , CLong   }+#{curlopt CURLOPT_RANDOM_FILE                , CString }+#{curlopt CURLOPT_EGDSOCKET                  , CString }+#{curlopt CURLOPT_CONNECTTIMEOUT             , CLong   }+#{curlopt CURLOPT_HEADERFUNCTION             , FunPtr  }+#{curlopt CURLOPT_HTTPGET                    , CLong   }+#{curlopt CURLOPT_SSL_VERIFYHOST             , CLong   }+#{curlopt CURLOPT_COOKIEJAR                  , CString }+#{curlopt CURLOPT_SSL_CIPHER_LIST            , CString }+#{curlopt CURLOPT_HTTP_VERSION               , CLong   }+#{curlopt CURLOPT_FTP_USE_EPSV               , CLong   }+#{curlopt CURLOPT_SSLCERTTYPE                , CString }+#{curlopt CURLOPT_SSLKEY                     , CString }+#{curlopt CURLOPT_SSLKEYTYPE                 , CString }+#{curlopt CURLOPT_SSLENGINE                  , CString }+#{curlopt CURLOPT_SSLENGINE_DEFAULT          , CLong   }+{-# DEPRECATED cCURLOPT_DNS_USE_GLOBAL_CACHE      "" #-} |7220:----|+#{curlopt CURLOPT_DNS_USE_GLOBAL_CACHE       , CLong   }+#{curlopt CURLOPT_DNS_CACHE_TIMEOUT          , CLong   }+#{curlopt CURLOPT_PREQUOTE                   , SList   }+#{curlopt CURLOPT_DEBUGFUNCTION              , FunPtr  }+#{curlopt CURLOPT_DEBUGDATA                  , UsrPtr  }+#{curlopt CURLOPT_COOKIESESSION              , CLong   }+#{curlopt CURLOPT_CAPATH                     , CString }+#{curlopt CURLOPT_BUFFERSIZE                 , CLong   }+#{curlopt CURLOPT_NOSIGNAL                   , CLong   }+#{curlopt CURLOPT_SHARE                      , CURLSH  }+#{curlopt CURLOPT_PROXYTYPE                  , CLong   }+#{curlopt CURLOPT_ENCODING                   , CString } |----:7215|+#{curlopt CURLOPT_ACCEPT_ENCODING            , CString } |7216:----|+#{curlopt CURLOPT_PRIVATE                    , UsrPtr  }+#{curlopt CURLOPT_HTTP200ALIASES             , SList   }+#{curlopt CURLOPT_UNRESTRICTED_AUTH          , CLong   }+#{curlopt CURLOPT_FTP_USE_EPRT               , CLong   }+#{curlopt CURLOPT_HTTPAUTH                   , CLong   }+#{curlopt CURLOPT_SSL_CTX_FUNCTION           , FunPtr  }+#{curlopt CURLOPT_SSL_CTX_DATA               , UsrPtr  }+#{curlopt CURLOPT_FTP_CREATE_MISSING_DIRS    , CLong   }+#{curlopt CURLOPT_PROXYAUTH                  , CLong   }+#{curlopt CURLOPT_FTP_RESPONSE_TIMEOUT       , CLong   }+#{curlopt CURLOPT_IPRESOLVE                  , CLong   }+#{curlopt CURLOPT_MAXFILESIZE                , CLong   }+#{curlopt CURLOPT_INFILESIZE_LARGE           , Int64   }+#{curlopt CURLOPT_RESUME_FROM_LARGE          , Int64   }+#{curlopt CURLOPT_MAXFILESIZE_LARGE          , Int64   }+#{curlopt CURLOPT_NETRC_FILE                 , CString }+#{curlopt CURLOPT_USE_SSL                    , CLong   }+#{curlopt CURLOPT_POSTFIELDSIZE_LARGE        , Int64   }+#{curlopt CURLOPT_TCP_NODELAY                , CLong   }+#{curlopt CURLOPT_FTPSSLAUTH                 , CLong   }+#{curlopt CURLOPT_IOCTLFUNCTION              , FunPtr  }+#{curlopt CURLOPT_IOCTLDATA                  , UsrPtr  }+#{curlopt CURLOPT_FTP_ACCOUNT                , CString }+#{curlopt CURLOPT_COOKIELIST                 , CString }+#{curlopt CURLOPT_IGNORE_CONTENT_LENGTH      , CLong   }+#{curlopt CURLOPT_FTP_SKIP_PASV_IP           , CLong   }+#{curlopt CURLOPT_FTP_FILEMETHOD             , CLong   }+#{curlopt CURLOPT_LOCALPORT                  , CLong   }+#{curlopt CURLOPT_LOCALPORTRANGE             , CLong   }+#{curlopt CURLOPT_CONNECT_ONLY               , CLong   }+#{curlopt CURLOPT_CONV_FROM_NETWORK_FUNCTION , FunPtr  }+#{curlopt CURLOPT_CONV_TO_NETWORK_FUNCTION   , FunPtr  }+#{curlopt CURLOPT_CONV_FROM_UTF8_FUNCTION    , FunPtr  }+#{curlopt CURLOPT_MAX_SEND_SPEED_LARGE       , Int64   }+#{curlopt CURLOPT_MAX_RECV_SPEED_LARGE       , Int64   }+#{curlopt CURLOPT_FTP_ALTERNATIVE_TO_USER    , CString }+#{curlopt CURLOPT_SOCKOPTFUNCTION            , FunPtr  }+#{curlopt CURLOPT_SOCKOPTDATA                , UsrPtr  }+#{curlopt CURLOPT_SSL_SESSIONID_CACHE        , CLong   }+#{curlopt CURLOPT_SSH_AUTH_TYPES             , CLong   }+#{curlopt CURLOPT_SSH_PUBLIC_KEYFILE         , CString }+#{curlopt CURLOPT_SSH_PRIVATE_KEYFILE        , CString }+#{curlopt CURLOPT_FTP_SSL_CCC                , CLong   }+#{curlopt CURLOPT_TIMEOUT_MS                 , CLong   }+#{curlopt CURLOPT_CONNECTTIMEOUT_MS          , CLong   }+#{curlopt CURLOPT_HTTP_TRANSFER_DECODING     , CLong   }+#{curlopt CURLOPT_HTTP_CONTENT_DECODING      , CLong   }+#{curlopt CURLOPT_NEW_FILE_PERMS             , CLong   }+#{curlopt CURLOPT_NEW_DIRECTORY_PERMS        , CLong   }+#{curlopt CURLOPT_POSTREDIR                  , CLong   }+#{curlopt CURLOPT_SSH_HOST_PUBLIC_KEY_MD5    , CString }+#{curlopt CURLOPT_OPENSOCKETFUNCTION         , FunPtr  }+#{curlopt CURLOPT_OPENSOCKETDATA             , UsrPtr  }+#{curlopt CURLOPT_COPYPOSTFIELDS             , CString }+#{curlopt CURLOPT_PROXY_TRANSFER_MODE        , CLong   }+#{curlopt CURLOPT_SEEKFUNCTION               , FunPtr  }+#{curlopt CURLOPT_SEEKDATA                   , UsrPtr  }+#{curlopt CURLOPT_CRLFILE                    , CString }+#{curlopt CURLOPT_ISSUERCERT                 , CString }+#{curlopt CURLOPT_ADDRESS_SCOPE              , CLong   }+#{curlopt CURLOPT_CERTINFO                   , CLong   }+#{curlopt CURLOPT_USERNAME                   , CString }+#{curlopt CURLOPT_PASSWORD                   , CString }+#{curlopt CURLOPT_PROXYUSERNAME              , CString }+#{curlopt CURLOPT_PROXYPASSWORD              , CString }+#{curlopt CURLOPT_NOPROXY                    , CString }+#{curlopt CURLOPT_TFTP_BLKSIZE               , CLong   }+#{curlopt CURLOPT_SOCKS5_GSSAPI_SERVICE      , CString }+#{curlopt CURLOPT_SOCKS5_GSSAPI_NEC          , CLong   }+#{curlopt CURLOPT_PROTOCOLS                  , CLong   }+#{curlopt CURLOPT_REDIR_PROTOCOLS            , CLong   }+#{curlopt CURLOPT_SSH_KNOWNHOSTS             , CString }+#{curlopt CURLOPT_SSH_KEYFUNCTION            , FunPtr  }+#{curlopt CURLOPT_SSH_KEYDATA                , UsrPtr  }+#{curlopt CURLOPT_MAIL_FROM                  , CString }+#{curlopt CURLOPT_MAIL_RCPT                  , SList   }+#{curlopt CURLOPT_FTP_USE_PRET               , CLong   }+#{curlopt CURLOPT_RTSP_REQUEST               , CLong   }+#{curlopt CURLOPT_RTSP_SESSION_ID            , CString }+#{curlopt CURLOPT_RTSP_STREAM_URI            , CString }+#{curlopt CURLOPT_RTSP_TRANSPORT             , CString }+#{curlopt CURLOPT_RTSP_CLIENT_CSEQ           , CLong   }+#{curlopt CURLOPT_RTSP_SERVER_CSEQ           , CLong   }+#{curlopt CURLOPT_INTERLEAVEDATA             , UsrPtr  }+#{curlopt CURLOPT_INTERLEAVEFUNCTION         , FunPtr  }+#{curlopt CURLOPT_WILDCARDMATCH              , CLong   } |7210:----|+#{curlopt CURLOPT_CHUNK_BGN_FUNCTION         , FunPtr  } |7210:----|+#{curlopt CURLOPT_CHUNK_END_FUNCTION         , FunPtr  } |7210:----|+#{curlopt CURLOPT_FNMATCH_FUNCTION           , FunPtr  } |7210:----|+#{curlopt CURLOPT_CHUNK_DATA                 , UsrPtr  } |7210:----|+#{curlopt CURLOPT_FNMATCH_DATA               , UsrPtr  } |7210:----|+#{curlopt CURLOPT_RESOLVE                    , SList   } |7213:----|+#{curlopt CURLOPT_TLSAUTH_USERNAME           , CString } |7214:----|+#{curlopt CURLOPT_TLSAUTH_PASSWORD           , CString } |7214:----|+#{curlopt CURLOPT_TLSAUTH_TYPE               , CString } |7214:----|+#{curlopt CURLOPT_TRANSFER_ENCODING          , CLong   } |7216:----|+#{curlopt CURLOPT_CLOSESOCKETFUNCTION        , FunPtr  } |7217:----|+#{curlopt CURLOPT_CLOSESOCKETDATA            , UsrPtr  } |7217:----|+#{curlopt CURLOPT_GSSAPI_DELEGATION          , CLong   } |7220:----|+#{curlopt CURLOPT_DNS_SERVERS                , CString } |7240:----|+#{curlopt CURLOPT_ACCEPTTIMEOUT_MS           , CLong   } |7240:----|+#{curlopt CURLOPT_TCP_KEEPALIVE              , CLong   } |7250:----|+#{curlopt CURLOPT_TCP_KEEPIDLE               , CLong   } |7250:----|+#{curlopt CURLOPT_TCP_KEEPINTVL              , CLong   } |7250:----|+#{curlopt CURLOPT_SSL_OPTIONS                , CLong   } |7250:----|+#{curlopt CURLOPT_MAIL_AUTH                  , CString } |7250:----|++#{curlopt CURLOPT_WRITEDATA                  , UsrPtr  }+#{curlopt CURLOPT_READDATA                   , UsrPtr  }+#{curlopt CURLOPT_HEADERDATA                 , UsrPtr  }+#{curlopt CURLOPT_RTSPHEADER                 , SList   }+++-------------------------------------------------------------------------------+-- *** CURLipresolve+-------------------------------------------------------------------------------+#{cconst CURL_IPRESOLVE_WHATEVER, CLong}+#{cconst CURL_IPRESOLVE_V4      , CLong}+#{cconst CURL_IPRESOLVE_V6      , CLong}+++-------------------------------------------------------------------------------+-- *** CURLhttpver+-------------------------------------------------------------------------------+#{cconst CURL_HTTP_VERSION_NONE, CLong}+#{cconst CURL_HTTP_VERSION_1_0 , CLong}+#{cconst CURL_HTTP_VERSION_1_1 , CLong}+++-------------------------------------------------------------------------------+-- *** CURLrtspreq+-------------------------------------------------------------------------------+#{cconst CURL_RTSPREQ_NONE         , CLong}+#{cconst CURL_RTSPREQ_OPTIONS      , CLong}+#{cconst CURL_RTSPREQ_DESCRIBE     , CLong}+#{cconst CURL_RTSPREQ_ANNOUNCE     , CLong}+#{cconst CURL_RTSPREQ_SETUP        , CLong}+#{cconst CURL_RTSPREQ_PLAY         , CLong}+#{cconst CURL_RTSPREQ_PAUSE        , CLong}+#{cconst CURL_RTSPREQ_TEARDOWN     , CLong}+#{cconst CURL_RTSPREQ_GET_PARAMETER, CLong}+#{cconst CURL_RTSPREQ_SET_PARAMETER, CLong}+#{cconst CURL_RTSPREQ_RECORD       , CLong}+#{cconst CURL_RTSPREQ_RECEIVE      , CLong}+++-------------------------------------------------------------------------------+-- *** CURLnetrc+-------------------------------------------------------------------------------+#{cconst CURL_NETRC_IGNORED , CLong}+#{cconst CURL_NETRC_OPTIONAL, CLong}+#{cconst CURL_NETRC_REQUIRED, CLong}+++-------------------------------------------------------------------------------+-- *** CURLsslver+-------------------------------------------------------------------------------+#{cconst CURL_SSLVERSION_DEFAULT, CLong}+#{cconst CURL_SSLVERSION_TLSv1  , CLong}+#{cconst CURL_SSLVERSION_SSLv2  , CLong}+#{cconst CURL_SSLVERSION_SSLv3  , CLong}+++-------------------------------------------------------------------------------+-- *** CURLtlsauth+-------------------------------------------------------------------------------+#{cconst CURL_TLSAUTH_NONE, CLong}                               |7214:----|+#{cconst CURL_TLSAUTH_SRP , CLong}                               |7214:----|+++-------------------------------------------------------------------------------+-- *** CURLredir+-------------------------------------------------------------------------------+#{cconst CURL_REDIR_GET_ALL , CLong}+#{cconst CURL_REDIR_POST_301, CLong}+#{cconst CURL_REDIR_POST_302, CLong}+#{cconst CURL_REDIR_POST_ALL, CLong}+++-------------------------------------------------------------------------------+-- *** CURLtimecond+-------------------------------------------------------------------------------+#{cconst CURL_TIMECOND_NONE        , CLong}+#{cconst CURL_TIMECOND_IFMODSINCE  , CLong}+#{cconst CURL_TIMECOND_IFUNMODSINCE, CLong}+#{cconst CURL_TIMECOND_LASTMOD     , CLong}+++-------------------------------------------------------------------------------+-- ** Functions+-------------------------------------------------------------------------------+{-# DEPRECATED ccurl_strequal "" #-}+foreign import ccall "curl_strequal"+  ccurl_strequal+    :: Ptr CChar+    -> Ptr CChar+    -> IO CInt+++-------------------------------------------------------------------------------+{-# DEPRECATED ccurl_strnequal "" #-}+foreign import ccall "curl_strnequal"+  ccurl_strnequal+    :: Ptr CChar+    -> Ptr CChar+    -> CSize+    -> IO CInt+++-------------------------------------------------------------------------------+-- ** CURL_forms+-------------------------------------------------------------------------------+newtype CCURLformoption = CCURLformoption CInt deriving (Eq, Show)+ +-- #{symbol CURLFORM_COPYNAME      , CURLformoption}+-- #{symbol CURLFORM_PTRNAME       , CURLformoption}+-- #{symbol CURLFORM_NAMELENGTH    , CURLformoption}+-- #{symbol CURLFORM_COPYCONTENTS  , CURLformoption}+-- #{symbol CURLFORM_PTRCONTENTS   , CURLformoption}+-- #{symbol CURLFORM_CONTENTSLENGTH, CURLformoption}+-- #{symbol CURLFORM_FILECONTENT   , CURLformoption}+-- #{symbol CURLFORM_ARRAY         , CURLformoption}+-- #{symbol CURLFORM_FILE          , CURLformoption}+-- #{symbol CURLFORM_BUFFER        , CURLformoption}+-- #{symbol CURLFORM_BUFFERPTR     , CURLformoption}+-- #{symbol CURLFORM_BUFFERLENGTH  , CURLformoption}+-- #{symbol CURLFORM_CONTENTTYPE   , CURLformoption}+-- #{symbol CURLFORM_CONTENTHEADER , CURLformoption}+-- #{symbol CURLFORM_FILENAME      , CURLformoption}+-- #{symbol CURLFORM_END           , CURLformoption}+-- #{symbol CURLFORM_STREAM        , CURLformoption}+++-------------------------------------------------------------------------------+data CCURL_forms = CCURL_forms+  { ccurl_forms_option :: CCURLformoption+  , ccurl_forms_value  :: Ptr CChar+  } deriving (Show)++-- instance Storable CCURL_forms where+--   sizeOf _    = #{size    struct curl_forms}+--   alignment _ = #{alignof struct curl_forms}+--   poke _ _    = undefined+--   peek _      = undefined+++-------------------------------------------------------------------------------+newtype CCURLformcode = CCURLformcode CInt deriving (Eq, Show)++#{symbol CURL_FORMADD_OK            , CURLformcode}+#{symbol CURL_FORMADD_MEMORY        , CURLformcode}+#{symbol CURL_FORMADD_OPTION_TWICE  , CURLformcode}+#{symbol CURL_FORMADD_NULL          , CURLformcode}+#{symbol CURL_FORMADD_UNKNOWN_OPTION, CURLformcode}+#{symbol CURL_FORMADD_INCOMPLETE    , CURLformcode}+#{symbol CURL_FORMADD_ILLEGAL_ARRAY , CURLformcode}+#{symbol CURL_FORMADD_DISABLED      , CURLformcode}+++-- ----------------------------------------------------------------------------+-- CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost,+--                                       struct curl_httppost **last_post,+--                                       ...);+++-------------------------------------------------------------------------------+type CCURL_formget_callback+  = Ptr () -> Ptr CChar -> CSize -> IO CSize++foreign import ccall "wrapper"+  wrap_ccurl_formget_callback+    :: CCURL_formget_callback+    -> IO (FunPtr CCURL_formget_callback)+++-------------------------------------------------------------------------------+foreign import ccall "curl_formget"+  ccurl_formget+    :: Ptr CCURL_httppost+    -> Ptr ()+    -> FunPtr CCURL_formget_callback+    -> IO CInt+++-------------------------------------------------------------------------------+foreign import ccall "curl_formfree"+  ccurl_formfree+    :: Ptr CCURL_httppost+    -> IO ()+++-------------------------------------------------------------------------------+-- ** Functions+-------------------------------------------------------------------------------+{-# DEPRECATED ccurl_getenv "" #-}+foreign import ccall "curl_getenv"+  ccurl_getenv+    :: Ptr CChar+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_version"+  ccurl_version+    :: IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_escape"+  ccurl_easy_escape+    :: Ptr CCURL+    -> Ptr CChar+    -> CInt+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_escape"+  ccurl_escape+    :: Ptr CChar+    -> CInt+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_unescape"+  ccurl_easy_unescape+    :: Ptr CCURL+    -> Ptr CChar+    -> CInt+    -> Ptr CInt+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_unescape"+  ccurl_unescape+    :: Ptr CChar+    -> CInt+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_free"+  ccurl_free+    :: Ptr a+    -> IO ()+++-------------------------------------------------------------------------------+foreign import ccall "curl_global_init"+  ccurl_global_init+    :: CLong+    -> IO CCURLcode+++-------------------------------------------------------------------------------+foreign import ccall "curl_global_init_mem"+  ccurl_global_init_mem+    :: CLong+    -> FunPtr CCURL_malloc_callback+    -> FunPtr CCURL_free_callback+    -> FunPtr CCURL_realloc_callback+    -> FunPtr CCURL_strdup_callback+    -> FunPtr CCURL_calloc_callback+    -> IO CCURLcode+++-------------------------------------------------------------------------------+foreign import ccall "curl_global_cleanup"+  ccurl_global_cleanup+    :: IO ()+++-------------------------------------------------------------------------------+-- ** CURL_slist+-------------------------------------------------------------------------------+data CCURL_slist = CCURL_slist+  { ccurl_slist_data :: Ptr CChar+  , ccurl_slist_next :: Ptr CCURL_slist+  } deriving (Show)++instance Storable CCURL_slist where+  sizeOf _    = #{size    struct curl_slist}+  alignment _ = #{alignof struct curl_slist}+  poke _ _    = undefined+  peek ptr    = CCURL_slist+    <$> #{peek struct curl_slist, data} ptr+    <*> #{peek struct curl_slist, next} ptr++ +-------------------------------------------------------------------------------+-- ** Functions+-------------------------------------------------------------------------------+foreign import ccall "curl_slist_append"+  ccurl_slist_append+    :: Ptr CCURL_slist+    -> Ptr CChar+    -> IO (Ptr CCURL_slist)+++-------------------------------------------------------------------------------+foreign import ccall "curl_slist_free_all"+  ccurl_slist_free_all+    :: Ptr CCURL_slist+    -> IO ()++ +-------------------------------------------------------------------------------+foreign import ccall "curl_getdate"+  ccurl_getdate+    :: Ptr CChar+    -> Ptr CTime+    -> IO CTime+++-------------------------------------------------------------------------------+-- ** CURL_certinfo+-------------------------------------------------------------------------------+data CCURL_certinfo = CCURL_certinfo+  { ccurl_certinfo_num_of_certs :: CInt+  , ccurl_certinfo_certinfo     :: Ptr (Ptr CCURL_slist)+  } deriving (Show)++instance Storable CCURL_certinfo where+  sizeOf _    = #{size    struct curl_certinfo}+  alignment _ = #{alignof struct curl_certinfo}+  poke _ _    = undefined+  peek ptr    = CCURL_certinfo+    <$> #{peek struct curl_certinfo, num_of_certs} ptr+    <*> #{peek struct curl_certinfo, certinfo    } ptr+++-------------------------------------------------------------------------------+-- ** Constants+-------------------------------------------------------------------------------+-- *** CURLinfo+-------------------------------------------------------------------------------+newtype CCURLinfo'CString = CCURLinfo'CString CInt deriving (Eq, Show)+newtype CCURLinfo'CDouble = CCURLinfo'CDouble CInt deriving (Eq, Show)+newtype CCURLinfo'CLong   = CCURLinfo'CLong   CInt deriving (Eq, Show)+newtype CCURLinfo'SList   = CCURLinfo'SList   CInt deriving (Eq, Show)+newtype CCURLinfo'CertI   = CCURLinfo'CertI   CInt deriving (Eq, Show)++#define hsc_curlinfo(name, type) \+  printf("c" #name " :: CCURLinfo'" #type "\n"); \+  printf("c" #name " =  CCURLinfo'" #type " "); hsc_const(name);++#{curlinfo CURLINFO_EFFECTIVE_URL          , CString}+#{curlinfo CURLINFO_RESPONSE_CODE          , CLong  }+#{curlinfo CURLINFO_TOTAL_TIME             , CDouble}+#{curlinfo CURLINFO_NAMELOOKUP_TIME        , CDouble}+#{curlinfo CURLINFO_CONNECT_TIME           , CDouble}+#{curlinfo CURLINFO_PRETRANSFER_TIME       , CDouble}+#{curlinfo CURLINFO_SIZE_UPLOAD            , CDouble}+#{curlinfo CURLINFO_SIZE_DOWNLOAD          , CDouble}+#{curlinfo CURLINFO_SPEED_DOWNLOAD         , CDouble}+#{curlinfo CURLINFO_SPEED_UPLOAD           , CDouble}+#{curlinfo CURLINFO_HEADER_SIZE            , CLong  }+#{curlinfo CURLINFO_REQUEST_SIZE           , CLong  }+#{curlinfo CURLINFO_SSL_VERIFYRESULT       , CLong  }+#{curlinfo CURLINFO_FILETIME               , CLong  }+#{curlinfo CURLINFO_CONTENT_LENGTH_DOWNLOAD, CDouble}+#{curlinfo CURLINFO_CONTENT_LENGTH_UPLOAD  , CDouble}+#{curlinfo CURLINFO_STARTTRANSFER_TIME     , CDouble}+#{curlinfo CURLINFO_CONTENT_TYPE           , CString}+#{curlinfo CURLINFO_REDIRECT_TIME          , CDouble}+#{curlinfo CURLINFO_REDIRECT_COUNT         , CLong  }+#{curlinfo CURLINFO_PRIVATE                , CString}+#{curlinfo CURLINFO_HTTP_CONNECTCODE       , CLong  }+#{curlinfo CURLINFO_HTTPAUTH_AVAIL         , CLong  }+#{curlinfo CURLINFO_PROXYAUTH_AVAIL        , CLong  }+#{curlinfo CURLINFO_OS_ERRNO               , CLong  }+#{curlinfo CURLINFO_NUM_CONNECTS           , CLong  }+#{curlinfo CURLINFO_SSL_ENGINES            , SList  }+#{curlinfo CURLINFO_COOKIELIST             , SList  }+#{curlinfo CURLINFO_LASTSOCKET             , CLong  }+#{curlinfo CURLINFO_FTP_ENTRY_PATH         , CString}+#{curlinfo CURLINFO_REDIRECT_URL           , CString}+#{curlinfo CURLINFO_PRIMARY_IP             , CString}+#{curlinfo CURLINFO_APPCONNECT_TIME        , CDouble}+#{curlinfo CURLINFO_CERTINFO               , CertI  }+#{curlinfo CURLINFO_CONDITION_UNMET        , CLong  }+#{curlinfo CURLINFO_RTSP_SESSION_ID        , CString}+#{curlinfo CURLINFO_RTSP_CLIENT_CSEQ       , CLong  }+#{curlinfo CURLINFO_RTSP_SERVER_CSEQ       , CLong  }+#{curlinfo CURLINFO_RTSP_CSEQ_RECV         , CLong  }+#{curlinfo CURLINFO_PRIMARY_PORT           , CLong  } |7210:----|+#{curlinfo CURLINFO_LOCAL_IP               , CString} |7210:----|+#{curlinfo CURLINFO_LOCAL_PORT             , CLong  } |7210:----|+++-------------------------------------------------------------------------------+-- *** CURLclosepol+-------------------------------------------------------------------------------+#{cconst CURLCLOSEPOLICY_NONE               , CLong}+#{cconst CURLCLOSEPOLICY_OLDEST             , CLong}+#{cconst CURLCLOSEPOLICY_LEAST_RECENTLY_USED, CLong}+#{cconst CURLCLOSEPOLICY_LEAST_TRAFFIC      , CLong}+#{cconst CURLCLOSEPOLICY_SLOWEST            , CLong}+#{cconst CURLCLOSEPOLICY_CALLBACK           , CLong}+++-------------------------------------------------------------------------------+-- *** CURLglobal+-------------------------------------------------------------------------------+#{cconst CURL_GLOBAL_SSL    , CLong}+#{cconst CURL_GLOBAL_WIN32  , CLong}+#{cconst CURL_GLOBAL_ALL    , CLong}+#{cconst CURL_GLOBAL_NOTHING, CLong}+#{cconst CURL_GLOBAL_DEFAULT, CLong}+++-------------------------------------------------------------------------------+-- ** Share interface+-------------------------------------------------------------------------------+newtype CCURL_lock_data = CCURL_lock_data CInt deriving (Eq, Show)++#{symbol CURL_LOCK_DATA_COOKIE     , CURL_lock_data}+#{symbol CURL_LOCK_DATA_DNS        , CURL_lock_data}+#{symbol CURL_LOCK_DATA_SSL_SESSION, CURL_lock_data}+#{symbol CURL_LOCK_DATA_CONNECT    , CURL_lock_data}+ ++-------------------------------------------------------------------------------+newtype CCURL_lock_access = CCURL_lock_access CInt deriving (Eq, Show)++#{symbol CURL_LOCK_ACCESS_NONE  , CURL_lock_access}+#{symbol CURL_LOCK_ACCESS_SHARED, CURL_lock_access}+#{symbol CURL_LOCK_ACCESS_SINGLE, CURL_lock_access}+++-------------------------------------------------------------------------------+type CCURL_lock_function+  = Ptr CCURL -> CCURL_lock_data -> CCURL_lock_access -> Ptr () -> IO ()++foreign import ccall "wrapper"+  wrap_ccurl_lock_function+    :: CCURL_lock_function+    -> IO (FunPtr CCURL_lock_function)+++-------------------------------------------------------------------------------+type CCURL_unlock_function+  = Ptr CCURL -> CCURL_lock_data -> Ptr () -> IO ()++foreign import ccall "wrapper"+  wrap_ccurl_unlock_function+    :: CCURL_unlock_function+    -> IO (FunPtr CCURL_unlock_function)+++-------------------------------------------------------------------------------+data CCURLSH++ +-------------------------------------------------------------------------------+newtype CCURLSHcode = CCURLSHcode CInt deriving (Eq, Show)++#{symbol CURLSHE_OK          , CURLSHcode}+#{symbol CURLSHE_BAD_OPTION  , CURLSHcode}+#{symbol CURLSHE_IN_USE      , CURLSHcode}+#{symbol CURLSHE_INVALID     , CURLSHcode}+#{symbol CURLSHE_NOMEM       , CURLSHcode}+#{symbol CURLSHE_NOT_BUILT_IN, CURLSHcode} |7230:----|+++-------------------------------------------------------------------------------+newtype CCURLSHoption'Lock    = CCURLSHoption'Lock    CInt deriving (Eq, Show)+newtype CCURLSHoption'FLOCK   = CCURLSHoption'FLOCK   CInt deriving (Eq, Show)+newtype CCURLSHoption'FUNLOCK = CCURLSHoption'FUNLOCK CInt deriving (Eq, Show)+newtype CCURLSHoption'UsrPtr  = CCURLSHoption'UsrPtr  CInt deriving (Eq, Show)++#define hsc_curlshopt(name, type) \+  printf("c" #name " :: CCURLSHoption'" #type "\n"); \+  printf("c" #name " =  CCURLSHoption'" #type " "); hsc_const(name);++#{curlshopt CURLSHOPT_SHARE     , Lock   }+#{curlshopt CURLSHOPT_UNSHARE   , Lock   }+#{curlshopt CURLSHOPT_LOCKFUNC  , FLOCK  }+#{curlshopt CURLSHOPT_UNLOCKFUNC, FUNLOCK}+#{curlshopt CURLSHOPT_USERDATA  , UsrPtr }+++-------------------------------------------------------------------------------+foreign import ccall "curl_share_init"+  ccurl_share_init+    :: IO (Ptr CCURLSH)+++-------------------------------------------------------------------------------+foreign import ccall "curl_share_setopt"+  ccurl_share_setopt'Lock   +    :: Ptr CCURLSH+    -> CCURLSHoption'Lock   +    -> CCURL_lock_data+    -> IO CCURLSHcode++foreign import ccall "curl_share_setopt"+  ccurl_share_setopt'FLOCK+    :: Ptr CCURLSH+    -> CCURLSHoption'FLOCK+    -> FunPtr CCURL_lock_function+    -> IO CCURLSHcode++foreign import ccall "curl_share_setopt"+  ccurl_share_setopt'FUNLOCK+    :: Ptr CCURLSH+    -> CCURLSHoption'FUNLOCK+    -> FunPtr CCURL_unlock_function+    -> IO CCURLSHcode++foreign import ccall "curl_share_setopt"+  ccurl_share_setopt'UsrPtr +    :: Ptr CCURLSH+    -> CCURLSHoption'UsrPtr +    -> Ptr ()+    -> IO CCURLSHcode+++-------------------------------------------------------------------------------+foreign import ccall "curl_share_cleanup"+  ccurl_share_cleanup+    :: Ptr CCURLSH+    -> IO CCURLSHcode+++-------------------------------------------------------------------------------+-- ** CURL_version_info+-------------------------------------------------------------------------------+newtype CCURLversion = CCURLversion CInt deriving (Eq, Show)++instance Storable CCURLversion where+  sizeOf _    = #{size    CURLversion}+  alignment _ = #{alignof CURLversion}+  poke _ _    = undefined+  peek ptr    = CCURLversion <$> peek (castPtr ptr)++#{symbol CURLVERSION_FIRST , CURLversion}+#{symbol CURLVERSION_SECOND, CURLversion}+#{symbol CURLVERSION_THIRD , CURLversion}+#{symbol CURLVERSION_FOURTH, CURLversion}+#{symbol CURLVERSION_NOW   , CURLversion}+++-------------------------------------------------------------------------------+data CCURL_version_info_data = CCURL_version_info_data+  { ccurl_version_info_data_age             :: CCURLversion+  , ccurl_version_info_data_version         :: Ptr CChar+  , ccurl_version_info_data_version_num     :: CUInt+  , ccurl_version_info_data_host            :: Ptr CChar+  , ccurl_version_info_data_features        :: CInt+  , ccurl_version_info_data_ssl_version     :: Ptr CChar+  , ccurl_version_info_data_ssl_version_num :: CLong+  , ccurl_version_info_data_libz_version    :: Ptr CChar+  , ccurl_version_info_data_protocols       :: Ptr (Ptr CChar)+  , ccurl_version_info_data_ares            :: Ptr CChar+  , ccurl_version_info_data_ares_num        :: CInt+  , ccurl_version_info_data_libidn          :: Ptr CChar+  , ccurl_version_info_data_iconv_ver_num   :: CInt+  , ccurl_version_info_data_libssh_version  :: Ptr CChar+  } deriving (Show)++instance Storable CCURL_version_info_data where+  sizeOf _    = #{size    curl_version_info_data}+  alignment _ = #{alignof curl_version_info_data}+  poke _ _    = undefined+  peek ptr    = CCURL_version_info_data+    <$> #{peek curl_version_info_data, age            } ptr+    <*> #{peek curl_version_info_data, version        } ptr+    <*> #{peek curl_version_info_data, version_num    } ptr+    <*> #{peek curl_version_info_data, host           } ptr+    <*> #{peek curl_version_info_data, features       } ptr+    <*> #{peek curl_version_info_data, ssl_version    } ptr+    <*> #{peek curl_version_info_data, ssl_version_num} ptr+    <*> #{peek curl_version_info_data, libz_version   } ptr+    <*> #{peek curl_version_info_data, protocols      } ptr+    <*> #{peek curl_version_info_data, ares           } ptr+    <*> #{peek curl_version_info_data, ares_num       } ptr+    <*> #{peek curl_version_info_data, libidn         } ptr+    <*> #{peek curl_version_info_data, iconv_ver_num  } ptr+    <*> #{peek curl_version_info_data, libssh_version } ptr+++-------------------------------------------------------------------------------+#{cconst CURL_VERSION_IPV6        , CInt}+#{cconst CURL_VERSION_KERBEROS4   , CInt}+#{cconst CURL_VERSION_SSL         , CInt}+#{cconst CURL_VERSION_LIBZ        , CInt}+#{cconst CURL_VERSION_NTLM        , CInt}+#{cconst CURL_VERSION_GSSNEGOTIATE, CInt}+#{cconst CURL_VERSION_DEBUG       , CInt}+#{cconst CURL_VERSION_ASYNCHDNS   , CInt}+#{cconst CURL_VERSION_SPNEGO      , CInt}+#{cconst CURL_VERSION_LARGEFILE   , CInt}+#{cconst CURL_VERSION_IDN         , CInt}+#{cconst CURL_VERSION_SSPI        , CInt}+#{cconst CURL_VERSION_CONV        , CInt}+#{cconst CURL_VERSION_CURLDEBUG   , CInt}+#{cconst CURL_VERSION_TLSAUTH_SRP , CInt} |7214:----|+#{cconst CURL_VERSION_NTLM_WB     , CInt} |7220:----|++ +-------------------------------------------------------------------------------+-- ** Functions+-------------------------------------------------------------------------------+foreign import ccall "curl_version_info"+  ccurl_version_info+    :: CCURLversion+    -> IO (Ptr CCURL_version_info_data)+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_strerror"+  ccurl_easy_strerror+    :: CCURLcode+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_share_strerror"+  ccurl_share_strerror+    :: CCURLSHcode+    -> IO (Ptr CChar)+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_pause"+  ccurl_easy_pause+    :: Ptr CCURL+    -> CInt+    -> IO CCURLcode+ +#{cconst CURLPAUSE_RECV     , CInt}+#{cconst CURLPAUSE_RECV_CONT, CInt}+#{cconst CURLPAUSE_SEND     , CInt}+#{cconst CURLPAUSE_SEND_CONT, CInt}+#{cconst CURLPAUSE_ALL      , CInt}+#{cconst CURLPAUSE_CONT     , CInt}+++-------------------------------------------------------------------------------+-- * Definitions from \"curl/easy.h\"+-------------------------------------------------------------------------------+foreign import ccall "curl_easy_init"+  ccurl_easy_init+    :: IO (Ptr CCURL)+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'CLong+    :: Ptr CCURL+    -> CCURLoption'CLong+    -> CLong+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'Int64+    :: Ptr CCURL+    -> CCURLoption'Int64+    -> CCURL_off_t+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'CString+    :: Ptr CCURL+    -> CCURLoption'CString+    -> Ptr CChar+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'CFile+    :: Ptr CCURL+    -> CCURLoption'CFile+    -> Ptr CFile+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'SList+    :: Ptr CCURL+    -> CCURLoption'SList+    -> Ptr CCURL_slist+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'HTTPP+    :: Ptr CCURL+    -> CCURLoption'HTTPP+    -> Ptr CCURL_httppost+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'CURLSH+    :: Ptr CCURL+    -> CCURLoption'CURLSH+    -> Ptr CCURLSH+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'UsrPtr+    :: Ptr CCURL+    -> CCURLoption'UsrPtr+    -> Ptr ()+    -> IO CCURLcode++foreign import ccall "curl_easy_setopt"+  ccurl_easy_setopt'FunPtr+    :: Ptr CCURL+    -> CCURLoption'FunPtr+    -> FunPtr a+    -> IO CCURLcode++#define hsc_setFunPtrAlias(fn, un, ln) \+  printf("ccurl_easy_setopt'" #fn "\n"); \+  printf("  :: Ptr CCURL -> FunPtr CCURL_" #ln "_callback -> IO CCURLcode\n");\+  printf("ccurl_easy_setopt'" #fn " curl fptr\n"); \+  printf("  = ccurl_easy_setopt'FunPtr curl cCURLOPT_" #un "FUNCTION fptr");++#{setFunPtrAlias FWRITE      , WRITE      , write      }+#{setFunPtrAlias FREAD       , READ       , read       }+#{setFunPtrAlias FPROGRESS   , PROGRESS   , progress   }+#{setFunPtrAlias FHEADER     , HEADER     , write      }+#{setFunPtrAlias FDEBUG      , DEBUG      , debug      }+#{setFunPtrAlias FSSLCTX     , SSL_CTX_   , ssl_ctx    }+#{setFunPtrAlias FIOCTL      , IOCTL      , ioctl      }+#{setFunPtrAlias FCONVFROM   , CONV_FROM_NETWORK_, conv}+#{setFunPtrAlias FCONVTO     , CONV_TO_NETWORK_  , conv}+#{setFunPtrAlias FCONVUTF8   , CONV_FROM_UTF8_   , conv}+#{setFunPtrAlias FSOCKOPT    , SOCKOPT    , sockopt    }+#{setFunPtrAlias FOPENSOCKET , OPENSOCKET , opensocket }+#{setFunPtrAlias FSEEK       , SEEK       , seek       }+#{setFunPtrAlias FSSHKEY     , SSH_KEY    , sshkey     }+#{setFunPtrAlias FINTERLEAVE , INTERLEAVE , write      }+#{setFunPtrAlias FCHUNKBGN   , CHUNK_BGN_ , chunk_bgn  } |7210:----|+#{setFunPtrAlias FCHUNKEND   , CHUNK_END_ , chunk_end  } |7210:----|+#{setFunPtrAlias FFNMATCH    , FNMATCH_   , fnmatch    } |7210:----|+#{setFunPtrAlias FCLOSESOCKET, CLOSESOCKET, closesocket} |7217:----|+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_perform"+  ccurl_easy_perform+    :: Ptr CCURL+    -> IO CCURLcode+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_cleanup"+  ccurl_easy_cleanup+    :: Ptr CCURL+    -> IO ()+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_getinfo"+  ccurl_easy_getinfo'CString+    :: Ptr CCURL+    -> CCURLinfo'CString+    -> Ptr (Ptr CChar)+    -> IO CCURLcode++foreign import ccall "curl_easy_getinfo"+  ccurl_easy_getinfo'CDouble+    :: Ptr CCURL+    -> CCURLinfo'CDouble+    -> Ptr CDouble+    -> IO CCURLcode++foreign import ccall "curl_easy_getinfo"+  ccurl_easy_getinfo'CLong+    :: Ptr CCURL+    -> CCURLinfo'CLong+    -> Ptr CLong+    -> IO CCURLcode++foreign import ccall "curl_easy_getinfo"+  ccurl_easy_getinfo'SList+    :: Ptr CCURL+    -> CCURLinfo'SList+    -> Ptr (Ptr CCURL_slist)+    -> IO CCURLcode++foreign import ccall "curl_easy_getinfo"+  ccurl_easy_getinfo'CertI+    :: Ptr CCURL+    -> CCURLinfo'CertI+    -> Ptr (Ptr CCURL_certinfo)+    -> IO CCURLcode+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_duphandle"+  ccurl_easy_duphandle+    :: Ptr CCURL+    -> IO (Ptr CCURL)+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_reset"+  ccurl_easy_reset+    :: Ptr CCURL+    -> IO ()+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_recv"+  ccurl_easy_recv+    :: Ptr CCURL+    -> Ptr a+    -> CSize+    -> Ptr CSize+    -> IO CCURLcode+++-------------------------------------------------------------------------------+foreign import ccall "curl_easy_send"+  ccurl_easy_send+    :: Ptr CCURL+    -> Ptr a+    -> CSize+    -> Ptr CSize+    -> IO CCURLcode++ +-------------------------------------------------------------------------------+-- * Definitions from \"curl/multi.h\"+-------------------------------------------------------------------------------+-- todo+
+ Network/Curlhs/Core.hs view
@@ -0,0 +1,122 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  Network.Curlhs.Core+-- Copyright   :  Copyright © 2012 Krzysztof Kardzis+-- License     :  ISC License (MIT/BSD-style, see LICENSE file for details)+-- +-- Maintainer  :  Krzysztof Kardzis <kkardzis@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+--+--+-- Module "Network.Curlhs.Core" provides a mid-level interface to @libcurl@.+-- For a direct low-level bindings go to "Network.Curlhs.Base".+--+-- API of this module follows the API of @libcurl@ as defined in version+-- 7.25.0 of the library. But it also depends on the version of @libcurl@+-- that is used during compilation of the @curlhs@ package. It is possible+-- to use @curlhs@ with older versions of @libcurl@, just keep in mind+-- that some features may not be available then.+--+-- There is not much documentation here, maybe the future will change that,+-- but for now please use the original @libcurl@ documentation. API provided+-- here follows the original API, so this shouldn't be a big problem.+-- Documentation about @libcurl@ and/or its particular functions may be+-- found in manual pages, which are available among others at the @libcurl@+-- project site (please refer to <http://curl.haxx.se/libcurl/>).+-- +-- Exposed API is still somewhat incomplete, but is usable.+-- Work on the rest are in progress.+--+-- Simple example:+--+-- > import qualified Data.ByteString.Char8 as BS+-- > import Data.IORef (newIORef, readIORef, atomicModifyIORef)+-- > import Control.Exception (bracket)+-- > import Network.Curlhs.Core+-- > +-- > curlGET :: BS.ByteString -> IO BS.ByteString+-- > curlGET url = do+-- >   buff <- newIORef BS.empty+-- >   bracket (curl_easy_init) (curl_easy_cleanup) $ \curl -> do+-- >     curl_easy_setopt curl+-- >       [ CURLOPT_URL     url+-- >       , CURLOPT_VERBOSE True+-- >       , CURLOPT_WRITEFUNCTION $ Just (memwrite buff)+-- >       ]+-- >     curl_easy_perform curl+-- >   readIORef buff+-- > +-- > memwrite buff newbs = atomicModifyIORef buff $ \oldbuff ->+-- >   (BS.append oldbuff newbs, CURL_WRITEFUNC_OK)+--+-------------------------------------------------------------------------------++module Network.Curlhs.Core (++  -- * Global interface++  -- ** Version info+    curl_version+  , curl_version_info+  , CURL_version_info_data (..)+  , CURL_version (..)++  -- ** Error codes+  -- |  More about error codes in libcurl on+  --    <http://curl.haxx.se/libcurl/c/libcurl-errors.html>+  , curl_easy_strerror+  , CURLcode (..)++  -- * Easy interface+  -- | See <http://curl.haxx.se/libcurl/c/libcurl-easy.html>+  --   for easy interface overview.++  -- ** Init, reset, cleanup+  , curl_easy_init+  , curl_easy_reset+  , curl_easy_cleanup+  , CURL++  -- ** Transfer+  , curl_easy_perform++  -- ** Get info+  , curl_easy_getinfo+  , CURLinfo (..)++  -- ** Set options+  , curl_easy_setopt+  , CURLoption (..)++  -- *** Callbacks+  , CURL_write_callback, CURL_write_response (..)+  , CURL_read_callback , CURL_read_response  (..)++  -- *** Constants+  , CURLproto     (..)+  , CURLproxy     (..)+  , CURLnetrc     (..)+  , CURLauth      (..)+  , CURLtlsauth   (..) |7214:----|+  , CURLredir     (..)+  , CURLhttpver   (..)+  , CURLftpcreate (..)+  , CURLftpauth   (..)+  , CURLftpssl    (..)+  , CURLftpmethod (..)+  , CURLrtspreq   (..)+  , CURLtimecond  (..)+  , CURLclosepol  (..)+  , CURLipresolve (..)+  , CURLusessl    (..)+  , CURLsslver    (..)+  , CURLsslopt    (..) |7250:----|+  , CURLgssapi    (..) |7220:----|+  , CURLsshauth   (..)++  ) where++import Network.Curlhs.Types+import Network.Curlhs.Easy+
+ Network/Curlhs/Easy.hs view
@@ -0,0 +1,284 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  Network.Curlhs.Easy+-- Copyright   :  Copyright © 2012 Krzysztof Kardzis+-- License     :  ISC License (MIT/BSD-style, see LICENSE file for details)+-- +-- Maintainer  :  Krzysztof Kardzis <kkardzis@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+--+-------------------------------------------------------------------------------++module Network.Curlhs.Easy+  ( curl_version+  , curl_version_info+  , curl_easy_strerror+  , curl_easy_init+  , curl_easy_reset+  , curl_easy_cleanup+  , curl_easy_perform+  , curl_easy_getinfo+  , curl_easy_setopt+  ) where++import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Utils (toBool)+import Foreign.Storable      (peek, sizeOf)+import Foreign.C.String      (peekCString)+import Foreign.C.Types       (CChar, CInt)+import Foreign.Ptr           (Ptr, nullPtr, plusPtr)++import Data.Time.Clock.POSIX (posixSecondsToUTCTime)+import Data.Time.Clock       (UTCTime)+import Data.Maybe            (mapMaybe)+import Data.Bits             ((.&.))+import Data.IORef            (newIORef)++import Control.Applicative   ((<$>), (<*>))+import Control.Exception     (throwIO)++import Network.Curlhs.Errors+import Network.Curlhs.Setopt+import Network.Curlhs.Types+import Network.Curlhs.Base+++-------------------------------------------------------------------------------+-- | Returns the libcurl version string+--   (<http://curl.haxx.se/libcurl/c/curl_version.html>).+-------------------------------------------------------------------------------+curl_version :: IO String+curl_version = ccurl_version >>= peekCString+++-------------------------------------------------------------------------------+-- | Returns run-time libcurl version info+--   (<http://curl.haxx.se/libcurl/c/curl_version_info.html>).+-------------------------------------------------------------------------------+curl_version_info :: IO CURL_version_info_data+curl_version_info = ccurl_version_info cCURLVERSION_NOW >>= peek >>=+  \cval -> CURL_version_info_data+    <$> (peekCString      $ ccurl_version_info_data_version         cval)+    <*> (peekCIntegral    $ ccurl_version_info_data_version_num     cval)+    <*> (peekCString      $ ccurl_version_info_data_host            cval)+    <*> (peekCFeatures    $ ccurl_version_info_data_features        cval)+    <*> (peekCStringMaybe $ ccurl_version_info_data_ssl_version     cval)+    <*> (peekCIntegral    $ ccurl_version_info_data_ssl_version_num cval)+    <*> (peekCStringMaybe $ ccurl_version_info_data_libz_version    cval)+    <*> (peekCStringList  $ ccurl_version_info_data_protocols       cval)+    <*> (peekCStringMaybe $ ccurl_version_info_data_ares            cval)+    <*> (peekCIntegral    $ ccurl_version_info_data_ares_num        cval)+    <*> (peekCStringMaybe $ ccurl_version_info_data_libidn          cval)+    <*> (peekCIntegral    $ ccurl_version_info_data_iconv_ver_num   cval)+    <*> (peekCStringMaybe $ ccurl_version_info_data_libssh_version  cval)++peekCStringList :: Ptr (Ptr CChar) -> IO [String]+peekCStringList ptr = peek ptr >>= \cstring ->+  if (cstring == nullPtr) then return [] else do+    let size = sizeOf (undefined :: Ptr CChar)+    strings <- peekCStringList (plusPtr ptr size)+    string  <- peekCString cstring+    return (string : strings)++peekCStringMaybe :: Ptr CChar -> IO (Maybe String)+peekCStringMaybe ptr = if (ptr /= nullPtr)+  then Just <$> peekCString ptr+  else return Nothing++peekCIntegral :: (Num h, Integral c) => c -> IO h+peekCIntegral = return . fromIntegral++peekCFeatures :: CInt -> IO [CURL_version]+peekCFeatures mask =+  return $ mapMaybe (\(v, b) -> if (mask .&. b == 0) then Nothing else Just v)+    [ (CURL_VERSION_IPV6        , cCURL_VERSION_IPV6        )+    , (CURL_VERSION_KERBEROS4   , cCURL_VERSION_KERBEROS4   )+    , (CURL_VERSION_SSL         , cCURL_VERSION_SSL         )+    , (CURL_VERSION_LIBZ        , cCURL_VERSION_LIBZ        )+    , (CURL_VERSION_NTLM        , cCURL_VERSION_NTLM        )+    , (CURL_VERSION_GSSNEGOTIATE, cCURL_VERSION_GSSNEGOTIATE)+    , (CURL_VERSION_DEBUG       , cCURL_VERSION_DEBUG       )+    , (CURL_VERSION_ASYNCHDNS   , cCURL_VERSION_ASYNCHDNS   )+    , (CURL_VERSION_SPNEGO      , cCURL_VERSION_SPNEGO      )+    , (CURL_VERSION_LARGEFILE   , cCURL_VERSION_LARGEFILE   )+    , (CURL_VERSION_IDN         , cCURL_VERSION_IDN         )+    , (CURL_VERSION_SSPI        , cCURL_VERSION_SSPI        )+    , (CURL_VERSION_CONV        , cCURL_VERSION_CONV        )+    , (CURL_VERSION_CURLDEBUG   , cCURL_VERSION_CURLDEBUG   )+    , (CURL_VERSION_TLSAUTH_SRP , cCURL_VERSION_TLSAUTH_SRP ) |7214:----|+    , (CURL_VERSION_NTLM_WB     , cCURL_VERSION_NTLM_WB     ) |7220:----|+    ]+++-------------------------------------------------------------------------------+-- | Start a libcurl easy session+--   (<http://curl.haxx.se/libcurl/c/curl_easy_init.html>).+-------------------------------------------------------------------------------+curl_easy_init :: IO CURL+curl_easy_init = ccurl_easy_init >>= \ccurl -> if (ccurl == nullPtr)+  then throwIO CURLE_FAILED_INIT+  else CURL ccurl+    <$> newIORef Nothing+    <*> newIORef Nothing+++-------------------------------------------------------------------------------+-- | Reset all options of a libcurl session handle+--   (<http://curl.haxx.se/libcurl/c/curl_easy_reset.html>).+-------------------------------------------------------------------------------+curl_easy_reset :: CURL -> IO ()+curl_easy_reset curl =+  ccurl_easy_reset (ccurlptr curl) >> freeCallbacks curl+++-------------------------------------------------------------------------------+-- | End a libcurl easy session+--   (<http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html>).+-------------------------------------------------------------------------------+curl_easy_cleanup :: CURL -> IO ()+curl_easy_cleanup curl =+  ccurl_easy_cleanup (ccurlptr curl) >> freeCallbacks curl+++-------------------------------------------------------------------------------+-- | Perform a file transfer+--   (<http://curl.haxx.se/libcurl/c/curl_easy_perform.html>).+-------------------------------------------------------------------------------+curl_easy_perform :: CURL -> IO ()+curl_easy_perform curl = withCODE $ ccurl_easy_perform (ccurlptr curl)+++-------------------------------------------------------------------------------+-- | Extract information from a curl handle+--   (<http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html>).+-------------------------------------------------------------------------------+curl_easy_getinfo :: CURL -> IO CURLinfo+curl_easy_getinfo curl = let ccurl = ccurlptr curl in CURLinfo+  <$> getinfo'String   ccurl cCURLINFO_EFFECTIVE_URL+  <*> getinfo'RespCode ccurl cCURLINFO_RESPONSE_CODE+  <*> getinfo'RespCode ccurl cCURLINFO_HTTP_CONNECTCODE+  <*> getinfo'FileTime ccurl cCURLINFO_FILETIME+  <*> getinfo'Double   ccurl cCURLINFO_TOTAL_TIME+  <*> getinfo'Double   ccurl cCURLINFO_NAMELOOKUP_TIME+  <*> getinfo'Double   ccurl cCURLINFO_CONNECT_TIME+  <*> getinfo'Double   ccurl cCURLINFO_APPCONNECT_TIME+  <*> getinfo'Double   ccurl cCURLINFO_PRETRANSFER_TIME+  <*> getinfo'Double   ccurl cCURLINFO_STARTTRANSFER_TIME+  <*> getinfo'Double   ccurl cCURLINFO_REDIRECT_TIME+  <*> getinfo'Int      ccurl cCURLINFO_REDIRECT_COUNT+  <*> getinfo'MString  ccurl cCURLINFO_REDIRECT_URL+  <*> getinfo'Double   ccurl cCURLINFO_SIZE_UPLOAD+  <*> getinfo'Double   ccurl cCURLINFO_SIZE_DOWNLOAD+  <*> getinfo'Double   ccurl cCURLINFO_SPEED_DOWNLOAD+  <*> getinfo'Double   ccurl cCURLINFO_SPEED_UPLOAD+  <*> getinfo'Int      ccurl cCURLINFO_HEADER_SIZE+  <*> getinfo'Int      ccurl cCURLINFO_REQUEST_SIZE+  <*> getinfo'Int      ccurl cCURLINFO_SSL_VERIFYRESULT+  <*> getinfo'SList    ccurl cCURLINFO_SSL_ENGINES+  <*> getinfo'ContentL ccurl cCURLINFO_CONTENT_LENGTH_DOWNLOAD+  <*> getinfo'ContentL ccurl cCURLINFO_CONTENT_LENGTH_UPLOAD+  <*> getinfo'MString  ccurl cCURLINFO_CONTENT_TYPE+--  <*> getinfo'String   ccurl cCURLINFO_PRIVATE+  <*> getinfo'CurlAuth ccurl cCURLINFO_HTTPAUTH_AVAIL+  <*> getinfo'CurlAuth ccurl cCURLINFO_PROXYAUTH_AVAIL+  <*> getinfo'Int      ccurl cCURLINFO_OS_ERRNO+  <*> getinfo'Int      ccurl cCURLINFO_NUM_CONNECTS+  <*> getinfo'String   ccurl cCURLINFO_PRIMARY_IP+  <*> getinfo'Int      ccurl cCURLINFO_PRIMARY_PORT+  <*> getinfo'String   ccurl cCURLINFO_LOCAL_IP+  <*> getinfo'Int      ccurl cCURLINFO_LOCAL_PORT+  <*> getinfo'SList    ccurl cCURLINFO_COOKIELIST+  <*> getinfo'Socket   ccurl cCURLINFO_LASTSOCKET+  <*> getinfo'MString  ccurl cCURLINFO_FTP_ENTRY_PATH+  <*> getinfo'CertInfo ccurl cCURLINFO_CERTINFO+  <*> getinfo'TimeCond ccurl cCURLINFO_CONDITION_UNMET+  <*> getinfo'MString  ccurl cCURLINFO_RTSP_SESSION_ID+  <*> getinfo'Int      ccurl cCURLINFO_RTSP_CLIENT_CSEQ+  <*> getinfo'Int      ccurl cCURLINFO_RTSP_SERVER_CSEQ+  <*> getinfo'Int      ccurl cCURLINFO_RTSP_CSEQ_RECV++getinfo'String :: Ptr CCURL -> CCURLinfo'CString -> IO String+getinfo'String ccurl cinfo = alloca $ \ptr -> do+  withCODE $ ccurl_easy_getinfo'CString ccurl cinfo ptr+  peek ptr >>= peekCString++getinfo'MString :: Ptr CCURL -> CCURLinfo'CString -> IO (Maybe String)+getinfo'MString ccurl cinfo = alloca $ \ptr -> do+  withCODE $ ccurl_easy_getinfo'CString ccurl cinfo ptr+  peek ptr >>= \csptr -> if (csptr /= nullPtr)+    then Just <$> peekCString csptr+    else return Nothing++getinfo'Double :: Ptr CCURL -> CCURLinfo'CDouble -> IO Double+getinfo'Double ccurl cinfo = alloca $ \ptr -> do+  withCODE $ ccurl_easy_getinfo'CDouble ccurl cinfo ptr+  realToFrac <$> peek ptr++getinfo'ContentL :: Ptr CCURL -> CCURLinfo'CDouble -> IO (Maybe Double)+getinfo'ContentL ccurl cinfo = getinfo'Double ccurl cinfo >>= \v ->+  return $ if (v == (-1)) then Nothing else Just v++getinfo'SList :: Ptr CCURL -> CCURLinfo'SList -> IO [String]+getinfo'SList ccurl cinfo = alloca $ \ptr -> do+  withCODE $ ccurl_easy_getinfo'SList ccurl cinfo ptr+  peek ptr >>= \slist -> do+    strings <- peek'CCURL_slist slist+    ccurl_slist_free_all slist+    return strings++getinfo'CertInfo :: Ptr CCURL -> CCURLinfo'CertI -> IO [[String]]+getinfo'CertInfo ccurl cinfo = alloca $ \ptr -> do+  withCODE $ ccurl_easy_getinfo'CertI ccurl cinfo ptr+  peek ptr >>= peek'CCURL_certinfo++getinfo'Int :: Ptr CCURL -> CCURLinfo'CLong -> IO Int+getinfo'Int ccurl cinfo = alloca $ \ptr -> do+  withCODE $ ccurl_easy_getinfo'CLong ccurl cinfo ptr+  fromIntegral <$> peek ptr++getinfo'RespCode :: Ptr CCURL -> CCURLinfo'CLong -> IO (Maybe Int)+getinfo'RespCode ccurl cinfo = getinfo'Int ccurl cinfo >>= \v ->+  return $ if (v == 0) then Nothing else Just v++getinfo'FileTime :: Ptr CCURL -> CCURLinfo'CLong -> IO (Maybe UTCTime)+getinfo'FileTime ccurl cinfo = getinfo'Int ccurl cinfo >>= \v ->+  return $ if (v == (-1) || v == 0) then Nothing+    else Just (posixSecondsToUTCTime $ realToFrac v)++getinfo'Socket :: Ptr CCURL -> CCURLinfo'CLong -> IO (Maybe Int)+getinfo'Socket ccurl cinfo = getinfo'Int ccurl cinfo >>= \v ->+  return $ if (v == (-1)) then Nothing else Just v++getinfo'TimeCond :: Ptr CCURL -> CCURLinfo'CLong -> IO Bool+getinfo'TimeCond ccurl cinfo = toBool <$> getinfo'Int ccurl cinfo++getinfo'CurlAuth :: Ptr CCURL -> CCURLinfo'CLong -> IO [CURLauth]+getinfo'CurlAuth ccurl cinfo = do+  mask <- fromIntegral <$> getinfo'Int ccurl cinfo+  return $ mapMaybe (\(v, b) -> if (mask .&. b == 0) then Nothing else Just v)+    [ (CURLAUTH_BASIC       , cCURLAUTH_BASIC       )+    , (CURLAUTH_DIGEST      , cCURLAUTH_DIGEST      )+    , (CURLAUTH_DIGEST_IE   , cCURLAUTH_DIGEST_IE   )+    , (CURLAUTH_GSSNEGOTIATE, cCURLAUTH_GSSNEGOTIATE)+    , (CURLAUTH_NTLM        , cCURLAUTH_NTLM        )+    , (CURLAUTH_NTLM_WB     , cCURLAUTH_NTLM_WB     ) |7220:----|+    ]+++peek'CCURL_slist :: Ptr CCURL_slist -> IO [String]+peek'CCURL_slist ptr =+  if (ptr == nullPtr) then return [] else peek ptr >>= \slist -> do+    slist_head <- peekCString      $ ccurl_slist_data slist+    slist_tail <- peek'CCURL_slist $ ccurl_slist_next slist+    return (slist_head : slist_tail)++peek'CCURL_certinfo :: Ptr CCURL_certinfo -> IO [[String]]+peek'CCURL_certinfo ptr =+  if (ptr == nullPtr) then return [] else peek ptr >>= \certinfo -> do+    let numOfCerts = fromIntegral $ ccurl_certinfo_num_of_certs certinfo+    let size = sizeOf (undefined :: Ptr CCURL_slist)+    let ptr0 = ccurl_certinfo_certinfo certinfo+    let ptrs = map (\i -> plusPtr ptr0 (i * size)) [0 .. (numOfCerts - 1)]+    mapM (\sptr -> peek sptr >>= peek'CCURL_slist) ptrs+
+ Network/Curlhs/Errors.hsc view
@@ -0,0 +1,216 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  Network.Curlhs.Errors+-- Copyright   :  Copyright © 2012 Krzysztof Kardzis+-- License     :  ISC License (MIT/BSD-style, see LICENSE file for details)+-- +-- Maintainer  :  Krzysztof Kardzis <kkardzis@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+--+-------------------------------------------------------------------------------++module Network.Curlhs.Errors+  ( curl_easy_strerror+  , withCODE+  ) where++import Data.ByteString   (ByteString, packCString)++import Control.Exception (throwIO)+import Control.Monad     (when)++import Network.Curlhs.Types+import Network.Curlhs.Base+++-------------------------------------------------------------------------------+withCODE :: IO CCURLcode -> IO ()+withCODE action =+  action >>= \code -> when (code /= cCURLE_OK) (throwIO (fromCCURLcode code))+++-------------------------------------------------------------------------------+-- | Returns a string describing error code+--   (<http://curl.haxx.se/libcurl/c/curl_easy_strerror.html>).+-------------------------------------------------------------------------------+curl_easy_strerror :: CURLcode -> IO ByteString+curl_easy_strerror code =+  ccurl_easy_strerror (fromCURLcode code) >>= packCString+++-------------------------------------------------------------------------------+#define hsc_curlcode(code) printf(#code " -> c" #code);++fromCURLcode :: CURLcode -> CCURLcode+fromCURLcode x = case x of+  #{curlcode CURLE_OK                      }+  #{curlcode CURLE_UNSUPPORTED_PROTOCOL    }+  #{curlcode CURLE_FAILED_INIT             }+  #{curlcode CURLE_URL_MALFORMAT           }+  #{curlcode CURLE_NOT_BUILT_IN            } |7215:----|+  #{curlcode CURLE_COULDNT_RESOLVE_PROXY   }+  #{curlcode CURLE_COULDNT_RESOLVE_HOST    }+  #{curlcode CURLE_COULDNT_CONNECT         }+  #{curlcode CURLE_FTP_WEIRD_SERVER_REPLY  }+  #{curlcode CURLE_REMOTE_ACCESS_DENIED    }+  #{curlcode CURLE_FTP_ACCEPT_FAILED       } |7240:----|+  #{curlcode CURLE_FTP_WEIRD_PASS_REPLY    }+  #{curlcode CURLE_FTP_ACCEPT_TIMEOUT      } |7240:----|+  #{curlcode CURLE_FTP_WEIRD_PASV_REPLY    }+  #{curlcode CURLE_FTP_WEIRD_227_FORMAT    }+  #{curlcode CURLE_FTP_CANT_GET_HOST       }+  #{curlcode CURLE_FTP_COULDNT_SET_TYPE    }+  #{curlcode CURLE_PARTIAL_FILE            }+  #{curlcode CURLE_FTP_COULDNT_RETR_FILE   }+  #{curlcode CURLE_QUOTE_ERROR             }+  #{curlcode CURLE_HTTP_RETURNED_ERROR     }+  #{curlcode CURLE_WRITE_ERROR             }+  #{curlcode CURLE_UPLOAD_FAILED           }+  #{curlcode CURLE_READ_ERROR              }+  #{curlcode CURLE_OUT_OF_MEMORY           }+  #{curlcode CURLE_OPERATION_TIMEDOUT      }+  #{curlcode CURLE_FTP_PORT_FAILED         }+  #{curlcode CURLE_FTP_COULDNT_USE_REST    }+  #{curlcode CURLE_RANGE_ERROR             }+  #{curlcode CURLE_HTTP_POST_ERROR         }+  #{curlcode CURLE_SSL_CONNECT_ERROR       }+  #{curlcode CURLE_BAD_DOWNLOAD_RESUME     }+  #{curlcode CURLE_FILE_COULDNT_READ_FILE  }+  #{curlcode CURLE_LDAP_CANNOT_BIND        }+  #{curlcode CURLE_LDAP_SEARCH_FAILED      }+  #{curlcode CURLE_FUNCTION_NOT_FOUND      }+  #{curlcode CURLE_ABORTED_BY_CALLBACK     }+  #{curlcode CURLE_BAD_FUNCTION_ARGUMENT   }+  #{curlcode CURLE_INTERFACE_FAILED        }+  #{curlcode CURLE_TOO_MANY_REDIRECTS      }+  #{curlcode CURLE_UNKNOWN_TELNET_OPTION   } |----:7214|+  #{curlcode CURLE_UNKNOWN_OPTION          } |7215:----|+  #{curlcode CURLE_TELNET_OPTION_SYNTAX    }+  #{curlcode CURLE_PEER_FAILED_VERIFICATION}+  #{curlcode CURLE_GOT_NOTHING             }+  #{curlcode CURLE_SSL_ENGINE_NOTFOUND     }+  #{curlcode CURLE_SSL_ENGINE_SETFAILED    }+  #{curlcode CURLE_SEND_ERROR              }+  #{curlcode CURLE_RECV_ERROR              }+  #{curlcode CURLE_SSL_CERTPROBLEM         }+  #{curlcode CURLE_SSL_CIPHER              }+  #{curlcode CURLE_SSL_CACERT              }+  #{curlcode CURLE_BAD_CONTENT_ENCODING    }+  #{curlcode CURLE_LDAP_INVALID_URL        }+  #{curlcode CURLE_FILESIZE_EXCEEDED       }+  #{curlcode CURLE_USE_SSL_FAILED          }+  #{curlcode CURLE_SEND_FAIL_REWIND        }+  #{curlcode CURLE_SSL_ENGINE_INITFAILED   }+  #{curlcode CURLE_LOGIN_DENIED            }+  #{curlcode CURLE_TFTP_NOTFOUND           }+  #{curlcode CURLE_TFTP_PERM               }+  #{curlcode CURLE_REMOTE_DISK_FULL        }+  #{curlcode CURLE_TFTP_ILLEGAL            }+  #{curlcode CURLE_TFTP_UNKNOWNID          }+  #{curlcode CURLE_REMOTE_FILE_EXISTS      }+  #{curlcode CURLE_TFTP_NOSUCHUSER         }+  #{curlcode CURLE_CONV_FAILED             }+  #{curlcode CURLE_CONV_REQD               }+  #{curlcode CURLE_SSL_CACERT_BADFILE      }+  #{curlcode CURLE_REMOTE_FILE_NOT_FOUND   }+  #{curlcode CURLE_SSH                     }+  #{curlcode CURLE_SSL_SHUTDOWN_FAILED     }+  #{curlcode CURLE_AGAIN                   }+  #{curlcode CURLE_SSL_CRL_BADFILE         }+  #{curlcode CURLE_SSL_ISSUER_ERROR        }+  #{curlcode CURLE_FTP_PRET_FAILED         }+  #{curlcode CURLE_RTSP_CSEQ_ERROR         }+  #{curlcode CURLE_RTSP_SESSION_ERROR      }+  #{curlcode CURLE_FTP_BAD_FILE_LIST       } |7210:----|+  #{curlcode CURLE_CHUNK_FAILED            } |7210:----|+++-------------------------------------------------------------------------------+#define hsc_ccurlcode(code) printf("| x == c" #code " = " #code);++fromCCURLcode :: CCURLcode -> CURLcode+fromCCURLcode x+  #{ccurlcode CURLE_OK                      }+  #{ccurlcode CURLE_UNSUPPORTED_PROTOCOL    }+  #{ccurlcode CURLE_FAILED_INIT             }+  #{ccurlcode CURLE_URL_MALFORMAT           }+  #{ccurlcode CURLE_NOT_BUILT_IN            } |7215:----|+  #{ccurlcode CURLE_COULDNT_RESOLVE_PROXY   }+  #{ccurlcode CURLE_COULDNT_RESOLVE_HOST    }+  #{ccurlcode CURLE_COULDNT_CONNECT         }+  #{ccurlcode CURLE_FTP_WEIRD_SERVER_REPLY  }+  #{ccurlcode CURLE_REMOTE_ACCESS_DENIED    }+  #{ccurlcode CURLE_FTP_ACCEPT_FAILED       } |7240:----|+  #{ccurlcode CURLE_FTP_WEIRD_PASS_REPLY    }+  #{ccurlcode CURLE_FTP_ACCEPT_TIMEOUT      } |7240:----|+  #{ccurlcode CURLE_FTP_WEIRD_PASV_REPLY    }+  #{ccurlcode CURLE_FTP_WEIRD_227_FORMAT    }+  #{ccurlcode CURLE_FTP_CANT_GET_HOST       }+  #{ccurlcode CURLE_FTP_COULDNT_SET_TYPE    }+  #{ccurlcode CURLE_PARTIAL_FILE            }+  #{ccurlcode CURLE_FTP_COULDNT_RETR_FILE   }+  #{ccurlcode CURLE_QUOTE_ERROR             }+  #{ccurlcode CURLE_HTTP_RETURNED_ERROR     }+  #{ccurlcode CURLE_WRITE_ERROR             }+  #{ccurlcode CURLE_UPLOAD_FAILED           }+  #{ccurlcode CURLE_READ_ERROR              }+  #{ccurlcode CURLE_OUT_OF_MEMORY           }+  #{ccurlcode CURLE_OPERATION_TIMEDOUT      }+  #{ccurlcode CURLE_FTP_PORT_FAILED         }+  #{ccurlcode CURLE_FTP_COULDNT_USE_REST    }+  #{ccurlcode CURLE_RANGE_ERROR             }+  #{ccurlcode CURLE_HTTP_POST_ERROR         }+  #{ccurlcode CURLE_SSL_CONNECT_ERROR       }+  #{ccurlcode CURLE_BAD_DOWNLOAD_RESUME     }+  #{ccurlcode CURLE_FILE_COULDNT_READ_FILE  }+  #{ccurlcode CURLE_LDAP_CANNOT_BIND        }+  #{ccurlcode CURLE_LDAP_SEARCH_FAILED      }+  #{ccurlcode CURLE_FUNCTION_NOT_FOUND      }+  #{ccurlcode CURLE_ABORTED_BY_CALLBACK     }+  #{ccurlcode CURLE_BAD_FUNCTION_ARGUMENT   }+  #{ccurlcode CURLE_INTERFACE_FAILED        }+  #{ccurlcode CURLE_TOO_MANY_REDIRECTS      }+  #{ccurlcode CURLE_UNKNOWN_TELNET_OPTION   } |----:7214|+  #{ccurlcode CURLE_UNKNOWN_OPTION          } |7215:----|+  #{ccurlcode CURLE_TELNET_OPTION_SYNTAX    }+  #{ccurlcode CURLE_PEER_FAILED_VERIFICATION}+  #{ccurlcode CURLE_GOT_NOTHING             }+  #{ccurlcode CURLE_SSL_ENGINE_NOTFOUND     }+  #{ccurlcode CURLE_SSL_ENGINE_SETFAILED    }+  #{ccurlcode CURLE_SEND_ERROR              }+  #{ccurlcode CURLE_RECV_ERROR              }+  #{ccurlcode CURLE_SSL_CERTPROBLEM         }+  #{ccurlcode CURLE_SSL_CIPHER              }+  #{ccurlcode CURLE_SSL_CACERT              }+  #{ccurlcode CURLE_BAD_CONTENT_ENCODING    }+  #{ccurlcode CURLE_LDAP_INVALID_URL        }+  #{ccurlcode CURLE_FILESIZE_EXCEEDED       }+  #{ccurlcode CURLE_USE_SSL_FAILED          }+  #{ccurlcode CURLE_SEND_FAIL_REWIND        }+  #{ccurlcode CURLE_SSL_ENGINE_INITFAILED   }+  #{ccurlcode CURLE_LOGIN_DENIED            }+  #{ccurlcode CURLE_TFTP_NOTFOUND           }+  #{ccurlcode CURLE_TFTP_PERM               }+  #{ccurlcode CURLE_REMOTE_DISK_FULL        }+  #{ccurlcode CURLE_TFTP_ILLEGAL            }+  #{ccurlcode CURLE_TFTP_UNKNOWNID          }+  #{ccurlcode CURLE_REMOTE_FILE_EXISTS      }+  #{ccurlcode CURLE_TFTP_NOSUCHUSER         }+  #{ccurlcode CURLE_CONV_FAILED             }+  #{ccurlcode CURLE_CONV_REQD               }+  #{ccurlcode CURLE_SSL_CACERT_BADFILE      }+  #{ccurlcode CURLE_REMOTE_FILE_NOT_FOUND   }+  #{ccurlcode CURLE_SSH                     }+  #{ccurlcode CURLE_SSL_SHUTDOWN_FAILED     }+  #{ccurlcode CURLE_AGAIN                   }+  #{ccurlcode CURLE_SSL_CRL_BADFILE         }+  #{ccurlcode CURLE_SSL_ISSUER_ERROR        }+  #{ccurlcode CURLE_FTP_PRET_FAILED         }+  #{ccurlcode CURLE_RTSP_CSEQ_ERROR         }+  #{ccurlcode CURLE_RTSP_SESSION_ERROR      }+  #{ccurlcode CURLE_FTP_BAD_FILE_LIST       } |7210:----|+  #{ccurlcode CURLE_CHUNK_FAILED            } |7210:----|+  | otherwise = error "unknown CURLcode"++
+ Network/Curlhs/Setopt.hsc view
@@ -0,0 +1,513 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  Network.Curlhs.Setopt+-- Copyright   :  Copyright © 2012 Krzysztof Kardzis+-- License     :  ISC License (MIT/BSD-style, see LICENSE file for details)+-- +-- Maintainer  :  Krzysztof Kardzis <kkardzis@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+--+-------------------------------------------------------------------------------++module Network.Curlhs.Setopt+  ( curl_easy_setopt+  , freeCallbacks+  ) where++import Foreign.Marshal.Utils (copyBytes, fromBool)+import Foreign.C.Types       (CLong)+import Foreign.Ptr           (FunPtr, nullFunPtr, freeHaskellFunPtr)++import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)+import Data.Time.Clock       (UTCTime)+import Data.Bits             ((.|.))+import Data.List             (foldl')+import Data.IORef            (IORef, atomicModifyIORef)++import qualified Data.ByteString as BS+import Data.ByteString.Unsafe (unsafeUseAsCStringLen)+import Data.ByteString        (ByteString, useAsCString, packCStringLen)++import Network.Curlhs.Errors+import Network.Curlhs.Types+import Network.Curlhs.Base+++-------------------------------------------------------------------------------+freeCallbacks :: CURL -> IO ()+freeCallbacks curl = do+  keepCallback (cb_write curl) Nothing+  keepCallback (cb_read  curl) Nothing++keepCallback :: IORef (Maybe (FunPtr a)) -> Maybe (FunPtr a) -> IO ()+keepCallback r mf =+  atomicModifyIORef r (\v -> (mf, v)) >>= maybe (return ()) freeHaskellFunPtr++makeCallback :: Maybe cb -> IORef (Maybe (FunPtr a))+             -> (FunPtr a -> IO CCURLcode) -> (cb -> IO (FunPtr a)) -> IO ()+makeCallback (Just cb) ref setcb wrapcb = withCODE $ do+  fptr <- wrapcb cb+  code <- setcb fptr+  if (code == cCURLE_OK)+    then keepCallback ref (Just fptr)+    else freeHaskellFunPtr fptr+  return code+makeCallback Nothing ref setcb _ = withCODE $ do+  code <- setcb nullFunPtr+  keepCallback ref Nothing+  return code+++-------------------------------------------------------------------------------+#define hsc_setopt(opt, fun) printf(#opt " x -> " #fun " c" #opt " x");++-------------------------------------------------------------------------------+-- | Set options for a curl easy handle+--   (<http://curl.haxx.se/libcurl/c/curl_easy_setopt.html>).+-------------------------------------------------------------------------------+curl_easy_setopt :: CURL -> [CURLoption] -> IO ()+curl_easy_setopt curl opts = flip mapM_ opts $ \opt -> case opt of++  ---- CALLBACK OPTIONS -------------------------------------------------------+  CURLOPT_WRITEFUNCTION f -> so'FWRITE curl f+  CURLOPT_READFUNCTION  f -> so'FREAD  curl f++  ---- BEHAVIOR OPTIONS -------------------------------------------------------+  #{setopt CURLOPT_VERBOSE                , bool     }+  #{setopt CURLOPT_HEADER                 , bool     }+  #{setopt CURLOPT_NOPROGRESS             , bool     }+  #{setopt CURLOPT_NOSIGNAL               , bool     }+  #{setopt CURLOPT_WILDCARDMATCH          , bool     } |7210:----|++  ---- ERROR OPTIONS ----------------------------------------------------------+  -- CURLOPT_ERRORBUFFER+  -- CURLOPT_STDERR+  #{setopt CURLOPT_FAILONERROR            , bool     }++  ---- NETWORK OPTIONS --------------------------------------------------------+  #{setopt CURLOPT_URL                    , string   }+  #{setopt CURLOPT_PROTOCOLS              , enum     }+  #{setopt CURLOPT_REDIR_PROTOCOLS        , enum     }+  #{setopt CURLOPT_PROXY                  , string   }+  #{setopt CURLOPT_PROXYPORT              , int      }+  #{setopt CURLOPT_PROXYTYPE              , enum     }+  #{setopt CURLOPT_NOPROXY                , string   }+  #{setopt CURLOPT_HTTPPROXYTUNNEL        , bool     }+  #{setopt CURLOPT_SOCKS5_GSSAPI_SERVICE  , string   }+  #{setopt CURLOPT_SOCKS5_GSSAPI_NEC      , bool     }+  #{setopt CURLOPT_INTERFACE              , string   }+  #{setopt CURLOPT_LOCALPORT              , int      }+  #{setopt CURLOPT_LOCALPORTRANGE         , int      }+  #{setopt CURLOPT_DNS_CACHE_TIMEOUT      , int      }+  #{setopt CURLOPT_DNS_USE_GLOBAL_CACHE   , bool     }+  #{setopt CURLOPT_BUFFERSIZE             , int      }+  #{setopt CURLOPT_PORT                   , int      }+  #{setopt CURLOPT_TCP_NODELAY            , bool     }+  #{setopt CURLOPT_ADDRESS_SCOPE          , int      }+  #{setopt CURLOPT_TCP_KEEPALIVE          , bool     } |7250:----|+  #{setopt CURLOPT_TCP_KEEPIDLE           , int      } |7250:----|+  #{setopt CURLOPT_TCP_KEEPINTVL          , int      } |7250:----|++  ---- NAMES and PASSWORDS OPTIONS (Authentication) ---------------------------+  #{setopt CURLOPT_NETRC                  , enum     }+  #{setopt CURLOPT_NETRC_FILE             , string   }+  #{setopt CURLOPT_USERPWD                , string   }+  #{setopt CURLOPT_PROXYUSERPWD           , string   }+  #{setopt CURLOPT_USERNAME               , string   }+  #{setopt CURLOPT_PASSWORD               , string   }+  #{setopt CURLOPT_PROXYUSERNAME          , string   }+  #{setopt CURLOPT_PROXYPASSWORD          , string   }+  #{setopt CURLOPT_HTTPAUTH               , enum     }+  #{setopt CURLOPT_TLSAUTH_TYPE           , string   } |7214:----|+  #{setopt CURLOPT_TLSAUTH_USERNAME       , string   } |7214:----|+  #{setopt CURLOPT_TLSAUTH_PASSWORD       , string   } |7214:----|+  #{setopt CURLOPT_PROXYAUTH              , enum     }++  ---- HTTP OPTIONS -----------------------------------------------------------+  #{setopt CURLOPT_AUTOREFERER            , bool     }+  #{setopt CURLOPT_ENCODING               , string   } |----:7215|+  #{setopt CURLOPT_ACCEPT_ENCODING        , string   } |7216:----|+  #{setopt CURLOPT_TRANSFER_ENCODING      , bool     } |7216:----|+  #{setopt CURLOPT_FOLLOWLOCATION         , bool     }+  #{setopt CURLOPT_UNRESTRICTED_AUTH      , bool     }+  #{setopt CURLOPT_MAXREDIRS              , int      }+  #{setopt CURLOPT_POSTREDIR              , enum     }+  #{setopt CURLOPT_PUT                    , bool     }+  #{setopt CURLOPT_POST                   , bool     }+  -- #{setopt CURLOPT_POSTFIELDS             , buffer   }+  #{setopt CURLOPT_POSTFIELDSIZE          , int      }+  #{setopt CURLOPT_POSTFIELDSIZE_LARGE    , int64    }+  #{setopt CURLOPT_COPYPOSTFIELDS         , string   }+  -- CURLOPT_HTTPPOST+  #{setopt CURLOPT_REFERER                , string   }+  #{setopt CURLOPT_USERAGENT              , string   }+  -- #{setopt CURLOPT_HTTPHEADER             , slist    }+  -- #{setopt CURLOPT_HTTP200ALIASES         , slist    }+  #{setopt CURLOPT_COOKIE                 , string   }+  #{setopt CURLOPT_COOKIEFILE             , string   }+  #{setopt CURLOPT_COOKIEJAR              , string   }+  #{setopt CURLOPT_COOKIESESSION          , bool     }+  #{setopt CURLOPT_COOKIELIST             , string   }+  #{setopt CURLOPT_HTTPGET                , bool     }+  #{setopt CURLOPT_HTTP_VERSION           , enum     }+  #{setopt CURLOPT_IGNORE_CONTENT_LENGTH  , bool     }+  #{setopt CURLOPT_HTTP_CONTENT_DECODING  , bool     }+  #{setopt CURLOPT_HTTP_TRANSFER_DECODING , bool     }++  ---- SMTP OPTIONS -----------------------------------------------------------+  #{setopt CURLOPT_MAIL_FROM              , string   }+  -- #{setopt CURLOPT_MAIL_RCTP              , slist    }+  #{setopt CURLOPT_MAIL_AUTH              , string   } |7250:----|++  ---- TFTP OPTIONS -----------------------------------------------------------+  #{setopt CURLOPT_TFTP_BLKSIZE           , int      }++  ---- FTP OPTIONS ------------------------------------------------------------+  #{setopt CURLOPT_FTPPORT                , string   }+  -- #{setopt CURLOPT_QUOTE                  , slist    }+  -- #{setopt CURLOPT_POSTQUOTE              , slist    }+  -- #{setopt CURLOPT_PREQUOTE               , slist    }+  #{setopt CURLOPT_DIRLISTONLY            , bool     }+  #{setopt CURLOPT_APPEND                 , bool     }+  #{setopt CURLOPT_FTP_USE_EPRT           , bool     }+  #{setopt CURLOPT_FTP_USE_EPSV           , bool     }+  #{setopt CURLOPT_FTP_USE_PRET           , bool     }+  #{setopt CURLOPT_FTP_CREATE_MISSING_DIRS, enum     }+  #{setopt CURLOPT_FTP_RESPONSE_TIMEOUT   , int      }+  #{setopt CURLOPT_FTP_ALTERNATIVE_TO_USER, string   }+  #{setopt CURLOPT_FTP_SKIP_PASV_IP       , bool     }+  #{setopt CURLOPT_FTPSSLAUTH             , enum     }+  #{setopt CURLOPT_FTP_SSL_CCC            , enum     }+  #{setopt CURLOPT_FTP_ACCOUNT            , string   }+  #{setopt CURLOPT_FTP_FILEMETHOD         , enum     }++  ---- RTSP OPTIONS -----------------------------------------------------------+  #{setopt CURLOPT_RTSP_REQUEST           , enum     }+  #{setopt CURLOPT_RTSP_SESSION_ID        , string   }+  #{setopt CURLOPT_RTSP_STREAM_URI        , string   }+  #{setopt CURLOPT_RTSP_TRANSPORT         , string   }+  -- #{setopt CURLOPT_RTSP_HEADER            , slist    }+  #{setopt CURLOPT_RTSP_CLIENT_CSEQ       , int      }+  #{setopt CURLOPT_RTSP_SERVER_CSEQ       , int      }++  ---- PROTOCOL OPTIONS -------------------------------------------------------+  #{setopt CURLOPT_TRANSFERTEXT           , bool     }+  #{setopt CURLOPT_PROXY_TRANSFER_MODE    , bool     }+  #{setopt CURLOPT_CRLF                   , bool     }+  #{setopt CURLOPT_RANGE                  , string   }+  #{setopt CURLOPT_RESUME_FROM            , int      }+  #{setopt CURLOPT_RESUME_FROM_LARGE      , int64    }+  #{setopt CURLOPT_CUSTOMREQUEST          , string   }+  #{setopt CURLOPT_FILETIME               , bool     }+  #{setopt CURLOPT_NOBODY                 , bool     }+  #{setopt CURLOPT_INFILESIZE             , int      }+  #{setopt CURLOPT_INFILESIZE_LARGE       , int64    }+  #{setopt CURLOPT_UPLOAD                 , bool     }+  #{setopt CURLOPT_MAXFILESIZE            , int      }+  #{setopt CURLOPT_MAXFILESIZE_LARGE      , int64    }+  #{setopt CURLOPT_TIMECONDITION          , enum     }+  #{setopt CURLOPT_TIMEVALUE              , time     }++  ---- CONNECTION OPTIONS -----------------------------------------------------+  #{setopt CURLOPT_TIMEOUT                , int      }+  #{setopt CURLOPT_TIMEOUT_MS             , int      }+  #{setopt CURLOPT_LOW_SPEED_LIMIT        , int      }+  #{setopt CURLOPT_LOW_SPEED_TIME         , int      }+  #{setopt CURLOPT_MAX_SEND_SPEED_LARGE   , int64    }+  #{setopt CURLOPT_MAX_RECV_SPEED_LARGE   , int64    }+  #{setopt CURLOPT_MAXCONNECTS            , int      }+  #{setopt CURLOPT_CLOSEPOLICY            , enum     }+  #{setopt CURLOPT_FRESH_CONNECT          , bool     }+  #{setopt CURLOPT_FORBID_REUSE           , bool     }+  #{setopt CURLOPT_CONNECTTIMEOUT         , int      }+  #{setopt CURLOPT_CONNECTTIMEOUT_MS      , int      }+  #{setopt CURLOPT_IPRESOLVE              , enum     }+  #{setopt CURLOPT_CONNECT_ONLY           , bool     }+  #{setopt CURLOPT_USE_SSL                , enum     }+  -- #{setopt CURLOPT_RESOLVE                , slist    } |7213:----|+  #{setopt CURLOPT_DNS_SERVERS            , string   } |7240:----|+  #{setopt CURLOPT_ACCEPTTIMEOUT_MS       , int      } |7240:----|++  ---- SSL and SECURITY OPTIONS -----------------------------------------------+  #{setopt CURLOPT_SSLCERT                , string   }+  #{setopt CURLOPT_SSLCERTTYPE            , string   }+  #{setopt CURLOPT_SSLKEY                 , string   }+  #{setopt CURLOPT_SSLKEYTYPE             , string   }+  #{setopt CURLOPT_KEYPASSWD              , string   }+  #{setopt CURLOPT_SSLENGINE              , string   }+  #{setopt CURLOPT_SSLENGINE_DEFAULT      , bool     }+  #{setopt CURLOPT_SSLVERSION             , enum     }+  #{setopt CURLOPT_SSL_VERIFYPEER         , bool     }+  #{setopt CURLOPT_CAINFO                 , string   }+  #{setopt CURLOPT_ISSUERCERT             , string   }+  #{setopt CURLOPT_CAPATH                 , string   }+  #{setopt CURLOPT_CRLFILE                , string   }+  #{setopt CURLOPT_SSL_VERIFYHOST         , int      }+  #{setopt CURLOPT_CERTINFO               , bool     }+  #{setopt CURLOPT_RANDOM_FILE            , string   }+  #{setopt CURLOPT_EGDSOCKET              , string   }+  #{setopt CURLOPT_SSL_CIPHER_LIST        , string   }+  #{setopt CURLOPT_SSL_SESSIONID_CACHE    , bool     }+  #{setopt CURLOPT_SSL_OPTIONS            , enum     } |7250:----|+  #{setopt CURLOPT_KRBLEVEL               , string   }+  #{setopt CURLOPT_GSSAPI_DELEGATION      , enum     } |7220:----|++  ---- SSH OPTIONS ------------------------------------------------------------+  #{setopt CURLOPT_SSH_AUTH_TYPES         , enum     }+  #{setopt CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, string   }+  #{setopt CURLOPT_SSH_PUBLIC_KEYFILE     , string   }+  #{setopt CURLOPT_SSH_PRIVATE_KEYFILE    , string   }+  #{setopt CURLOPT_SSH_KNOWNHOSTS         , string   }+  -- CURLOPT_SSH_KEYFUNCTION+  -- CURLOPT_SSH_KEYDATA++  ---- OTHER OPTIONS ----------------------------------------------------------+  -- CURLOPT_PRIVATE+  -- CURLOPT_SHARE+  #{setopt CURLOPT_NEW_FILE_PERMS         , int      }+  #{setopt CURLOPT_NEW_DIRECTORY_PERMS    , int      }++  ---- TELNET OPTIONS ---------------------------------------------------------+  -- #{setopt CURLOPT_TELNETOPTIONS          , slist    }++  -----------------------------------------------------------------------------+  where+    string copt s = setopt'CString curl copt s+    int64  copt x = setopt'Int64   curl copt (fromIntegral   x)+    int    copt x = setopt'CLong   curl copt (fromIntegral   x)+    bool   copt x = setopt'CLong   curl copt (fromBool       x)+    time   copt x = setopt'CLong   curl copt (fromUTCTime    x)+    enum   copt x = setopt'CLong   curl copt (fromCURLenum   x)++++-------------------------------------------------------------------------------+setopt'CString :: CURL -> CCURLoption'CString -> ByteString -> IO ()+setopt'CString curl copt val = useAsCString val $ \ptr ->+  withCODE $ ccurl_easy_setopt'CString (ccurlptr curl) copt ptr++setopt'Int64 :: CURL -> CCURLoption'Int64 -> CCURL_off_t -> IO ()+setopt'Int64 curl copt cval =+  withCODE $ ccurl_easy_setopt'Int64 (ccurlptr curl) copt cval++setopt'CLong :: CURL -> CCURLoption'CLong -> CLong -> IO ()+setopt'CLong curl copt cval =+  withCODE $ ccurl_easy_setopt'CLong (ccurlptr curl) copt cval+++-------------------------------------------------------------------------------+so'FWRITE :: CURL -> Maybe CURL_write_callback -> IO ()+so'FWRITE curl mcb = makeCallback mcb (cb_write curl)+  (ccurl_easy_setopt'FWRITE (ccurlptr curl))+  (\cb -> wrap_ccurl_write_callback (write_callback cb))++write_callback :: CURL_write_callback -> CCURL_write_callback+write_callback fwrite ptr size nmemb _ = do+  stat <- packCStringLen (ptr, fromIntegral (size * nmemb)) >>= fwrite+  return $ case stat of+    CURL_WRITEFUNC_OK    -> (size * nmemb)+    CURL_WRITEFUNC_FAIL  -> 0+    CURL_WRITEFUNC_PAUSE -> cCURL_WRITEFUNC_PAUSE+++-------------------------------------------------------------------------------+so'FREAD :: CURL -> Maybe CURL_read_callback -> IO ()+so'FREAD curl mcb = makeCallback mcb (cb_read curl)+  (ccurl_easy_setopt'FREAD (ccurlptr curl))+  (\cb -> wrap_ccurl_read_callback (read_callback cb))++read_callback :: CURL_read_callback -> CCURL_read_callback+read_callback fread buff size nmemb _ = do+  let buffLen = fromIntegral (size * nmemb)+  stat <- fread buffLen+  case stat of+    CURL_READFUNC_PAUSE -> return cCURL_READFUNC_PAUSE+    CURL_READFUNC_ABORT -> return cCURL_READFUNC_ABORT+    CURL_READFUNC_OK bs -> unsafeUseAsCStringLen (BS.take buffLen bs)+      (\(cs, cl) -> copyBytes buff cs cl >> return (fromIntegral cl))+++-------------------------------------------------------------------------------+fromUTCTime :: UTCTime -> CLong+fromUTCTime = truncate . utcTimeToPOSIXSeconds+++-------------------------------------------------------------------------------+#define hsc_option(opt) printf(#opt " -> c" #opt);++class CURLenum a where+  fromCURLenum :: a -> CLong++instance CURLenum a => CURLenum [a] where+  fromCURLenum xs = foldl' (.|.) 0 $ map fromCURLenum xs++instance CURLenum CURLproto where+  fromCURLenum x = case x of+    #{option CURLPROTO_ALL   }+    #{option CURLPROTO_HTTP  }+    #{option CURLPROTO_HTTPS }+    #{option CURLPROTO_FTP   }+    #{option CURLPROTO_FTPS  }+    #{option CURLPROTO_SCP   }+    #{option CURLPROTO_SFTP  }+    #{option CURLPROTO_TELNET}+    #{option CURLPROTO_LDAP  }+    #{option CURLPROTO_LDAPS }+    #{option CURLPROTO_DICT  }+    #{option CURLPROTO_FILE  }+    #{option CURLPROTO_TFTP  }+    #{option CURLPROTO_IMAP  }+    #{option CURLPROTO_IMAPS }+    #{option CURLPROTO_POP3  }+    #{option CURLPROTO_POP3S }+    #{option CURLPROTO_SMTP  }+    #{option CURLPROTO_SMTPS }+    #{option CURLPROTO_RTSP  }+    #{option CURLPROTO_RTMP  } |7210:----|+    #{option CURLPROTO_RTMPT } |7210:----|+    #{option CURLPROTO_RTMPE } |7210:----|+    #{option CURLPROTO_RTMPTE} |7210:----|+    #{option CURLPROTO_RTMPS } |7210:----|+    #{option CURLPROTO_RTMPTS} |7210:----|+    #{option CURLPROTO_GOPHER} |7212:----|++instance CURLenum CURLproxy where+  fromCURLenum x = case x of+    #{option CURLPROXY_HTTP           }+    #{option CURLPROXY_HTTP_1_0       }+    #{option CURLPROXY_SOCKS4         }+    #{option CURLPROXY_SOCKS5         }+    #{option CURLPROXY_SOCKS4A        }+    #{option CURLPROXY_SOCKS5_HOSTNAME}++instance CURLenum CURLnetrc where+  fromCURLenum x = case x of+    #{option CURL_NETRC_IGNORED }+    #{option CURL_NETRC_OPTIONAL}+    #{option CURL_NETRC_REQUIRED}++instance CURLenum CURLauth where+  fromCURLenum x = case x of+    #{option CURLAUTH_BASIC       }+    #{option CURLAUTH_DIGEST      }+    #{option CURLAUTH_DIGEST_IE   }+    #{option CURLAUTH_GSSNEGOTIATE}+    #{option CURLAUTH_NTLM        }+    #{option CURLAUTH_NTLM_WB     } |7220:----|+    #{option CURLAUTH_ONLY        } |7213:----|+    #{option CURLAUTH_ANY         }+    #{option CURLAUTH_ANYSAFE     }++instance CURLenum CURLtlsauth where                              |7214:----|+  fromCURLenum x = case x of                                     |7214:----|+    #{option CURL_TLSAUTH_SRP}                                   |7214:----|++instance CURLenum CURLredir where+  fromCURLenum x = case x of+    #{option CURL_REDIR_GET_ALL }+    #{option CURL_REDIR_POST_301}+    #{option CURL_REDIR_POST_302}+    #{option CURL_REDIR_POST_ALL}++instance CURLenum CURLhttpver where+  fromCURLenum x = case x of+    #{option CURL_HTTP_VERSION_NONE}+    #{option CURL_HTTP_VERSION_1_0 }+    #{option CURL_HTTP_VERSION_1_1 }++instance CURLenum CURLftpcreate where+  fromCURLenum x = case x of+    #{option CURLFTP_CREATE_DIR_NONE }+    #{option CURLFTP_CREATE_DIR      }+    #{option CURLFTP_CREATE_DIR_RETRY}++instance CURLenum CURLftpauth where+  fromCURLenum x = case x of+    #{option CURLFTPAUTH_DEFAULT}+    #{option CURLFTPAUTH_SSL    }+    #{option CURLFTPAUTH_TLS    }++instance CURLenum CURLftpssl where+  fromCURLenum x = case x of+    #{option CURLFTPSSL_CCC_NONE   }+    #{option CURLFTPSSL_CCC_PASSIVE}+    #{option CURLFTPSSL_CCC_ACTIVE }++instance CURLenum CURLftpmethod where+  fromCURLenum x = case x of+    #{option CURLFTPMETHOD_DEFAULT  }+    #{option CURLFTPMETHOD_MULTICWD }+    #{option CURLFTPMETHOD_NOCWD    }+    #{option CURLFTPMETHOD_SINGLECWD}++instance CURLenum CURLrtspreq where+  fromCURLenum x = case x of+    #{option CURL_RTSPREQ_OPTIONS      }+    #{option CURL_RTSPREQ_DESCRIBE     }+    #{option CURL_RTSPREQ_ANNOUNCE     }+    #{option CURL_RTSPREQ_SETUP        }+    #{option CURL_RTSPREQ_PLAY         }+    #{option CURL_RTSPREQ_PAUSE        }+    #{option CURL_RTSPREQ_TEARDOWN     }+    #{option CURL_RTSPREQ_GET_PARAMETER}+    #{option CURL_RTSPREQ_SET_PARAMETER}+    #{option CURL_RTSPREQ_RECORD       }+    #{option CURL_RTSPREQ_RECEIVE      }++instance CURLenum CURLtimecond where+  fromCURLenum x = case x of+    #{option CURL_TIMECOND_NONE        }+    #{option CURL_TIMECOND_IFMODSINCE  }+    #{option CURL_TIMECOND_IFUNMODSINCE}+    #{option CURL_TIMECOND_LASTMOD     }++instance CURLenum CURLclosepol where+  fromCURLenum x = case x of+    #{option CURLCLOSEPOLICY_NONE               }+    #{option CURLCLOSEPOLICY_OLDEST             }+    #{option CURLCLOSEPOLICY_LEAST_RECENTLY_USED}+    #{option CURLCLOSEPOLICY_LEAST_TRAFFIC      }+    #{option CURLCLOSEPOLICY_SLOWEST            }+    #{option CURLCLOSEPOLICY_CALLBACK           }++instance CURLenum CURLipresolve where+  fromCURLenum x = case x of+    #{option CURL_IPRESOLVE_WHATEVER}+    #{option CURL_IPRESOLVE_V4      }+    #{option CURL_IPRESOLVE_V6      }++instance CURLenum CURLusessl where+  fromCURLenum x = case x of+    #{option CURLUSESSL_NONE   }+    #{option CURLUSESSL_TRY    }+    #{option CURLUSESSL_CONTROL}+    #{option CURLUSESSL_ALL    }++instance CURLenum CURLsslver where+  fromCURLenum x = case x of+    #{option CURL_SSLVERSION_DEFAULT}+    #{option CURL_SSLVERSION_TLSv1  }+    #{option CURL_SSLVERSION_SSLv2  }+    #{option CURL_SSLVERSION_SSLv3  }++instance CURLenum CURLsslopt where                               |7250:----|+  fromCURLenum x = case x of                                     |7250:----|+    #{option CURLSSLOPT_ALLOW_BEAST}                             |7250:----|++instance CURLenum CURLgssapi where                               |7220:----|+  fromCURLenum x = case x of                                     |7220:----|+    #{option CURLGSSAPI_DELEGATION_NONE       }                  |7220:----|+    #{option CURLGSSAPI_DELEGATION_POLICY_FLAG}                  |7220:----|+    #{option CURLGSSAPI_DELEGATION_FLAG       }                  |7220:----|++instance CURLenum CURLsshauth where+  fromCURLenum x = case x of+    #{option CURLSSH_AUTH_ANY      }+    #{option CURLSSH_AUTH_NONE     }+    #{option CURLSSH_AUTH_PUBLICKEY}+    #{option CURLSSH_AUTH_PASSWORD }+    #{option CURLSSH_AUTH_HOST     }+    #{option CURLSSH_AUTH_KEYBOARD }+    #{option CURLSSH_AUTH_DEFAULT  }+
+ Network/Curlhs/Types.hs view
@@ -0,0 +1,675 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  Network.Curlhs.Types+-- Copyright   :  Copyright © 2012 Krzysztof Kardzis+-- License     :  ISC License (MIT/BSD-style, see LICENSE file for details)+-- +-- Maintainer  :  Krzysztof Kardzis <kkardzis@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+--+-------------------------------------------------------------------------------++{-# LANGUAGE DeriveDataTypeable #-}++module Network.Curlhs.Types where++import Foreign.Ptr       (Ptr, FunPtr)++import Data.ByteString   (ByteString)+import Data.Typeable     (Typeable)+import Data.IORef        (IORef)+import Data.Time         (UTCTime)+import Data.Int          (Int64)++import Control.Exception (Exception)++import Network.Curlhs.Base+++-------------------------------------------------------------------------------+data CURL = CURL+  { ccurlptr :: Ptr CCURL+  , cb_write :: IORef (Maybe (FunPtr CCURL_write_callback))+  , cb_read  :: IORef (Maybe (FunPtr CCURL_read_callback ))+  }+++-------------------------------------------------------------------------------+data CURLcode+  = CURLE_OK+  | CURLE_UNSUPPORTED_PROTOCOL+  | CURLE_FAILED_INIT+  | CURLE_URL_MALFORMAT+  | CURLE_NOT_BUILT_IN             |7215:----|+  | CURLE_COULDNT_RESOLVE_PROXY+  | CURLE_COULDNT_RESOLVE_HOST+  | CURLE_COULDNT_CONNECT+  | CURLE_FTP_WEIRD_SERVER_REPLY+  | CURLE_REMOTE_ACCESS_DENIED+  | CURLE_FTP_ACCEPT_FAILED        |7240:----|+  | CURLE_FTP_WEIRD_PASS_REPLY+  | CURLE_FTP_ACCEPT_TIMEOUT       |7240:----|+  | CURLE_FTP_WEIRD_PASV_REPLY+  | CURLE_FTP_WEIRD_227_FORMAT+  | CURLE_FTP_CANT_GET_HOST+  | CURLE_FTP_COULDNT_SET_TYPE+  | CURLE_PARTIAL_FILE+  | CURLE_FTP_COULDNT_RETR_FILE+  | CURLE_QUOTE_ERROR+  | CURLE_HTTP_RETURNED_ERROR+  | CURLE_WRITE_ERROR+  | CURLE_UPLOAD_FAILED+  | CURLE_READ_ERROR+  | CURLE_OUT_OF_MEMORY+  | CURLE_OPERATION_TIMEDOUT+  | CURLE_FTP_PORT_FAILED+  | CURLE_FTP_COULDNT_USE_REST+  | CURLE_RANGE_ERROR+  | CURLE_HTTP_POST_ERROR+  | CURLE_SSL_CONNECT_ERROR+  | CURLE_BAD_DOWNLOAD_RESUME+  | CURLE_FILE_COULDNT_READ_FILE+  | CURLE_LDAP_CANNOT_BIND+  | CURLE_LDAP_SEARCH_FAILED+  | CURLE_FUNCTION_NOT_FOUND+  | CURLE_ABORTED_BY_CALLBACK+  | CURLE_BAD_FUNCTION_ARGUMENT+  | CURLE_INTERFACE_FAILED+  | CURLE_TOO_MANY_REDIRECTS+  | CURLE_UNKNOWN_TELNET_OPTION    |----:7214|+  | CURLE_UNKNOWN_OPTION           |7215:----|+  | CURLE_TELNET_OPTION_SYNTAX+  | CURLE_PEER_FAILED_VERIFICATION+  | CURLE_GOT_NOTHING+  | CURLE_SSL_ENGINE_NOTFOUND+  | CURLE_SSL_ENGINE_SETFAILED+  | CURLE_SEND_ERROR+  | CURLE_RECV_ERROR+  | CURLE_SSL_CERTPROBLEM+  | CURLE_SSL_CIPHER+  | CURLE_SSL_CACERT+  | CURLE_BAD_CONTENT_ENCODING+  | CURLE_LDAP_INVALID_URL+  | CURLE_FILESIZE_EXCEEDED+  | CURLE_USE_SSL_FAILED+  | CURLE_SEND_FAIL_REWIND+  | CURLE_SSL_ENGINE_INITFAILED+  | CURLE_LOGIN_DENIED+  | CURLE_TFTP_NOTFOUND+  | CURLE_TFTP_PERM+  | CURLE_REMOTE_DISK_FULL+  | CURLE_TFTP_ILLEGAL+  | CURLE_TFTP_UNKNOWNID+  | CURLE_REMOTE_FILE_EXISTS+  | CURLE_TFTP_NOSUCHUSER+  | CURLE_CONV_FAILED+  | CURLE_CONV_REQD+  | CURLE_SSL_CACERT_BADFILE+  | CURLE_REMOTE_FILE_NOT_FOUND+  | CURLE_SSH+  | CURLE_SSL_SHUTDOWN_FAILED+  | CURLE_AGAIN+  | CURLE_SSL_CRL_BADFILE+  | CURLE_SSL_ISSUER_ERROR+  | CURLE_FTP_PRET_FAILED+  | CURLE_RTSP_CSEQ_ERROR+  | CURLE_RTSP_SESSION_ERROR+  | CURLE_FTP_BAD_FILE_LIST        |7210:----|+  | CURLE_CHUNK_FAILED             |7210:----|+  deriving (Eq, Show, Typeable)++instance Exception CURLcode+++-------------------------------------------------------------------------------+data CURL_version_info_data = CURL_version_info_data+  { curl_version_info_data_version         :: String+  , curl_version_info_data_version_num     :: Int+  , curl_version_info_data_host            :: String+  , curl_version_info_data_features        :: [CURL_version]+  , curl_version_info_data_ssl_version     :: Maybe String+  , curl_version_info_data_ssl_version_num :: Int+  , curl_version_info_data_libz_version    :: Maybe String+  , curl_version_info_data_protocols       :: [String]+  , curl_version_info_data_ares            :: Maybe String+  , curl_version_info_data_ares_num        :: Int+  , curl_version_info_data_libidn          :: Maybe String+  , curl_version_info_data_iconv_ver_num   :: Int+  , curl_version_info_data_libssh_version  :: Maybe String+  } deriving (Show)+++-------------------------------------------------------------------------------+data CURL_version+  = CURL_VERSION_IPV6+  | CURL_VERSION_KERBEROS4+  | CURL_VERSION_SSL+  | CURL_VERSION_LIBZ+  | CURL_VERSION_NTLM+  | CURL_VERSION_GSSNEGOTIATE+  | CURL_VERSION_DEBUG+  | CURL_VERSION_ASYNCHDNS+  | CURL_VERSION_SPNEGO+  | CURL_VERSION_LARGEFILE+  | CURL_VERSION_IDN+  | CURL_VERSION_SSPI+  | CURL_VERSION_CONV+  | CURL_VERSION_CURLDEBUG+  | CURL_VERSION_TLSAUTH_SRP+  | CURL_VERSION_NTLM_WB+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLinfo = CURLinfo+  { curlinfo_effective_url           :: String+  , curlinfo_response_code           :: Maybe Int+  , curlinfo_http_connectcode        :: Maybe Int+  , curlinfo_filetime                :: Maybe UTCTime+  , curlinfo_total_time              :: Double+  , curlinfo_namelookup_time         :: Double+  , curlinfo_connect_time            :: Double+  , curlinfo_appconnect_time         :: Double+  , curlinfo_pretransfer_time        :: Double+  , curlinfo_starttransfer_time      :: Double+  , curlinfo_redirect_time           :: Double+  , curlinfo_redirect_count          :: Int+  , curlinfo_redirect_url            :: Maybe String+  , curlinfo_size_upload             :: Double+  , curlinfo_size_download           :: Double+  , curlinfo_speed_download          :: Double+  , curlinfo_speed_upload            :: Double+  , curlinfo_header_size             :: Int+  , curlinfo_request_size            :: Int+  , curlinfo_ssl_verifyresult        :: Int  -- Bool??+  , curlinfo_ssl_engines             :: [String]+  , curlinfo_content_length_download :: Maybe Double+  , curlinfo_content_length_upload   :: Maybe Double+  , curlinfo_content_type            :: Maybe String+--  , curlinfo_private                 :: String   -- void??+  , curlinfo_httpauth_avail          :: [CURLauth]+  , curlinfo_proxyauth_avail         :: [CURLauth]+  , curlinfo_os_errno                :: Int+  , curlinfo_num_connects            :: Int+  , curlinfo_primary_ip              :: String+  , curlinfo_primary_port            :: Int+  , curlinfo_local_ip                :: String+  , curlinfo_local_port              :: Int+  , curlinfo_cookielist              :: [String]+  , curlinfo_lastsocket              :: Maybe Int+  , curlinfo_ftp_entry_path          :: Maybe String+  , curlinfo_certinfo                :: [[String]]+  , curlinfo_condition_unmet         :: Bool+  , curlinfo_rtsp_session_id         :: Maybe String+  , curlinfo_rtsp_client_cseq        :: Int+  , curlinfo_rtsp_server_cseq        :: Int+  , curlinfo_rtsp_cseq_recv          :: Int+  } deriving (Show)++++-------------------------------------------------------------------------------+data CURLoption+  ---- BEHAVIOR OPTIONS -------------------------------------------------------+  = CURLOPT_VERBOSE                 Bool+  | CURLOPT_HEADER                  Bool+  | CURLOPT_NOPROGRESS              Bool+  | CURLOPT_NOSIGNAL                Bool+  | CURLOPT_WILDCARDMATCH           Bool |7210:----|++  ---- CALLBACK OPTIONS -------------------------------------------------------+  | CURLOPT_WRITEFUNCTION           (Maybe CURL_write_callback)+ -- CURLOPT_WRITEDATA+  | CURLOPT_READFUNCTION            (Maybe CURL_read_callback)+ -- CURLOPT_READDATA+ -- CURLOPT_IOCTLFUNCTION+ -- CURLOPT_IOCTLDATA+ -- CURLOPT_SEEKFUNCTION+ -- CURLOPT_SEEKDATA+ -- CURLOPT_SOCKOPTFUNCTION+ -- CURLOPT_SOCKOPTDATA+ -- CURLOPT_OPENSOCKETFUNCTION+ -- CURLOPT_OPENSOCKETDATA+ -- CURLOPT_CLOSESOCKETFUNCTION |7217:----|+ -- CURLOPT_CLOSESOCKETDATA     |7217:----|+ -- CURLOPT_PROGRESSFUNCTION+ -- CURLOPT_PROGRESSDATA+ -- CURLOPT_HEADERFUNCTION+ -- CURLOPT_HEADERDATA+ -- CURLOPT_DEBUGFUNCTION+ -- CURLOPT_DEBUGDATA+ -- CURLOPT_SSL_CTX_FUNCTION+ -- CURLOPT_SSL_CTX_DATA+ -- CURLOPT_CONV_TO_NETWORK_FUNCTION+ -- CURLOPT_CONV_FROM_NETWORK_FUNCTION+ -- CURLOPT_CONV_FROM_UTF8_FUNCTION+ -- CURLOPT_INTERLEAVEFUNCTION+ -- CURLOPT_INTERLEAVEDATA+ -- CURLOPT_CHUNK_BGN_FUNCTION |7210:----|+ -- CURLOPT_CHUNK_END_FUNCTION |7210:----|+ -- CURLOPT_CHUNK_DATA         |7210:----|+ -- CURLOPT_FNMATCH_FUNCTION   |7210:----|+ -- CURLOPT_FNMATCH_DATA       |7210:----|++  ---- ERROR OPTIONS ----------------------------------------------------------+ -- CURLOPT_ERRORBUFFER             (IORef (Maybe ByteString))+ -- CURLOPT_STDERR                  Handle+  | CURLOPT_FAILONERROR             Bool++  ---- NETWORK OPTIONS --------------------------------------------------------+  | CURLOPT_URL                     ByteString+  | CURLOPT_PROTOCOLS               [CURLproto]+  | CURLOPT_REDIR_PROTOCOLS         [CURLproto]+  | CURLOPT_PROXY                   ByteString+  | CURLOPT_PROXYPORT               Int+  | CURLOPT_PROXYTYPE               CURLproxy+  | CURLOPT_NOPROXY                 ByteString+  | CURLOPT_HTTPPROXYTUNNEL         Bool+  | CURLOPT_SOCKS5_GSSAPI_SERVICE   ByteString+  | CURLOPT_SOCKS5_GSSAPI_NEC       Bool+  | CURLOPT_INTERFACE               ByteString+  | CURLOPT_LOCALPORT               Int+  | CURLOPT_LOCALPORTRANGE          Int+  | CURLOPT_DNS_CACHE_TIMEOUT       Int+  | CURLOPT_DNS_USE_GLOBAL_CACHE    Bool+  | CURLOPT_BUFFERSIZE              Int+  | CURLOPT_PORT                    Int+  | CURLOPT_TCP_NODELAY             Bool+  | CURLOPT_ADDRESS_SCOPE           Int+  | CURLOPT_TCP_KEEPALIVE           Bool          |7250:----|+  | CURLOPT_TCP_KEEPIDLE            Int           |7250:----|+  | CURLOPT_TCP_KEEPINTVL           Int           |7250:----|++  ---- NAMES and PASSWORDS OPTIONS (Authentication) ---------------------------+  | CURLOPT_NETRC                   CURLnetrc+  | CURLOPT_NETRC_FILE              ByteString+  | CURLOPT_USERPWD                 ByteString+  | CURLOPT_PROXYUSERPWD            ByteString+  | CURLOPT_USERNAME                ByteString+  | CURLOPT_PASSWORD                ByteString+  | CURLOPT_PROXYUSERNAME           ByteString+  | CURLOPT_PROXYPASSWORD           ByteString+  | CURLOPT_HTTPAUTH                [CURLauth]+ -- CURLOPT_TLSAUTH_TYPE            [CURLtlsauth] |7214:----|+  | CURLOPT_TLSAUTH_TYPE            ByteString    |7214:----|+  | CURLOPT_TLSAUTH_USERNAME        ByteString    |7214:----|+  | CURLOPT_TLSAUTH_PASSWORD        ByteString    |7214:----|+  | CURLOPT_PROXYAUTH               [CURLauth]++  ---- HTTP OPTIONS -----------------------------------------------------------+  | CURLOPT_AUTOREFERER             Bool+  | CURLOPT_ENCODING                ByteString    |----:7215|+  | CURLOPT_ACCEPT_ENCODING         ByteString    |7216:----|+  | CURLOPT_TRANSFER_ENCODING       Bool          |7216:----|+  | CURLOPT_FOLLOWLOCATION          Bool+  | CURLOPT_UNRESTRICTED_AUTH       Bool+  | CURLOPT_MAXREDIRS               Int+  | CURLOPT_POSTREDIR               [CURLredir]+  | CURLOPT_PUT                     Bool+  | CURLOPT_POST                    Bool+ -- CURLOPT_POSTFIELDS              ByteString -- not copied+  | CURLOPT_POSTFIELDSIZE           Int+  | CURLOPT_POSTFIELDSIZE_LARGE     Int64+  | CURLOPT_COPYPOSTFIELDS          ByteString+ -- CURLOPT_HTTPPOST                [CURL_httppost]+  | CURLOPT_REFERER                 ByteString+  | CURLOPT_USERAGENT               ByteString+ -- CURLOPT_HTTPHEADER              [ByteString]+ -- CURLOPT_HTTP200ALIASES          [ByteString]+  | CURLOPT_COOKIE                  ByteString+  | CURLOPT_COOKIEFILE              ByteString+  | CURLOPT_COOKIEJAR               ByteString+  | CURLOPT_COOKIESESSION           Bool+  | CURLOPT_COOKIELIST              ByteString+  | CURLOPT_HTTPGET                 Bool+  | CURLOPT_HTTP_VERSION            CURLhttpver+  | CURLOPT_IGNORE_CONTENT_LENGTH   Bool+  | CURLOPT_HTTP_CONTENT_DECODING   Bool+  | CURLOPT_HTTP_TRANSFER_DECODING  Bool++  ---- SMTP OPTIONS -----------------------------------------------------------+  | CURLOPT_MAIL_FROM               ByteString+ -- CURLOPT_MAIL_RCTP               [ByteString]+  | CURLOPT_MAIL_AUTH               ByteString    |7250:----|++  ---- TFTP OPTIONS -----------------------------------------------------------+  | CURLOPT_TFTP_BLKSIZE            Int++  ---- FTP OPTIONS ------------------------------------------------------------+  | CURLOPT_FTPPORT                 ByteString+ -- CURLOPT_QUOTE                   [ByteString]+ -- CURLOPT_POSTQUOTE               [ByteString]+ -- CURLOPT_PREQUOTE                [ByteString]+  | CURLOPT_DIRLISTONLY             Bool+  | CURLOPT_APPEND                  Bool+  | CURLOPT_FTP_USE_EPRT            Bool+  | CURLOPT_FTP_USE_EPSV            Bool+  | CURLOPT_FTP_USE_PRET            Bool+  | CURLOPT_FTP_CREATE_MISSING_DIRS CURLftpcreate+  | CURLOPT_FTP_RESPONSE_TIMEOUT    Int+  | CURLOPT_FTP_ALTERNATIVE_TO_USER ByteString+  | CURLOPT_FTP_SKIP_PASV_IP        Bool+  | CURLOPT_FTPSSLAUTH              CURLftpauth+  | CURLOPT_FTP_SSL_CCC             CURLftpssl+  | CURLOPT_FTP_ACCOUNT             ByteString+  | CURLOPT_FTP_FILEMETHOD          CURLftpmethod++  ---- RTSP OPTIONS -----------------------------------------------------------+  | CURLOPT_RTSP_REQUEST            CURLrtspreq+  | CURLOPT_RTSP_SESSION_ID         ByteString+  | CURLOPT_RTSP_STREAM_URI         ByteString+  | CURLOPT_RTSP_TRANSPORT          ByteString+ -- CURLOPT_RTSP_HEADER             [ByteString]+  | CURLOPT_RTSP_CLIENT_CSEQ        Int+  | CURLOPT_RTSP_SERVER_CSEQ        Int++  ---- PROTOCOL OPTIONS -------------------------------------------------------+  | CURLOPT_TRANSFERTEXT            Bool+  | CURLOPT_PROXY_TRANSFER_MODE     Bool+  | CURLOPT_CRLF                    Bool+  | CURLOPT_RANGE                   ByteString+  | CURLOPT_RESUME_FROM             Int+  | CURLOPT_RESUME_FROM_LARGE       Int64+  | CURLOPT_CUSTOMREQUEST           ByteString+  | CURLOPT_FILETIME                Bool+  | CURLOPT_NOBODY                  Bool+  | CURLOPT_INFILESIZE              Int+  | CURLOPT_INFILESIZE_LARGE        Int64+  | CURLOPT_UPLOAD                  Bool+  | CURLOPT_MAXFILESIZE             Int+  | CURLOPT_MAXFILESIZE_LARGE       Int64+  | CURLOPT_TIMECONDITION           CURLtimecond+  | CURLOPT_TIMEVALUE               UTCTime++  ---- CONNECTION OPTIONS -----------------------------------------------------+  | CURLOPT_TIMEOUT                 Int+  | CURLOPT_TIMEOUT_MS              Int+  | CURLOPT_LOW_SPEED_LIMIT         Int+  | CURLOPT_LOW_SPEED_TIME          Int+  | CURLOPT_MAX_SEND_SPEED_LARGE    Int64+  | CURLOPT_MAX_RECV_SPEED_LARGE    Int64+  | CURLOPT_MAXCONNECTS             Int+  | CURLOPT_CLOSEPOLICY             CURLclosepol+  | CURLOPT_FRESH_CONNECT           Bool+  | CURLOPT_FORBID_REUSE            Bool+  | CURLOPT_CONNECTTIMEOUT          Int+  | CURLOPT_CONNECTTIMEOUT_MS       Int+  | CURLOPT_IPRESOLVE               CURLipresolve+  | CURLOPT_CONNECT_ONLY            Bool+  | CURLOPT_USE_SSL                 CURLusessl+ -- CURLOPT_RESOLVE                 [ByteString]  |7213:----|+  | CURLOPT_DNS_SERVERS             ByteString    |7240:----|+  | CURLOPT_ACCEPTTIMEOUT_MS        Int           |7240:----|++  ---- SSL and SECURITY OPTIONS -----------------------------------------------+  | CURLOPT_SSLCERT                 ByteString+  | CURLOPT_SSLCERTTYPE             ByteString+  | CURLOPT_SSLKEY                  ByteString+  | CURLOPT_SSLKEYTYPE              ByteString+  | CURLOPT_KEYPASSWD               ByteString+  | CURLOPT_SSLENGINE               ByteString+  | CURLOPT_SSLENGINE_DEFAULT       Bool+  | CURLOPT_SSLVERSION              CURLsslver+  | CURLOPT_SSL_VERIFYPEER          Bool+  | CURLOPT_CAINFO                  ByteString+  | CURLOPT_ISSUERCERT              ByteString+  | CURLOPT_CAPATH                  ByteString+  | CURLOPT_CRLFILE                 ByteString+  | CURLOPT_SSL_VERIFYHOST          Int+  | CURLOPT_CERTINFO                Bool+  | CURLOPT_RANDOM_FILE             ByteString+  | CURLOPT_EGDSOCKET               ByteString+  | CURLOPT_SSL_CIPHER_LIST         ByteString+  | CURLOPT_SSL_SESSIONID_CACHE     Bool+  | CURLOPT_SSL_OPTIONS             CURLsslopt    |7250:----|+  | CURLOPT_KRBLEVEL                ByteString+  | CURLOPT_GSSAPI_DELEGATION       CURLgssapi    |7220:----|++  ---- SSH OPTIONS ------------------------------------------------------------+  | CURLOPT_SSH_AUTH_TYPES          [CURLsshauth]+  | CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 ByteString+  | CURLOPT_SSH_PUBLIC_KEYFILE      ByteString+  | CURLOPT_SSH_PRIVATE_KEYFILE     ByteString+  | CURLOPT_SSH_KNOWNHOSTS          ByteString+ -- CURLOPT_SSH_KEYFUNCTION         (Maybe CURL_sshkey_callback)+ -- CURLOPT_SSH_KEYDATA             -- ?++  ---- OTHER OPTIONS ----------------------------------------------------------+ -- CURLOPT_PRIVATE                 -- ?+ -- CURLOPT_SHARE                   CURLSH+  | CURLOPT_NEW_FILE_PERMS          Int+  | CURLOPT_NEW_DIRECTORY_PERMS     Int++  ---- TELNET OPTIONS ---------------------------------------------------------+ -- CURLOPT_TELNETOPTIONS           [ByteString]+++-------------------------------------------------------------------------------+data CURLproto+  = CURLPROTO_ALL+  | CURLPROTO_HTTP+  | CURLPROTO_HTTPS+  | CURLPROTO_FTP+  | CURLPROTO_FTPS+  | CURLPROTO_SCP+  | CURLPROTO_SFTP+  | CURLPROTO_TELNET+  | CURLPROTO_LDAP+  | CURLPROTO_LDAPS+  | CURLPROTO_DICT+  | CURLPROTO_FILE+  | CURLPROTO_TFTP+  | CURLPROTO_IMAP+  | CURLPROTO_IMAPS+  | CURLPROTO_POP3+  | CURLPROTO_POP3S+  | CURLPROTO_SMTP+  | CURLPROTO_SMTPS+  | CURLPROTO_RTSP+  | CURLPROTO_RTMP   |7210:----|+  | CURLPROTO_RTMPT  |7210:----|+  | CURLPROTO_RTMPE  |7210:----|+  | CURLPROTO_RTMPTE |7210:----|+  | CURLPROTO_RTMPS  |7210:----|+  | CURLPROTO_RTMPTS |7210:----|+  | CURLPROTO_GOPHER |7212:----|+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLproxy+  = CURLPROXY_HTTP+  | CURLPROXY_HTTP_1_0+  | CURLPROXY_SOCKS4+  | CURLPROXY_SOCKS5+  | CURLPROXY_SOCKS4A+  | CURLPROXY_SOCKS5_HOSTNAME+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLnetrc+  = CURL_NETRC_IGNORED+  | CURL_NETRC_OPTIONAL+  | CURL_NETRC_REQUIRED+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLauth+  = CURLAUTH_BASIC+  | CURLAUTH_DIGEST+  | CURLAUTH_DIGEST_IE+  | CURLAUTH_GSSNEGOTIATE+  | CURLAUTH_NTLM+  | CURLAUTH_NTLM_WB      |7220:----|+  | CURLAUTH_ONLY         |7213:----|+  | CURLAUTH_ANY+  | CURLAUTH_ANYSAFE+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLtlsauth                                                 |7214:----|+  = CURL_TLSAUTH_SRP                                             |7214:----|+  deriving (Eq, Show)                                            |7214:----|+++-------------------------------------------------------------------------------+data CURLredir+  = CURL_REDIR_GET_ALL+  | CURL_REDIR_POST_301+  | CURL_REDIR_POST_302+  | CURL_REDIR_POST_ALL+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLhttpver+  = CURL_HTTP_VERSION_NONE+  | CURL_HTTP_VERSION_1_0+  | CURL_HTTP_VERSION_1_1+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLftpcreate+  = CURLFTP_CREATE_DIR_NONE+  | CURLFTP_CREATE_DIR+  | CURLFTP_CREATE_DIR_RETRY+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLftpauth+  = CURLFTPAUTH_DEFAULT+  | CURLFTPAUTH_SSL+  | CURLFTPAUTH_TLS+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLftpssl+  = CURLFTPSSL_CCC_NONE+  | CURLFTPSSL_CCC_PASSIVE+  | CURLFTPSSL_CCC_ACTIVE+  deriving (Eq, Show)+ ++-------------------------------------------------------------------------------+data CURLftpmethod+  = CURLFTPMETHOD_DEFAULT+  | CURLFTPMETHOD_MULTICWD+  | CURLFTPMETHOD_NOCWD+  | CURLFTPMETHOD_SINGLECWD+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLrtspreq+  = CURL_RTSPREQ_OPTIONS+  | CURL_RTSPREQ_DESCRIBE+  | CURL_RTSPREQ_ANNOUNCE+  | CURL_RTSPREQ_SETUP+  | CURL_RTSPREQ_PLAY+  | CURL_RTSPREQ_PAUSE+  | CURL_RTSPREQ_TEARDOWN+  | CURL_RTSPREQ_GET_PARAMETER+  | CURL_RTSPREQ_SET_PARAMETER+  | CURL_RTSPREQ_RECORD+  | CURL_RTSPREQ_RECEIVE+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLtimecond+  = CURL_TIMECOND_NONE+  | CURL_TIMECOND_IFMODSINCE+  | CURL_TIMECOND_IFUNMODSINCE+  | CURL_TIMECOND_LASTMOD+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLclosepol+  = CURLCLOSEPOLICY_NONE+  | CURLCLOSEPOLICY_OLDEST+  | CURLCLOSEPOLICY_LEAST_RECENTLY_USED+  | CURLCLOSEPOLICY_LEAST_TRAFFIC+  | CURLCLOSEPOLICY_SLOWEST+  | CURLCLOSEPOLICY_CALLBACK+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLipresolve+  = CURL_IPRESOLVE_WHATEVER+  | CURL_IPRESOLVE_V4+  | CURL_IPRESOLVE_V6+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLusessl+  = CURLUSESSL_NONE+  | CURLUSESSL_TRY+  | CURLUSESSL_CONTROL+  | CURLUSESSL_ALL+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLsslver+  = CURL_SSLVERSION_DEFAULT+  | CURL_SSLVERSION_TLSv1+  | CURL_SSLVERSION_SSLv2+  | CURL_SSLVERSION_SSLv3+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+data CURLsslopt                                                  |7250:----|+  = CURLSSLOPT_ALLOW_BEAST                                       |7250:----|+  deriving (Eq, Show)                                            |7250:----|+++-------------------------------------------------------------------------------+data CURLgssapi                                                  |7220:----|+  = CURLGSSAPI_DELEGATION_NONE                                   |7220:----|+  | CURLGSSAPI_DELEGATION_POLICY_FLAG                            |7220:----|+  | CURLGSSAPI_DELEGATION_FLAG                                   |7220:----|+  deriving (Eq, Show)                                            |7220:----|+++-------------------------------------------------------------------------------+data CURLsshauth+  = CURLSSH_AUTH_ANY+  | CURLSSH_AUTH_NONE+  | CURLSSH_AUTH_PUBLICKEY+  | CURLSSH_AUTH_PASSWORD+  | CURLSSH_AUTH_HOST+  | CURLSSH_AUTH_KEYBOARD+  | CURLSSH_AUTH_DEFAULT+  deriving (Eq, Show)+++-------------------------------------------------------------------------------+type CURL_write_callback = ByteString -> IO CURL_write_response++data CURL_write_response+  = CURL_WRITEFUNC_OK+  | CURL_WRITEFUNC_FAIL+  | CURL_WRITEFUNC_PAUSE+  deriving (Eq)+++type CURL_read_callback = Int -> IO CURL_read_response++data CURL_read_response+  = CURL_READFUNC_OK ByteString+  | CURL_READFUNC_ABORT+  | CURL_READFUNC_PAUSE+  deriving (Eq)++
+ README view
@@ -0,0 +1,6 @@+This package provides a Haskell bindings to libcurl, the multiprotocol file+transfer library which powers the popular tool curl (see http://curl.haxx.se+and http://curl.haxx.se/libcurl/ for more info).++The project is in early stage so please be patient.+
+ Setup.hs view
@@ -0,0 +1,109 @@+module Main where++import Distribution.Simple+import Distribution.Simple.Utils+import Distribution.Simple.PreProcess+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, buildDir)+import Distribution.PackageDescription    (BuildInfo)+import Distribution.Verbosity             (Verbosity)+import System.FilePath                    ((</>), replaceExtension)+import Text.ParserCombinators.ReadP+import Text.Read.Lex (readDecP)+import Data.IORef    (IORef, newIORef, readIORef, writeIORef)+import Data.List     (find, isPrefixOf)+++-------------------------------------------------------------------------------+main = newIORef Nothing >>= \cvr -> defaultMainWithHooks simpleUserHooks+  { hookedPreProcessors = ("hs", ppHsX cvr) : ("hsc", ppHscX cvr)+                        : knownSuffixHandlers }+++-------------------------------------------------------------------------------+ppHsX :: IORef (Maybe Int) -> BuildInfo -> LocalBuildInfo -> PreProcessor+ppHsX cvr bi lbi = PreProcessor+  { platformIndependent = False+  , runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> do+      cv <- findCURLVER cvr bi lbi verbosity+      withUTF8FileContents inFile (writeUTF8File outFile . processFile cv)+  }++-------------------------------------------------------------------------------+ppHscX :: IORef (Maybe Int) -> BuildInfo -> LocalBuildInfo -> PreProcessor+ppHscX cvr bi lbi = PreProcessor+  { platformIndependent = False+  , runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> do+      cv <- findCURLVER cvr bi lbi verbosity+      let hscFile = replaceExtension outFile "hsc"+      withUTF8FileContents inFile (writeUTF8File hscFile . processFile cv)+      runSimplePreProcessor (ppHsc2hs bi lbi) hscFile outFile verbosity+  }++-------------------------------------------------------------------------------+findCURLVER :: IORef (Maybe Int)+            -> BuildInfo -> LocalBuildInfo -> Verbosity -> IO Int+findCURLVER cvr bi lbi verbosity = readIORef cvr >>= \mcv -> case mcv of+  Just cv -> return cv+  Nothing -> do+    info verbosity "Looking for LIBCURL_VERSION_NUM in \"curl/curl.h\""+    let cvFile = buildDir lbi </> "CURLVER"+    writeUTF8File cvFile curlverFileContent+    runSimplePreProcessor (ppHsc2hs bi lbi) cvFile cvFile verbosity+    mcv <- fmap parseCV $ readUTF8File cvFile+    case mcv of+      Nothing -> die "Can't find libcurl version info"+      Just cv -> writeIORef cvr mcv >> return cv++curlverFileContent :: String+curlverFileContent = unlines+  [ "#include \"curl/curl.h\""+  , "CURLVER = #{const LIBCURL_VERSION_NUM}" ]++parseCV :: String -> Maybe Int+parseCV cvf = do+  cvl <- find (isPrefixOf "CURLVER") $ lines cvf+  case (readP_to_S readDecP $ last $ words cvl) of+    [(cv,[])] -> Just cv+    _         -> Nothing++-------------------------------------------------------------------------------+processFile :: Int -> String -> String+processFile cv file = unlines $ map (processLine cv) $ lines file++processLine :: Int -> String -> String+processLine cv line =+  case (readP_to_S parseLine $ reverse line) of+    [((vmin, vmax, text),[])]+      -> if (vmin <= cv && cv <= vmax) then text else concat ["-- ", line]+    _ -> line++parseLine :: ReadP (Int, Int, String)+parseLine =+  char '|' >> parseVTAG >>= \vmax ->+  char ':' >> parseVTAG >>= \vmin ->+  char '|' >> parseTEXT >>= \text ->+  return (maybe 0x000000 id vmin, maybe 0xFFFFFF id vmax, text)++parseTEXT :: ReadP String+parseTEXT = skipSpaces >> manyTill get eof >>= return . reverse++parseVTAG :: ReadP (Maybe Int)+parseVTAG = count 4 get >>= \vtag -> if (vtag == "----") then return Nothing+  else maybe pfail (return . Just) $ lookup (reverse vtag)+    [ ("7200", 0x071400)+    , ("7201", 0x071401)+    , ("7210", 0x071500)+    , ("7211", 0x071501)+    , ("7212", 0x071502)+    , ("7213", 0x071503)+    , ("7214", 0x071504)+    , ("7215", 0x071505)+    , ("7216", 0x071506)+    , ("7217", 0x071507)+    , ("7220", 0x071600)+    , ("7230", 0x071700)+    , ("7231", 0x071701)+    , ("7240", 0x071800)+    , ("7250", 0x071900)+    ]+
+ curlhs.cabal view
@@ -0,0 +1,88 @@+name:           curlhs+version:        0.0.1+synopsis:       bindings to libcurl, the multiprotocol file transfer library+author:         Krzysztof Kardzis <kkardzis@gmail.com>+maintainer:     Krzysztof Kardzis <kkardzis@gmail.com>+copyright:      Copyright © 2012 Krzysztof Kardzis+-- license:     ISC License (MIT/BSD-style, see LICENSE file for details)+license:        OtherLicense+license-file:   LICENSE+category:       Network, Web, FFI+stability:      Experimental+build-type:     Custom+cabal-version:  >=1.6+tested-with:    GHC ==7.0.3+homepage:       https://github.com/kkardzis/curlhs++description:+  Package @curlhs@ provides a mid-level interface to @libcurl@, the+  multiprotocol file transfer library which powers the popular tool @curl@+  (please see <http://curl.haxx.se/> for more info). As described on the+  @libcurl@'s project site (<http://curl.haxx.se/libcurl/>):+  .+  /libcurl is a free and easy-to-use client-side URL transfer library,       /+  /supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, /+  /LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP.  /+  /libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading,    /+  /HTTP form based upload, proxies, cookies, user+password authentication    /+  /(Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume,         /+  /http proxy tunneling and more!                                            /+  .+  /libcurl is highly portable, it builds and works identically on numerous   /+  /platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HPUX,     /+  /IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/\//2, BeOs,   /+  /Mac OS X, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS and more...  /+  .+  /libcurl is free, thread-safe, IPv6 compatible, feature rich, well         /+  /supported, fast, thoroughly documented and is already used by many        /+  /known, big and successful companies and numerous applications.            /+  .+  Package @curlhs@ depends on @libcurl@ as an external library. To compile+  and later use @curlhs@, it is required to first install @libcurl@ somewhere+  on the system, best in place that is easy to locate by the compiler.+  Information about how to compile and install @libcurl@ may be found on+  its project site. A simple way may be to use one of the available+  precompiled packages.+  .+  Current version of @curlhs@ follows @libcurl@ in version 7.25.0. It is+  also possible to use @curlhs@ with older versions of @libcurl@, but some+  features may not be available then (@curlhs@ should easily compile+  with @libcurl@ from version 7.20.0 upward).+  .+  Package is distributed under ISC License (MIT/BSD-style, see LICENSE file+  for details). It is marked as @OtherLicense@ due to limitations of Cabal.++extra-source-files:+  README++library+  extra-libraries: curl+  build-tools:     hsc2hs+  ghc-options:     -Wall -fwarn-tabs++  build-depends:+    bytestring == 0.9.*,+    base       == 4.*,+    time       == 1.*++  exposed-modules:+    Network.Curlhs.Base+    Network.Curlhs.Core++  other-modules:+    Network.Curlhs.Easy+    -- Network.Curlhs.Multi+    -- Network.Curlhs.Share+    Network.Curlhs.Setopt+    Network.Curlhs.Errors+    Network.Curlhs.Types++  -- maybe not elegant, but convenient during tests+  -- if os(windows)+  --   include-dirs:   .\curl-7.25.0-devel-mingw32\include+  --   extra-lib-dirs: .\curl-7.25.0-devel-mingw32\bin++source-repository head+  type:     git+  location: https://github.com/kkardzis/curlhs+