A
download External.cs
Language: C#
Copyright: (c) 2004, Jeff Phillips, (jeff@seasideresearch.com), et al.
LOC: 179
Project Info
libcurl-mono
Server: Novell Forge
Type: cvs
...bcurl‑mono\libcurlmono\src\
   AssemblyInfo.cs
   Curl.cs
   Easy.cs
   Enums.cs
   External.cs
   Multi.cs
   MultiInfo.cs
   MultiPartForm.cs
   Share.cs
   Slist.cs
   SSLContext.cs
   VersionInfoData.cs

/***************************************************************************
 *
 * Project: libcurl.mono
 *
 * Copyright (c) 2004, Jeff Phillips, (jeff@seasideresearch.com), et al.
 *
 * This software is licensed as described in the file COPYING, which you
 * should have received as part of this distribution. The terms are also
 * available at http://www.seasideresearch.com/libcurlmono/copyright.html.
 *
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
 * copies of this Software, and permit persons to whom the Software is
 * furnished to do so, under the terms of the COPYING file.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
 * ANY KIND, either express or implied.
 *
 * $Id: External.cs,v 1.2 2004/12/08 20:13:50 seasideresearch Exp $
 **************************************************************************/

using System;
using System.Runtime.InteropServices;

namespace SeasideResearch.LibCurlNet
{
    /// <summary>
    /// P/Invoke signatures.
    /// </summary>
    internal class External
    {
        // private members
        private const String m_libCurlBase = "libcurl.so.3";
        private const String m_libCurlShim = "libcurlshim.so";

        // internal delegates from cURL
        internal delegate int CURL_WRITE_CALLBACK(IntPtr buf, int sz,
            int nmemb, IntPtr parm);
        internal delegate int CURL_READ_CALLBACK(IntPtr buf, int sz,
            int nmemb, IntPtr parm);
        internal delegate int CURL_PROGRESS_CALLBACK(IntPtr parm,
            double dlTotal, double dlNow, double ulTotal, double ulNow);
        internal delegate int CURL_DEBUG_CALLBACK(IntPtr curl,
            CURLINFOTYPE infoType, IntPtr msgBuf,
            int msgBufSize, IntPtr parm);
        internal delegate int CURL_HEADER_CALLBACK(IntPtr buf, int sz,
            int nmemb, IntPtr stream);
        internal delegate int CURL_SSL_CTX_CALLBACK(IntPtr curl,
            IntPtr ctx, IntPtr parm);
        internal delegate void CURLSH_LOCK_CALLBACK(IntPtr curl,
            int data, int access, IntPtr userPtr);
        internal delegate void CURLSH_UNLOCK_CALLBACK(IntPtr curl,
            int data, IntPtr userPtr);

        // libcurl imports
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLcode curl_global_init(int flags);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_global_cleanup();
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             CharSet=CharSet.Ansi)]
        internal static extern IntPtr curl_escape(String url, int length);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             CharSet=CharSet.Ansi)]
        internal static extern IntPtr curl_unescape(String url, int length);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_free(IntPtr p);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_version();

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_easy_init();
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_easy_cleanup(IntPtr pCurl);

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLcode curl_easy_setopt(IntPtr pCurl,
            CURLoption opt, IntPtr parm);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
            EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_writefunction(
            IntPtr pCurl, CURLoption opt, CURL_WRITE_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_readfunction(
            IntPtr pCurl, CURLoption opt, CURL_READ_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_progressfunction(
            IntPtr pCurl, CURLoption opt, CURL_PROGRESS_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_headerfunction(
            IntPtr pCurl, CURLoption opt, CURL_HEADER_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_debugfunction(
            IntPtr pCurl, CURLoption opt, CURL_DEBUG_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_sslctxfunction(
            IntPtr pCurl, CURLoption opt, CURL_SSL_CTX_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
            EntryPoint="curl_easy_setopt")]
        internal static extern CURLcode curl_easy_setopt_64(IntPtr pCurl,
            CURLoption opt, long parm);

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLcode curl_easy_perform(IntPtr pCurl);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_easy_duphandle(IntPtr pCurl);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_easy_strerror(CURLcode err);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLcode curl_easy_getinfo(IntPtr pCurl,
            CURLINFO info, ref IntPtr pInfo);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
            EntryPoint="curl_easy_getinfo")]
        internal static extern CURLcode curl_easy_getinfo_64(IntPtr pCurl,
            CURLINFO info, ref double dblVal);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_easy_reset(IntPtr pCurl);

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_multi_init();
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLMcode curl_multi_cleanup(IntPtr pmulti);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLMcode curl_multi_add_handle(IntPtr pmulti,
            IntPtr peasy);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLMcode curl_multi_remove_handle(IntPtr pmulti,
            IntPtr peasy);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_multi_strerror(CURLMcode errorNum);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLMcode curl_multi_perform(IntPtr pmulti,
            ref int runningHandles);

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_formfree(IntPtr pForm);

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_share_init();
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLSHcode curl_share_cleanup(IntPtr pShare);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_share_strerror(CURLSHcode errorCode);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLSHcode curl_share_setopt(IntPtr pShare,
            CURLSHoption optCode, IntPtr option);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
            EntryPoint="curl_share_setopt")]
        internal static extern CURLSHcode curl_share_setopt_lockfunction(
            IntPtr pCurl, CURLSHoption opt, CURLSH_LOCK_CALLBACK cb);
        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl,
             EntryPoint="curl_share_setopt")]
        internal static extern CURLSHcode curl_share_setopt_unlockfunction(
            IntPtr pCurl, CURLSHoption opt, CURLSH_UNLOCK_CALLBACK cb);

        [DllImport(m_libCurlBase, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_version_info(CURLversion ver);

        // libcurlshim imports
        internal static void curl_shim_initialize() {
            curl_shim_init(m_libCurlBase);
        }
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl,
            CharSet=CharSet.Ansi, EntryPoint="curl_shim_initialize")]
        private static extern void curl_shim_init(String strLibCurl);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_shim_cleanup();
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_shim_alloc_strings();
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl,
            CharSet=CharSet.Ansi)]
        internal static extern IntPtr curl_shim_add_string_to_slist(
            IntPtr pStrings, String str);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl,
            CharSet=CharSet.Ansi)]
        internal static extern IntPtr curl_shim_add_string(IntPtr pStrings, String str);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_shim_free_strings(IntPtr pStrings);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_shim_get_file_time(int unixTime,
            ref int yy, ref int mm, ref int dd, ref int hh, ref int mn,
            ref int ss);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_shim_free_slist(IntPtr p);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_shim_alloc_fd_sets();
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_shim_free_fd_sets(IntPtr fdsets);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern CURLMcode curl_shim_multi_fdset(IntPtr multi,
            IntPtr fdsets, ref int maxFD);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern int curl_shim_select(int maxFD, IntPtr fdsets,
            int timeoutMillis);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_shim_multi_info_read(IntPtr multi,
            ref int nMsgs);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern void curl_shim_multi_info_free(IntPtr multiInfo);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern int curl_shim_formadd(IntPtr[] ppForms,
            IntPtr[] pParams, int nParams);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern int curl_shim_get_version_int_value(IntPtr p, int offset);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_shim_get_version_char_ptr(IntPtr p, int offset);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern int curl_shim_get_number_of_protocols(IntPtr p, int offset);
        [DllImport(m_libCurlShim, CallingConvention=CallingConvention.Cdecl)]
        internal static extern IntPtr curl_shim_get_protocol_string(IntPtr p, int offset,
            int index);
    }
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us