void Role::makeConnection() { connect(logic->getClient(),SIGNAL(getMessage(QString)),this,SLOT(decipher(QString))); connect(this,SIGNAL(sendCommand(QString)),logic->getClient(),SLOT(sendMessage(QString))); connect(decisionArea,SIGNAL(okClicked()),this,SLOT(onOkClicked())); connect(decisionArea,SIGNAL(cancelClicked()),this,SLOT(onCancelClicked())); connect(decisionArea,SIGNAL(exchangeClicked()),this,SLOT(exchangeCards())); connect(decisionArea,SIGNAL(resignClicked()),this,SLOT(resign())); connect(buttonArea->getButtons().at(0),SIGNAL(buttonSelected(int)),this,SLOT(buy())); connect(buttonArea->getButtons().at(1),SIGNAL(buttonSelected(int)),this,SLOT(synthetize())); connect(buttonArea->getButtons().at(2),SIGNAL(buttonSelected(int)),this,SLOT(extract())); connect(buttonArea,SIGNAL(buttonUnselected()),this,SLOT(onCancelClicked())); connect(handArea,SIGNAL(cardReady()),this,SLOT(cardAnalyse())); connect(coverArea,SIGNAL(cardReady()),this,SLOT(coverCardAnalyse())); connect(playerArea,SIGNAL(playerReady()),this,SLOT(playerAnalyse())); }
int initializeInventoryVector(InventoryVector * self, InventoryVectorType type, ByteArray * hash, void (*onErrorReceived)(Error error,char *,...)) { assert(self != NULL); assert(hash != NULL); assert(type != NULL); assert(onErrorReceived != NULL); self->type = type; self->hash = hash; incrementReferenceCount(hash); if (!initializeMessageFromObject(getMessage(self), onErrorReceived)) { return FALSE; } return TRUE; }
void processEvents() { Message mes; while (queue.count > 0) { getMessage(&mes); if (mes.rcvr_t == O_SERVER) handleServerEvent(&mes); else if (mes.rcvr_t == O_GAME) handleGameEvent(mes.rcvr.game, &mes); else if (mes.rcvr_t == O_PLAYER) handlePlayerEvent(mes.rcvr.player, &mes); } }
QVariant QProtobufModel::data(const QModelIndex &_index, int _role) const { switch(_role) { case Qt::EditRole: case Qt::DisplayRole: { PBMessage* msg = getMessage(_index); } } return QVariant(); }
void AddFriendForm::handleDnsLookup() { const QString idKeyWord("id="); if (dns.error() == QDnsLookup::NotFoundError) { showWarning(tr("This address does not exist","The DNS gives the Tox ID associated to toxme.se addresses")); return; } else if (dns.error() != QDnsLookup::NoError) { showWarning(tr("Error while looking up DNS","The DNS gives the Tox ID associated to toxme.se addresses")); return; } const QList<QDnsTextRecord> textRecords = dns.textRecords(); if (textRecords.length() != 1) { showWarning(tr("Unexpected number of text records", "Error with the DNS")); return; } const QList<QByteArray> textRecordValues = textRecords.first().values(); if (textRecordValues.length() != 1) { showWarning(tr("Unexpected number of values in text record", "Error with the DNS")); return; } const QString entry(textRecordValues.first()); int idx = entry.indexOf(idKeyWord); if (idx < 0) { showWarning(tr("The DNS lookup does not contain any Tox ID", "Error with the DNS")); return; } idx += idKeyWord.length(); if (entry.length() < idx + static_cast<int>(TOX_ID_LENGTH)) { showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS")); return; } const QString friendAdress = entry.mid(idx, TOX_ID_LENGTH); if (!isToxId(friendAdress)) { showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS")); return; } // finally we got it emit friendRequested(friendAdress, getMessage()); }
void eventbus_send(String address,String replyAddress,String Headers,String Body){ jsonMessage_t js; js.address=address; js.replyAddress=replyAddress; js.type="send"; JSON_Value *body = json_parse_string(Body); JSON_Value *headers = json_parse_string(Headers); js.body=body; js.headers=headers; String message=NULL; getMessage(js,&message); send_frame(&message); free(message); }
/** * map<uint16_t, Message> AppConfig::getMessages() * * Reads the config.dbc file in the current directory and extracts a CAN spec * from it. The function will then build a map from CAN ID to a Message struct * which will encompass the entire spec. * * @returns The CAN spec in map<uint16_t, Message> form. If an error was * encountered processing any of the messages, this function will return * an empty map. */ map<uint16_t, Message> AppConfig::getMessages() { QVector< QVector<QString> > messageBlocks = readFile(); map<uint16_t, Message> messages; for (QVector<QString> messageBlock: messageBlocks) { Message msg = getMessage(messageBlock); if (msg.valid()) { messages[msg.id] = msg; } else { map<uint16_t, Message> empty; return empty; } } return messages; }
void handlePOST(TCPSocket* sock, TupleList& headers, const char* uri) { debug("POST request: %s", uri); if (isSpecialURI(uri)) { if (matchURL(uri, "/dune/messages/imc/", true)) getMessage(sock, headers, uri); else sendResponse403(sock); } else { sendResponse403(sock); } }
bool SetExceptionBreakpointsCommand::executeImpl(DebuggerSession* session, folly::dynamic* /*responseMsg*/ ) { folly::dynamic& message = getMessage(); const folly::dynamic& args = tryGetObject(message, "arguments", s_emptyArgs); const auto exceptionOptions = tryGetObject(args, "exceptionOptions", s_emptyArgs); auto breakMode = tryGetString(exceptionOptions, "breakMode", ""); // TODO: Named exception breakpoint filters not supported yet. if (breakMode == "") { const folly::dynamic& filters = args["filters"]; if (filters.isArray()) { for (auto it = filters.begin(); it != filters.end(); it++) { const folly::dynamic& filterName = *it; if (filterName.isString()) { const std::string& filterString = filterName.getString(); breakMode = filterString; break; } } } } ExceptionBreakMode mode = ExceptionBreakMode::BreakNone; if (breakMode == "" || breakMode == "never" || breakMode == "none") { mode = ExceptionBreakMode::BreakNone; } else if (breakMode == "always" || breakMode == "all") { mode = ExceptionBreakMode::BreakAll; } else if (breakMode == "unhandled" || breakMode == "uncaught") { mode = ExceptionBreakMode::BreakUnhandled; } else if (breakMode == "userUnhandled") { mode = ExceptionBreakMode::BreakUserUnhandled; } else { throw DebuggerCommandException( "Invalid exception break mode specified." ); } BreakpointManager* bpMgr = session->getBreakpointManager(); bpMgr->setExceptionBreakMode(mode); // Completion of this command does not resume the target. return false; }
void ParserBase::onUse(const std::string &ns, const std::string &as) { if (m_aliases.find(as) != m_aliases.end()) { error("Cannot use %s as %s because the name is already in use: %s", ns.c_str(), as.c_str(), getMessage().c_str()); return; } string key = as; if (key.empty()) { size_t pos = ns.rfind(NAMESPACE_SEP); if (pos == string::npos) { key = ns; } else { key = ns.substr(pos + 1); } } m_aliases[key] = ns; }
void Synapse::readSetPoints(float* setPointArray) { uint8_t message[messageSize]; binaryFloat data; unsigned int i=0, j, k; getMessage(message); for(j=0;j<6;j++) { if(message[i]==fingerAddress[j]) { i++; for(k=0;k<floatSize;k++) { data.binary[k] = message[i]; i++; } setPointArray[j] = data.floating; } } return; }
bool TMonitoring::startLoop() { // for debug getMessage(0, "*****@*****.**", "testtest"); QSqlQuery query; query.exec("SELECT id, account, password, startMonitor, endMonitor, status FROM accounts ORDER BY startMonitor DESC;"); //================обрабатываем каждый ящик =========================// while (query.next()) { QString id = query.value(0).toString(); QString username = query.value(1).toString(); QString password = query.value(2).toString(); QDateTime startTime = query.value(3).toDateTime(); QDateTime endTime = query.value(4).toDateTime(); bool isActive = query.value(5).toBool(); currentAccountId = id; if (isActive == false) continue; // проверка расписания unsigned long sleepValue = checkSchedule(startTime, endTime); if (sleepValue == NO_START_MONITORING) continue; else { qDebug() << "Sleeping staus.Monitoring is in waiting mode............................" ; sleep(sleepValue); qDebug() << "Monitoring is started............................" ; startMonitoring(id, username, password); qDebug() << "Monitoring is ended..............................." ; continue; } } return true; }
// Object Constructor XmippError::XmippError(const ErrorType nerr, const String &what, const String &fileArg, const long lineArg) { __errno = nerr; msg = colorString(what.c_str(), RED); file = fileArg; line = lineArg; char* path = getenv("XMIPP_DEBUG"); if (path != NULL) std::cout << "XMIPP_DEBUG: " << getMessage() << std::endl; //Store information about the stack calls //#ifdef LINUX // void *array[10]; // size = backtrace(array, 10); // strings = backtrace_symbols(array, size); //#endif }
void DatabasePluginTests::testPut() { auto s = getPlugin()->put(kQueries, "test_put", "bar"); EXPECT_TRUE(s.ok()); EXPECT_EQ(s.getMessage(), "OK"); s = setDatabaseValue(kQueries, "test_put", ""); EXPECT_TRUE(s.ok()); PluginRequest req = {{"action", "put"}, {"domain", kQueries}, {"key", "test_put"}, {"value", "bar"}}; s = Registry::call("database", getName(), req); EXPECT_TRUE(s.ok()); auto reset = std::async(std::launch::async, kTestReseter); reset.get(); }
/*----------------------------------------------------------------------*/ int main(int argc, char *argv[]) { char *keyword, *message; if (argc == 2 && argIsValid(argv[1])) { keyword = argv[1]; message = getMessage(); printCipher(message, keyword); free(message); return 0; } else { printf("Usage: %s <keyword>\n", argv[0]); return 1; } }
void ParserBase::addLabel(const std::string &label, LocationPtr loc, ScannerToken *stmt) { assert(!m_labelInfos.empty()); LabelInfo &info = m_labelInfos.back(); if (info.labels.find(label) != info.labels.end()) { error("Label '%s' already defined: %s", label.c_str(), getMessage().c_str()); invalidateLabel(extractStatement(stmt)); return; } assert(!info.scopes.empty()); LabelStmtInfo labelInfo; labelInfo.scopeId = info.scopes.back(); labelInfo.stmt = extractStatement(stmt); labelInfo.loc = loc; info.labels[label] = labelInfo; }
Status EventFactory::run(EventPublisherID& type_id) { if (FLAGS_disable_events) { return Status(0, "Events disabled"); } // An interesting take on an event dispatched entrypoint. // There is little introspection into the event type. // Assume it can either make use of an entrypoint poller/selector or // take care of async callback registrations in setUp/configure/run // only once and handle event queuing/firing in callbacks. EventPublisherRef publisher = nullptr; { auto& ef = EventFactory::getInstance(); auto read_lock = ef.requestRead(); publisher = ef.getEventPublisher(type_id); } if (publisher == nullptr) { return Status(1, "Event publisher is missing"); } else if (publisher->hasStarted()) { return Status(1, "Cannot restart an event publisher"); } VLOG(1) << "Starting event publisher run loop: " + type_id; publisher->hasStarted(true); auto status = Status(0, "OK"); while (!publisher->isEnding() && status.ok()) { // Can optionally implement a global cooloff latency here. status = publisher->run(); publisher->restart_count_++; osquery::publisherSleep(EVENTS_COOLOFF); } // The runloop status is not reflective of the event type's. VLOG(1) << "Event publisher " << publisher->type() << " run loop terminated for reason: " << status.getMessage(); // Publishers auto tear down when their run loop stops. publisher->tearDown(); // Do not remove the publisher from the event factory. // If the event factory's `end` method was called these publishers will be // cleaned up after their thread context is removed; otherwise, a removed // thread context and failed publisher will remain available for stats. return Status(0, "OK"); }
uint32_t serializeBlockHeaders(BlockHeaders * self){ assert(self != NULL); ByteArray * bytes = getMessage(self)->bytes; if (! bytes) { getMessage(self)->onErrorReceived(ERROR_MESSAGE_SERIALISATION_NULL_BYTES,"Attempting to serialize a BlockHeaders with no bytes."); return 0; } if (bytes->length < 81 * self->numOfHeaders) { getMessage(self)->onErrorReceived(ERROR_MESSAGE_DESERIALISATION_BAD_BYTES,"Attempting to deserialize a BlockHeaders with less bytes than minimally required."); return 0; } VarLenInt num = createVarLenIntFromUInt64(self->numOfHeaders); encodeVarLenInt(bytes, 0, num); uint16_t cursor = num.storageSize; uint16_t x; for ( x = 0; x < num.value; x++) { getMessage(self->blockHeaders[x])->bytes = getByteArraySubsectionReference(bytes, cursor, bytes->length-cursor); if (! getMessage(self->blockHeaders[x])->bytes) { getMessage(self)->onErrorReceived(ERROR_INIT_FAIL,"Cannot create a new ByteArray sub reference in serializeBlockHeaders for the header number %u",x); return 0; } uint32_t len = serializeBlock(self->blockHeaders[x],false); /* false for no transactions.*/ if (!len) { getMessage(self)->onErrorReceived(ERROR_MESSAGE_SERIALISATION_BAD_BYTES,"BlockHeaders cannot be serialized because of an error with the Block number %u.",x); /* Release ByteArray objects to avoid problems overwritting pointer without release, if serialisation is tried again. */ uint8_t y; for ( y = 0; y < x + 1; y++) { destroyObject(getMessage(self->blockHeaders[y])->bytes); } return 0; } getMessage(self->blockHeaders[x])->bytes->length = len; cursor += len; } return cursor; }
void eventbus_unregister(String address){ if(find(address)==false){ jsonMessage_t js; js.address=address; js.type="register"; js.replyAddress=NULL; JSON_Value *body = json_parse_string(NULL); JSON_Value *headers = json_parse_string(NULL); js.body=body; js.headers=headers; String message=NULL; getMessage(js,&message); send_frame(&message); free(message); } delete_node(&address); }
void AddFriendForm::onSendTriggered() { QString id = toxId.text().trimmed(); if (id.isEmpty()) { showWarning(tr("Please fill in a valid Tox ID","Tox ID of the friend you're sending a friend request to")); } else if (isToxId(id)) { if (id.toUpper() == Core::getInstance()->getSelfId().toString().toUpper()) showWarning(tr("You can't add yourself as a friend!","When trying to add your own Tox ID as friend")); else emit friendRequested(id, getMessage()); this->toxId.setText(""); this->message.setText(""); } else { id = id.replace("@", "._tox."); dns.setName(id); dns.lookup(); } }
const char* CanteraError::what() const throw() { try { formattedMessage_ = "\n"; formattedMessage_ += stars; formattedMessage_ += getClass(); if (procedure_.size()) { formattedMessage_ += " thrown by " + procedure_; } formattedMessage_ += ":\n" + getMessage(); if (formattedMessage_.compare(formattedMessage_.size()-1, 1, "\n")) { formattedMessage_.append("\n"); } formattedMessage_ += stars; } catch (...) { // Something went terribly wrong and we couldn't even format the message. } return formattedMessage_.c_str(); }
void HumanClient::launch(struct timeval timeout){ fd_set dsc; int inet = getDescriptor(); int stdfd = STDIN_FILENO; struct timeval tmp; const int BUFFSIZE = 64; char buffer[BUFFSIZE]; int length; while(true){ FD_ZERO(&dsc); FD_SET(inet, &dsc); FD_SET(stdfd, &dsc); tmp = timeout; select(((inet>stdfd)?inet:stdfd)+1, &dsc, NULL, NULL, &tmp); if(FD_ISSET(stdfd, &dsc)){ length = read(stdfd, buffer, BUFFSIZE); if(length != 0){ send(buffer, length); } } if(FD_ISSET(inet, &dsc)){ check(timeout); for(int i = 0; i <= PREFIX_QUANTITY; ++i){ TypedClient::message_type type = TypedClient::message_type(i); while(!isEmpty(type)){ char * s = getMessage(type); if(type != S_MACHINE && type != S_BROADCAST) { if(type == U_BROADCAST || type == U_PRIVATE){ printf("[user message] "); } printf("%s", s); } free(s); } } } } }
/** * @time * @l */ int MPITestProbe::outputState(double timed) { int status = StatsProbe::outputState(timed); InterColComm * icComm = getTargetLayer()->getParent()->icCommunicator(); const int rcvProc = 0; if( icComm->commRank() != rcvProc ) { return status; } double tol = 1e-4f; // if many to one connection, each neuron should receive its global x/y/f position // if one to many connection, the position of the nearest sending cell is received // assume sending layer has scale factor == 1 int xScaleLog2 = getTargetLayer()->getCLayer()->xScale; // determine min/max position of receiving layer const PVLayerLoc * loc = getTargetLayer()->getLayerLoc(); int nf = loc->nf; int nxGlobal = loc->nxGlobal; int nyGlobal = loc->nyGlobal; float min_global_xpos = xPosGlobal(0, xScaleLog2, nxGlobal, nyGlobal, nf); int kGlobal = nf * nxGlobal * nyGlobal - 1; float max_global_xpos = xPosGlobal(kGlobal, xScaleLog2, nxGlobal, nyGlobal, nf); if (xScaleLog2 < 0) { float xpos_shift = 0.5 - min_global_xpos; min_global_xpos = 0.5; max_global_xpos -= xpos_shift; } float ave_global_xpos = (min_global_xpos + max_global_xpos) / 2.0f; outputStream->printf("%s min_global_xpos==%f ave_global_xpos==%f max_global_xpos==%f", getMessage(), min_global_xpos, ave_global_xpos, max_global_xpos); output() << std::endl; for(int b = 0; b < parent->getNBatch(); b++){ if (timed > 3.0f) { assert((fMin[b]/min_global_xpos > (1 - tol)) && (fMin[b]/min_global_xpos < (1 + tol))); assert((fMax[b]/max_global_xpos > (1 - tol)) && (fMax[b]/max_global_xpos < (1 + tol))); assert((avg[b]/ave_global_xpos > (1 - tol)) && (avg[b]/ave_global_xpos < (1 + tol))); } } return status; }
void attachEvents() { // Caller may disable events, do not setup any publishers or subscribers. if (FLAGS_disable_events) { return; } const auto& publishers = Registry::all("event_publisher"); for (const auto& publisher : publishers) { EventFactory::registerEventPublisher(publisher.second); } const auto& subscribers = Registry::all("event_subscriber"); for (const auto& subscriber : subscribers) { auto status = EventFactory::registerEventSubscriber(subscriber.second); if (!status.ok()) { LOG(ERROR) << "Error registering subscriber: " << status.getMessage(); } } }
int cmd_date(char *rest) { char s[40]; if (!rest || !*rest) { struct dosdate_t d; _dos_getdate(&d); displayString(TEXT_MSG_CURRENT_DATE, day_strings[d.dayofweek], d.month, d.day, d.year); rest = NULL; } while (1) /*forever loop */ { if (!rest) { if ((rest = getMessage(TEXT_MSG_ENTER_DATE)) == NULL) return 1; /* failed, error message on screan already */ fputs(rest, stdout); /* put onto screen */ free(rest); fgets(s, sizeof(s), stdin); if (cbreak) return 1; if (parsedate(s)) return 0; } else { if (parsedate(rest)) return 0; } displayString(TEXT_ERROR_INVALID_DATE); // force input the next time around. rest = NULL; } }
bool SessionChannel::sendPrivate(UserSession * pUser,const char * fromName,const char* mess,...) { if (!mess || !pUser || !fromName) return false; char buf[MAX_CHATINFO]; bzero(buf,sizeof(buf)); getMessage(buf,MAX_CHATINFO,mess); Cmd::stChannelChatUserCmd send; send.dwType = Cmd::CHAT_TYPE_PRIVATE; bzero(send.pstrName,sizeof(send.pstrName)); strncpy(send.pstrName,fromName,MAX_NAMESIZE); bzero(send.pstrChat,sizeof(send.pstrChat)); strncpy(send.pstrChat,buf,MAX_CHATINFO); pUser->sendCmdToMe(&send,sizeof(send)); return true; }
void SocketServer::handleMessages() { Message message; for (auto& clientList : clientLists) { auto i = clientList->clients.begin(); while (i != clientList->clients.end()) { auto& client = *i; if (!getMessage(client, &message)) { // Nothing to read yet i++; continue; } // Pass to handler or whatever if (clientList->messageHandler(message, client)) // Done with this client i = clientList->clients.erase(i); else i++; } } }
std::ostream& Message::printTo(std::ostream& out) const { // start with type ... switch(getType()) { case insieme::core::checks::Message::Type::WARNING: out << "WARNING: "; break; case insieme::core::checks::Message::Type::ERROR: out << "ERROR: "; break; } // add error code out << getErrorCode(); // .. continue with location .. out << " @ (" << getLocation(); // .. and conclude with the message. out << ") - MSG: " << getMessage(); return out; }
main() { char *message; char key[KEYSIZE] = "loser"; int i, length; FILE *enc = fopen("encrypted.txt", "r"); FILE *plain = fopen("plain.txt", "w"); //Setting up message buffer. message = malloc(1000); getMessage(message, enc); length = getSize(enc); //Converting the ciphertext to plaintext for(i = 0; i < length; i++) message[i] = decrypt(message[i], key[i % KEYSIZE]); //Writing message into file for(i = 0; i < length; i++) fputc(message[i], plain); printf("Decryption finished.\n"); } //End main()
Client::Client(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); tcpSocket = new QTcpSocket(this); promptConnect = new ConnectDialog(this); credentialsSent = false; ui.actionDisconnect->setDisabled(true); ui.actionReconnect->setDisabled(true); connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(getMessage())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); connect(tcpSocket, SIGNAL(connected()), this, SLOT(sendCredentials())); connect(tcpSocket, SIGNAL(connected()), this, SLOT(onConnect())); connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(onDisconnect())); connect(ui.userList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(whisperOnClick(QListWidgetItem*))); }