Beispiel #1
0
        /// <summary>
        /// Set options for this object.
        /// </summary>
        /// <param name="option">
        /// One of the values in the <see cref="CURLSHoption"/>
        /// enumeration.
        /// </param>
        /// <param name="parameter">
        /// An appropriate object based on the value passed in the
        /// <c>option</c> argument. See <see cref="CURLSHoption"/>
        /// for more information about the appropriate parameter type.
        /// </param>
        /// <returns>
        /// A <see cref="CURLSHcode"/>, hopefully
        /// <c>CURLSHcode.CURLSHE_OK</c>.
        /// </returns>
        /// <exception cref="System.NullReferenceException">This is thrown if
        /// the native <c>share</c> handle wasn't created successfully.</exception>
        public CURLSHcode SetOpt(CURLSHoption option, Object parameter)
        {
            EnsureHandle();
            CURLSHcode retCode = CURLSHcode.CURLSHE_OK;

            switch (option)
            {
            case CURLSHoption.CURLSHOPT_LOCKFUNC:
                LockFunction lf = parameter as LockFunction;
                if (lf == null)
                {
                    return(CURLSHcode.CURLSHE_BAD_OPTION);
                }
                m_pfLock = lf;
                break;

            case CURLSHoption.CURLSHOPT_UNLOCKFUNC:
                UnlockFunction ulf = parameter as UnlockFunction;
                if (ulf == null)
                {
                    return(CURLSHcode.CURLSHE_BAD_OPTION);
                }
                m_pfUnlock = ulf;
                break;

            case CURLSHoption.CURLSHOPT_SHARE:
            case CURLSHoption.CURLSHOPT_UNSHARE:
            {
                CURLlockData opt = (CURLlockData)
                                   Convert.ToInt32(parameter);
                if ((opt != CURLlockData.CURL_LOCK_DATA_COOKIE) &&
                    (opt != CURLlockData.CURL_LOCK_DATA_DNS))
                {
                    return(CURLSHcode.CURLSHE_BAD_OPTION);
                }
                retCode = External.curl_share_setopt(m_pShare,
                                                     option, (IntPtr)opt);
                break;
            }

            case CURLSHoption.CURLSHOPT_USERDATA:
                m_userData = parameter;
                break;

            default:
                retCode = CURLSHcode.CURLSHE_BAD_OPTION;
                break;
            }
            return(retCode);
        }
Beispiel #2
0
        /// <summary>
        /// Set options for this object.
        /// </summary>
        /// <param name="option">
        /// One of the values in the <see cref="CURLSHoption"/>
        /// enumeration.
        /// </param>
        /// <param name="parameter">
        /// An appropriate object based on the value passed in the
        /// <c>option</c> argument. See <see cref="CURLSHoption"/>
        /// for more information about the appropriate parameter type.
        /// </param>
        /// <returns>
        /// A <see cref="CURLSHcode"/>, hopefully
        /// <c>CURLSHcode.CURLSHE_OK</c>.
        /// </returns>
        /// <exception cref="System.NullReferenceException">This is thrown if
        /// the native <c>share</c> handle wasn't created successfully.</exception>
        public CURLSHcode SetOpt(CURLSHoption option, Object parameter)
        {
            EnsureHandle();
            CURLSHcode retCode = CURLSHcode.CURLSHE_OK;

            switch(option)
            {
                case CURLSHoption.CURLSHOPT_LOCKFUNC:
                    LockFunction lf = parameter as LockFunction;
                    if (lf == null)
                        return CURLSHcode.CURLSHE_BAD_OPTION;
                    m_pfLock = lf;
                    break;

                case CURLSHoption.CURLSHOPT_UNLOCKFUNC:
                    UnlockFunction ulf = parameter as UnlockFunction;
                    if (ulf == null)
                        return CURLSHcode.CURLSHE_BAD_OPTION;
                    m_pfUnlock = ulf;
                    break;

                case CURLSHoption.CURLSHOPT_SHARE:
                case CURLSHoption.CURLSHOPT_UNSHARE:
                {
                    CURLlockData opt = (CURLlockData)
                        Convert.ToInt32(parameter);
                    if ((opt != CURLlockData.CURL_LOCK_DATA_COOKIE) &&
                        (opt != CURLlockData.CURL_LOCK_DATA_DNS))
                        return CURLSHcode.CURLSHE_BAD_OPTION;
                    retCode = External.curl_share_setopt(m_pShare,
                        option, (IntPtr)opt);
                    break;
                }

                case CURLSHoption.CURLSHOPT_USERDATA:
                    m_userData = parameter;
                    break;

                default:
                    retCode = CURLSHcode.CURLSHE_BAD_OPTION;
                    break;
            }
            return retCode;
        }
Beispiel #3
0
 internal static extern CURLSHcode curl_share_setopt(IntPtr pShare,
                                                     CURLSHoption optCode, IntPtr option);
Beispiel #4
0
 internal static extern CURLSHcode curl_share_setopt(IntPtr pShare, CURLSHoption optCode, IntPtr option);