Esempio n. 1
0
HttpListener* HttpListenerList::get( const char * pName, const char * pAddr )
{
    iterator iter;
    char achBuf[256];
    if ( pName )
    {
        iter = bfind( pName, f_compare );
        if ( iter != end() )
            return *iter;
    }
    if ( pAddr )
    {
        iter = bfind( pAddr, f_compare );
        if ( iter != end() )
        {
            HttpListener * p = *iter;
            p->setName( pName );
            sort( s_compare );
            return p;
        }
        if ( strncmp( pAddr, "0.0.0.0:", 8 ) == 0 )
        {
            snprintf( achBuf, 256, "*:%s", pAddr + 8 );
            pAddr = achBuf;
        }
        for( iterator iter = begin(); iter != end(); ++iter )
        {
            if ( strcasecmp( pAddr, (*iter)->getAddrStr() ) == 0 )
            {
                HttpListener * p = *iter;
                p->setName( pName );
                sort( s_compare );
                return p;
            }
        }
    }
    return NULL;
}
HttpListener* HttpListenerList::get( const char * pName, const char * pAddr )
{
    iterator iter;
    if ( pName )
    {
        iter = bfind( pName, f_compare );
        if ( iter != end() )
            return *iter;
    }
    if ( pAddr )
    {
        iter = bfind( pAddr, f_compare );
        if ( iter != end() )
        {
            HttpListener * p = *iter;
            erase( iter );
            p->setName( pName );
            push_back( p );
            sort( s_compare );
            return p;
        }
    }
    return NULL;
}