/// parses the command string void parse(teasafe::TeaSafe &theBfs, std::string const &commandStr, std::string &workingDir) { std::vector<std::string> comTokens; boost::algorithm::split_regex(comTokens, commandStr, boost::regex("\\s+")); if (comTokens[0] == "ls") { if (comTokens.size() > 1) { com_ls(theBfs, formattedPath(workingDir, comTokens[1])); } com_ls(theBfs, workingDir); } else if (comTokens[0] == "pwd") { std::cout<<workingDir<<std::endl; } else if (comTokens[0] == "rm") { if (comTokens.size() < 2) { std::cout<<"Error: please specify /path"<<std::endl; } else { com_rm(theBfs, formattedPath(workingDir, comTokens[1])); } } else if (comTokens[0] == "mkdir") { if (comTokens.size() < 2) { std::cout<<"Error: please specify /path"<<std::endl; } else { com_mkdir(theBfs, formattedPath(workingDir, comTokens[1])); } } else if (comTokens[0] == "add") { if (comTokens.size() < 2) { std::cout<<"Error: please specify file:///path"<<std::endl; } else { com_add(theBfs, workingDir, comTokens[1]); } } else if (comTokens[0] == "push") { if (comTokens.size() < 2) { std::cout<<"Error: please specify /path"<<std::endl; } else { com_push(theBfs, workingDir, comTokens[1]); } } else if (comTokens[0] == "pop") { com_pop(theBfs, workingDir); } else if (comTokens[0] == "cd") { if (comTokens.size() < 2) { std::cout<<"Error: please specify path"<<std::endl; } else { com_cd(theBfs, workingDir, formattedPath(workingDir, comTokens[1])); } } else if (comTokens[0] == "extract") { if (comTokens.size() < 3) { std::cout<<"Error: please specify /src/path and file:///dst/parent/path/"<<std::endl; } else { com_extract(theBfs, formattedPath(workingDir, comTokens[1]), comTokens[2]); } } else if (comTokens[0] == "help") { com_help(); } else if (comTokens[0] == "quit") { exit(0); } else if (comTokens[0] == "exit") { exit(0); } }
/** **************************************************************************************** * @brief EACI send PDU * **************************************************************************************** */ void com_pdu_send(uint8_t len, uint8_t *par) { // Allocate one msg for EACI tx uint8_t *msg_param = (uint8_t*)ke_msg_alloc(0, 0, 0, len); // Save the PDU in the MSG memcpy(msg_param, par, len); //extract the ke_msg pointer from the param passed and push it in HCI queue com_push(ke_param2msg(msg_param)); }