增加ExplorerSystem的命令交互功能

This commit is contained in:
chenxinquan 2022-11-17 17:52:59 +08:00
parent f03e600f2d
commit 0378cb1495
1 changed files with 46 additions and 0 deletions

View File

@ -37,6 +37,13 @@ import (
//
// go 有点拉
sandbox "main/genmai/Sandbox"
// TODO:
// 应该写成相对路径因为genmai应该是编译成库所以包路径不
// 是以main开头。
//
// go 有点拉
inter "main/genmai/Interpreter"
)
type ExplorerConfigSystem struct {
@ -95,6 +102,45 @@ func (ek *ExplorerSystem)startWithPath(execpath string, args ...string) error {
return rc
} // if (nil != ...
for _, itr := range config.SiteRequests.Implement.Inter {
icmd := itr[ : inter.INTERPRETER_CMD_LEN]
icmd_len := len(icmd)
switch (icmd) {
case inter.INTERPRETER_CMD_SEND:
interio.Send(itr[ icmd_len : ] + "\n")
case inter.INTERPRETER_CMD_RECV:
// TODO
//out, rc_t := interio.Recv( icmd_len )
interio.Recv( len(itr[ icmd_len :]) )
case inter.INTERPRETER_CMD_RECVUNTIL:
interio.RecvUntil( itr[ icmd_len : ] )
//case ">.":
// A_DEBUG_INFO(">.")
//
//case "<?":
// A_DEBUG_INFO("<?")
//
case inter.INTERPRETER_CMD_RECV_POC_CHECK:
ou, _ := interio.Recv( len (itr[icmd_len : ]) )
/* */
if ( ou == itr[ icmd_len : ] ) {
A_DEBUG_INFO("startWithPath():",
"\"" + inter.INTERPRETER_CMD_RECV_POC_CHECK + "\":",
"Check poc successfully!")
/* */
return RC_POC_CHECK_SUCCESSFULLY
} else {
A_DEBUG_INFO("startWithPath():\"<?\":Check poc failed!")
/* */
return RC_POC_CHECK_FAILED
}
} // switch (inter ...
} // for _ , itr
return rc
}