|
@@ -96,9 +96,10 @@ shellmatta_retCode_t shellmatta_doInit(
|
|
|
inst->hereLength = 0u;
|
|
|
inst->mode = SHELLMATTA_MODE_INSERT;
|
|
|
inst->cmdList = &(inst->helpCmd);
|
|
|
+ inst->continuousCmd = NULL;
|
|
|
inst->cmdListIsConst = false;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
memcpy(&(inst->helpCmd), &helpCmd, sizeof(shellmatta_cmd_t));
|
|
|
|
|
|
if(NULL != cmdList)
|
|
@@ -132,11 +133,12 @@ shellmatta_retCode_t shellmatta_resetShell( shellmatta_handle_t handle, bool pri
|
|
|
shellmatta_instance_t *inst = (shellmatta_instance_t *)handle;
|
|
|
shellmatta_retCode_t ret = SHELLMATTA_OK;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if( (NULL != handle)
|
|
|
&& (SHELLMATTA_MAGIC == inst->magic))
|
|
|
{
|
|
|
inst->inputCount = 0u;
|
|
|
+ inst->continuousCmd = NULL;
|
|
|
inst->lastNewlineIdx = 0u;
|
|
|
inst->cursor = 0u;
|
|
|
inst->stdinIdx = 0u;
|
|
@@ -276,25 +278,25 @@ shellmatta_retCode_t shellmatta_removeCmd(shellmatta_handle_t handle, shellmatta
|
|
|
tempCmd = inst->cmdList;
|
|
|
prevCmd = NULL;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
while(NULL != tempCmd)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if (0 == strcmp( tempCmd->cmd,
|
|
|
cmd->cmd)
|
|
|
&& (strlen(tempCmd->cmd) == strlen(cmd->cmd)))
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if(NULL == prevCmd)
|
|
|
{
|
|
|
inst->cmdList = tempCmd->next;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
else if(NULL == tempCmd->next)
|
|
|
{
|
|
|
prevCmd->next = NULL;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
else
|
|
|
{
|
|
|
prevCmd->next = tempCmd->next;
|
|
@@ -363,6 +365,7 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
uint32_t byteCounter;
|
|
|
|
|
|
shellmatta_retCode_t ret = SHELLMATTA_OK;
|
|
|
+ shellmatta_retCode_t cmdRet;
|
|
|
shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
|
|
|
|
|
|
|
|
@@ -372,8 +375,22 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
|
|
|
for (byteCounter = 0u; byteCounter < size; byteCounter++)
|
|
|
{
|
|
|
+
|
|
|
+ if(NULL != inst->continuousCmd)
|
|
|
+ {
|
|
|
+
|
|
|
+ inst->buffer[inst->stdinIdx] = data[byteCounter];
|
|
|
+ inst->stdinLength = 1u;
|
|
|
+ cmdRet = inst->continuousCmd->cmdFct(inst, inst->buffer, inst->inputCount);
|
|
|
+
|
|
|
+
|
|
|
+ if(('\x03' == data[byteCounter]) || (SHELLMATTA_CONTINUE != cmdRet))
|
|
|
+ {
|
|
|
+ utils_terminateInput(inst);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(inst->escapeCounter != 0u)
|
|
|
+ else if(inst->escapeCounter != 0u)
|
|
|
{
|
|
|
escape_handleSequence(inst, *data);
|
|
|
}
|
|
@@ -460,8 +477,8 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
history_storeCmd(inst);
|
|
|
history_reset(inst);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
inst->stdinIdx = inst->hereDelimiterIdx + inst->hereLength;
|
|
|
while( ('\n' == inst->buffer[inst->stdinIdx])
|
|
|
|| ('\r' == inst->buffer[inst->stdinIdx]))
|
|
@@ -481,7 +498,7 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
inst->lastNewlineIdx = inst->inputCount;
|
|
|
utils_insertChars(inst, data, 1u);
|
|
|
}
|
|
@@ -519,7 +536,15 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
utils_writeEcho(inst, "\r\n", 2u);
|
|
|
shellmatta_opt_init(inst, cmdLen + 1u);
|
|
|
cmdExecuted = 1u;
|
|
|
- cmd->cmdFct(inst, inst->buffer, inst->inputCount);
|
|
|
+ cmdRet = cmd->cmdFct(inst, inst->buffer, inst->inputCount);
|
|
|
+ if(SHELLMATTA_CONTINUE == cmdRet)
|
|
|
+ {
|
|
|
+ inst->continuousCmd = cmd;
|
|
|
+
|
|
|
+
|
|
|
+ inst->stdinIdx = inst->inputCount + 1u;
|
|
|
+ inst->stdinLength = 0u;
|
|
|
+ }
|
|
|
cmd = NULL;
|
|
|
}
|
|
|
else
|
|
@@ -534,9 +559,13 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
inst->write(inst->buffer, inst->inputCount);
|
|
|
inst->write(" not found", 10u);
|
|
|
}
|
|
|
- utils_terminateInput(inst);
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+ if(NULL == inst->continuousCmd)
|
|
|
+ {
|
|
|
+ utils_terminateInput(inst);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
else if('\t' == *data)
|
|
@@ -546,7 +575,7 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|
|
}
|
|
|
|
|
|
* terminate current input and print prompt again */
|
|
|
- else if(3 == *data)
|
|
|
+ else if('\x03' == *data)
|
|
|
{
|
|
|
inst->dirty = false;
|
|
|
history_reset(inst);
|
|
@@ -614,7 +643,7 @@ shellmatta_retCode_t shellmatta_write( shellmatta_handle_t handle,
|
|
|
|
|
|
* @brief reads the stdin like buffer
|
|
|
* @param[in] handle shellmatta instance handle
|
|
|
- * @param[out] data pointer to pointer to store ref to the buffer
|
|
|
+ * @param[out] data stdin data or NULL
|
|
|
* @param[out] length size of the stdin data
|
|
|
* @return
|
|
|
*/
|
|
@@ -631,8 +660,15 @@ shellmatta_retCode_t shellmatta_read( shellmatta_handle_t handle,
|
|
|
&& (NULL != data)
|
|
|
&& (NULL != length))
|
|
|
{
|
|
|
-
|
|
|
- *data = &(inst->buffer[inst->stdinIdx]);
|
|
|
+
|
|
|
+ if(0u == inst->stdinLength)
|
|
|
+ {
|
|
|
+ *data = NULL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ *data = &(inst->buffer[inst->stdinIdx]);
|
|
|
+ }
|
|
|
*length = inst->stdinLength;
|
|
|
}
|
|
|
|