コード例 #1
0
ファイル: FTP_ClientRequestHandler.cpp プロジェクト: CCJY/ACE
    bool
    ClientRequestHandler::parse_address (const ACE_CString& str, ACE_INET_Addr& addr)
      {
        static const int eof_ = std::char_traits<char>::eof ();

        ACE::IOS::CString_OStream sos_host;
        u_short port_hi = 0, port_lo = 0;

        ACE::IOS::CString_IStream sis (str);
        sis.ignore (str.length (), '(');
        int ch = sis.get ();
        if (ACE_OS::ace_isdigit (ch))
          {
            for (int i=0; i<4 ;++i)
              {
                if (ch == ',')
                  {
                    sos_host.put ('.');
                    ch = sis.get ();
                  }
                while (ch != eof_ && ACE_OS::ace_isdigit (ch))
                  {
                    sos_host.put (ch);
                    ch = sis.get ();
                  }
              }
            if (ch == ',')
              {
                sis >> port_hi;
                ch = sis.get ();
                if (ch == ',')
                  {
                    sis >> port_lo;

                    u_short port = port_hi*256 + port_lo;
                    addr.set (port, sos_host.str ().c_str ());
                    return true;
                  }
              }