/* would be static, but used in test_wmbiff */ int permissions_ok(Pop3 pc, const char *askpass_fname) { struct stat st; if (index(askpass_fname, ' ')) { DM(pc, DEBUG_INFO, "askpass has a space in it; not verifying ownership/permissions on '%s'\n", askpass_fname); return (1); } if (stat(askpass_fname, &st)) { DM(pc, DEBUG_ERROR, "Can't stat askpass program: '%s'\n", askpass_fname); if (askpass_fname[0] != '/') { DM(pc, DEBUG_ERROR, "For your own good, use a full pathname.\n"); } return (0); } if (st.st_uid != 0 && st.st_uid != getuid()) { DM(pc, DEBUG_ERROR, "askpass program isn't owned by you or root: '%s'\n", askpass_fname); return (0); } if (st.st_mode & S_IWOTH) { DM(pc, DEBUG_ERROR, "askpass program is world writable: '%s'\n", askpass_fname); return (0); } return (1); }
// 收获资源 void BuildingSprite::harvest() { int stamp = GM()->getTimeStamp(); if (_type == BUILDING_TYPE_MineFactory) { int diff = stamp - _lastGoldHarvest; int gold = (diff * _goldProduct) / 3600; HomeMapLayer* parent = (HomeMapLayer*)this->getParent(); HomeHudLayer* hud = (HomeHudLayer*)parent->_hudLayer; hud->addGold(gold); _lastGoldHarvest = stamp; DM()->updateLastGoldHarvest(_id, _lastGoldHarvest); } else { int diff = stamp - _lastWoodHarvest; int wood = (diff * _woodProduct) / 3600; HomeMapLayer* parent = (HomeMapLayer*)this->getParent(); HomeHudLayer* hud = (HomeHudLayer*)parent->_hudLayer; hud->addWood(wood); _lastWoodHarvest = stamp; DM()->updateLastWoodHarvest(_id, _lastWoodHarvest); } bubble = nullptr; }
int mboxCreate(Pop3 pc, const char *str) { /* MBOX format: mbox:fullpathname */ pc->TotalMsgs = 0; pc->UnreadMsgs = 0; pc->OldMsgs = -1; pc->OldUnreadMsgs = -1; pc->checkMail = mboxCheckHistory; /* default boxes are mbox... cut mbox: if it exists */ if (!strncasecmp(pc->path, "mbox:", 5)) { if (strlen(str + 5) + 1 > BUF_BIG) { DM(pc, DEBUG_ERROR, "mbox '%s' is too long.\n", str + 5); memset(pc->path, 0, BUF_BIG); } else { strncpy(pc->path, str + 5, BUF_BIG - 1); /* cut off ``mbox:'' */ } } DM(pc, DEBUG_INFO, "mbox: str = '%s'\n", str); DM(pc, DEBUG_INFO, "mbox: path= '%s'\n", pc->path); return 0; }
static void get_password_from_command(Pop3 pc, const char *username, const char *servername, /*@out@ */ char *password, /*@out@ */ unsigned char *password_len) { password[*password_len - 1] = '\0'; password[0] = '\0'; /* check that the executed file is a good one. */ if (permissions_ok(pc, pc->askpass)) { char *command; char *password_ptr; int len = strlen(pc->askpass) + strlen(username) + strlen(servername) + 40; command = malloc(len); snprintf(command, len, "%s 'password for wmbiff: %s@%s'", pc->askpass, username, servername); (void) grabCommandOutput(pc, command, &password_ptr, NULL); /* it's not clear what to do with the exit status, though we can get it from grabCommandOutput if needed to deal with some programs that will print a message but exit non-zero on error */ free(command); if (password_ptr == NULL) { /* this likely means that the user cancelled, and doesn't want us to keep asking about the password. */ DM(pc, DEBUG_ERROR, "passmgr: fgets password failed, exiting\n"); DM(pc, DEBUG_ERROR, "passmgr: (it looks like you pressed 'cancel')\n"); /* this seems like the sanest thing to do, for now */ exit(EXIT_FAILURE); } strncpy(password, password_ptr, *password_len); if (password[*password_len - 1] != '\0') { DM(pc, DEBUG_ERROR, "passmgr: warning: your password appears longer (%lu) than expected (%d)\n", (unsigned long) strlen(password_ptr), *password_len - 1); } free(password_ptr); password[*password_len - 1] = '\0'; *password_len = strlen(password); } else { /* consider this error to be particularly troublesome */ DM(pc, DEBUG_ERROR, "passmgr: permissions check of '%s' failed.", pc->askpass); exit(EXIT_FAILURE); } }
// 升级设施 void BuildingSprite::upgrade() { // 更新数据库 : 正在建设 DM()->updateBuildingBuildState(_id, BUILDING_STATE_BUILDING); // 更新内容 ValueMap& map = DM()->getBuilding(_id); _buildState = BUILDING_STATE_BUILDING; _lastBuildTime = map["LastBuildTime"].asInt(); showUpgradePro(); }
void MenuActions::doNewSession( bool lock ) { int result = KMessageBox::warningContinueCancel( kapp->desktop()->screen(kapp->desktop()->screenNumber(this)), i18n("<p>You have chosen to open another desktop session.<br>" "The current session will be hidden " "and a new login screen will be displayed.<br>" "An F-key is assigned to each session; " "F%1 is usually assigned to the first session, " "F%2 to the second session and so on. " "You can switch between sessions by pressing " "Ctrl, Alt and the appropriate F-key at the same time. " "Additionally, the KDE Panel and Desktop menus have " "actions for switching between sessions.</p>") .arg(7).arg(8), i18n("Warning - New Session"), KGuiItem(i18n("&Start New Session"), "fork"), ":confirmNewSession", KMessageBox::PlainCaption | KMessageBox::Notify); if (result==KMessageBox::Cancel) return; if (lock) slotLock(); DM().startReserve(); }
void run_pipeline() { if(Register::cycle == 59) { printf("in main before WB ID_EX.$rt_out = %d\n", ID_EX.$rt_out); } WB(); if(Register::cycle == 59) { printf("in main before DM ID_EX.$rt_out = %d\n", ID_EX.$rt_out); } DM(); if(Register::cycle == 59) { printf("in main before EX ID_EX.$rt_out = %d\n", ID_EX.$rt_out); } EX(); if(Register::cycle == 59) { printf("in main before ID ID_EX.$rt_out = %d\n", ID_EX.$rt_out); } ID(); if(Register::cycle == 59) { printf("in main before IF ID_EX.$rt_out = %d\n", ID_EX.$rt_out); } IF(); if(Register::cycle == 59) { printf("in main after IF ID_EX.$rt_out = %d\n", ID_EX.$rt_out); } }
void WorldHudLayer::loadData() { ValueMap data = DM()->_player.at(1).asValueMap(); _name = data["Name"].asString(); _level = data["Level"].asInt(); _exp = data["Exp"].asInt(); _expRequire = DM()->getPlayerExpRequire(_level); _ringCount = data["RingCount"].asInt(); _goldCount = data["GoldCount"].asInt(); _woodCount = data["WoodCount"].asInt(); _goldCapacity = data["GoldCapacity"].asInt(); _woodCapacity = data["WoodCapacity"].asInt(); // CCLOG("%s %d %d %d", _name.c_str(), _level, _exp, _expRequire); // CCLOG("(%d,%d,%d) (%d,%d)", _goldCount, _woodCount, _ringCount, _goldCapacity, _woodCapacity); }
/* count the messages in a mailbox */ static void countMessages(Pop3 pc, const char *mbox_filename) { FILE *F; char buf[BUF_SIZE]; int is_header = 0; int next_from_is_start_of_header = 1; int count_from = 0, count_status = 0; int len_from = strlen(FROM_STR), len_status = strlen(STATUS_STR); int pseudo_mail = 0; F = openMailbox(pc, mbox_filename); if (F == NULL) return; /* count message */ while (fgets(buf, BUF_SIZE, F)) { // The first message usually is automatically created by POP3/IMAP // clients for internal record keeping and is ignored // (not displayed) by most email clients. if (is_header && !strncmp(buf, "X-IMAP: ", 8)) { pseudo_mail = 1; } if (buf[0] == '\n') { /* a newline by itself terminates the header */ if (is_header) is_header = 0; else next_from_is_start_of_header = 1; } else if (!strncmp(buf, FROM_STR, len_from)) { /* A line starting with "From" is the beginning of a new header. "From" in the text of the mail should get escaped by the MDA. If your MDA doesn't do that, it is broken. */ if (next_from_is_start_of_header) is_header = 1; if (is_header) count_from++; } else { next_from_is_start_of_header = 0; if (is_header && !strncmp(buf, STATUS_STR, len_status) && strrchr(buf, 'R')) { count_status++; } } } if (count_from && pseudo_mail) { count_from--; if (count_status) count_status--; } DM(pc, DEBUG_INFO, "from: %d status: %d\n", count_from, count_status); pc->TotalMsgs = count_from; pc->UnreadMsgs = count_from - count_status; fclose(F); }
void PanelKMenu::slotSessionActivated( int ent ) { if (ent == 100) doNewSession( true ); else if (ent == 101) doNewSession( false ); else if (!sessionsMenu->isItemChecked( ent )) DM().lockSwitchVT( ent ); }
/* declare stubs when tls isn't compiled in */ struct connection_state *initialize_gnutls(UNUSED(intptr_t sd), UNUSED(char *name), UNUSED(Pop3 pc), UNUSED(const char *remote_hostname)) { DM(pc, DEBUG_ERROR, "FATAL: tried to initialize ssl when ssl wasn't compiled in.\n"); exit(EXIT_FAILURE); }
static void get_password_from_keychain(Pop3 pc, const char *username, const char *servername, /*@out@ */ char *password, /*@out@ */ unsigned char *password_len) { SecKeychainRef kc; OSStatus rc; char *secpwd; UInt32 pwdlen; rc = SecKeychainCopyDefault(&kc); if (rc != noErr) { DM(pc, DEBUG_ERROR, "passmgr: unable to open keychain, exiting\n"); exit(EXIT_FAILURE); } rc = SecKeychainFindInternetPassword(kc, strlen(servername), servername, 0, NULL, strlen(username), username, 0, NULL, 0, NULL, kSecAuthenticationTypeDefault, &pwdlen, (void **) &secpwd, NULL); if (rc != noErr) { DM(pc, DEBUG_ERROR, "passmgr: keychain password grab for %s at %s failed, exiting\n", username, servername); DM(pc, DEBUG_ERROR, "passmgr: (perhaps you pressed 'deny')\n"); /* this seems like the sanest thing to do, for now */ exit(EXIT_FAILURE); } if (pwdlen < *password_len) { strncpy(password, secpwd, pwdlen); password[pwdlen] = '\0'; *password_len = pwdlen; } else { DM(pc, DEBUG_ERROR, "passmgr: warning: your password appears longer (%lu) than expected (%d)\n", strlen(secpwd), *password_len - 1); } rc = SecKeychainItemFreeContent(NULL, secpwd); return; }
void GBitset::pageStart(vector<vector<int> > &INFase, vector<vector<int> > &INGilb, vector<vector<int> > &Buf1, vector<vector<int> > &Buf2, vector<int> &LFase, vector<int> &LGilb, float &Alpha){ TIME_START DM(END); localSum(INFase,INGilb,Buf1,Buf2);DM("localSum "); TIME_PRINT CalculatAmplitude(INFase,INGilb); DM("CalculatAmplitude "); TIME_PRINT deltaSlice(INFase,INGilb); DM("deltaSlice "); TIME_PRINT matExpDispers(INFase,INGilb,LFase,LGilb); DM("matExpDispers "); TIME_PRINT }//_____________________________________________________________________________
FILE *openMailbox(Pop3 pc, const char *mbox_filename) { FILE *mailbox; if ((mailbox = fopen(mbox_filename, "r")) == NULL) { DM(pc, DEBUG_ERROR, "Error opening mailbox '%s': %s\n", mbox_filename, strerror(errno)); pc->TotalMsgs = -1; pc->UnreadMsgs = -1; } return (mailbox); }
void HomeHudLayer::addPlayerExp(int add) { DM()->updatePlayerExp(add); loadData(); // player auto ui = (Widget*)this->getChildByName("UI"); auto playerLevel = (Text*)Helper::seekWidgetByName(ui, "PlayerLevel"); auto playerBar = (LoadingBar*)Helper::seekWidgetByName(ui, "PlayerBar"); playerLevel->setString(GM()->getIntToStr(_level)); playerBar->setPercent(100.0 * _exp / _expRequire); }
LabDialog::LabDialog() : fighter(DM()->getSoilder(SOILDER_TYPE_FIGHTER)), bowman(DM()->getSoilder(SOILDER_TYPE_BOWMAN)), gunner(DM()->getSoilder(SOILDER_TYPE_GUNNER)), meat(DM()->getSoilder(SOILDER_TYPE_MEAT)), labLevel(DM()->getLabLevel()), gold(DM()->getGoldCount()), wood(DM()->getWoodCount()) { }
int maildirCreate(Pop3 pc, const char *str) { int i; char c; /* Maildir format: maildir:fullpathname */ pc->TotalMsgs = 0; pc->UnreadMsgs = 0; pc->OldMsgs = -1; pc->OldUnreadMsgs = -1; pc->checkMail = maildirCheckHistory; pc->u.maildir.dircache_flush = 0; /* special flags */ if (*(str + 8) == ':') { /* path is of the format maildir::flags:path */ c = ' '; for (i = 1; c != ':' && c != '\0'; i++) { c = *(str + 8 + i); switch (c) { case 'F': pc->u.maildir.dircache_flush = 1; DM(pc, DEBUG_INFO, "maildir: dircache_flush enabled\n"); } } } else { i = 0; } if (strlen(str + 8 + i) + 1 > BUF_BIG) { DM(pc, DEBUG_ERROR, "maildir '%s' is too long.\n", str + 8 + i); memset(pc->path, 0, BUF_BIG); } else { strncpy(pc->path, str + 8 + i, BUF_BIG - 1); /* cut off ``maildir:'' */ } DM(pc, DEBUG_INFO, "maildir: str = '%s'\n", str); DM(pc, DEBUG_INFO, "maildir: path= '%s'\n", pc->path); return 0; }
void BattleHudLayer::loadData() { ValueMap& data = DM()->getTownInfo(GM()->_townID); ValueMap& s1 = DM()->getSoilder(1); ValueMap& s2 = DM()->getSoilder(2); ValueMap& s3 = DM()->getSoilder(3); ValueMap& s4 = DM()->getSoilder(4); _name = data["Name"].asString(); _level = data["Level"].asInt(); _goldReward = data["GoldReward"].asInt(); _woodReward = data["WoodReward"].asInt(); _ringReward = data["RingReward"].asInt(); _count[1] = s1["Count"].asInt(); _count[2] = s2["Count"].asInt(); _count[3] = s3["Count"].asInt(); _count[4] = s4["Count"].asInt(); skill1 = 1; skill2 = 1; }
void HomeHudLayer::setWoodCapacity(int capacity) { _woodCapacity = capacity; DM()->updateWoodCapacity(_woodCapacity); auto ui = (Widget*)this->getChildByName("UI"); auto woodCount = (Text*)Helper::seekWidgetByName(ui, "WoodCount"); auto woodCapacity = (Text*)Helper::seekWidgetByName(ui, "WoodCapacity"); auto woodBar = (LoadingBar*)Helper::seekWidgetByName(ui, "WoodBar"); woodCount->setString(GM()->getIntToStr(_woodCount)); woodCapacity->setString(GM()->getIntToStr(_woodCapacity)); woodBar->setPercent(100.0 * _woodCount / _woodCapacity); }
void HomeHudLayer::addGold(int add) { _goldCount = GM()->getMin(_goldCount + add, _goldCapacity); DM()->updateGold(_goldCount); auto ui = (Widget*)this->getChildByName("UI"); auto goldCount = (Text*)Helper::seekWidgetByName(ui, "GoldCount"); auto goldCapacity = (Text*)Helper::seekWidgetByName(ui, "GoldCapacity"); auto goldBar = (LoadingBar*)Helper::seekWidgetByName(ui, "GoldBar"); goldCount->setString(GM()->getIntToStr(_goldCount)); goldCapacity->setString(GM()->getIntToStr(_goldCapacity)); goldBar->setPercent(100.0 * _goldCount / _goldCapacity); }
void WorldHudLayer::addWood(int add) { auto ui = (Widget*)this->getChildByName("UI"); auto woodCount = (Text*)Helper::seekWidgetByName(ui, "WoodCount"); auto woodCapacity = (Text*)Helper::seekWidgetByName(ui, "WoodCapacity"); auto woodBar = (LoadingBar*)Helper::seekWidgetByName(ui, "WoodBar"); _woodCount = GM()->getMin(_woodCount + add, _woodCapacity); DM()->updateWood(_woodCount); woodCount->setString(GM()->getIntToStr(_woodCount)); woodCapacity->setString(GM()->getIntToStr(_woodCapacity)); woodBar->setPercent(100.0 * _woodCount / _woodCapacity); }
RTFformatting::RTFformatting(RTFFileContext* pContext, FormattingLocation fLocation) : RTFObject(rotFormatting, pContext), m_fLocation(fLocation), the_RTFbrdrdef(0), the_RTFparfmt(0), the_RTFapoctl(0), the_RTFtapoctl(0), the_RTFtabdef(0), the_RTFchrfmt(0), the_RTFshading(0), the_RTFpnprops(0), the_RTFpn(0), m_iRBound(0), m_iCellWidth(0),m_bNestedTblDef(false), m_bAddExtraScope(false), m_bIsTableOfContentsPara(false), m_bIsListFormatting(false) { bNoObjectSinceEndOfScope = false; // We must be very careful that type doesn't get overridden inappropriately #ifdef _DEBUG_FORMATCOUNT DM("New : %d \n",m_icount); #endif INCOBJCOUNT(); }
void MenuActions::slotSessionActivated(int ent) { if (ent == 100) { doNewSession(true); } else if (ent == 101) { doNewSession(false); } else if (!m_sessionsMenu->isItemChecked(ent)) { DM().lockSwitchVT(ent); } }
void System::startup() { ScriptEngine::GetInstance(); try{ String code; if(!code.loadFromFile(L"Startup.tjs")) { DM(L"Startup.tjs启动失败!"); return; } ScriptEngine::GetInstance()->pushFile(L"【GLOBAL】"); ScriptEngine::GetInstance()->pushFile(L"startup.tjs"); ScriptEngine::GetInstance()->exec(code, NULL); ScriptEngine::GetInstance()->popFile(); } TJS_CATCH }
void Soilder::loadData() { ValueMap& data = DM()->getSoilderInfo(_soilderID); _type = data["Type"].asInt(); _level = data["Level"].asInt(); _name = data["Name"].asInt(); _healthPoint = data["HealthPoint"].asInt(); _totalHP = _healthPoint; _damage = data["Damage"].asInt(); _attackSpeed = data["AttackSpeed"].asInt(); _shootRange = data["ShootRange"].asInt(); _isbroken = false; }
void SoilderInfoDialog::showInfo() { auto ui = (Widget*)this->getChildByName("UI"); ValueMap& map = DM()->getSoilder(_id); string t = map["Name"].asString() + "(等级" + map["Level"].asString() + ")"; auto title = (Text*)Helper::seekWidgetByName(ui, "Title"); auto description = (Text*)Helper::seekWidgetByName(ui, "Description"); auto healthPoint = (Text*)Helper::seekWidgetByName(ui, "HealthPoint"); auto damage = (Text*)Helper::seekWidgetByName(ui, "Damage"); auto atkspeed = (Text*)Helper::seekWidgetByName(ui, "AttackSpeed"); auto shootrange = (Text*)Helper::seekWidgetByName(ui, "ShootRange"); title->setString(t); description->setString(map["Description"].asString()); healthPoint->setString(map["HealthPoint"].asString()); damage->setString(map["Damage"].asString()); atkspeed->setString(map["AttackSpeed"].asString()); shootrange->setString(map["ShootRange"].asString()); // 士兵动画 switch (_id) { case SOILDER_TYPE_FIGHTER: { arm = Armature::create(ANIM_NAME_FIGHTER); } break; case SOILDER_TYPE_BOWMAN: { arm = Armature::create(ANIM_NAME_BOWMAN); } break; case SOILDER_TYPE_GUNNER: { arm = Armature::create(ANIM_NAME_GUNNER); } break; case SOILDER_TYPE_MEAT: { arm = Armature::create(ANIM_NAME_MEATSHIELD); } break; default: break; } arm->setPosition(Vec2(250, 300)); arm->setScale(2.0f); ui->addChild(arm); arm->getAnimation()->play("run1"); }
RTFformatting::~RTFformatting() { #ifdef _DEBUG_FORMATCOUNT DM("Deleted : %d \n",m_icount); #endif delete DetachBrdrDef(); // delete the_RTFparfmt; delete DetachParfmt(); delete the_RTFapoctl; delete the_RTFtapoctl; delete the_RTFtabdef; delete DetachChrfmt(); delete the_RTFpnprops; delete the_RTFshading; delete the_RTFpn; DECOBJCOUNT(); }
// 设置瓦片坐标 void BuildingSprite::setTiledPos() { auto mapPos = this->getPosition(); if (GM()->isOutMap(mapPos) || GM()->isCovered(GM()->getTiledPos(mapPos))) { this->setPosition(GM()->getMapPos(_pos)); } else { _pos = GM()->getTiledPos(this->getPosition()); // 更新数据库 DM()->updateBuildingPos(_id, _pos); } this->setLocalZOrder(_pos.y + _pos.x); // 恢复占地 GM()->setCoverd(_pos, 1); }
void BuildingSprite::loadData(int index) { ValueMap data = DM()->_building.at(index).asValueMap(); _id = data["ID"].asInt(); _BuildingID = data["BuildingID"].asInt(); _pos = Vec2(data["PositionX"].asInt(), data["PositionY"].asInt()); _buildState = data["BuildState"].asInt(); _lastBuildTime = data["LastBuildTime"].asInt(); _lastGoldHarvest = data["LastGoldHarvest"].asInt(); _lastWoodHarvest = data["LastWoodHarvest"].asInt(); _type = data["Type"].asInt(); _level = data["Level"].asInt(); _name = data["Name"].asString(); _healthPoint = data["HealthPoint"].asInt(); _description = data["Description"].asString(); _goldRequire = data["GoldRequire"].asInt(); _woodRequire = data["WoodRequire"].asInt(); _timeRequire = data["TimeRequire"].asInt(); _baseLevelRequire = data["BaseLevelRequire"].asInt(); _playerLevelRequire = data["PlayerLevelRequire"].asInt(); _expReward = data["ExpReward"].asInt(); // 生产属性 _goldProduct = data["GoldProduct"].asInt(); _woodProduct = data["WoodProduct"].asInt(); // 资源属性 _goldCapacity = data["GoldCapacity"].asInt(); _woodCapacity = data["WoodCapacity"].asInt(); // 攻击属性 _isBroken = false; _canAttack = data["CanAttack"].asInt(); _damage = data["Damage"].asInt(); _attackSpeed = data["AttackSpeed"].asInt(); _shootRange = data["ShootRange"].asInt(); _damageRange = data["DamageRange"].asInt(); // 覆盖地面 GM()->setCoverd(_pos, 1); // CCLOG("%d: %d, %s (%d,%d)", _id, _BuildingID, _name.c_str(), _buildState, _lastBuildTime); }
/* exported for testing */ extern int getline_from_buffer(char *readbuffer, char *linebuffer, int linebuflen) { char *p, *q; int i; /* find end of line (stopping if linebuflen is too small. */ for (p = readbuffer, i = 0; *p != '\n' && *p != '\0' && i < linebuflen - 1; p++, i++); /* gobble \n if it starts the line. */ if (*p == '\n') { /* grab the end of line too! and then advance past the newline */ i++; p++; } else { /* TODO -- perhaps we should return no line at all here, as it might be incomplete. don't want to break anything though. */ DMA(DEBUG_INFO, "expected line doesn't end on its own.\n"); } if (i != 0) { /* copy a line into the linebuffer */ strncpy(linebuffer, readbuffer, (size_t) i); /* sigh, null terminate */ linebuffer[i] = '\0'; /* shift the rest over; this could be done instead with strcpy... I think. */ q = readbuffer; if (*p != '\0') { while (*p != '\0') { *(q++) = *(p++); } } /* null terminate */ *(q++) = *(p++); /* return the length of the line */ } if (i < 0 || i > linebuflen) { DM((Pop3) NULL, DEBUG_ERROR, "bork bork bork!: %d %d\n", i, linebuflen); } return i; }