void DebuggerServlet::processDisconnect(const HTTPServer::Request& request) { tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); Data replyData; if (!request.data.at("content").hasKey("session")) { replyData.compound["status"] = Data("failure", Data::VERBATIM); replyData.compound["reason"] = Data("No session given", Data::VERBATIM); returnData(request, replyData); } std::string sessionId = request.data.at("content").at("session").atom; if (_sessionForId.find(sessionId) == _sessionForId.end()) { replyData.compound["status"] = Data("failure", Data::VERBATIM); replyData.compound["reason"] = Data("No such session", Data::VERBATIM); } else { replyData.compound["status"] = Data("success", Data::VERBATIM); detachSession(_sessionForId[sessionId]->getInterpreter()); _sessionForId[sessionId]->debugStop(request.data["content"]); _clientConns.erase(_sessionForId[sessionId]); _sendQueues.erase(_sessionForId[sessionId]); _sessionForId.erase(sessionId); } returnData(request, replyData); }
CUltrasonicData CUltraROSStub::readData(int index) { /* cir_msgs::UltraService service; service.request.command = COMMAND_ULTRA_READ_DATA; if(_ultraClient.call(service)) { //ROS_INFO("[CUltraROSStub] COMMAND_ULTRA_READ_DATA success"); unsigned short tempData[12] = { service.response.msg.param.at(0), service.response.msg.param.at(1), service.response.msg.param.at(2), service.response.msg.param.at(3), service.response.msg.param.at(4), service.response.msg.param.at(5), service.response.msg.param.at(6), service.response.msg.param.at(7), service.response.msg.param.at(8), service.response.msg.param.at(9), service.response.msg.param.at(10), service.response.msg.param.at(11), }; //return RETURN_SUCCESS; CUltrasonicData returnData(0, 0, tempData); return returnData; } else { //ROS_ERROR("[CUltraROSStub] COMMAND_ULTRA_READ_DATA fail"); //return RETURN_FAIL; CUltrasonicData garbage; return garbage; } */ CUltrasonicData returnData(0, 0, tempData); return returnData; }
std::vector<char> Convert::getVectorForChar(v8::Local<v8::Value> js) { std::string content = Convert::getNativeString(js); std::vector<char> returnData(content.begin(), content.end()); return returnData; }
CBatteryData CBatteryROSStub::readData( int index ) { unsigned int tempData[2] = {_current_voltage,0}; CBatteryData returnData( 0, 0, tempData ); return returnData; }
api::DirectionData DirectionReader::getDirectionData() { myOutDirectionData = initializeData(); updateTimeForOffset(); parsePlacement(); parseValues(); // need to make sure all the MarkData item times match the DirectionData time fixTimes(); return returnData(); }
void DebuggerServlet::serverPushData(boost::shared_ptr<DebugSession> session) { if (_sendQueues[session].isEmpty()) return; if (!_clientConns[session]) return; Data reply = _sendQueues[session].pop(); std::cout << "pushing " << reply["replyType"].atom << std::endl; returnData(_clientConns[session], reply); _clientConns[session] = HTTPServer::Request(); }
// someone connected, create a new session void DebuggerServlet::processConnect(const HTTPServer::Request& request) { tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); std::string sessionId = UUID::getUUID(); _sessionForId[sessionId] = boost::shared_ptr<DebugSession>(new DebugSession()); _sessionForId[sessionId]->setDebugger(this); Data replyData; replyData.compound["session"] = Data(sessionId, Data::VERBATIM); replyData.compound["status"] = Data("success", Data::VERBATIM); returnData(request, replyData); }
static CMPIStatus __rft_returnData(const CMPIResult * result, const CMPIValue * val, CMPIType type) { // NativeResult *r = (NativeResult*) result; if (type==CMPI_ref) { mlogf(M_ERROR,M_SHOW,"--- CMPIResult does not yet support returning references\n"); abort(); } return returnData(result,val,type); }
// seteando a "true" el parámetro adicional (isReg) se transforma en un reg write int AX12::writeData (byte start, byte length, byte* values, bool isReg) { byte data [length+1]; data [0] = start; memcpy (&data[1], values, length); if (isReg) { sendPacket (id, length+1, REG_WRITE, data); } else { sendPacket (id, length+1, WRITE_DATA, data); } int error = returnData (RETURN_ALL).error; if (start < 23) delay (5); // Wait 5 seconds if writing to eprom // (las operaciones en la EEPROM no suelen ser real-time) return error; }
// seteando a "true" el parámetro adicional (isReg) se transforma en un reg write int AX12::writeData (byte start, byte length, byte* values, bool isReg) { byte data [length+1]; data [0] = start; memcpy (&data[1], values, length); if (isReg) { sendPacket (id, length+1, REG_WRITE, data); } else { sendPacket (id, length+1, WRITE_DATA, data); } int error = returnData (RETURN_ALL).error; if (start < 23) {delayMicroseconds (5000);} // si la operación de escritura es en la EEPROM, este delay previene el embotellamiento // (las operaciones en la EEPROM no suelen ser real-time) return error; }
void getData(int & cli){ int proxCli; if ((proxCli = socket(AF_INET, SOCK_STREAM, 0)) == -1){ perror("proxyCli socket: "); close(proxCli); exit(-1); } //Convert domain name to ip address struct hostent * ip; if((ip = gethostbyname(request.host.c_str())) == NULL){ perror("gethostbyname"); exit(-1); }; struct in_addr **addr_list = (struct in_addr **)ip->h_addr_list; std::string str = inet_ntoa(*addr_list[0]); printf("The ip address is %s ", str.c_str()); //Fill struct struct sockaddr_in servAddr; servAddr.sin_family = AF_INET; servAddr.sin_port = htons(request.port); inet_aton(str.c_str(),&servAddr.sin_addr); //Connect if((connect(proxCli, (struct sockaddr *) & servAddr, sizeof(servAddr))) != 0){ perror("connect"); close(proxCli); exit(-1); } //Send if(send(proxCli, &request.buffer, std::strlen(request.buffer), 0) == -1){ perror("send request"); exit(-1); } //Get Response char response[RESPONSESIZE]; while(recv(proxCli,response,RESPONSESIZE,0) > 0){ returnData(response, cli); } close(proxCli); delete[] ip; }
static CMPIStatus __rft_returnObjectPath(const CMPIResult * result, const CMPIObjectPath * cop) { int size; void *ptr; NativeResult *r = (NativeResult*) result; if (r->legacy) { CMPIValue v; v.ref = (CMPIObjectPath*)cop; return returnData(result, &v, CMPI_ref); } size=getObjectPathSerializedSize(cop); ptr=nextResultBufferPos(r, MSG_SEG_OBJECTPATH, size); getSerializedObjectPath(cop,ptr); CMReturn(CMPI_RC_OK); }
void AuthenticationMgr::parserSid(const QByteArray &aData) { LOG_METHOD; QString returnData(aData); QStringList strList = returnData.split("\n"); QString strItor; QStringList tempList; foreach(strItor, strList) { tempList.clear(); tempList = strItor.split("=", QString::SkipEmptyParts); if(!tempList.isEmpty()) { mParaMap.insert(tempList.first(), tempList.last()); } }
void // virtual KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) { pExp = exp; if (echo) exp = 0; else if (!authTok) exp = 1; else { QString pr( prompt ); if (pr.find( QRegExp( "\\bpassword\\b", false ) ) >= 0) { if (pr.find( QRegExp( "\\b(re-?(enter|type)|again|confirm|repeat)\\b", false ) ) >= 0) exp = 3; else if (pr.find( QRegExp( "\\bnew\\b", false ) ) >= 0) exp = 2; else { // QRegExp( "\\b(old|current)\\b", false ) is too strict handler->gplugReturnText( "", KGreeterPluginHandler::IsOldPassword | KGreeterPluginHandler::IsSecret ); return; } } else { handler->gplugMsgBox( QMessageBox::Critical, i18n("Unrecognized prompt \"%1\"") .arg( prompt ) ); handler->gplugReturnText( 0, 0 ); exp = -1; return; } } if (pExp >= 0 && pExp >= exp) { revive(); has = -1; } if (has >= exp || nonBlocking) returnData(); }
void DebuggerServlet::processListSessions(const HTTPServer::Request& request) { Data replyData; std::map<std::string, boost::weak_ptr<InterpreterImpl> > instances = Interpreter::getInstances(); for (std::map<std::string, boost::weak_ptr<InterpreterImpl> >::iterator instIter = instances.begin(); instIter != instances.end(); instIter++) { boost::shared_ptr<InterpreterImpl> instance = instIter->second.lock(); if (instance) { Data sessionData; sessionData.compound["name"] = Data(instance->getName(), Data::VERBATIM); sessionData.compound["id"] = Data(instance->getSessionId(), Data::VERBATIM); sessionData.compound["source"] = Data(instance->getSourceURI().asString(), Data::VERBATIM); sessionData.compound["xml"].node = instance->getDocument(); replyData.compound["sessions"].array.push_back(sessionData); } } replyData.compound["status"] = Data("success", Data::VERBATIM); returnData(request, replyData); }
void // virtual KClassicGreeter::next() { // assert( running ); if (loginEdit && loginEdit->hasFocus()) { passwdEdit->setFocus(); // will cancel running login if necessary has = 0; } else if (passwdEdit && passwdEdit->hasFocus()) { if (passwd1Edit) passwd1Edit->setFocus(); has = 1; } else if (passwd1Edit) { if (passwd1Edit->hasFocus()) { passwd2Edit->setFocus(); has = 1; // sic! } else has = 3; } else has = 1; if (exp < 0) handler->gplugStart(); else if (has >= exp) returnData(); }
void Test::startTest() { redis = new QtRedis("localhost",6379); connect(redis, SIGNAL(returnData(QtRedis::Reply)), this, SLOT(slotMessage(QtRedis::Reply))); QtRedis::Reply reply; if (!redis->openConnection()) { qDebug() << "Could not connect to server..."; exit(0); } qDebug() << "Connected to server..."; //qDebug() << "AUTH:" << redis->auth("redisZzZ"); // Set and Get example qDebug() << "SET:" << redis->set("key", "\"Hello World\""); qDebug() << "GET:" << redis->get("key"); // Append to Key example qDebug() << "SET:" << redis->set("key", "\"Hello\""); qDebug() << "EXISTS:" << redis->exists("key"); qDebug() << "GET:" << redis->get("key"); qDebug() << "APPEND:" << redis->append("key", "\" World\""); qDebug() << "GET:" << redis->get("key"); // Multi Set and Get example QMap<QString,QVariant> keypairs; keypairs["key1"] = QString("\"Hello\""); keypairs["key2"] = QString("\" world\""); qDebug() << "MSET:" << redis->mset(keypairs); qDebug() << "MGET:" << redis->mget("key1 key2 nonexisting"); // Incr, incrby decr, decrby example. qDebug() << "SET:" << redis->set("count", "10"); qDebug() << "INCR:" << redis->incr("count"); qDebug() << "GET:" << redis->get("count"); qDebug() << "INCRBY:" << redis->incrby("count",5); qDebug() << "GET:" << redis->get("count"); qDebug() << "DECR:" << redis->decr("count"); qDebug() << "GET:" << redis->get("count"); qDebug() << "DECRBY:" << redis->decrby("count",5); qDebug() << "GET:" << redis->get("count"); // SET and GET Range examples qDebug() << "SETRANGE:" << redis->setrange("key",6 ,"Redis"); qDebug() << "GET:" << redis->get("key"); qDebug() << "GETRANGE:" << redis->getrange("key",-5 ,-1); qDebug() << "GETRANGE:" << redis->getrange("key",0 ,4); qDebug() << "GETRANGE:" << redis->getrange("key",0 ,-1); //Hashmap example qDebug() << "HSET:" << redis->hset("hashmap","key1" ,"value1"); qDebug() << "HSET:" << redis->hset("hashmap","key2" ,"value2"); qDebug() << "HSET:" << redis->hset("hashmap","key3" ,"value3"); qDebug() << "HGETALL:"; QMap<QString,QVariant> hashmap = redis->hgetall("hashmap"); QMapIterator<QString, QVariant> mi(hashmap); while (mi.hasNext()) { mi.next(); qDebug() << mi.key() << "=" << mi.value().toString(); } qDebug() << "HVALS:" << redis->hvals("hashmap"); // Raw Command example reply = redis->command("GET key"); qDebug() << "RAW:" << "("<< reply.type << ")" << reply.value.toString(); redis->subscribe("notifications"); redis->psubscribe("news.*"); //reply = redis->command("SUBSCRIBE notifications"); //qDebug() << "("<< reply.type << ")" << reply.value.toStringList(); }
CTouchButtonData CTouchButtonROSStub::readData( int index ) { CTouchButtonData returnData(0, 0, data); return returnData; }
/** ping */ int AX12::ping () { byte* data; sendPacket (id, 0, AX_PING, data); return returnData (RETURN_NONE).error; }
// SLOT function to get data at specified address void memory::getDataAtAddr(word addr) { emit returnData(dataMem[addr]); }
/** reset */ int AX12::reset () { byte* data; sendPacket (id, 0, RESET, data); return returnData (RETURN_ALL).error; }
/** action */ int AX12::action () { byte *data; sendPacket (id, 0, ACTION, data); return returnData (RETURN_ALL).error; }
/** read data */ AX12data AX12::readData (byte start, byte length) { byte data [2]; data [0] = start; data [1] = length; sendPacket (id, 2, READ_DATA, data); return returnData (RETURN_READ); }
bool DebuggerServlet::httpRecvRequest(const HTTPServer::Request& request) { if (!request.data.hasKey("path")) return false; // returnError(request); if (isCORS(request)) { handleCORS(request); return true; } std::cout << request.data["path"] << ": " << request.data["content"] << std::endl; Data replyData; // process request that don't need a session if (false) { } else if (boost::starts_with(request.data.at("path").atom, "/debug/connect")) { processConnect(request); return true; } else if (boost::starts_with(request.data.at("path").atom, "/debug/sessions")) { processListSessions(request); return true; } // get session or return error if (false) { } else if (!request.data.at("content").hasKey("session")) { replyData.compound["status"] = Data("failure", Data::VERBATIM); replyData.compound["reason"] = Data("No session given", Data::VERBATIM); } else if (_sessionForId.find(request.data.at("content").at("session").atom) == _sessionForId.end()) { replyData.compound["status"] = Data("failure", Data::VERBATIM); replyData.compound["reason"] = Data("No such session", Data::VERBATIM); } if (replyData) { returnData(request, replyData); return true; } boost::shared_ptr<DebugSession> session = _sessionForId[request.data.at("content").at("session").atom]; if (false) { } else if (boost::starts_with(request.data.at("path").atom, "/debug/poll")) { // save long-standing client poll _clientConns[session] = request; serverPushData(session); } else if (boost::starts_with(request.data.at("path").atom, "/debug/disconnect")) { processDisconnect(request); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/enable/all")) { replyData = session->enableAllBreakPoints(); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/disable/all")) { replyData = session->disableAllBreakPoints(); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/skipto")) { replyData = session->skipToBreakPoint(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/add")) { replyData = session->addBreakPoint(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/remove")) { replyData = session->removeBreakPoint(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/enable")) { replyData = session->enableBreakPoint(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/disable")) { replyData = session->disableBreakPoint(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/stop")) { replyData = session->debugStop(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/prepare")) { replyData = session->debugPrepare(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/attach")) { replyData = session->debugAttach(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/start")) { replyData = session->debugStart(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/step")) { replyData = session->debugStep(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/pause")) { replyData = session->debugPause(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/resume")) { replyData = session->debugResume(request.data["content"]); } else if (boost::starts_with(request.data.at("path").atom, "/debug/eval")) { replyData = session->debugEval(request.data["content"]); } if (replyData) { returnData(request, replyData); return true; } return true; }
static CMPIStatus __rft_returnInstance(const CMPIResult * result, const CMPIInstance * instance) { int size,isInst=isInstance(instance); void *ptr; NativeResult *r = (NativeResult*) result; int releaseInstance=0; CMPIStatus st={CMPI_RC_OK,NULL}; _SFCB_ENTER(TRACE_PROVIDERDRV, "__rft_returnInstance"); if (r->qs) { int irc; if (r->qs->where) { r->qs->propSrc.data=(CMPIInstance *)instance; irc=r->qs->where->ft->evaluate(r->qs->where,&r->qs->propSrc); if (irc==1) { if (r->qs->allProps==0) { instance= r->qs->ft->cloneAndFilter(r->qs,(CMPIInstance *)instance,CMGetObjectPath(instance, NULL),r->qs->keys); releaseInstance=1; } } else CMReturn(CMPI_RC_OK); } else { if (r->qs->allProps==0) { instance=r->qs->ft->cloneAndFilter(r->qs,(CMPIInstance *)instance,CMGetObjectPath(instance,NULL), r->qs->keys); releaseInstance=1; } } } if (r->legacy) { CMPIValue v; CMPIStatus rc; _SFCB_TRACE(1,("--- Legacy Mode")); if(isInst) { v.inst = CMClone(instance,NULL); memLinkInstance(v.inst); } else v.inst = (CMPIInstance *) instance; rc=returnData(result, &v, CMPI_instance); if (releaseInstance) instance->ft->release((CMPIInstance*)instance); _SFCB_RETURN(rc); } if (isInst) { size=getInstanceSerializedSize(instance); ptr=nextResultBufferPos(r, MSG_SEG_INSTANCE, (unsigned long)size); _SFCB_TRACE(1,("--- Moving instance %d",size)); getSerializedInstance(instance,ptr); /* memcpy inst to ptr */ } else { size=getConstClassSerializedSize((CMPIConstClass*)instance); ptr=nextResultBufferPos(r, MSG_SEG_CONSTCLASS, (unsigned long)size); _SFCB_TRACE(1,("--- Moving class %d",size)); getSerializedConstClass((CMPIConstClass*)instance,ptr); } if (releaseInstance) instance->ft->release((CMPIInstance*)instance); _SFCB_RETURN(st); }