Example #1
0
        // called by libcurlshim
        private static int WriteDelegate(IntPtr buf, int sz, int nmemb,
                                         IntPtr parm)
        {
            int bytes = sz * nmemb;

            byte[] b = new byte[bytes];
            for (int i = 0; i < bytes; i++)
            {
                b[i] = Marshal.ReadByte(buf, i);
            }
            GCHandle gch  = (GCHandle)parm;
            Easy     easy = (Easy)gch.Target;

            if (easy == null)
            {
                return(0);
            }
            if (easy.m_pfWrite == null)
            {
                return(bytes);   // keep going
            }
            return(easy.m_pfWrite(b, sz, nmemb, easy.m_writeData));
        }