Esempio n. 1
0
        /// <summary>
        /// Extract <c>Slist</c> information from an <c>Easy</c> object.
        /// </summary>
        /// <param name="info">One of the values in the
        /// <see cref="CURLINFO"/> enumeration. In this case, it must
        /// specifically be one of the members that obtains an <c>Slist</c>.
        /// </param>
        /// <param name="slist">Reference to an <c>Slist</c> value.</param>
        /// <returns>The <see cref="CURLcode"/> obtained from the internal
        /// call to <c>curl_easy_getinfo()</c>.
        /// </returns>
        /// <exception cref="System.NullReferenceException">This is thrown if
        /// the native <c>CURL*</c> handle wasn't created successfully.</exception>
        public CURLcode GetInfo(CURLINFO info, ref Slist slist)
        {
            EnsureHandle();
            CURLcode retCode = CURLcode.CURLE_OK;
            IntPtr   ptr = IntPtr.Zero, ptrs = IntPtr.Zero;

            if ((int)info < CURLINFO_SLIST)
            {
                return(CURLcode.CURLE_BAD_FUNCTION_ARGUMENT);
            }
            retCode = External.curl_easy_getinfo(m_pCURL, info, ref ptr);
            if (retCode != CURLcode.CURLE_OK)
            {
                return(retCode);
            }
            slist = new Slist();
            while (ptr != IntPtr.Zero)
            {
                ptr = External.curl_shim_get_string_from_slist(
                    ptr, ref ptrs);
                slist.Append(Marshal.PtrToStringAnsi(ptrs));
            }
            return(retCode);
        }