void processCommand(std::vector< std::string > &args) { /* printf("PROCESS: "); for(int i = 0; i < args.size(); i ++) { printf("[%s] ", args[i].c_str()); } printf("\n");*/ if(args.empty()) { *mAction = BNBActions::ERASE; } else if(args[0] == "forward") { *mAction = BNBActions::FORWARD | BNBActions::ERASE; eraseCommand(); } else if(args[0] == "drop") { *mAction = BNBActions::DROP | BNBActions::ERASE; eraseCommand(); } else if(args[0] == "var") { BNB_ASSERT(args.size() == 2); processVar(args[1]); } else if(args[0] == "set") { BNB_ASSERT(args.size() == 3); processAssign(args[1], args[2]); } else if(args[0] == "inc") { BNB_ASSERT(args.size() == 3); processInc(args[1], args[2]); } else if(args[0] == "cat") { BNB_ASSERT(args.size() == 3); processCat(args[1], args[2]); } else if(args[0] == "wait") { BNB_ASSERT(args.size() == 4); processWait(args[1], args[2], args[3]); } else if(args[0] == "echo") { processEcho(args); } else if(args[0] == "erase") { *mAction = BNBActions::ERASE; eraseCommand(); } else if(args[0] == "save") { processSave(args[1], args[2]); } else if(args[0] == "append") { processAppend(args[1], args[2]); } else if(args[0] == "load") { processLoad(args[1], args[2]); } else if(args[0] == "mkdir") { processMkdir(args[1]); } else if(args[0] == "skip") { eraseCommand(); } else if(args[0] == "exec") { processExec(args[1]); } else if(args[0] == "exit") { *mAction = BNBActions::EXIT; eraseCommand(); } else { printf("%s\n", args[0].c_str()); BNB_ERROR_REPORT("Unrecognized command"); } }
int SSIEngine::executeComponent(HttpSession *pSession, SSIComponent *pComponent) { AutoBuf *pBuf; int ret; LS_DBG_H(pSession->getLogSession(), "SSI Process component: %d", pComponent->getType()); switch (pComponent->getType()) { case SSIComponent::SSI_String: pBuf = pComponent->getContentBuf(); pSession->appendDynBody(pBuf->begin(), pBuf->size()); break; case SSIComponent::SSI_Config: updateSSIConfig(pSession, pComponent, pSession->getReq()->getSSIRuntime()); break; case SSIComponent::SSI_Echo: processEcho(pSession, pComponent); break; case SSIComponent::SSI_Exec: ret = processExec(pSession, pComponent); return ret; break; case SSIComponent::SSI_FSize: case SSIComponent::SSI_Flastmod: processFileAttr(pSession, pComponent); break; case SSIComponent::SSI_Include: ret = processInclude(pSession, pComponent); return ret; break; case SSIComponent::SSI_Printenv: processPrintEnv(pSession); break; case SSIComponent::SSI_Set: processSet(pSession, pComponent); break; case SSIComponent::SSI_If: case SSIComponent::SSI_Elif: processIf(pSession, (SSI_If *)pComponent); break; //SSI_Else, //SSI_Elif, //SSI_Endif, } return 0; }