492 unsigned int shiftLen, execLen, newLen;
493 unsigned int removeLen = strlen(
"./");
496 char *execCmd = CMD_EXEC_COMMAND;
497 const char *cmdBuf = input;
498 unsigned int cmdBufLen = strlen(cmdBuf);
499 char *shiftStr = (
char *)
malloc(cmdBufLen + 1);
502 if (shiftStr == NULL) {
503 printf(
"malloc failure in %s[%d]\n", __FUNCTION__, __LINE__);
506 (
void)memset_s(shiftStr, cmdBufLen + 1, 0, cmdBufLen + 1);
510 shiftLen = strlen(shiftStr);
511 if ((ret != SH_OK) || (shiftLen == 0)) {
513 goto END_FREE_SHIFTSTR;
516 *outputlen = shiftLen;
519 if ((shiftLen > removeLen) && (shiftStr[0] ==
'.') && (shiftStr[1] ==
'/')) {
520 execLen = strlen(execCmd);
521 newLen = execLen + shiftLen - removeLen;
522 newCmd = (
char *)
malloc(newLen + 1);
523 if (newCmd == NULL) {
525 printf(
"malloc failure in %s[%d]\n", __FUNCTION__, __LINE__);
526 goto END_FREE_SHIFTSTR;
529 err = memcpy_s(newCmd, newLen, execCmd, execLen);
531 printf(
"memcpy_s failure in %s[%d]\n", __FUNCTION__, __LINE__);
533 goto END_FREE_NEWCMD;
536 err = memcpy_s(newCmd + execLen, newLen - execLen, shiftStr + removeLen, shiftLen - removeLen);
538 printf(
"memcpy_s failure in %s[%d]\n", __FUNCTION__, __LINE__);
540 goto END_FREE_NEWCMD;
542 newCmd[newLen] =
'\0';
547 goto END_FREE_SHIFTSTR;
unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)