Exemplo n.º 1
0
        private void ReceiveResponse(string response, StateObject state)
        {
            string    scode     = string.Empty;
            ArrayList lResponse = new ArrayList();

            int i, j;
            int maxline = 0;

            i = 0;
            do
            {
                j = response.IndexOf(CRLF, i);
                if (j > -1)
                {
                    lResponse.Add(response.Substring(i, j - i));
                    i = j + 2;
                }
                else
                {
                    lResponse.Add(response.Substring(i, response.Length - i));
                }
                maxline++;
            } while (i < response.Length);

            int idline  = 0;
            int idstart = 0;

            do
            {
                if (((string)lResponse[idline]).Length > 3)
                {
                    if (((string)lResponse[idline])[3] == '-' || state.multires.Length > 0)
                    {
                        if (state.multires.Length == 0)
                        {
                            state.multires.Append(lResponse[idline]);
                            state.scode = ((string)lResponse[idline]).Substring(0, 3);
                            idstart     = idline + 1;
                        }
                        else
                        {
                            idstart = idline;
                        }
                        for (j = idstart; j < lResponse.Count; j++)
                        {
                            state.multires.Append(lResponse[j]);
                            if (((string)lResponse[j]).Length > 3)
                            {
                                if (((string)lResponse[j]).Substring(0, 3) == state.scode && ((string)lResponse[j])[3] != '-')
                                {
                                    break;
                                }
                            }
                        }
                        if (j < lResponse.Count)
                        {
                            m_ftpmonitor.Reply(state.multires.ToString());
                            state.multires.Remove(0, state.multires.Length);
                        }
                        idline = j + 1;
                    }
                    else
                    {
                        m_ftpmonitor.Reply((string)lResponse[idline]);
                        idline++;
                    }
                }
                else
                {
                    idline++;
                }
            } while (idline < lResponse.Count);
        }