|
@@ -34,7 +34,7 @@
|
|
* @return #SHELLMATTA_BUSY => reading in data
|
|
* @return #SHELLMATTA_BUSY => reading in data
|
|
* #SHELLMATTA_OK => delimiter (e.g. enter) detected
|
|
* #SHELLMATTA_OK => delimiter (e.g. enter) detected
|
|
*/
|
|
*/
|
|
-shellmatta_retCode_t inputWrapper(shellmatta_instance_t *inst, char data, bool hide)
|
|
|
|
|
|
+static shellmatta_retCode_t inputWrapper(shellmatta_instance_t *inst, char data, bool hide)
|
|
{
|
|
{
|
|
shellmatta_retCode_t ret = SHELLMATTA_BUSY;
|
|
shellmatta_retCode_t ret = SHELLMATTA_BUSY;
|
|
bool echoEnabledBackup = inst->echoEnabled;
|
|
bool echoEnabledBackup = inst->echoEnabled;
|
|
@@ -108,7 +108,7 @@ static uint32_t getUserIdFromName(shellmatta_instance_t *inst, const char *usern
|
|
* @param[in] userId userId to check the password for
|
|
* @param[in] userId userId to check the password for
|
|
* @param[in] password password to check for - pointer to string
|
|
* @param[in] password password to check for - pointer to string
|
|
*/
|
|
*/
|
|
-void checkPassword(shellmatta_handle_t handle, uint32_t userId, char *password)
|
|
|
|
|
|
+static void checkPassword(shellmatta_handle_t handle, uint32_t userId, char *password)
|
|
{
|
|
{
|
|
shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
|
|
shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
|
|
uint32_t approvedUserId = 0u;
|
|
uint32_t approvedUserId = 0u;
|
|
@@ -144,11 +144,11 @@ void checkPassword(shellmatta_handle_t handle, uint32_t userId, char *password)
|
|
/** -# print login result */
|
|
/** -# print login result */
|
|
if (0 == approvedUserId)
|
|
if (0 == approvedUserId)
|
|
{
|
|
{
|
|
- shellmatta_write(handle, "username or password is wrong\r\n", 31);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("username or password is wrong\r\n", 31);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- shellmatta_write(handle, "login successful\r\n", 18);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("login successful\r\n", 18);
|
|
(void)shellmatta_auth_login(handle, approvedUserId);
|
|
(void)shellmatta_auth_login(handle, approvedUserId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -201,7 +201,7 @@ static shellmatta_retCode_t loginCmdFct(const shellmatta_handle_t handle, const
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- shellmatta_write(handle, "Unknown option\r\n", 16);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("Unknown option\r\n", 16);
|
|
return SHELLMATTA_USE_FAULT;
|
|
return SHELLMATTA_USE_FAULT;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -220,13 +220,13 @@ static shellmatta_retCode_t loginCmdFct(const shellmatta_handle_t handle, const
|
|
inst->cursor = 0u;
|
|
inst->cursor = 0u;
|
|
|
|
|
|
inst->tmpUserId = getUserIdFromName(handle, username);
|
|
inst->tmpUserId = getUserIdFromName(handle, username);
|
|
- shellmatta_write(handle, "\r\nenter password:\r\n", 19);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("\r\nenter password:\r\n", 19);
|
|
inst->loginState = SHELLMATTA_AUTH_PASSWORD;
|
|
inst->loginState = SHELLMATTA_AUTH_PASSWORD;
|
|
ret = SHELLMATTA_CONTINUE;
|
|
ret = SHELLMATTA_CONTINUE;
|
|
}
|
|
}
|
|
else if (NULL != password)
|
|
else if (NULL != password)
|
|
{
|
|
{
|
|
- shellmatta_write(handle, "Missing username\r\n", 18);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("Missing username\r\n", 18);
|
|
ret = SHELLMATTA_USE_FAULT;
|
|
ret = SHELLMATTA_USE_FAULT;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -234,7 +234,7 @@ static shellmatta_retCode_t loginCmdFct(const shellmatta_handle_t handle, const
|
|
/** -# no credentials are passed with the command - start the interactive input */
|
|
/** -# no credentials are passed with the command - start the interactive input */
|
|
inst->inputCount = 0u;
|
|
inst->inputCount = 0u;
|
|
inst->cursor = 0u;
|
|
inst->cursor = 0u;
|
|
- shellmatta_write(handle, "enter username:\r\n", 17);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("enter username:\r\n", 17);
|
|
inst->loginState = SHELLMATTA_AUTH_USERNAME;
|
|
inst->loginState = SHELLMATTA_AUTH_USERNAME;
|
|
ret = SHELLMATTA_CONTINUE;
|
|
ret = SHELLMATTA_CONTINUE;
|
|
}
|
|
}
|
|
@@ -253,7 +253,7 @@ static shellmatta_retCode_t loginCmdFct(const shellmatta_handle_t handle, const
|
|
inst->inputCount = 0u;
|
|
inst->inputCount = 0u;
|
|
inst->cursor = 0u;
|
|
inst->cursor = 0u;
|
|
|
|
|
|
- shellmatta_write(handle, "\r\nenter password:\r\n", 19);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("\r\nenter password:\r\n", 19);
|
|
inst->loginState = SHELLMATTA_AUTH_PASSWORD;
|
|
inst->loginState = SHELLMATTA_AUTH_PASSWORD;
|
|
}
|
|
}
|
|
ret = SHELLMATTA_CONTINUE;
|
|
ret = SHELLMATTA_CONTINUE;
|
|
@@ -266,7 +266,7 @@ static shellmatta_retCode_t loginCmdFct(const shellmatta_handle_t handle, const
|
|
{
|
|
{
|
|
/** -# check input username and password */
|
|
/** -# check input username and password */
|
|
inst->buffer[inst->inputCount] = '\0';
|
|
inst->buffer[inst->inputCount] = '\0';
|
|
- shellmatta_write(handle, "\r\n", 2);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("\r\n", 2);
|
|
checkPassword(handle, inst->tmpUserId, inst->buffer);
|
|
checkPassword(handle, inst->tmpUserId, inst->buffer);
|
|
inst->loginState = SHELLMATTA_AUTH_IDLE;
|
|
inst->loginState = SHELLMATTA_AUTH_IDLE;
|
|
}
|
|
}
|
|
@@ -311,7 +311,7 @@ static shellmatta_retCode_t logoutCmdFct(const shellmatta_handle_t handle, const
|
|
}
|
|
}
|
|
|
|
|
|
shellmatta_auth_logout(handle);
|
|
shellmatta_auth_logout(handle);
|
|
- shellmatta_write(handle, "good bye\r\n", 10);
|
|
|
|
|
|
+ SHELLMATTA_WRITE("good bye\r\n", 10);
|
|
|
|
|
|
(void)arguments;
|
|
(void)arguments;
|
|
(void)length;
|
|
(void)length;
|