Beispiel #1
0
bool _SYS_COMMAND_INIT(void)
{
    int         ix;

    CommandCleanup();       // just in case we have to deallocate previous data

    // construct the command history list
    for(ix = 0; ix<COMMAND_HISTORY_DEPTH; ix++)
    {
        cmdNode* pN;
        pN = (cmdNode*)SystemMalloc(sizeof(*pN));

        if(!pN)
        {
            return false;
        }
        pN->cmdBuff[0] = '\0';
        CmdAddHead(&_cmdList, pN);
    }
    _pCurrCmdN = 0;

// Console will be added automatically
#if defined(SYS_CONSOLE_ENABLE)
    // the console handle should be needed here but there's only one console for now
    _SYS_CMDIO_ADD(&sysConsoleApi, 0);
#endif

    //SYS_CONSOLE_MESSAGE(_promptStr);
    _cmdAlive = true;

    return true;
}
Beispiel #2
0
// quit
static int CommandQuit(_CMDIO_DEV_NODE* pCmdIO, int argc, char** argv)
{
    _CMDIO_DEV_NODE* pCmdIoNode;
    const void* cmdIoParam = pCmdIO->cmdIoParam;

    (*pCmdIO->pCmdApi->msg)(cmdIoParam, LINE_TERM " *** Quitting the Command Processor. Bye ***\r\n" );

    CommandCleanup();

    while ((pCmdIoNode = _SYS_CMDIO_GET_HANDLE(0)) != NULL)
    {
        if(_SYS_CMDIO_DELETE(pCmdIoNode)) SystemFree(pCmdIoNode);
    }

    return 0;
}
Beispiel #3
0
/* Function:
    bool SYS_CMD_Initialize( const SYS_MODULE_INIT * const init  )

  Summary:
    Initializes data for the instance of the Command Processor module.

  Description:
    This function initializes the Command Processor module.
    It also initializes any internal data structures.

  Precondition:
    None.

  Parameters:
    init            - Pointer to a data structure containing any data necessary
                      to initialize the sys command. This pointer may be null if no
                      data is required because static overrides have been
                      provided.

  Returns:
    If successful, returns true.
    If there is an error, returns false.

  Remarks:
    This routine should only be called once during system initialization.
*/
bool SYS_CMD_Initialize(const SYS_MODULE_INIT * const init )
{
    SYS_CMD_INIT *initConfig = (SYS_CMD_INIT*)init;
    int         ix;

    CommandCleanup();       // just in case we have to deallocate previous data

    // construct the command history list
    for(ix = 0; ix<COMMAND_HISTORY_DEPTH; ix++)
    {
        cmdNode* pN;
        pN = (cmdNode*)malloc(sizeof(*pN));

        if(!pN)
        {
            return false;
        }
        pN->cmdBuff[0] = '\0';
        CmdAddHead(&_cmdList, pN);
    }
    _pCurrCmdN = 0;

    // the console handle should be needed here but there's only one console for now
    if (initConfig != NULL)
    {
        SYS_CMDIO_ADD(&sysConsoleApi, &initConfig->consoleCmdIOParam, initConfig->consoleCmdIOParam);
    }
    else
    {
        SYS_CMDIO_ADD(&sysConsoleApi, NULL, SYS_CMD_SINGLE_CHARACTER_READ_CONSOLE_IO_PARAM);
    }

    _cmdAppData.moduleInFd = STDIN_FILENO;
    _cmdAppData.moduleOutFd = STDOUT_FILENO;

    return true;
}