예제 #1
0
Element& SyntaxNode::AddElement(Element* const PCLI_Element)
{
    CLI_ASSERT(PCLI_Element != NULL);

    for (   Element::List::Iterator it = m_cliElements.GetIterator();
            m_cliElements.IsValid(it);
            m_cliElements.MoveNext(it))
    {
        if (const Element* const pcli_Element = m_cliElements.GetAt(it))
        {
            if (pcli_Element->GetKeyword() == PCLI_Element->GetKeyword())
            {
                if (PCLI_Element != pcli_Element)
                {
                    //! @warning Conflicting names:
                    //!         The behaviour is the following: deletion of the new element,
                    //!         and retrieval of the element with the same name.
                    //!         This could be convenient if both elements are keywords for instance,
                    //!         but there is absolutely no guarantee for any other conditions.
                    delete PCLI_Element;
                    return const_cast<Element&>(*pcli_Element);
                }
                else
                {
                    // Element already available from this syntaxe node.
                    // Do not add it again.
                    // Just return the reference.
                    return *PCLI_Element;
                }
            }
        }
    }

    // Regular behaviour.
    PCLI_Element->SetCli(GetCli());
    m_cliElements.AddTail(PCLI_Element);
    return *PCLI_Element;
}
예제 #2
0
void cli_telnetd_loop(void * data)
{
    cli_telnet_ctrl_t * t = (cli_telnet_ctrl_t*)data;
    FILE * in;
    FILE * out;

    CLI_ASSERT(data != NULL);

    if(CLI_OK == t->server->open_stream(t->socket,&in,&out)){
        t->out_fd = out;
        cli_main(CLI_SESSION_TELNET,in,out);
#ifdef CLI_OS_LINUX
        pthread_mutex_lock(&g_telnet_lock);
#endif
        t->out_fd = NULL;
        t->valid = 0;
        t->server->close_stream(t->socket,&in,&out);
#ifdef CLI_OS_LINUX
        pthread_mutex_unlock(&g_telnet_lock);
#endif
    }
    
}