static void stat_ip(const char* ip) { time_t now; struct stat s; int fd; if ((fd = open(ip, O_RDONLY)) == -1) { if (errno == ENOENT) { if (log_ips) msg3("IP ", ip, " not found"); } else warn3sys("Could not open IP file '", ip, "'"); } else { if (fstat(fd, &s) == -1) warn1sys("Could not fstat opened IP file?!?"); else { now = time(0); if (s.st_mtime + expiry >= now) { if (log_ips) msg3("IP ", ip, " found, setting $RELAYCLIENT"); setenv("RELAYCLIENT", rc, 1); load_env(fd); close(fd); } else { if (log_ips) msg3("Expired IP ", ip, " found, removing"); unlink(ip); } } } }
void raw_sender(zmq::socket_t& s) { for (size_t i = 0; i < ITERS; ++i) { zmq::message_t msg1(ARRAY_LEN(PART1)-1); memcpy(msg1.data(), PART1, msg1.size()); s.send(msg1, ZMQ_SNDMORE); zmq::message_t msg2(ARRAY_LEN(PART2)-1); memcpy(msg2.data(), PART2, msg2.size()); s.send(msg2, ZMQ_SNDMORE); zmq::message_t msg3(ARRAY_LEN(PART3)-1); memcpy(msg3.data(), PART3, msg3.size()); s.send(msg3); zmq::message_t msg_res; s.recv(&msg_res, 0); if (i % 1000 == 0) { std::cout << "."; std::cout.flush(); } } }
int smtp_dispatch(const struct command* commands) { static unsigned long notimpl = 0; struct dispatch* d; const struct command* c; if (!parse_line()) return 1; for (c = commands; c->name != 0; c++) if (strcasecmp(c->name, cmd.s) == 0) { if (c->fn_enabled == 0 || c->fn_enabled()) { notimpl = 0; if (arg.len == 0) { if (c->fn_noparam == 0) return respond(&resp_noparam); return c->fn_noparam(); } else { if (c->fn_hasparam == 0) return respond(&resp_needsparam); return c->fn_hasparam(&arg); } } } for (d = dispatch_table; d->cmd != 0; ++d) if (strcasecmp(d->cmd, cmd.s) == 0) { notimpl = 0; return d->fn(); } msg3(cmd.s, " ", arg.s); if (maxnotimpl > 0 && ++notimpl > maxnotimpl) { respond(&resp_toomanyunimp); return 0; } return respond(&resp_unimp); }
int startup(int argc, char* argv[]) { const char* env; if (argc > 2) { msg3("usage: ", program, " [default-maildir]"); return 0; } if ((env = getenv("MAX_MESSAGES")) != 0) max_count = atol(env); if ((env = getenv("MAX_CUR_MESSAGES")) != 0) max_cur_count = atol(env); if ((env = getenv("MAX_NEW_MESSAGES")) != 0) max_new_count = atol(env); if ((env = getenv("MAILBOX")) == 0) { if (argc < 2) { error1("Mailbox not specified"); return 0; } env = argv[1]; } if (chdir(env) == -1) { respond("-ERR Could not chdir to maildir"); return 0; } if (!scan_maildir()) { respond("-ERR Could not access maildir"); return 0; } atexit(report_io_bytes); return 1; }
bool CPlayGameVorticon::init() { CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer ); MapLoader.m_checkpointset = m_checkpointset; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; gpSaveGameController->setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map mMap->drawAll(); // Now Scroll to the position of the player and center him mMap->gotoPos( 32, 64 ); // Assure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. g_pTimer->ResetSecondsTimer(); g_pInput->flushAll(); // Initialize the AI mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, m_NumPlayers, m_Episode, m_Level, mMap->m_Dark) ); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode has reached verifyFinales(); // When Level starts it's never dark! g_pGfxEngine->Palette.setdark(false); if(m_level_command == GOTO_FINALE) createFinale(); else if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); mMessageBoxes.push_back(move(msg1)); mMessageBoxes.push_back(move(msg2)); mMessageBoxes.push_back(move(msg3)); mMessageBoxes.push_back(move(msg4)); mMessageBoxes.push_back(move(msg5)); mMessageBoxes.push_back(move(msg6)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
int main(int argc, char* argv[]) { const char* bitstr; const char* polystr; int bits; int digits; uint64 poly; const char* suffix; int columns; char* end; int i; const char* name; int reflected; if (argc != 5) { msg3("usage: ", program, " NAME BITS POLY [normal|reflected]"); return 1; } name = argv[1]; bitstr = argv[2]; bits = strtol(bitstr, &end, 0); if (*end != 0) die2(1, "Invalid bits value: ", bitstr); if (bits <= 0 || bits > 64) die1(1, "bits must be between 1 and 64"); digits = (bits + 3) / 4; if (bits > 32) suffix = "ULL,"; else if (bits > 16) suffix = "UL,"; else suffix = "U,"; columns = calc_columns(bits, suffix); polystr = argv[3]; poly = strtoull(polystr, &end, 0); if (*end != 0) die2(1, "Invalid poly value: ", polystr); reflected = 0; if (strcasecmp(argv[4], "reflected") == 0) reflected = 1; else if (strcasecmp(argv[4], "normal") != 0) die2(1, "Must be either 'normal' or 'reflected': ", argv[4]); gentab(bits, poly, reflected); obuf_put3s(&outbuf, "#include \"", name, ".h\"\n\n"); obuf_put5s(&outbuf, "const uint", bitstr, " ", name, "_table[256] = {\n"); for (i = 0; i < 256; ++i) { int column = i % columns; if (column == 0) obuf_puts(&outbuf, " "); obuf_puts(&outbuf, "0x"); if (bits > 32) { obuf_putxw(&outbuf, crctab[i]>>32, digits-8, '0'); obuf_putxw(&outbuf, crctab[i] & 0xffffffffUL, 8, '0'); } else
int cli_main(int argc, char* argv[]) { nistp224key sec; nistp224key pub; obuf out; str str = {0,0,0}; const char* home; const char* keypath; uskey_path = "secret"; upkey_path = "public"; if (argc > 0) keypath = argv[0]; else { if ((home = getenv("HOME")) == 0) die1(1, "$HOME is not set."); if (chdir(home) != 0) die3sys(1, "Could not change directory to '", home, "'"); mkdir(".srcmd", 0700); keypath = ".srcmd/key"; } mkdir(keypath, 0755); if (chdir(keypath) != 0) die3sys(1, "Could not chdir to '", keypath, "'"); random_key(sec); nistp224wrap(pub, BASEP224, sec); base64_encode_line(sec, sizeof sec, &str); if (!obuf_open(&out, uskey_path, OBUF_CREATE|OBUF_EXCLUSIVE, 0400, 0) || !obuf_putstr(&out, &str) || !obuf_putc(&out, '\n') || !obuf_close(&out)) die3sys(1, "Could not create secret key file '", uskey_path, "'"); str_truncate(&str, 0); base64_encode_line(pub, sizeof pub, &str); if (!obuf_open(&out, upkey_path, OBUF_CREATE|OBUF_EXCLUSIVE, 0444, 0) || !obuf_putstr(&out, &str) || !obuf_putc(&out, '\n') || !obuf_close(&out)) die3sys(1, "Could not create public key file '", upkey_path, "'"); msg3("Your public key is '", str.s, "'"); return 0; argc = 1; }
TEST(Serialization, WriteBitsEasy) { QByteArray msg(1, 'a'); QBitArray bits(1, false); Serialization::WriteBitArray(bits, msg, 0); EXPECT_EQ((char)0x00, (char)msg[0]); QByteArray msg1(1, 'a'); QBitArray bits1(0, false); Serialization::WriteBitArray(bits1, msg1, 0); EXPECT_EQ((char)0x00, (char)msg1[0]); QByteArray msg2(1, 'a'); QBitArray bits2(1, true); Serialization::WriteBitArray(bits2, msg2, 0); EXPECT_EQ((char)0x01, (char)msg2[0]); QByteArray msg3(2, 'a'); QBitArray bits3(8, true); Serialization::WriteBitArray(bits3, msg3, 0); EXPECT_EQ((char)0xFF, (char)msg3[0]); EXPECT_EQ((char)'a', (char)msg3[1]); QByteArray msg4(2, 'a'); QBitArray bits4(8, true); Serialization::WriteBitArray(bits4, msg4, 1); EXPECT_EQ((char)'a', (char)msg4[0]); EXPECT_EQ((char)0xFF, (char)msg4[1]); QByteArray msg5(2, 'a'); QBitArray bits5(9, true); Serialization::WriteBitArray(bits5, msg5, 0); EXPECT_EQ((char)0xFF, (char)msg5[0]); EXPECT_EQ((char)0x01, (char)msg5[1]); QByteArray msg6(2, 'a'); QBitArray bits6(10, true); Serialization::WriteBitArray(bits6, msg6, 0); EXPECT_EQ((char)0xFF, (char)msg6[0]); EXPECT_EQ((char)0x03, (char)msg6[1]); }
bool CPlayGameVorticon::init() { const GsRect<Uint16> gameRect = gVideoDriver.getVidConfig().m_GameRect; gVideoDriver.setNativeResolution(gameRect); // Create the special merge effect (Fadeout) CColorMerge *pColorMergeFX = new CColorMerge(8); gEffectController.setupEffect(pColorMergeFX); CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer ); MapLoader.m_checkpointset = m_checkpointset; const int numPlayers = g_pBehaviorEngine->mPlayers; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; gpSaveGameController->setLevel(m_Level); mMap->setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map mMap->drawAll(); // Now Scroll to the position of the player and center him mMap->gotoPos( 32, 64 ); // Ensure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. gTimer.ResetSecondsTimer(); gInput.flushAll(); // Initialize the AI mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, numPlayers, m_Episode, m_Level, mMap->m_Dark) ); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode is reached verifyFinales(); // When Level starts it's never dark! gGraphics.Palette.setdark(false); const std::string finaleStr = gArgs.getValue("finale"); if(finaleStr == "on") { createFinale(); gArgs.removeTag("finale"); } if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); mMessageBoxes.push_back(move(msg1)); mMessageBoxes.push_back(move(msg2)); mMessageBoxes.push_back(move(msg3)); mMessageBoxes.push_back(move(msg4)); mMessageBoxes.push_back(move(msg5)); mMessageBoxes.push_back(move(msg6)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
void warn_connection(const struct connections_entry* c, const char* s) { msg3(format_connection(c), "Warning: ", s); }
void error_connection(const struct connections_entry* c, const char* s) { msg3(format_connection(c), "Error: ", s); }
// used for collation result reporting, defined here for convenience // (maybe moved later) void IntlTestCollator::reportCResult( const UnicodeString &source, const UnicodeString &target, CollationKey &sourceKey, CollationKey &targetKey, Collator::EComparisonResult compareResult, Collator::EComparisonResult keyResult, Collator::EComparisonResult incResult, Collator::EComparisonResult expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { errln("***** invalid call to reportCResult ****"); return; } UBool ok1 = (compareResult == expectedResult); UBool ok2 = (keyResult == expectedResult); UBool ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !verbose) { // Keep non-verbose, passing tests fast return; } else { UnicodeString msg1(ok1 ? "Ok: compare(" : "FAIL: compare("); UnicodeString msg2(", "), msg3(") returned "), msg4("; expected "); UnicodeString prettySource, prettyTarget, sExpect, sResult; IntlTest::prettify(source, prettySource); IntlTest::prettify(target, prettyTarget); appendCompareResult(compareResult, sResult); appendCompareResult(expectedResult, sExpect); if (ok1) { logln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult); } else { errln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult + msg4 + sExpect); } msg1 = UnicodeString(ok2 ? "Ok: key(" : "FAIL: key("); msg2 = ").compareTo(key("; msg3 = ")) returned "; appendCompareResult(keyResult, sResult); if (ok2) { logln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult); } else { errln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult + msg4 + sExpect); msg1 = " "; msg2 = " vs. "; prettify(sourceKey, prettySource); prettify(targetKey, prettyTarget); errln(msg1 + prettySource + msg2 + prettyTarget); } msg1 = UnicodeString (ok3 ? "Ok: incCompare(" : "FAIL: incCompare("); msg2 = ", "; msg3 = ") returned "; appendCompareResult(incResult, sResult); if (ok3) { logln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult); } else { errln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult + msg4 + sExpect); } } }
void CInputDialogOrdering::press_ok(void) { CDealer de; bool bOk=true; COrdering ord; int i,dealer_id=-1; QString s,name=ui->comboBoxDealer->itemText(ui->comboBoxDealer->currentIndex());; QMessageBox msg(QMessageBox::Question,"",""); QPushButton * yesButton=msg.addButton(QString("Ja"),QMessageBox::YesRole); msg.addButton(QString("Nein"),QMessageBox::NoRole); msg.setWindowTitle("?"); msg.setInformativeText(QString::fromUtf8("Soll dieser Händler angelegt werden?")); QMessageBox msg2(QMessageBox::Information,"",""); msg2.setWindowTitle("!"); msg2.setText(QString::fromUtf8("Der Datensatz wurde von einer anderen Programminstanz gelöscht!")); QMessageBox msg3(QMessageBox::Information,"",""); msg3.setWindowTitle("!"); msg3.setText(QString::fromUtf8("Artikel aus der Warenliste wurde(n) von einer anderen Programminstanz gelöscht!")); if(m_pThread!=NULL) { if(m_pThread->m_pDbInterface!=NULL) { //another client delete this record? if(m_iMarkId>0)//edit-mode? { s=QString("id = %1").arg(m_iMarkId); s+=QString(" AND wares = '%1'").arg(m_sMarkWares); i=m_pThread->m_pDbInterface->ordering_get_count(s); if(i<=0)//record delete? { msg2.exec(); bOk=false; } } //- if(bOk) { //check wares -> article delete from another client? s=QString(""); get_data(ord); if(!m_pThread->m_pDbInterface->check_article_at_wares(ord.get_wares(),s)) {//error article was delete msg3.exec(); bOk=false; } //-check dealer-= if(name.length()>0 && bOk==true) { dealer_id=m_pThread->m_pDbInterface->dealer_get_id(name);//search if(dealer_id==-1) {//dealer not found? s=QString::fromUtf8("Der Händler '%1' existiert nicht.").arg(name); msg.setText(s); msg.exec(); if(msg.clickedButton()==yesButton) { //insert new maker in db de.set_name(name); m_pThread->m_pDbInterface->dealer_add(de); m_iNewDealerId=de.get_id(); } } } } } } //- if(bOk) done(1); else close(); }